在串行通信中收到不正确的两个字节 [英] Received incorrect two bytes in serial communication

查看:82
本文介绍了在串行通信中收到不正确的两个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的环回设置,即从端口A传输到端口B,然后从端口B传输回端口A.该程序不使用事件检测,而是依靠从一个端口传输到端口的已知时序.其他.配置效果很好,为99.99%,但偶尔 它看到两个不正确的前两个字节.更多细节和问题:

I have a simple loop back setting of transmitting from portA to PortB, then Port B back to port A. The program doesn't use event detection, but rely on the known timing it takes from one port to the other. The configuration works well 99.99%, but occasionally it sees two incorrect first two bytes. A bit more details and questions:

-默认情况下,在窗口中是启用还是禁用16C550中的16字节发送和接收FIFO?芯片的默认制造商为关闭,但是我在窗口中看到一些文档吗?如果启用,默认的触发级别是多少 接收FIFO?

- The 16-byte transmit and receive FIFOs in the 16C550 are they enabled or disabled by default in window? The manufacture of the chip default is off, but I see some documentation that it is on in window? If it is on, what is the default trigger level on receive FIFO?

-我使用的是Visual Studio2008.传输字节为18字节长,速度为19200bits/sec.在一个端口上进行写入与从另一端口进行读取之间的等待时间为15ms.

- I'm using Visual Studio 2008. The transfer byte is 18-byte long at 19200bits/sec. The wait between write on one port and read from the other port is 15ms.

-该程序在win7上运行. XP上的相同程序存在更大的问题.每次传输它必须接收两次,因为第一次读取/接收未获得完整的18个字节.

- The program runs on win7. The same program on XP has bigger problem. It has to receive twice for each transfer as the first read/receive doesn't get full 18-bytes.

推荐答案

Microsoft不会"不知道如何隐含16C550硬件中断.自从尝试使用XBasic在第一代PC(8086)上读取80C50以来,我一直遇到这个问题.不要笑.是真的.我是UART的专家, 从开始就在PC上对其进行编程.

Microsoft doesn't know how to impliment the 16C550 hardware interupt.  I've been having this problem since I tried to read a 80C50 on a first generation PC (8086) using XBasic.  Don't laugh.  It is true.  I'm an expert with UARTs and programming them on PC since the beginning of time.

大多数人编写自己的驱动程序来读写UART,因为Windows中的驱动程序使用缓冲而不是硬件中断.缓冲在PC计时器滴答声之后运行,并且在高传输速率下可能无法恢复到足够快的速度来读取数据 由于PC上正在运行其他进程.

Most people write their own driver to read and write UART because the drivers in windows use buffering instead of hardware interupts.  The buffering is runs off the PC timer tick and at high transfer rates may not get back to read data quick enough because of other processes running on the PC.

您使用的是硬件还是软件控件?在接口上启用硬件控制将允许UART在发生溢出之前停止数据.您可能需要阅读uart中的溢出位,以帮助确定问题是否在 Uart本身或网络库(实际上是Windows的一部分)中的其他缓冲区会丢失数据.我已经看到从UART读取数据后出现的窗口问题.

Are you using hardware or software controls?  Enabling hardware control on the interface will allow the UART to stop data before an overflow occurs.  You may want to read the overflow bit in the uart to help determine if the problem is in the Uart itself or other buffers in the Net Library (actually part of windows) the is dropping the data.  I've seen problems in windows that occured after the data was read out of the UART.


这篇关于在串行通信中收到不正确的两个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆