OVERLAPPED os ;
WaitCommEvent( m_idComDev, &dwEvtMask, &os ) ;
用串口轉USB線后,
if ((dwEvtMask & EV_ERR) == EV_ERR)
走到這里了報錯了
串口接受端 讀資料時調以下函式
ClearCommError( m_idComDev, &dwErrorFlags, &ComStat ) ;
其中有一次 dwErrorFlags 回傳0x0008 (CE_FRAME)
網上查了下EV_ERR有以下三種
CE_FRAME 0x0008 The hardware detected a framing error.
CE_OVERRUN 0x0002 A character-buffer overrun has occurred. The next character is lost.
CE_RXPARITY 0x0004 The hardware detected a parity error.
網上這3個錯誤的解釋太少,求大神解答下,什么原因會出現這3種錯誤!!!
uj5u.com熱心網友回復:
Special transceiver conditions[edit]Overrun error[edit]
An "overrun error" occurs when the receiver cannot process the character that just came in before the next one arrives. Various devices have different amounts of buffer space to hold received characters. The CPU or DMA controller must service the UART in order to remove characters from the input buffer. If the CPU or DMA controller does not service the UART quickly enough and the buffer becomes full, an Overrun Error will occur, and incoming characters will be lost.
Underrun error[edit]
An "underrun error" occurs when the UART transmitter has completed sending a character and the transmit buffer is empty. In asynchronous modes this is treated as an indication that no data remains to be transmitted, rather than an error, since additional stop bits can be appended. This error indication is commonly found in USARTs, since an underrun is more serious in synchronous systems.
Framing error[edit]
A "framing error" occurs when the designated "start" and "stop" bits are not found. As the "start" bit is used to identify the beginning of an incoming character, it acts as a reference for the remaining bits. If the data line is not in the expected state (hi/lo) when the "stop" bit is expected, a Framing Error will occur.
Parity error[edit]
A Parity Error occurs when the parity of the number of 1 bits disagrees with that specified by the parity bit. Use of a parity bit is optional, so this error will only occur if parity-checking has been enabled.
Break condition[edit]
A "break condition" occurs when the receiver input is at the "space" (logic low, i.e., '0') level for longer than some duration of time, typically, for more than a character time. This is not necessarily an error, but appears to the receiver as a character of all zero bits with a framing error. The term "break" derives from current loop signaling, which was the traditional signaling used for teletypewriters. The "spacing" condition of a current loop line is indicated by no current flowing, and a very long period of no current flowing is often caused by a break or other fault in the line.
Some equipment will deliberately transmit the "space" level for longer than a character as an attention signal. When signaling rates are mismatched, no meaningful characters can be sent, but a long "break" signal can be a useful way to get the attention of a mismatched receiver to do something (such as resetting itself). Unix-like systems can use the long "break" level as a request to change the signaling rate, to support dial-in access at multiple signaling rates. The DMX512 protocol uses the break condition to signal the start of a new packet.
uj5u.com熱心網友回復:
搜索“Universal asynchronous receiver-transmitter“uj5u.com熱心網友回復:
CE_FRAME 0x0008 The hardware detected a framing error.//幀錯誤,比如位數不足或者超過CE_OVERRUN 0x0002 A character-buffer overrun has occurred. The next character is lost. //緩沖區溢位,緩沖區滿之后,就不再接收資料
CE_RXPARITY 0x0004 The hardware detected a parity error.//硬體奇偶校驗出錯,校驗位的值和資料不符合
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/73814.html
標籤:基礎類
