I'm coding a serial protocol to control the arduino (like the "arduino" gem).
The problem I have is that the transmission will hit timeouts continuosly, making it unusable. I also tried the "arduino" gem and got the same problem.
So, after a lot of trials and errors, I found the solution/bug.
Start the arduino IDE -> Start the Serial Monitor -> Close it.
Doing this, the serial port gets "fixed" and no more timeouts happen with the "arduino" gem or my own code.
I initialize the serial port like this:
def initialize(port = "/dev/ttyUSB0") @serial = SerialPort.new(port, BAUDRATE, 8, 1, SerialPort::NONE) @serial.sync = true @serial.read_timeout = TIMEOUT end
My conclussion is the "serialport" gem initializes in a wrong way the serial port, and the Arduino Serial Monitor fixes that.
Have you faced this trouble?