Re: more CommEvents than expected
- From: "Chris Burnette" <burnette@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 18 Jun 2006 04:05:39 GMT
He resets proc to 0 at the beginning of the loop and only sets it to 1 when
WaitCommEvent returns true or when WaitForMultipleObjects indicates that his
object is signalled.
So, I don't see how it could be getting into the if(proc) block multiple
times without having the one of those 2 things occurring.
Chris
"Rhett Gong [MSFT]" <v-raygon@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:n3X3blzOFHA.920@xxxxxxxxxxxxxxxxxxxxxxxx
Hello
After checking your code, it seems that following lines are called several
times even if WaitCommEvent is not called in the for loop. Since dwEvtMask
works like a global variable to the for(::) loops, that is why you always
get the EV code repeated.
//-----------------------------------------
if (proc)
{
if (dwEvtMask & EV_DSR) printf("ev_dsr pin six fPending = %d ",
fPending);
if (dwEvtMask & EV_CTS) printf("ev_cts pin eight fPending = %d ",
fPending);
if (dwEvtMask & EV_RING) printf("ev_ring pin nine fPending = %d ",
fPending);
if (dwEvtMask & EV_RLSD) printf("ev_rlsd pin one fPending = %d ",
fPending);
if (GetCommModemStatus(hCom, &dwCommStatus))
printf("commStatus = %x\n", dwCommStatus);
else
printf("Error = %d\n", GetLastError());
}
//----------------------------------------
You may use following ways to resolve this issue:
1> clear dwEvtMask every time when you get into the new loop, I suggest
you
add dwEvtMask=0 as following:
for(;;)
{
dwEvtMask =0;
proc = 0;
if (!fPending)
/.....
2> or you can add the " if(proc) ..." above when WaitCommEvent return
TRUE,
like following:
if (WaitCommEvent(hCom, &dwEvtMask, &o))
{
proc = 1;
// add them
here
}
Please let me know if my answer helps you resolve the problem. If there is
anything more I can assist you, please feel free to let me know.
Thanks,
Rhett Gong [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
.
- References:
- more CommEvents than expected
- From: Tony
- RE: more CommEvents than expected
- From: Rhett Gong [MSFT]
- more CommEvents than expected
- Prev by Date: Re: Threading Delay
- Next by Date: Re: Threading Delay
- Previous by thread: RE: more CommEvents than expected
- Next by thread: Re: more CommEvents than expected
- Index(es):
Relevant Pages
|