- Jul 23, 2006
- 3,934
- 0
- 76
I'm working on a project that needs to keep track of time between certain events. There are two timers, timer 'A' is set for 1.5*x, while timer 'B' is set for 3.5*x, and 'x' is some constant (these values end up around 1ms and 2ms).
Timer 'B' is a timer that frames rs232 serial messages, while timer 'A' is used to determine errors. Example: the application is in a waiting state (either initialized or timer 'B' has already tripped at some point in the past). The first byte to come over rs232 represents the first byte of the message. Subsequent bytes are considered to be part of that same message until timer 'B' runs out again. This means that every time a byte is received, these timers need to be reset. If timer 'A' times out, then the message is invalid unless no more bytes are received before timer 'B' times out.
So basically I need something high precision (1-2ms +- 1ms), resettable, and able to call a callback when timed out. I've read on the multitude of different Win32 timers and am a bit lost as to which ones to use in this scenario.
Timer 'B' is a timer that frames rs232 serial messages, while timer 'A' is used to determine errors. Example: the application is in a waiting state (either initialized or timer 'B' has already tripped at some point in the past). The first byte to come over rs232 represents the first byte of the message. Subsequent bytes are considered to be part of that same message until timer 'B' runs out again. This means that every time a byte is received, these timers need to be reset. If timer 'A' times out, then the message is invalid unless no more bytes are received before timer 'B' times out.
So basically I need something high precision (1-2ms +- 1ms), resettable, and able to call a callback when timed out. I've read on the multitude of different Win32 timers and am a bit lost as to which ones to use in this scenario.