Hi:
Here is to monitor the any character arrives in COM Port
Code:
while(TRUE)
{
if (!WaitCommEvent(COM1, &dwCommEvent, &osStatus))
{
if (GetLastError() != ERROR_IO_PENDING) // Wait not delayed!!
{
/*ERROR HANDLING HERE*/
}
else
// while(TRUE)
//{
deRes = WaitForSingleObject(osStatus.hEvent,3000);
switch(deRes)
{
case WAIT_OBJECT 0:
/*osStatus.hEvent gets signaled*/
break;
case WAIT_TIMEOUT:
MessageBox(0,"timeouts","ok",MB_OK);
break;
default:
............
break;
}
// }//end while(TRUE)
}
}
Here I hope those varaibles are cleared with the names.
The problem is that the GetLastError() is not pending after the first round WM_TIMEOUT,I just can't say the reason, but is there any way to avoid the error if I want to restart from WaitCommEvent() after every WM_TIMEOUT??
Thanx for the help!!!