Class: Modbus::Connection::Base
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Modbus::Connection::Base
- Defined in:
- lib/modbus/connection/base.rb
Instance Method Summary collapse
- #analyze_buffer ⇒ Object
-
#initialize(handler) ⇒ Base
constructor
A new instance of Base.
- #receive_data(data) ⇒ Object
- #reset_buffer ⇒ Object
Constructor Details
#initialize(handler) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/modbus/connection/base.rb', line 10 def initialize(handler) @handler = handler reset_buffer end |
Instance Method Details
#analyze_buffer ⇒ Object
32 33 34 35 |
# File 'lib/modbus/connection/base.rb', line 32 def analyze_buffer success = transaction_class.recv_adu @buffer, self analyze_buffer if success && !@buffer.empty? end |
#receive_data(data) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/modbus/connection/base.rb', line 16 def receive_data(data) @buffer << data analyze_buffer rescue => e # TODO log exception # puts e.message reset_buffer end |
#reset_buffer ⇒ Object
27 28 29 |
# File 'lib/modbus/connection/base.rb', line 27 def reset_buffer @buffer = String.new end |