|
- while (TRUE)
- {
-
- if(WaitCommEvent(ceSeries->m_hComm1,&evtMask,0))
- {
- SetCommMask (ceSeries->m_hComm1, EV_RXCHAR | EV_CTS | EV_DSR );
- //表示串口收到字符
- if(evtMask & EV_RXCHAR)
- {
- //清除错误并查询状态
- ClearCommError(ceSeries->m_hComm1,&dwReadErrors,&cmState);
- willReadLen = cmState.cbInQue ;//接收缓冲区中存储的待读取的字符数
- if (willReadLen <= 0)
- {
-
- continue;
- }
-
- readBuf = new BYTE[willReadLen+1];
-
- ReadFile(ceSeries->m_hComm1, readBuf, willReadLen, &actualReadLen,0);
- //如果读取的数据大于0,
- if(actualReadLen> 0)
- {
- WCHAR strmp[100]={0};
- MultiByteToWideChar(CP_ACP,0,(char *)readBuf,actualReadLen,strmp,actualReadLen);
- ceSeries->m_strRespBuf+=strmp;
- SetEvent(ceSeries->m_hATCmdRespEvent);
- actualReadLen=0;
- }
- }
- }
复制代码 |
|