WaitCommEvent

Tech-Archive recommends: Fix windows errors by optimizing your registry



I want to count pulses appearing on the CTS and DSR lines of a serial port.
The example "Monitoring Communications Events" in MSDN is perfect, except
that I can't get the code to work. I'd like to put this block into a
do-while loop, but it generates an error 87 (ERROR_INVALID_PARAMETER) on the
2nd pass through the loop.

if (WaitCommEvent(hCom, &dwEvtMask, &o))
{
if (dwEvtMask & EV_DSR)
{
// To do.... count DSR pulses
}

if (dwEvtMask & EV_CTS)
{
// To do.... count CTS pulses
}
}
else
{
DWORD dwRet = GetLastError();
if( ERROR_IO_PENDING == dwRet)
{
printf("I/O is pending...\n");

// To do... continue loop
}
else
printf("Wait failed with error %d.\n", GetLastError());
}

All parameters are the same as the MS example. Do I need to reset somthing
to be able to use WaitCommEvent in a loop?

Thanks

drc


.



Relevant Pages

  • Re: AT90S2313 TO PC
    ... terminal/oscilloscope. ... I did loop back too. ... tne OP might also need to jumper RTS to CTS and DTR to DSR ...
    (comp.arch.embedded)
  • Re: Precision peak detector
    ... will be used as an feedback for closed loop system therefore amplitude ... Do you have pulses that may go either above or below ground? ... Digital is a crock for high accuracy feedback loops running at any sort of speed. ...
    (sci.electronics.design)
  • Re: Precision peak detector
    ... Phil Hobbs wrote: ... will be used as an feedback for closed loop system therefore amplitude ... Do you have pulses that may go either above or below ground? ...
    (sci.electronics.design)
  • Re: Great, great Request
    ... It is urgent. ... I have a physical problem that I am solving in Matlab. ... Of course, I can copy 4 times the same loop for different pulses, but this loop is too big and it is very inconvenient. ...
    (comp.soft-sys.matlab)
  • Re: Serial Port programming - Reading DSR from port
    ... > am trying to do is get a count of how many pulses it sends per second. ... Therefore I haven't bothered to synchronize the inner ... long it takes to execute the inner loop. ...
    (comp.lang.perl.misc)