硬件流控制位不适用于 ruby​​-serialport gem [英] Hardware flow control bits not working for ruby-serialport gem

查看:47
本文介绍了硬件流控制位不适用于 ruby​​-serialport gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 USB 串行端口适配器的控制位用作通用 I/O.这个简单的例子应该将 DTR 线切换为高电平,然后是低电平.

I am trying to use the control bits of a USB serial port adapter as general purpose I/O. This simple example should toggle the DTR line high, then low.

require 'serialport'

DataBits = 8
StopBits = 1
Parity = SerialPort::NONE
Baud = 38400

port = '/dev/tty.usbserial-A100KXWU'

serial = SerialPort.new(port, 'baud' => Baud, 'data_bits' => DataBits, 'stop_bits' => StopBits, 'parity' => Parity)
serial.flow_control = SerialPort::HARD

loop do
    p serial.signals
    sleep(1)
    serial.dtr = (serial.dtr + 1) % 2
end

和输出:

{"rts"=>1, "dtr"=>1, "cts"=>1, "dsr"=>0, "dcd"=>0, "ri"=>0}
{"rts"=>1, "dtr"=>0, "cts"=>1, "dsr"=>0, "dcd"=>0, "ri"=>0}
{"rts"=>1, "dtr"=>1, "cts"=>1, "dsr"=>0, "dcd"=>0, "ri"=>0}
{"rts"=>1, "dtr"=>0, "cts"=>1, "dsr"=>0, "dcd"=>0, "ri"=>0}

就 Ruby 而言,serial.dtr 正在发生变化,但 DTR 引脚的输出电压没有变化.这是一个恒定的+7V.

As far as Ruby is concerned, serial.dtr is changing, but there is no change on the output voltage of the DTR pin. It's a constant +7V.

此外,serial 实例无法读取来自其他硬件设备的任何应用于 CTS、DSR 或 DCD 的更改.

Additionally, the serial instance is unable to read any changes applied to CTS, DSR, or DCD coming from other hardware devices.

它以 sudo 权限运行,所以这不是权限问题.这是在 OS X 10.10 Yosemite 上运行的.

It is being run with sudo privileges, so it's not a issue with permissions. This is on OS X 10.10 Yosemite.

推荐答案

我正在回答我自己的问题.事实证明,Apple 提供的 FTDI 驱动程序有问题.他们不提供任何控制信号的访问权限.

I'm answering my own question. It turns out that Apple's supplied FTDI drivers are buggy. They don't give any access to the control signals.

我安装了官方 FTDI VCP 驱动程序(在撰写本文时为 2.3 版),重新启动,现在我可以完全控制了.

I installed the official FTDI VCP drivers (version 2.3 at this time of writing), rebooted, and now I have full control.

这篇关于硬件流控制位不适用于 ruby​​-serialport gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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