Cant connect to serial port

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

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,

com = 3
sp =, parameters)
sp.flow_control = SerialPort::NONE