Method: OpenC3::SerialInterface#initialize

Defined in:
lib/openc3/interfaces/serial_interface.rb

#initialize(write_port_name, read_port_name, baud_rate, parity, stop_bits, write_timeout, read_timeout, protocol_type = nil, *protocol_args) ⇒ SerialInterface

Creates a serial interface which uses the specified stream protocol.

Parameters:

  • write_port_name (String)

    The name of the serial port to write

  • read_port_name (String)

    The name of the serial port to read

  • baud_rate (Integer)

    The serial port baud rate

  • parity (Symbol)

    The parity which is normally :NONE. Must be one of :NONE, :EVEN, or :ODD.

  • stop_bits (Integer)

    The number of stop bits which is normally 1.

  • write_timeout (Float)

    Seconds to wait before aborting writes

  • read_timeout (Float|nil)

    Seconds to wait before aborting reads. Pass nil to block until the read is complete.

  • protocol_type (String) (defaults to: nil)

    Combined with 'Protocol' to resolve to a OpenC3 protocol class

  • protocol_args (Array)

    Arguments to pass to the protocol constructor



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/openc3/interfaces/serial_interface.rb', line 43

def initialize(write_port_name,
               read_port_name,
               baud_rate,
               parity,
               stop_bits,
               write_timeout,
               read_timeout,
               protocol_type = nil,
               *protocol_args)
  super(protocol_type, protocol_args)

  @write_port_name = ConfigParser.handle_nil(write_port_name)
  @read_port_name = ConfigParser.handle_nil(read_port_name)
  @baud_rate = baud_rate
  @parity = parity.to_s.intern
  @stop_bits = stop_bits
  @write_timeout = write_timeout
  @read_timeout = read_timeout
  @write_allowed = false unless @write_port_name
  @write_raw_allowed = false unless @write_port_name
  @read_allowed = false unless @read_port_name
  @flow_control = :NONE
  @data_bits = 8
end