hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports
http://rubygems.org/gems/serialport
GNU General Public License v2.0
246 stars 58 forks source link

flow_control= does not seem to work #31

Closed erubin closed 12 years ago

erubin commented 12 years ago

I am trying to communicate via USB to a board that requires no flow control. I am creating the SerialPort as follows:

@@port = SerialPort.new("/dev/ttyUSB0", :baud => 9600, :data_bits => 8, :stop_bits => 1, :parity => SerialPort::NONE, :flow_control => SerialPort::NONE)

It says that @@port.flow_control is 0, but I can't communicate with the board. When I turn off flow control with minicom it works fine, and after that my ruby code can talk to the board (presumably because minicom leaves flow control off when it exits). Explicitly saying @@port.flow_control = SerialPort::NONE doesn't help.

So it seems that serialport (1.0.4) is not actually turning off flow control. Has anyone else seen this? An suggestions for a workaround? (I'm running Ruby 1.9 under CentOS 5.7)

Eric Rubin

hparra commented 12 years ago

Reviewed issue. Reviewing code.

hparra commented 12 years ago

If you can confirm that you are not getting an IOError thrown that would help.

erubin commented 12 years ago

It turned out that the problem was not just with flow_control but with other parameters as well.

There does seem to be a problem with setting parameters from a hash. When I do this:

@@port = SerialPort.new("/dev/ttyUSB0", :baud => 9600, :data_bits => 8, :stop_bits => 1, :parity => SerialPort::NONE)

parameters do not get set.

When I do this:

@@port = SerialPort.new("/dev/ttyUSB0") @@port.baud = 9600 @@port.data_bits = 8 @@port.stop_bits = 1 @@port.parity = SerialPort::NONE @@port.flow_control = SerialPort::NONE

It works fine.