+def init_serialport(conf)
+ puts("serial port interface version: " + SerialPort::VERSION);
+ $linewidth = 64
+ $linepos = 0
+ $testno = 0
+ params = { "baud" => conf["PORT"]["baud"].to_i,
+ "data_bits" => conf["PORT"]["databits"].to_i,
+ "stop_bits" => conf["PORT"]["stopbits"].to_i,
+ "parity" => SerialPort::NONE }
+ params["paraty"] = SerialPort::ODD if conf["PORT"]["paraty"].downcase == "odd"
+ params["paraty"] = SerialPort::EVEN if conf["PORT"]["paraty"].downcase == "even"
+ params["paraty"] = SerialPort::MARK if conf["PORT"]["paraty"].downcase == "mark"
+ params["paraty"] = SerialPort::SPACE if conf["PORT"]["paraty"].downcase == "space"
+
+ puts("\nPort: "+conf["PORT"]["port"]+"@" +
+ params["baud"].to_s +
+ " " +
+ params["data_bits"].to_s +
+ conf["PORT"]["paraty"][0,1].upcase +
+ params["stop_bits"].to_s +
+ "\n")
+
+ $sp = SerialPort.new(conf["PORT"]["port"], params)
+
+ $sp.read_timeout=1000; # 5 minutes
+ $sp.flow_control = SerialPort::SOFT
+
+ reset_system()
+end
+