3,245
社区成员
发帖
与我相关
我的任务
分享
for (;;)
{
bResult = WaitCommEvent(port->m_hComm, &Event, &port->m_ov);
if (!bResult)
{
// If WaitCommEvent() returns FALSE, process the last error to determin
// the reason..
switch (dwError = GetLastError())
{
case ERROR_IO_PENDING:
{
break;
}
case 87:
{
break;
}
default:
{
port->ProcessErrorMessage("WaitCommEvent()");
// add 2014-05-30 by shq, 检测到错误后停住串口进程
CloseHandle(port->m_hComm);
port->m_hComm = NULL;
port->m_bThreadAlive = FALSE;
AfxEndThread(100);
return 0;
// end
}
}
}
else
{
bResult = ClearCommError(port->m_hComm, &dwError, &comstat);
if (comstat.cbInQue == 0)
continue;
} // end if bResult
}