Tech Support > Microsoft Windows > Development Resources > Overlapped I/O Serial Port
Overlapped I/O Serial Port
Posted by Ricardo on January 11th, 2006


Hello! I've been working on a serial port class which uses overlapped
I/O and launches a read and write thread. The code is very similar to
the MTTTY sample from MSDN.

Everything works fine, except the first time I run my app after
rebooting the PC, my ReadFile refuses to complete. I have a ReadFile()
and a WaitCommEvent() being handled by a WaitForMultipleObjects(). The
comm event triggers and returns that a byte has been received, but the
ReadFile() never triggers. If I quit my application and restart it,
everything works fine from then on.

Has anyone ever seen this? Any insight is welcome!

~ Ricardo

Posted by Alexander Grigoriev on January 11th, 2006


Did you call SetCommTimeouts?

"Ricardo" <ricardo.net@ruizfamily.net> wrote in message
news:1136945475.631417.147450@g49g2000cwa.googlegr oups.com...


Posted by Ricardo on January 11th, 2006


Well.... actually found out what it was, I was starting the threads
before setting up the serial port with SetCommState and
SetCommTimeouts. So the threads where already
WaitingForMultipleObjects() before I set the timeouts! So, moral of the
story, don't do that!