this question has answer here:
i'm reading 5 bytes array
readdata = new byte[5]; bytewaiting = serialcomport.bytestoread; while (bytewaiting > 0) { readdata[i++] = (byte)serialcomport.readbyte(); **<--error: index outside bounds of array** bytewaiting = bytewaiting - 1; }
the receive buffer includes serial driver's receive buffer internal buffering in serialport
object itself.
because bytestoread
property represents both serialport
buffer , windows-created buffer, can return greater value readbuffersize property.
instead of watching bytestoread
should subscribe datareceived
event. automatically called when new data arrives.
if don't know how on above link corresponding msdn page you'll find example on how subscribe event , should within it.
Comments
Post a Comment