Module: ModBus::SP
Instance Attribute Summary collapse
-
#baud ⇒ Object
readonly
Returns the value of attribute baud.
-
#data_bits ⇒ Object
readonly
Returns the value of attribute data_bits.
-
#parity ⇒ Object
readonly
Returns the value of attribute parity.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#stop_bits ⇒ Object
readonly
Returns the value of attribute stop_bits.
Instance Method Summary collapse
-
#open_serial_port(port, baud, opts = {}) ⇒ SerialPort
Open serial port.
Instance Attribute Details
#baud ⇒ Object (readonly)
Returns the value of attribute baud.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def baud @baud end |
#data_bits ⇒ Object (readonly)
Returns the value of attribute data_bits.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def data_bits @data_bits end |
#parity ⇒ Object (readonly)
Returns the value of attribute parity.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def parity @parity end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def port @port end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def read_timeout @read_timeout end |
#stop_bits ⇒ Object (readonly)
Returns the value of attribute stop_bits.
11 12 13 |
# File 'lib/rmodbus/sp.rb', line 11 def stop_bits @stop_bits end |
Instance Method Details
#open_serial_port(port, baud, opts = {}) ⇒ SerialPort
Open serial port
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rmodbus/sp.rb', line 22 def open_serial_port(port, baud, opts = {}) @port, @baud = port, baud @data_bits, @stop_bits, @parity = 8, 1, :none @data_bits = opts[:data_bits] unless opts[:data_bits].nil? @stop_bits = opts[:stop_bits] unless opts[:stop_bits].nil? @parity = opts[:parity] unless opts[:parity].nil? CCutrer::SerialPort.new(@port, baud: @baud, data_bits: @data_bits, stop_bits: @stop_bits, parity: @parity) end |