|
It may be worth having a look at how external microcontrollers (microchip, atmel etc...) interface with computers to get some pointers. There are lots of examples around. You may find the easiest way could be to connect your hardware to one of those and use that to communicate with the computer via USART/SPI or whatever.
It can be done with a USB connection but that is going to be complicated. As Christian said, a serial port connection will probably be the easiest solution.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Direct connection between the actual transducer and teh serial / USB port won't work, unless (very unlikely) it transducer has an AtoD converter and interface built in. What yours provides is a TTL level: 0V or +5V (nominal, above ~3V is allowed) TTL Levels if you need to know or are interested.[^]
What you will need to do is to connect the transducer to either an interface board or some microcontroller (try PIC) that can interface directly to serial / USB.
You can then use whatever communications protocol you need (and can implement!)
Good luch, and have fun!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks again you have all been great help...Once I'm done I will post my work on the site, if its good enough. I'm sure someone somewhere will be interested in underwater ultrasonic communications. : )
|
|
|
|
|
in database the column is like this
EngyVal
10.05
111.9
11.89
after executing my query i want the above values as below
EngyVal
0010.05
0111.90
0011.89
how can i format the column in the select statement
|
|
|
|
|
Well, this would be a SQL question, except that you can't. The data in your database is not formatted in the DB, or in your dataset. It's formatted when you display it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
You can't.
What you need to do is format the output - wherever that is going.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
You could write function, but formatting is best handled at the client.
|
|
|
|
|
Hi,
Kindly let me know that, How may I send message to particular client. if four client are already connected. I want to send message to fourth-one.
Following Server-side script is working very good but it sends to every one.
please tell me where will I have to change following script to send message to particular client.
Thank you
Script is here:
using System;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace DefaultNamespace
{
public class SocketServer : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.RichTextBox richTextBoxReceivedMsg;
private System.Windows.Forms.TextBox textBoxPort;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBoxMsg;
private System.Windows.Forms.Button buttonStopListen;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.RichTextBox richTextBoxSendMsg;
private System.Windows.Forms.TextBox textBoxIP;
private System.Windows.Forms.Button buttonStartListen;
private System.Windows.Forms.Button buttonSendMsg;
private System.Windows.Forms.Button buttonClose;
const int MAX_CLIENTS = 10;
public AsyncCallback pfnWorkerCallBack ;
private Socket m_mainSocket;
private Socket [] m_workerSocket = new Socket[10];
private int m_clientCount = 0;
public SocketServer()
{
InitializeComponent();
textBoxIP.Text = GetIP();
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new SocketServer());
}
#region Windows Forms Designer generated code
private void InitializeComponent() {
this.buttonClose = new System.Windows.Forms.Button();
this.buttonSendMsg = new System.Windows.Forms.Button();
this.buttonStartListen = new System.Windows.Forms.Button();
this.textBoxIP = new System.Windows.Forms.TextBox();
this.richTextBoxSendMsg = new System.Windows.Forms.RichTextBox();
this.label1 = new System.Windows.Forms.Label();
this.buttonStopListen = new System.Windows.Forms.Button();
this.textBoxMsg = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.textBoxPort = new System.Windows.Forms.TextBox();
this.richTextBoxReceivedMsg = new System.Windows.Forms.RichTextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.buttonClose.Location = new System.Drawing.Point(321, 232);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(88, 24);
this.buttonClose.TabIndex = 11;
this.buttonClose.Text = "Close";
this.buttonClose.Click += new System.EventHandler(this.ButtonCloseClick);
this.buttonSendMsg.Location = new System.Drawing.Point(16, 192);
this.buttonSendMsg.Name = "buttonSendMsg";
this.buttonSendMsg.Size = new System.Drawing.Size(192, 24);
this.buttonSendMsg.TabIndex = 7;
this.buttonSendMsg.Text = "Send Message";
this.buttonSendMsg.Click += new System.EventHandler(this.ButtonSendMsgClick);
this.buttonStartListen.BackColor = System.Drawing.Color.Blue;
this.buttonStartListen.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonStartListen.ForeColor = System.Drawing.Color.Yellow;
this.buttonStartListen.Location = new System.Drawing.Point(227, 16);
this.buttonStartListen.Name = "buttonStartListen";
this.buttonStartListen.Size = new System.Drawing.Size(88, 40);
this.buttonStartListen.TabIndex = 4;
this.buttonStartListen.Text = "Start Listening";
this.buttonStartListen.Click += new System.EventHandler(this.ButtonStartListenClick);
this.textBoxIP.Location = new System.Drawing.Point(88, 16);
this.textBoxIP.Name = "textBoxIP";
this.textBoxIP.ReadOnly = true;
this.textBoxIP.Size = new System.Drawing.Size(120, 20);
this.textBoxIP.TabIndex = 12;
this.textBoxIP.Text = "";
this.richTextBoxSendMsg.Location = new System.Drawing.Point(16, 87);
this.richTextBoxSendMsg.Name = "richTextBoxSendMsg";
this.richTextBoxSendMsg.Size = new System.Drawing.Size(192, 104);
this.richTextBoxSendMsg.TabIndex = 6;
this.richTextBoxSendMsg.Text = "";
this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Port";
this.buttonStopListen.BackColor = System.Drawing.Color.Red;
this.buttonStopListen.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonStopListen.ForeColor = System.Drawing.Color.Yellow;
this.buttonStopListen.Location = new System.Drawing.Point(321, 16);
this.buttonStopListen.Name = "buttonStopListen";
this.buttonStopListen.Size = new System.Drawing.Size(88, 40);
this.buttonStopListen.TabIndex = 5;
this.buttonStopListen.Text = "Stop Listening";
this.buttonStopListen.Click += new System.EventHandler(this.ButtonStopListenClick);
this.textBoxMsg.BackColor = System.Drawing.SystemColors.Control;
this.textBoxMsg.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBoxMsg.ForeColor = System.Drawing.SystemColors.HotTrack;
this.textBoxMsg.Location = new System.Drawing.Point(120, 240);
this.textBoxMsg.Name = "textBoxMsg";
this.textBoxMsg.ReadOnly = true;
this.textBoxMsg.Size = new System.Drawing.Size(192, 13);
this.textBoxMsg.TabIndex = 14;
this.textBoxMsg.Text = "None";
this.label4.Location = new System.Drawing.Point(16, 71);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(192, 16);
this.label4.TabIndex = 8;
this.label4.Text = "Broadcast Message To Clients";
this.label5.Location = new System.Drawing.Point(217, 71);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(192, 16);
this.label5.TabIndex = 10;
this.label5.Text = "Message Received From Clients";
this.textBoxPort.Location = new System.Drawing.Point(88, 40);
this.textBoxPort.Name = "textBoxPort";
this.textBoxPort.Size = new System.Drawing.Size(40, 20);
this.textBoxPort.TabIndex = 0;
this.textBoxPort.Text = "8000";
this.richTextBoxReceivedMsg.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
this.richTextBoxReceivedMsg.Location = new System.Drawing.Point(217, 87);
this.richTextBoxReceivedMsg.Name = "richTextBoxReceivedMsg";
this.richTextBoxReceivedMsg.ReadOnly = true;
this.richTextBoxReceivedMsg.Size = new System.Drawing.Size(192, 129);
this.richTextBoxReceivedMsg.TabIndex = 9;
this.richTextBoxReceivedMsg.Text = "";
this.label2.Location = new System.Drawing.Point(16, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Server IP";
this.label3.Location = new System.Drawing.Point(0, 240);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(112, 16);
this.label3.TabIndex = 13;
this.label3.Text = "Status Message:";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 260);
this.Controls.Add(this.textBoxMsg);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBoxIP);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.label5);
this.Controls.Add(this.richTextBoxReceivedMsg);
this.Controls.Add(this.label4);
this.Controls.Add(this.buttonSendMsg);
this.Controls.Add(this.richTextBoxSendMsg);
this.Controls.Add(this.buttonStopListen);
this.Controls.Add(this.buttonStartListen);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxPort);
this.Name = "SocketServer";
this.Text = "SocketServer";
this.ResumeLayout(false);
}
#endregion
void ButtonStartListenClick(object sender, System.EventArgs e)
{
try
{
if(textBoxPort.Text == ""){
MessageBox.Show("Please enter a Port Number");
return;
}
string portStr = textBoxPort.Text;
int port = System.Convert.ToInt32(portStr);
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, port);
m_mainSocket.Bind( ipLocal );
m_mainSocket.Listen (4);
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
UpdateControls(true);
}
catch(SocketException se)
{
MessageBox.Show ( se.Message );
}
}
private void UpdateControls( bool listening )
{
buttonStartListen.Enabled = !listening;
buttonStopListen.Enabled = listening;
}
public void OnClientConnect(IAsyncResult asyn)
{
try
{
m_workerSocket[m_clientCount] = m_mainSocket.EndAccept (asyn);
WaitForData(m_workerSocket[m_clientCount]);
++m_clientCount;
String str = String.Format("Client # {0} connected", m_clientCount);
textBoxMsg.Text = str;
m_mainSocket.BeginAccept(new AsyncCallback ( OnClientConnect ),null);
}
catch(ObjectDisposedException)
{
System.Diagnostics.Debugger.Log(0,"1","\n OnClientConnection: Socket has been closed\n");
}
catch(SocketException se)
{
MessageBox.Show ( se.Message );
}
}
public class SocketPacket
{
public System.Net.Sockets.Socket m_currentSocket;
public byte[] dataBuffer = new byte[1];
}
public void WaitForData(System.Net.Sockets.Socket soc)
{
try
{
if ( pfnWorkerCallBack == null ){
pfnWorkerCallBack = new AsyncCallback (OnDataReceived);
}
SocketPacket theSocPkt = new SocketPacket ();
theSocPkt.m_currentSocket = soc;
soc .BeginReceive (theSocPkt.dataBuffer, 0,
theSocPkt.dataBuffer.Length,
SocketFlags.None,
pfnWorkerCallBack,
theSocPkt);
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
public void OnDataReceived(IAsyncResult asyn)
{
try
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;
int iRx = 0 ;
iRx = socketData.m_currentSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(socketData.dataBuffer,
0, iRx, chars, 0);
System.String szData = new System.String(chars);
richTextBoxReceivedMsg.AppendText(szData);
WaitForData( socketData.m_currentSocket );
}
catch (ObjectDisposedException )
{
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
void ButtonSendMsgClick(object sender, System.EventArgs e)
{
try
{
Object objData = richTextBoxSendMsg.Text;
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());
for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
if(m_workerSocket[i].Connected){
m_workerSocket[i].Send (byData);
}
}
}
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
void ButtonStopListenClick(object sender, System.EventArgs e)
{
CloseSockets();
UpdateControls(false);
}
String GetIP()
{
String strHostName = Dns.GetHostName();
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
String IPStr = "";
foreach(IPAddress ipaddress in iphostentry.AddressList){
IPStr = ipaddress.ToString();
return IPStr;
}
return IPStr;
}
void ButtonCloseClick(object sender, System.EventArgs e)
{
CloseSockets();
Close();
}
void CloseSockets()
{
if(m_mainSocket != null){
m_mainSocket.Close();
}
for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
m_workerSocket[i].Close();
m_workerSocket[i] = null;
}
}
}
}
}
|
|
|
|
|
M Riaz Bashir wrote: for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
if(m_workerSocket[i].Connected){
m_workerSocket[i].Send (byData);
}
}
}
I have two reasons to believe that you really have not the slightest idea what you're doing.
1 - you posted a ton of useless boilerplate code
2 - if you can't work out from this how to send to only one user, then you should take a class, read a book, do SOMETHING to create a basic understanding of programming before you play with other people's code. I assume you're playing with something you found online to teach yourself, I can't see how this could be work or school. So, take a step back, buy a book, and learn how to read some basic code before you start trying to mash up other people's.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: I have two reasons to believe that you really have not the slightest idea what you're doing
I agree
Moim Hossain
R&D Project Manager
BlueCielo ECM Solutions BV
|
|
|
|
|
i need to show a preview of my webcam in a picture box when i connected to the webcam. im using WIA.
how can i show preview of my webcam in a picturebox.
here is my code to connect to webcam...
private void btnDecode_Click_1(object sender, EventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
DeviceManager manager = new DeviceManagerClass();
Device d = null;
foreach (DeviceInfo info in manager.DeviceInfos)
{
d = info.Connect();
}
Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
foreach (string format in item.Formats)
{
i++;
WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
imagefile.SaveFile("d:\\" + i + ".jpg");
Bitmap image = new Bitmap("d:\\" + i + ".jpg");
Bitmap bm = new Bitmap(image, 200, 150);
Gray(bm);
|
|
|
|
|
Well, what does it do, and not do ? I know how to do this, but not with WIA, so you'll need to tell us what's going wrong.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
as my code show previous i take a picture of a QR barcode using my webcam. so i need to show a preview of my webcam befor take the picture of barcode. bcz that will be easy to user to show the barcode properly to the webcam. so i can get perfect image to process. that is the purpose.
A S E L A
|
|
|
|
|
So, wait, all this code works, but you can't work out how to set the properties of a picturebox to show the image ? I thought this was a web app ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
yaa untill now every thing work fine. can take image and as you told me earlierday doing image processing and filtering and convert to gray scale and adjust brightness and contrast. after process can deocde barcode to. some times got few errors. but now only problem is i have to take few images untill i get the fine image. bcz its very dificult to show QR properly without a preview of webcam.
my plane to user a another picturebox to show the preview of webcam.
sorry i forgot to tell you. this is not web app...just a windows app...
A S E L A
|
|
|
|
|
So, you have a picturebox, it has a property, called source or image. I forget which. Set it to point to your bitmap.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
|
what ? A picturebox shows pictures, and it does it in a pretty standard way. If you want to show video, then you need a timer to update the picture. A picturebox plainly is not a video control.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
hi
i m drawing a image using graphics on a image object
and i want to display that image in crystal report
i cant save the image in any drive as a user i dont have permission to read and write.
here is my code
public Image img;
img = Image.FromFile("Image1.jpg");
Graphics grf = Graphics.FromImage(img);
grf.Clear(Color.White);
now i drawn a picture using drwaline method of graphics
now i want to display this image "img" in crystal report
crystal report is binded to a table in dataset
i created a table for storing image in dataset
and to display image i m using
rptobj.Subreports["ImageReport.rpt"].SetDataSource(dt1);
plz help me
|
|
|
|
|
May this help u.........
{
DataTable dt = new DataTable("tblImgData");
dt.Columns.Add("Picture", typeof(Byte[]));
dt.Rows.Add(GetImageData(""));
Ds = new DataSet("NewDataSetName");
Ds.Tables.Add(dt);
objRpt.SetDataSource(Ds);
crystalReportViewer1.ReportSource =objRpt;
}
byte[] GetImageData(string fileName )
{
System.IO.FileStream fs = new System.IO.FileStream(fileName,System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length)));
}
|
|
|
|
|
hi
thanks for u r reply
but i m not storing the image in any file.
i have a blank image name "Image1.jpg"
i m calling this blank image and storing in img object
and in drawing lines on this image object using graphics
now i want add img to a table in a new row
it is showing error cannot convert to byte
|
|
|
|
|
Iam having values in datatable
datatable is having id's like 80,84,86
dtsecondlstbox-->datatable name
lstSelected.DataSource = dtsecondlstbox;
how to sort datatable values....
can anyone help me
|
|
|
|
|
//your question is already answered, The only way to sort datatable is to use dataview
DataView dv = new DataView(dtsecondlstbox, null, "Id", DataViewRowState.CurrentRows);
dtsecondlstbox= dv.ToTable();
lstSelected.DataSource = dtsecondlstbox;
|
|
|
|
|
DataView dv = new DataView(dtsecondlstbox, null, "Id", DataViewRowState.CurrentRows);
iam binding listbox not datagrid.
for listbox can u tell me
|
|
|
|
|
ListBox has Sorted property.
|
|
|
|
|