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
#debug, #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
21 22 23 24 25 26 27 28 |
# File 'lib/rmodbus/rtu_server.rb', line 21 def initialize(port, baud=9600, opts = {}) Thread.abort_on_exception = true if port.is_a?(IO) || port.respond_to?(:read) @sp = port else @sp = open_serial_port(port, baud, opts) end end |
Instance Method Details
#join ⇒ Object
Join server
44 45 46 |
# File 'lib/rmodbus/rtu_server.rb', line 44 def join @serv.join end |
#start ⇒ Object
Start server
31 32 33 34 35 |
# File 'lib/rmodbus/rtu_server.rb', line 31 def start @serv = Thread.new do serve(@sp) end end |
#stop ⇒ Object
Stop server
38 39 40 41 |
# File 'lib/rmodbus/rtu_server.rb', line 38 def stop Thread.kill(@serv) @sp.close end |