天天晴天 发表于 2008-9-1 20:12:30

[求助]关于串口出错的问题

我在进行串口数据接收和显示的时候串口老是出现 A framing error ocurred during transfer这个错误,发现在串口接收数据的时候,如果发出的速度太快总会出现这个错误,譬如我将两台PC机连接后,一台机子上用串口助手发送10个数据,另一台用LV接收,在自动发送周期长的时候,譬如1000毫秒的时候不会出现这个错误,但是当自动发送周期调到100毫秒以下时,总会出现这个错误,有哪位大虾知道什么原因吗?是不是LV反应不过来啊?

真心求助啊,对LV处理串口数据的过程真不太了解。我理解是串口发数据到PC机硬件BUFFER,然后LV把这个BUFFER里的数据存到LV软件BUFFER,那个LV里设置BUFFER大小的函数就是设置这个吧?把这个设置为4096,然后在读数的时候,用函数Number of port那个每次读出的数据,观察那个数值,却发现每次只有二三十个,这些读取数据真的把我搞晕了,有大虾不厌其烦给我讲讲吗??

谢谢~~~~!~~~

天天晴天 发表于 2008-9-2 10:12:26

没人知道吗。。。。。。。

飞雨天 发表于 2008-9-2 10:34:23

确实没有人知道~~~
除非你上传你的程序

cpubbs 发表于 2008-9-2 10:37:33

这种情况我好像曾经遇到过,但是后面不知道咋弄好的!会不会是前面的数据没有传输完成后面的数据把前面的覆盖掉导致的呢?这个确实不懂!

cpubbs 发表于 2008-9-2 10:42:42

也有可能是设置不同导致的!或者干扰!刚找了一些相关的东西看了一下!在NI上面找到的!

What Does Framing Error in Serial Communication Mean?

Primary Software: Driver Software>>NI-VISA
Primary Software Version: 3.2
Primary Software Fixed Version: N/A
Secondary Software: N/A



Problem: I received an error that says, "A framing error occurred during transfer" while performing serial communication. What does this error mean and how can I solve it?

Solution: Serial data is transferred one byte at a time. Each byte has a specific format with a start bit, data bits, parity, and stop bits. A framing error occurs when a byte of data is received, but it is not in the format expected.

Framing errors can be caused by a number of reasons. The most common reason is that your serial port and device are configured to use a different settings. To solve this problem in the Measurement and Automation Explorer (MAX) Select your serial port under Devices and Interfaces and verify that the Baud rate, Data bits, Parity, and Stop bits all match the settings of your device. Alternatively you can change these settings programmatically.

If your settings match your devices settings, and you are still receiving a framing error, you may be experiencing noise on your serial line.

天天晴天 发表于 2008-9-2 16:06:01

谢谢LS,但是应该不是干扰或者是帧格式不对了,因为这样的话应该跟传输速度没有关系吧~~
现在没有办法,只能慢慢地传,然后当读完1000多个点后存在数组里再做处理了~
这个问题不会是LV的BUG吧~其实我估计有可能想LS说的,是后面的数传过来了,但是前面的数还没有读完,后面的数把前面的数覆盖了~那这也太软肋了吧。。。

飞雨天 发表于 2008-9-2 16:19:38

我感到很奇怪,传个程序都不行吗?别动不动就说lv的bug

飞雨天 发表于 2008-9-2 16:27:41

串口很重要的就是配置,一些参数的配置。。
还有,问问题最好描述清楚一点,10个数据,每个数据多少字节?100ms以下,那是多少ms?不要用一个问题来,然后让大家猜测,这不是智力游戏,解决问题要有的放矢,就你这个frame error,起码有5种情况都可以产生这个现象,难道要大家一个一个来猜不成?
设置为4096,bytes atserial port(不是number of ports)去读取,数值为20、30很是正常,说明后续字节根本就没有把前面的给覆盖了,或者说是溢出。。。
当然,如果程序涉及保密,可以理解,那样就只能自己琢磨了。。
页: [1]
查看完整版本: [求助]关于串口出错的问题