|
代码如下:
- if (WaitCommEvent(ceSeries->m_hComm,&evtMask,0))
- {
- SetCommMask (ceSeries->m_hComm, EV_RXCHAR);// | EV_CTS | EV_DSR );
- //表示串口收到字符
- if (evtMask & EV_RXCHAR)
- {
- //清除错误并查询状态
- ClearCommError(ceSeries->m_hComm,&dwReadErrors,&cmState);
- willReadLen = cmState.cbInQue ;//接收缓冲区中存储的待读取的字符数
- if (willReadLen <= 0)
- {
- continue;
- }
- readBuf = new BYTE[willReadLen+1];
-
- ReadFile(ceSeries->m_hComm, readBuf, willReadLen, &actualReadLen,0);
- readBuf[willReadLen]=0;
-
- //如果读取的数据大于0,
- if (actualReadLen>0)
- { //修改
- //触发读取回调函数,发送数据到应用程序
-
- //////////////////////////////////////////////////////////////////////////
- //Test
- TCHAR TempPrint[512] = {0};
- mbstowcs(TempPrint, (const CHAR*)readBuf, willReadLen);
- RETAILMSG(1, (TempPrint));
- RETAILMSG(1, (_T("\r\n ::Actual Read Len = %d \r\n"), actualReadLen));
- //Test
- //////////////////////////////////////////////////////////////////////////
- memset(readBuf, 0, sizeof(readBuf));[/align] }
- }
- }
复制代码
第一次运行到ClearCommError就阻塞在这里了;
如果我在这里加个断点,单步执行下去就没有问题
指教,谢谢!
|
|