Reputation: 334
I work on serial Port to read data. serial port's baud-rate is 921600 bps and i use these code to read data:
while(true)
{
bytesToRead = sensor.BytesToRead;
if (bytesToRead > 0)
{
byte[] input = new byte[bytesToRead];
sensor.Read(input, 0, bytesToRead);
}
}
sending protocols is like this. (five digit numbers in bytes + \n\r )
48 48 49 52 50 10 13 , ....
that means : "00142\n\r" -> 00142 -> 142
in each loop I read 4096 bytes of data and i looking for fast way to read all numbers in buffer. i use readLine() function also but it is too slow and some data has been lost.
is there any idea what shroud i do? thanks.
Upvotes: 0
Views: 101