懂串口的大神进来~~~~

sharp0077 2018-02-28 02:54:12
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种错误!!!

...全文
465 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
worldy 2018-02-28
  • 打赏
  • 举报
回复
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.//硬件奇偶校验出错,校验位的值和数据不符合
schlafenhamster 2018-02-28
  • 打赏
  • 举报
回复
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.
schlafenhamster 2018-02-28
  • 打赏
  • 举报
回复
搜索“Universal asynchronous receiver-transmitter“

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧