Forum: Ruby Cant connect to serial port

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C54593ef3484f721bb5bd98dd32d07a0?d=identicon&s=25 William Volz (billv)
on 2016-12-26 18:33
I have a A/D converter board attached to a serial port that I access
though Ruby. The problem is that the program won't connect to the serial
port unless I first connect to the port using Putty. I'd like to resolve
this issue so I can run the program automatically after a reboot. It
hangs when .new is called. I think it has to do with the flow control -
it needs to be None but I don't see a way of setting that before calling
.new.

Also is there a way to programmically determine the COM port? I was COM3
and then suddenly changed to COM4.

The relevant code section is:

parameters = { "baud"=>9600,
               "data_bits"=>8,
               "stop_bits"=>1,
               "parity"=>SerialPort::NONE}

com = 3
sp = SerialPort.new(com, parameters)
sp.flow_control = SerialPort::NONE
This topic is locked and can not be replied to.