Overlapped IO or non overlapped?
-
Hello guru's around the world! I'm writing some software to handle some simple home-made hardware under windows2000. I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using
CreateFile(..)
, non overlapped. Toggleing the output channels withEscapeCommFunction(..)
works fine too. A worker tread is in an infinite loop (while(true)) in which it waits for aWaitCommEvent(..)
. When the DSR or the CTS lines change state, I get notified - just as it should be. But I want to keep polling withWaitCommEvent(..)
and I want to useEscapeCommFunction(..)
to toggle the output lines. To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly,EscapeCommFunction(..)
hangs ifWaitCommEvent(..)
is still waiting for an event. Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS? Thanks in advance, Regards, Griffith Sutherns
Everything you say will be misquoted, ripped out of context and used against you.
-
Hello guru's around the world! I'm writing some software to handle some simple home-made hardware under windows2000. I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using
CreateFile(..)
, non overlapped. Toggleing the output channels withEscapeCommFunction(..)
works fine too. A worker tread is in an infinite loop (while(true)) in which it waits for aWaitCommEvent(..)
. When the DSR or the CTS lines change state, I get notified - just as it should be. But I want to keep polling withWaitCommEvent(..)
and I want to useEscapeCommFunction(..)
to toggle the output lines. To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly,EscapeCommFunction(..)
hangs ifWaitCommEvent(..)
is still waiting for an event. Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS? Thanks in advance, Regards, Griffith Sutherns
Everything you say will be misquoted, ripped out of context and used against you.
In non-overlapped IO each call will block the IO resource. You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent. You have a couple of choices: 1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus. Polling can be OK if done infrequently. 2. Use overlapped IO. A little more complicated but it won't block the IO resource. I'd go with overlapped IO. Col :-)
-
In non-overlapped IO each call will block the IO resource. You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent. You have a couple of choices: 1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus. Polling can be OK if done infrequently. 2. Use overlapped IO. A little more complicated but it won't block the IO resource. I'd go with overlapped IO. Col :-)
Thanks a lot Colin! I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably. Once again, your help's greatly appriciated. Regards, Griffith
Everything you say will be misquoted, ripped out of context and used against you.
-
Thanks a lot Colin! I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably. Once again, your help's greatly appriciated. Regards, Griffith
Everything you say will be misquoted, ripped out of context and used against you.
BTW, Since you plan to poll you should do it at least double the maximum possible expected input frequency to ensure you do not miss a pulse. Col :-)