timing of reads from serial port on windows

Posted by Marcin K on Stack Overflow See other posts from Stack Overflow or by Marcin K
Published on 2010-04-15T16:16:04Z Indexed on 2010/04/15 19:03 UTC
Read the original article Hit count: 306

Filed under:
|
|

I'm trying to implement a protocol over serial port on a windows(xp) machine. The problem is that message synchronization in the protocol is done via a gap in the messages, i.e., x millisecond gap between sent bytes signifies a new message. Now, I don't know if it is even possible to accurately detect this gap.
I'm using win32/serport.h api to read in one of the many threads of our server. Data from the serial port gets buffered, so if there is enough (and there will be enough) latency in our software, I will get multiple messages from the port buffer in one sequence of reads.

Is there a way of reading from the serial port, so that I would detect gaps in when particular bytes were received?

© Stack Overflow or respective owner

Related posts about c++

Related posts about serial-port