Class: Modbus::PDU::Exception
- Inherits:
-
Modbus::PDU
- Object
- Modbus::PDU
- Modbus::PDU::Exception
- Defined in:
- lib/modbus/pdu/exception.rb
Overview
PDU for modbus exception (response message)
Constant Summary
Constants inherited from Modbus::PDU
Instance Attribute Summary collapse
-
#exception_code ⇒ Object
Returns the value of attribute exception_code.
Attributes inherited from Modbus::PDU
Class Method Summary collapse
Instance Method Summary collapse
-
#decode(data) ⇒ Object
Decodes a PDU from protocol data.
-
#encode ⇒ Modbus::ProtocolData
Encodes a PDU into protocol data.
-
#length ⇒ Integer
Returns the length of the PDU in bytes.
Methods inherited from Modbus::PDU
Constructor Details
This class inherits a constructor from Modbus::PDU
Instance Attribute Details
#exception_code ⇒ Object
Returns the value of attribute exception_code.
12 13 14 |
# File 'lib/modbus/pdu/exception.rb', line 12 def exception_code @exception_code end |
Class Method Details
.create(func_code, error) ⇒ Object
15 16 17 18 19 |
# File 'lib/modbus/pdu/exception.rb', line 15 def self.create(func_code, error) obj = self.new nil, func_code + 0x80 obj.exception_code = error.code obj end |
Instance Method Details
#decode(data) ⇒ Object
Decodes a PDU from protocol data.
26 27 28 |
# File 'lib/modbus/pdu/exception.rb', line 26 def decode(data) @exception_code = data.shift_byte end |
#encode ⇒ Modbus::ProtocolData
Encodes a PDU into protocol data.
35 36 37 38 39 |
# File 'lib/modbus/pdu/exception.rb', line 35 def encode data = super data.push_byte @exception_code data end |
#length ⇒ Integer
Returns the length of the PDU in bytes.
46 47 48 |
# File 'lib/modbus/pdu/exception.rb', line 46 def length 2 end |