sgr_commhandler.driver.modbus.modbus_client_async
Provides the Modbus client implementation.
Attributes
Classes
Defines an abstract base class for Modbus clients. |
|
Implements a Modbus TCP client. |
|
Defines an abstract base class for Modbus clients. |
Module Contents
- sgr_commhandler.driver.modbus.modbus_client_async.logger
- class sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusClient(endianness, addr_offset, client)
Bases:
abc.ABCDefines an abstract base class for Modbus clients.
- Parameters:
endianness (sgr_specification.v0.product.modbus_types.BitOrder)
addr_offset (int)
client (pymodbus.client.base.ModbusBaseClient)
- _lock
- _client: pymodbus.client.base.ModbusBaseClient
- _byte_order: pymodbus.constants.Endian
- _word_order: pymodbus.constants.Endian
- _addr_offset: int
- async connect()
- async disconnect()
- is_connected()
- Return type:
bool
- async write_holding_registers(slave_id, address, data_type, value)
Encodes value to be written to holding register address.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
data_type (ModbusDataType) – The modbus type to encode
value (Any) – The value to be written
- async write_coils(slave_id, address, data_type, value)
Encodes value to be written to coil address.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
data_type (ModbusDataType) – The modbus type to encode
value (Any) – The value to be written
- async read_input_registers(slave_id, address, size, data_type)
Reads input registers and decodes the value.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
size (int) – The number of registers to read
data_type (ModbusDataType) – The modbus type to decode
- Returns:
Decoded value
- Return type:
Any
- async read_holding_registers(slave_id, address, size, data_type)
Reads holding registers and decodes the value.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
size (int) – The number of registers to read
data_type (ModbusDataType) – The modbus type to decode
- Returns:
Decoded value
- Return type:
Any
- async read_coils(slave_id, address, size, data_type)
Reads coils and decodes the value.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
size (int) – The number of coils to read
data_type (ModbusDataType) – The modbus type to decode
- Returns:
Decoded value
- Return type:
Any
- async read_discrete_inputs(slave_id, address, size, data_type)
Reads discrete inputs and decodes the value.
- Parameters:
slave_id (int) – The slave ID of the device
address (int) – The address to read from and decode
size (int) – The number of inputs to read
data_type (ModbusDataType) – The modbus type to decode
- Returns:
Decoded value
- Return type:
Any
- class sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusTCPClient(ip, port, endianness=BitOrder.BIG_ENDIAN, addr_offset=0)
Bases:
SGrModbusClientImplements a Modbus TCP client.
- Parameters:
ip (str)
port (int)
endianness (sgr_specification.v0.product.modbus_types.BitOrder)
addr_offset (int)
- _ip
- _port
- async connect()
- async disconnect()
- is_connected()
- Return type:
bool
- class sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusRTUClient(serial_port, parity, baudrate, endianness=BitOrder.BIG_ENDIAN, addr_offset=0)
Bases:
SGrModbusClientDefines an abstract base class for Modbus clients.
- Parameters:
serial_port (str)
parity (str)
baudrate (int)
endianness (sgr_specification.v0.product.modbus_types.BitOrder)
addr_offset (int)
- _serial_port
- async connect()
- async disconnect()
- is_connected()
- Return type:
bool