How to get incoming byte from serialport.

Posted by Sudhakar_A under WPF on 12/20/2013 | Points: 10 | Views : 1131 | Status : [Member] | Replies : 2
I made an apps in wpf using C#.net to send packet to the device and received response of the packet both in byte value. The packet response byte is based on the packet data length which keeps on varying as the data size increase.

I want to specific byte length which is to be read to read from the port,which keeps on changing.

Pls help how to read entire coming packet from port

i used following function:-

byte[] Responseofpacket_byte = datareceived(30);

DataReceive function:-
public byte[] datareceived(int length)
{
byte[] fp = new byte[length];


for (int i = 0; i < length; i++)
{

//objRawdata.portreceivedata = port.ReadByte();
x = port.ReadByte();
fp[i] = Convert.ToByte(x);

}
return fp;
}




Responses

Posted by: vishalneeraj-24503 on: 12/20/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer:-
http://social.msdn.microsoft.com/Forums/en-US/15debf11-b308-4e9d-a10d-cce137d3ee1b/serial-port-readwrite-a-big-question?forum=csharpgeneral

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/20/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://sites.cofa.unsw.edu.au/~z9270907/processing/read&write_serial.html
http://www.miltest.com/articles/application-notes/59-serial-port-buffering-csharp.html

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response