在串口初始化里设置超时部分
m_CommTimeouts.ReadIntervalTimeout = 10;          //两字符之间最大的延时
m_CommTimeouts.ReadTotalTimeoutMultiplier = 10;  //指定比例因子(毫秒)
m_CommTimeouts.ReadTotalTimeoutConstant = 100;   //一次读取串口数据的固定超时。
m_CommTimeouts.WriteTotalTimeoutMultiplier = 10; //写入每字符间的超时。
m_CommTimeouts.WriteTotalTimeoutConstant = 10;   //一次写入串口数据的固定超时。 // configure
if (SetCommTimeouts(m_hComm, &m_CommTimeouts))
{    
if (SetCommMask(m_hComm, dwCommEvents))
{
if (GetCommState(m_hComm, &m_dcb))
{
}
else
ProcessErrorMessage("GetCommState()");
}
else
ProcessErrorMessage("SetCommMask()");
}
else
  ProcessErrorMessage("SetCommTimeouts()"); 读串口
if (bRead)
{
bResult = ReadFile(port->m_hComm, // Handle to COMM port 
   pRXBuff, // RX Buffer Pointer
   comstat.cbInQue, // Read one byte
   &BytesRead, // Stores number of bytes read
   &rol);//port->m_ov); // pointer to the m_ov structure

if (!bResult)  

switch (dwError = GetLastError()) 

case ERROR_IO_PENDING: 

bRead = FALSE;
break;
}
default:
{
port->ProcessErrorMessage("ReadFile()");
break;

}
}
else
{
bRead = TRUE;
}
}  // close if (bRead) if (!bRead)
{
bRead = TRUE;   //当调用ReadFile, WriteFile 函数的时候,该GetOverlappedResult会自动被置为无信号状态;当重叠操作完成后,该成员变量会自动被置为有信号状态。
bResult = GetOverlappedResult(port->m_hComm, // Handle to COMM port 
  &port->m_ov, // Overlapped structure
  &BytesRead, // Stores number of bytes read
  TRUE);  // Wait flag if (!bResult)  
{
port->ProcessErrorMessage("GetOverlappedResults() in ReadFile()");
}
}  // close if (!bRead)




1。我设置软件上位机的接收字符最大延时不能超过10MS 
2。设置后我向上位机串口发送的字节与字节的时间间隔为100MS
3。我看了一些串口超时设置上面说“ 在用重叠方式读写串口时,虽然ReadFile和WriteFile在完成操作以前就可能返回,但超时仍然是起作用的。在这种情况下,超时规定的是操作的完成时间,而不是ReadFile和WriteFile的返回时间。

4。为上面发送时间间隔都100MS了,按道理来说应该出现串口的通讯错误提示,可是程序中并没有提示错误?WHY?