Class: ModBus::RTUClient
- Defined in:
- lib/rmodbus/rtu_client.rb
Overview
RTU client implementation
Instance Attribute Summary
Attributes included from TCP
Attributes included from SP
#baud, #data_bits, #parity, #port, #read_timeout, #stop_bits
Attributes included from Options
#raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Attributes included from Debug
#logger, #raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Instance Method Summary collapse
- #get_slave(uid, io) ⇒ Object protected
-
#open_connection(port_or_ipaddr, arg = nil, opts = {}) ⇒ Object
protected
Open serial port.
Methods included from TCP
Methods included from SP
Methods included from RTU
#clean_input_buff, #crc16, #read, #read_rtu_request, #read_rtu_response, #serve
Methods inherited from Client
#close, #closed?, #initialize, #with_slave
Methods included from Debug
Constructor Details
This class inherits a constructor from ModBus::Client
Instance Method Details
#get_slave(uid, io) ⇒ Object (protected)
39 40 41 |
# File 'lib/rmodbus/rtu_client.rb', line 39 def get_slave(uid, io) RTUSlave.new(uid, io) end |
#open_connection(port_or_ipaddr, arg = nil, opts = {}) ⇒ Object (protected)
Open serial port
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rmodbus/rtu_client.rb', line 27 def open_connection(port_or_ipaddr, arg = nil, opts = {}) if port_or_ipaddr.is_a?(IO) || port_or_ipaddr.respond_to?(:read) port_or_ipaddr elsif File.exist?(port_or_ipaddr) || port_or_ipaddr.start_with?('/dev') || port_or_ipaddr.start_with?('COM') arg ||= 9600 open_serial_port(port_or_ipaddr, arg, opts) else arg ||= 10002 open_tcp_connection(port_or_ipaddr, arg, opts) end end |