谁写过 API 串口 程序啊!我现在遇到关于 API 串口 程序问题,用重叠方式读写操作 ,就是在接收的时候怎么判断一帧数据接收完?我想了很多办法都不行啊?fState=ReadFile(pDoc->m_hCom,pDoc->m_OptionP.sReceive,dwsLen2,&length,&pDoc->m_osRead);
if(!fState)
{
     if(GetLastError()==ERROR_IO_PENDING)
     {
WaitForSingleObject(pDoc->m_osRead.hEvent, 2000);
while(!GetOverlappedResult(pDoc->m_hCom,&pDoc->m_osRead,&dwBytesRead,TRUE))
{
     dwError=GetLastError();
     if(dwError==ERROR_IO_INCOMPLETE)
continue;
pDoc->m_OptionP.bOt[2]=TRUE;
         }
      }
      else
     {
pDoc->m_OptionP.bOt[2]=TRUE;//通知视图
      }
}还有 我看资料说用 WaitCommEvent(pDoc->m_hCom, &dwMask, &os) 检测  MASK 事件;ClearCommError(m_hCom,&dwErrorFlags,&ComStat);
switch(dwErrorFlags)
{
case CE_BREAK:               // MSDN : The hardware detected a break condition.
break;
case CE_FRAME:               // MSDN : The hardware detected a framing error.
break;
case CE_IOE:                 // MSDN : An I/O error occurred during communications with the device.
break;
case CE_MODE:                // MSDN : The requested mode is not supported, or the hFile parameter is invalid. If this value is specified, it is the only valid error.
break;
case CE_OOP:                 // MSDN : Windows Me/98/95:  A parallel device signaled that it is out of paper.
break;
case CE_OVERRUN:             // MSDN : A character-buffer overrun has occurred. The next character is lost.
break;
case CE_PTO:                 // MSDN : Windows Me/98/95:  A time-out occurred on a parallel device.
break;
case CE_RXOVER:              // MSDN : An input buffer overflow has occurred. There is either no room in the input buffer, or a character was received after the end-of-file (EOF) character.
break;
case CE_RXPARITY:            // MSDN : The hardware detected a parity error.
break;
case CE_TXFULL:              // MSDN : The application tried to transmit a character, but the output buffer was full.
break;
}这里面也没有定义接收数据帧 完成 事件啊 ?只有发送最后一个完成 CE_RXPARITY 事件!我又想了检测超时的办法,但是连接收都接收不到啊!怎么检测接收超时事件?COMMTIMEOUTS TimeOuts;
         TimeOuts.ReadIntervalTimeout=6; 
TimeOuts.ReadTotalTimeoutMultiplier=1; 
TimeOuts.ReadTotalTimeoutConstant=2000;
SetCommTimeouts(m_hCom, &TimeOuts);这样设置对不对?