You should check if you have overrun errors. To do this call the
ClearCommError function (Windows)[
^].
If you got overrun errors you should increase the size of the driver's receive buffer with the
SetupComm function (Windows)[
^]. The buffer should be large enough to hold at least the max. size of a data line.
You might also improve your code to use event driven overlapped IO and read all available data at once. Upon the
EV_RXCHAR
event call
ClearCommError
to check for errors and get the number of available bytes from the
cbInQue
member of the passed
COMSTAT
structure.