sgr_commhandler.driver.modbus.modbus_client_async ================================================= .. py:module:: sgr_commhandler.driver.modbus.modbus_client_async .. autoapi-nested-parse:: Provides the Modbus client implementation. Attributes ---------- .. autoapisummary:: sgr_commhandler.driver.modbus.modbus_client_async.logger Classes ------- .. autoapisummary:: sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusClient sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusTCPClient sgr_commhandler.driver.modbus.modbus_client_async.SGrModbusRTUClient Module Contents --------------- .. py:data:: logger .. py:class:: SGrModbusClient(endianness, addr_offset, client) Bases: :py:obj:`abc.ABC` Defines an abstract base class for Modbus clients. .. py:attribute:: _lock .. py:attribute:: _client :type: pymodbus.client.base.ModbusBaseClient .. py:attribute:: _byte_order :type: pymodbus.constants.Endian .. py:attribute:: _word_order :type: pymodbus.constants.Endian .. py:attribute:: _addr_offset :type: int .. py:method:: connect() :async: .. py:method:: disconnect() :async: .. py:method:: is_connected() .. py:method:: write_holding_registers(slave_id, address, data_type, value) :async: Encodes value to be written to holding register address. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param data_type: The modbus type to encode :type data_type: ModbusDataType :param value: The value to be written :type value: Any .. py:method:: write_coils(slave_id, address, data_type, value) :async: Encodes value to be written to coil address. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param data_type: The modbus type to encode :type data_type: ModbusDataType :param value: The value to be written :type value: Any .. py:method:: read_input_registers(slave_id, address, size, data_type) :async: Reads input registers and decodes the value. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param size: The number of registers to read :type size: int :param data_type: The modbus type to decode :type data_type: ModbusDataType :returns: Decoded value :rtype: Any .. py:method:: read_holding_registers(slave_id, address, size, data_type) :async: Reads holding registers and decodes the value. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param size: The number of registers to read :type size: int :param data_type: The modbus type to decode :type data_type: ModbusDataType :returns: Decoded value :rtype: Any .. py:method:: read_coils(slave_id, address, size, data_type) :async: Reads coils and decodes the value. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param size: The number of coils to read :type size: int :param data_type: The modbus type to decode :type data_type: ModbusDataType :returns: Decoded value :rtype: Any .. py:method:: read_discrete_inputs(slave_id, address, size, data_type) :async: Reads discrete inputs and decodes the value. :param slave_id: The slave ID of the device :type slave_id: int :param address: The address to read from and decode :type address: int :param size: The number of inputs to read :type size: int :param data_type: The modbus type to decode :type data_type: ModbusDataType :returns: Decoded value :rtype: Any .. py:class:: SGrModbusTCPClient(ip, port, endianness = BitOrder.BIG_ENDIAN, addr_offset = 0) Bases: :py:obj:`SGrModbusClient` Implements a Modbus TCP client. .. py:attribute:: _ip .. py:attribute:: _port .. py:method:: connect() :async: .. py:method:: disconnect() :async: .. py:method:: is_connected() .. py:class:: SGrModbusRTUClient(serial_port, parity, baudrate, endianness = BitOrder.BIG_ENDIAN, addr_offset = 0) Bases: :py:obj:`SGrModbusClient` Defines an abstract base class for Modbus clients. .. py:attribute:: _serial_port .. py:method:: connect() :async: .. py:method:: disconnect() :async: .. py:method:: is_connected()