Ruby 串口随机丢失字节
使用串行端口库的人注意到了这一点,还是只有我注意到了?我发现很少有人处于同样的情况,但我没有找到解决方案。
这是我使用 ruby 串行端口得到的示例:
ff d8 ff e0 00 4a 46 49 46 00 01 02 03 04 05 06 07 08 09 0a ff db 00 43 00 10 0c 0c 0e 0c 0a 10 0e 0e 0e 12 12 10 14 18 28 1a 18 16 16 18 32 24 26 1e 28 3a 34 3e 3c 3a 34 38 38 40 48 5c 4e 40 44 58 46 38 38 50 6e 52 58 60 62 68 68 68 3e 4e 72 7a 70 64 78 5c 66 68 64 ff db 00 43 01 12 12 12 16 16 16 30 1a 1a 30 64 42 38 42 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 36 00
这是我同时使用 gtkterm 得到的示例!
ff d8 ff e0 00 11
4a 46 49 46 00 01 02 03 04 05 06 07 08 09 0a ff db 00 43 00 10 0c 0c 0e 0c 0a 10 0e 0e 0e 12 12 10 14 18 28 1a 18 16 16 18 32 24 26 1e 28 3a 34 3e 3c 3a 34 38 38 40 48 5c 4e 40 44 58 46 38 38 50 6e 52 58 60 62 68 68 68 3e 4e 72 7a 70 64 78 5c 66 68 64 ff db 00 43 01 12 12 12 16 16 16 30 1a 1a 30 64 42 38 42 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 36 00
我正在使用 FTDI 分线器和带有 uart 接口的设备。它似乎是随机的:(它是我用“sudo gem install serialport”安装的serialport-1.0.4。
谢谢!
Someone using the serialport library noticed that or it's just me? I found (very) few people in the same situation but I got no solution.
Here is an example of what I get with ruby serialport:
ff d8 ff e0 00 4a 46 49 46 00 01 02 03 04 05 06 07 08 09 0a ff db 00 43 00 10 0c 0c 0e 0c 0a 10 0e 0e 0e 12 12 10 14 18 28 1a 18 16 16 18 32 24 26 1e 28 3a 34 3e 3c 3a 34 38 38 40 48 5c 4e 40 44 58 46 38 38 50 6e 52 58 60 62 68 68 68 3e 4e 72 7a 70 64 78 5c 66 68 64 ff db 00 43 01 12 12 12 16 16 16 30 1a 1a 30 64 42 38 42 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 36 00
Here is an example of what I get with gtkterm, at the same time!
ff d8 ff e0 00 11
4a 46 49 46 00 01 02 03 04 05 06 07 08 09 0a ff db 00 43 00 10 0c 0c 0e 0c 0a 10 0e 0e 0e 12 12 10 14 18 28 1a 18 16 16 18 32 24 26 1e 28 3a 34 3e 3c 3a 34 38 38 40 48 5c 4e 40 44 58 46 38 38 50 6e 52 58 60 62 68 68 68 3e 4e 72 7a 70 64 78 5c 66 68 64 ff db 00 43 01 12 12 12 16 16 16 30 1a 1a 30 64 42 38 42 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 36 00
I'm using an FTDI breakout and a device with an uart interface. It seems to be random :( it's serialport-1.0.4 which I installed with "sudo gem install serialport".
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您是否在研究中偶然发现了这一点,但本文提到了对serialport.c 的修改,该修改修复了该错误:Ruby、Ruby-SerialPort 和丢失的字节
以下是链接中的文本,以防链接失效:
Not sure if you stumbled upon this in your researches, but this article mentions a modification to serialport.c that fixes the bug: Ruby, Ruby-SerialPort and the missing bytes
Here's the text from the link in case it ever goes down:
我遇到了完全相同的问题 - 始终丢失相同的字节。我将其范围缩小到
0x11
和0x13
,我注意到这也是您所缺少的。问题在于这些 ASCII 字符用于软件流控制。默认情况下,
SerialPort
实例启用软件流控制,从而过滤掉这些字节。您必须手动禁用它:I had this EXACT same issue - consistently missing the same bytes. I narrowed it down to
0x11
and0x13
, which I notice is also what you are missing.The problem is that these ASCII characters are used for software flow control. The
SerialPort
instance has software flow control on by default, which filters out these bytes. You must manually disable it: