hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports

Home Page:http://rubygems.org/gems/serialport

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XON is always activated

jvalrog opened this issue · comments

I'm trying to control an Arduino board with serialport, but I'm having difficulties. I'm calling "readbyte" several times to retrieve binary data, but it triggers a timeout at random intervals.

I found that the solution was to open the Arduino IDE, open the Serial Monitor, and close it.
By doing this, the Arduino IDE changed some parameters in the serial port and all the errors were gone after that.

Arduino requires no xon/xoff protocol.

So I investigated a bit and found that "serialport" disables xoff but not xon, while the arduino ide disabled both.

The output of "stty --file=/dev/ttyUSB0 -a" after opening the serial port with "serialport" is this (only interesting lines):

werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 10;
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff

And the output after opening it with the Arduino IDE is this:

werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 0;
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff

The only differences are the "time = 0" and "-ixon".
I'm opening the port with this code:

@serial = SerialPort.new(port, BAUDRATE, 8, 1, SerialPort::NONE)

I don't understand why XON is not disabled.

Also wanted to thank you for coding this gem!

This issue is related to this one: #34

Same problem/bug. I had to add "@serial.flow_control = SerialPort::NONE" by hand to fix my problem.