-
Polling serial ports
Well, what i want to do is a simple routine that polls a serial port every 10ms for [timeout] seconds.
This is under CE btw. but it shouldn't make a difference.
Looked around and found a function-call, called GetCommMask(), and thought to myself that i could just call that and check for the EV_RXCHAR bit of the mask.
Well, thing is, this function seems to just set mask to zero, or to whatever you have set using SetCommMask().
Looked around some more, and found a function called WaitForCommEvent, nice, well, this function does never timeout?!?!
So this was no good, read the stuff at MSDN, found out some way that you could make WaitCommEvent() return directly and just set the mask if it's ?OverLapped?, but that parameter doesn't seem to be valid for CE.
Now is there anyway way to accomplish this?
-
-
Did you try to give the window a timer? If not, use SetTimer() with the last argument NULL and then do everthing when the window receives a WM_TIMER message.
-
> Well, thing is, this function seems to just set mask to zero, or to whatever you have set using SetCommMask().
Which is precisely what it's documented as doing.
> Looked around some more, and found a function called WaitForCommEvent, nice, well, this function does never timeout?!?!
Have you tried using SetCommTimeouts?
If these timeouts don't work for WaitCommEvent (and the documentation doesn't specify), then the obvious thing to do is to use ReadFile, which does time out. Read the documentation for COMMTIMEOUTS.