Problem in Data receiving from serial port

Posted by Jagadisha.2805 under C# on 11/9/2012 | Points: 10 | Views : 1415 | Status : [Member] | Replies : 0
Hi can anybody help in solving the issue of receiving the data from serial, I have a device which sends data every 4ms of the format $0000010001..........0$00000....$... Here $ indicates the start of data frame, aftr $ i get 72 bytes of data containing only 0s n 1s. What i have to do is decode this frame n look for the position of 1s in the data stream n act accordingly.

private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
read = (byte)serialPort1.ReadByte();
this.Invoke(new EventHandler(DoUpdate));

}

public void DoUpdate(object sender, System.EventArgs e)
{
if (read == 36)
{
start_collction = 1;
}

if (start_collction == 1)
{

data_75[data_index++] = read;

if ((data_75[74] == 36))
{
start_collction = 0;
data_index = 0;

for (int i = 1; i < 73; i++)
{

if (data_75[i] == 1)
{
// MessageBox.Show("Got"+i);
q[i] = i;
NewMethod();
}


}


}

}
}




Responses

(No response found.)

Login to post response