Re: WaitCommEvent
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Thu, 9 Apr 2009 11:56:50 -0400
Dave Cullen <none@xxxxxxxx> wrote:
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
Is that your actual code? At this point, you need to wait for an
asynchronous operation to complete. You can't issue a second call while
that operation is in progress (as you appear to be doing).
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- References:
- WaitCommEvent
- From: Dave Cullen
- WaitCommEvent
- Prev by Date: WaitCommEvent
- Next by Date: assigning streams
- Previous by thread: WaitCommEvent
- Next by thread: Re: WaitCommEvent
- Index(es):
Relevant Pages
|