Re: more CommEvents than expected



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.



.



Relevant Pages

  • Re: more CommEvents than expected
    ... 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 ... > times even if WaitCommEvent is not called in the for loop. ... > fPending); ...
    (microsoft.public.win32.programmer.kernel)
  • RE: more CommEvents than expected
    ... times even if WaitCommEvent is not called in the for loop. ... if (proc) ... 1> clear dwEvtMask every time when you get into the new loop, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Deleting in a cursor loop
    ... cursor for loop and an iterative commit within the loop every 300,000 ... This is the proc: ... CURSOR delrowcur IS ... IF (RCOUNT>= 300000) THEN ...
    (comp.databases.oracle.server)
  • Re: tcl lists
    ... i need to be able to set ALL the elements of the list in the same loop. ... other lists with different numbers or arguments which can be passed to ... the runVpn proc. ... proc SetOpt { ...
    (comp.lang.tcl)
  • Re: WaitCommEvent
    ... on the 2nd pass through the loop. ... if (WaitCommEvent(hCom, &dwEvtMask, &o)) ... count DSR pulses ... asynchronous operation to complete. ...
    (microsoft.public.vc.language)