I have a tiny shell script that writes to a serial device:
require 'rubygems'
require 'serialport'
@sp = SerialPort.new "/dev/tty.usbserial-A6004cNN", 19200
@sp.write ["\x01\x01\x04\x00", "n", "\xff\xff\xff"]
This is not written to the serial device when I run ./script.shin this directory. However, when I go to IRB and run:
require 'serialport'
@sp = SerialPort.new "/dev/tty.usbserial-A6004cNN", 19200
@sp.write ["\x01\x01\x04\x00", "n", "\xff\xff\xff"]
This method works ... I'm puzzled. Could this be the way I am outputting my byte array? This does not seem to be correct, it’s just a ruby ruby, it has no obvious dependencies. In addition, the script does not throw exceptions, it runs just fine, but the device just doesn't respond.
How can I debug this? I'm not sure where to start.
source
share