Class: ModBus::RTUServer
- Inherits:
-
Object
- Object
- ModBus::RTUServer
- Defined in:
- lib/rmodbus/rtu_server.rb
Overview
RTU server implementation
Constant Summary
Constants included from Server
Instance Attribute Summary
Attributes included from SP
#baud, #data_bits, #parity, #port, #read_timeout, #stop_bits
Attributes included from Server
#promiscuous, #request_callback, #response_callback
Attributes included from Debug
#logger, #raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Instance Method Summary collapse
-
#initialize(port, baud = 9600, opts = {}) ⇒ RTUServer
constructor
Init RTU server.
-
#join ⇒ Object
Join server.
-
#start ⇒ Object
Start server.
-
#stop ⇒ Object
Stop server.
Methods included from SP
Methods included from Server
Constructor Details
#initialize(port, baud = 9600, opts = {}) ⇒ RTUServer
Init RTU server
23 24 25 26 27 28 29 30 |
# File 'lib/rmodbus/rtu_server.rb', line 23 def initialize(port, baud = 9600, opts = {}) Thread.abort_on_exception = true @sp = if port.is_a?(IO) || port.respond_to?(:read) port else open_serial_port(port, baud, opts) end end |
Instance Method Details
#join ⇒ Object
Join server
46 47 48 |
# File 'lib/rmodbus/rtu_server.rb', line 46 def join @serv.join end |
#start ⇒ Object
Start server
33 34 35 36 37 |
# File 'lib/rmodbus/rtu_server.rb', line 33 def start @serv = Thread.new do serve(@sp) end end |
#stop ⇒ Object
Stop server
40 41 42 43 |
# File 'lib/rmodbus/rtu_server.rb', line 40 def stop Thread.kill(@serv) @sp.close end |