Forum: Ruby Cant connect to serial port

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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.