Module: Modbus

Defined in:
lib/modbus/connection/base.rb,
lib/modbus/client.rb,
lib/modbus/server.rb,
lib/modbus/pdu/pdu.rb,
lib/modbus/version.rb,
lib/modbus/exceptions.rb,
lib/modbus/adu/rtu_adu.rb,
lib/modbus/adu/tcp_adu.rb,
lib/modbus/pdu/exception.rb,
lib/modbus/pdu/read_bits.rb,
lib/modbus/register/base.rb,
lib/modbus/pdu/read_coils.rb,
lib/modbus/transaction/base.rb,
lib/modbus/pdu/read_registers.rb,
lib/modbus/transaction/client.rb,
lib/modbus/transaction/server.rb,
lib/modbus/connection/tcp_client.rb,
lib/modbus/connection/tcp_server.rb,
lib/modbus/pdu/read_input_status.rb,
lib/modbus/pdu/write_single_coil.rb,
lib/modbus/register/bit_register.rb,
lib/modbus/register/word_register.rb,
lib/modbus/transaction/transaction.rb,
lib/modbus/connection/protocol_data.rb,
lib/modbus/pdu/read_input_registers.rb,
lib/modbus/pdu/read_holding_registers.rb,
lib/modbus/pdu/write_multiple_registers.rb

Overview

Copyright © 2016 Andy Rohr <[email protected]> All rights reserved.

Defined Under Namespace

Modules: Connection, Transaction Classes: Acknowledge, BitRegister, Client, GatewayPathUnavailable, GatewayTargetDeviceFailedToRespond, IllegalDataAddress, IllegalDataValue, IllegalFunction, MemoryParityError, ModbusError, PDU, ProtocolData, RTUADU, Register, Server, ServerDeviceBusy, ServerDeviceFailure, TCPADU, WordRegister

Constant Summary collapse

VERSION =
'0.2.0'
ClientError =
Class.new StandardError

Class Method Summary collapse

Class Method Details

.find_exception(code) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/modbus/exceptions.rb', line 90

def self.find_exception(code)
  exceptions = [
    IllegalFunction,
    IllegalDataAddress,
    IllegalDataValue,
    ServerDeviceFailure,
    Acknowledge,
    ServerDeviceBusy,
    MemoryParityError,
    GatewayPathUnavailable,
    GatewayTargetDeviceFailedToRespond
  ]

  exceptions.find { |e| e::CODE == code } || RuntimeError
end