Modbus

htf includes a full-stack Modbus implementation since version 1.3 with the following features:

  • Serial RTU, Serial ASCII, TCP, TLS and UDP support

  • client support

  • device simulator support

  • default Modbus protocol

  • extended Modbus protocol

  • supported endianness: little endian, big endian, word aligned and half-word aligned

  • protocol abstraction is based on oser

  • working with data oser structures instead of bits and bytes

  • fault insertion

  • possibility to extend client and device simulator with own commands

Use Cases

The Modbus implementation is made for testing Modbus clients and servers.

Examples

Simulating a Modbus-Device

import htf
from htf.communication.modbus import ModbusTCPDevice, ModbusTCPClient


ADDRESS = 'localhost'
PORT = 10502  # must be able to run for non-root users


class ModbusTCPTests(htf.TestCase):
    """
    This tests shows how to simulate a modbus device and how to use the client to query it via TCP/IP.
    """
    def create_device_simulator(self):
        device = ModbusTCPDevice(ADDRESS, port=PORT)
        return device

    def create_client(self, references_start_at_one=False, auto_disconnect=False):
        client = ModbusTCPClient(ADDRESS,
                                 port=PORT,
                                 references_start_at_one=references_start_at_one,
                                 auto_disconnect=auto_disconnect,
                                 debuglevel=0)  # set debuglevel to 1 or 2
        return client

    def setUp(self):
        super(ModbusTCPTests, self).setUp()
        self.device = self.create_device_simulator()

    def tearDown(self):
        try:
            self.device.close()
        except AttributeError:
            pass
        super(ModbusTCPTests, self).tearDown()

    def test_holding_registers(self):
        client = self.create_client()

        try:
            registers = client.read_multiple_holding_registers(0, 8)
            self.assertEqual(registers, [0] * 8)

            for address in range(10):
                client.write_multiple_holding_registers(address, [0, 1, 0, 1, 1, 0, 1, 0])
                registers = client.read_multiple_holding_registers(address, 8)
                self.assertEqual(registers, [0, 1, 0, 1, 1, 0, 1, 0])

                self.device.write_multiple_holding_registers(address, [1, 1, 0, 0, 1, 0, 1, 0])
                registers = client.read_multiple_holding_registers(address, 8)
                self.assertEqual(registers, [1, 1, 0, 0, 1, 0, 1, 0])
        finally:
            client.close()

    def test_input_registers(self):
        client = self.create_client()

        try:
            self.device.write_multiple_input_registers(0, list(range(10)))

            registers = client.read_multiple_input_registers(0, 10)
            self.assertEqual(registers, list(range(10)))

            registers = self.device.read_multiple_input_registers(0, 10)
            self.assertEqual(registers, list(range(10)))

            self.device.write_multiple_input_registers(10, list(range(20, 31)))

            registers = client.read_multiple_input_registers(5, 15)
            self.assertEqual(registers, list(range(5, 10)) + list(range(20, 30)))

            for i in range(10):
                r = client.read_input_register(i)
                self.assertEqual(r, i)

                r = self.device.read_input_register(i)
                self.assertEqual(r, i)

            for i in range(10, 20):
                r = client.read_input_register(i)
                self.assertEqual(r, i+10)

                r = self.device.read_input_register(i)
                self.assertEqual(r, i + 10)

            self.device.write_input_register(2323, 1)
            r = client.read_input_register(2323)
            self.assertEqual(r, 1)
        finally:
            client.close()


if __name__ == '__main__':
    htf.main(verbosity=2)

Special Modbus Data Structures

import htf
import oser
from datetime import datetime
from htf.communication.modbus import ModbusTCPDevice, ModbusTCPClient


ADDRESS = 'localhost'
PORT = 10502  # must be able to run for non-root users


class DateTime(oser.ByteStruct):
    def __init__(self, value=None):
        """
        ``DateTime`` data type.

        Args:
            value (datetime): a datetime instance to be used
        """
        super(DateTime, self).__init__()

        self.year = oser.UBInt16()
        self.month = oser.UBInt8()
        self.day = oser.UBInt8()

        self.hour = oser.UBInt8()
        self.minute = oser.UBInt8()
        self.second = oser.UBInt8()

        if value is not None:
            self.set(value)

    def set(self, value):
        """
        Set values from a ``datetime`` instance.

        Args:
            value (datetime): a ``datetime`` instance to be used
        """
        if not isinstance(value, datetime):
            raise ValueError("value must be of type datetime")

        self.year.set(value.year)
        self.month.set(value.month)
        self.day.set(value.day)

        self.hour.set(value.hour)
        self.minute.set(value.minute)
        self.second.set(value.second)

    def get(self):
        """
        Get values as datetime.

        Returns:
            datetime: an instance of ``datetime`` containing the current values
        """
        return datetime(year=self.year.get(), month=self.month.get(), day=self.day.get(),
                        hour=self.hour.get(), minute=self.minute.get(), second=self.second.get())


class ModbusDataStructureTests(htf.TestCase):
    """
    This test shows how to read and write own data structures using Modbus.
    """
    def create_device_simulator(self):
        device = ModbusTCPDevice(ADDRESS, port=PORT)
        return device

    def create_client(self, references_start_at_one=False, auto_disconnect=False):
        client = ModbusTCPClient(ADDRESS,
                                 port=PORT,
                                 references_start_at_one=references_start_at_one,
                                 auto_disconnect=auto_disconnect,
                                 debuglevel=0)  # set debuglevel to 1 or 2
        return client

    def setUp(self):
        super(ModbusDataStructureTests, self).setUp()
        self.device = self.create_device_simulator()

    def tearDown(self):
        try:
            self.device.close()
        except AttributeError:
            pass
        super(ModbusDataStructureTests, self).tearDown()

    def test_datetime_data_structure(self):
        """
        A DateTime data type can be read from input registers at address 23.
        """
        client = self.create_client()

        try:
            now = datetime.now()
            self.device.write_input_register_data(23, DateTime(now))

            current_date_struct = client.read_input_register_data(23, DateTime)

            self.assertEqual(current_date_struct.year, now.year)
            self.assertEqual(current_date_struct.month, now.month)
            self.assertEqual(current_date_struct.day, now.day)

            self.assertEqual(current_date_struct.hour, now.hour)
            self.assertEqual(current_date_struct.minute, now.minute)
            self.assertEqual(current_date_struct.second, now.second)

            print("device date time is:", current_date_struct.get())
        finally:
            client.close()


if __name__ == '__main__':
    htf.main(verbosity=2)

Interfaces

Interfaces are used to implement communication. The user may add other interfaces if needed.

Serial RTU Client Interface

class htf.communication.modbus.ModbusSerialRTUClientInterface(com_port=None, baud=9600, timeout=1.0, response_parser=<class 'htf.communication.modbus.protocol.SerialRTUModbusResponse'>)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • timeout (float) – the timeout in seconds

  • response_parser – the parser to parse responses

close()

Close serial port.

read()

Read Modbus serial RTU responses from server.

Returns

buffer, None

Return type

tuple

write(adu)

Write adu.

Parameters

adu – serializable RTU adu

Serial RTU Server Interface

class htf.communication.modbus.ModbusSerialRTUServerInterface(com_port=None, baud=9600, timeout=1.0, response_parser=<class 'htf.communication.modbus.protocol.SerialRTUModbusRequest'>)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • timeout (float) – the timeout in seconds

  • response_parser – the parser to parse responses

close()

Close serial port.

read()

Read Modbus serial RTU requests from client.

Returns

buffer, None

Return type

tuple

write(adu)

Write adu.

Parameters

adu – serializable RTU adu

Serial ASCII Client Interface

class htf.communication.modbus.ModbusSerialASCIIClientInterface(com_port=None, baud=9600, timeout=1.0, response_parser=<class 'htf.communication.modbus.protocol.SerialASCIIModbusResponse'>)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • timeout (float) – the timeout in seconds

  • response_parser – the parser to parse responses

change_ascii_delimiter(delimiter)

Change LF character to delimiter.

Parameters

delimiter (bytes) – bytes of length 1 containing the new ASCII delimiter

close()

Close serial port.

read()

Read Modbus serial ASCII responses from server. Read until line feed character.

Returns

buffer, None

Return type

tuple

write(adu)

Write adu.

Parameters

adu – serializable RTU adu

Serial ASCII Server Interface

class htf.communication.modbus.ModbusSerialASCIIServerInterface(com_port=None, baud=9600, timeout=1.0, response_parser=<class 'htf.communication.modbus.protocol.SerialASCIIModbusRequest'>)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • timeout (float) – the timeout in seconds

  • response_parser – the parser to parse responses

change_ascii_delimiter(delimiter)

Change LF character to delimiter.

Parameters

delimiter (bytes) – bytes of length 1 containing the new ASCII delimiter

close()

Close serial port.

read()

Read serial ASCII Modbus requests from client.

Returns

buffer, None

Return type

tuple

write(adu)

Write adu.

Parameters

adu – serializable RTU adu

TCP Client Interface

class htf.communication.modbus.ModbusTCPClientInterface(address, port=502, timeout=1.0, connect=True)
Parameters
  • address (str) – the ip-address to connect to

  • port (int) – the port

  • timeout (float) – the timeout in seconds

  • connect (bool) – if set to True the socket connects automatically

close()

Close TCP connection.

open()

Open a socket.

read()

Read a TCP request from TCP server.

Returns

buffer, None

Return type

tuple

reconnect()

Close socket and create a new one.

write(adu)

Write adu.

Parameters

adu – serializable TCP adu

TCP Server Interface

class htf.communication.modbus.ModbusTCPServerInterface(address, port=502, timeout=1.0)
Parameters
  • address (str) – the ip-address to listen on

  • port (int) – the port to listen on

  • timeout (float) – the timeout in seconds

accept()

Accept a new connection.

Returns

connection, address

Return type

tuple

close()

Close TCP socket.

close_connection(connection)

Close TCP connection.

read(connection)

Read a TCP request from TLS client.

Returns

buffer, None

Return type

tuple

write(connection, adu)

Write adu.

Parameters

adu – serializable TCP adu

UDP Client Interface

class htf.communication.modbus.ModbusUDPClientInterface(address, port=502, timeout=1.0)
Parameters
  • address (str) – the ip-address to connect to

  • port (int) – the port

  • timeout (float) – the timeout in seconds

close()

Close TCP connection.

open()

Open a socket.

read()

Read a TLS request from TLS server.

Returns

buffer, None

Return type

tuple

reconnect()

Close socket and create a new one.

write(adu)

Write adu.

Parameters

adu – serializable TCP adu

UDP Server Interface

class htf.communication.modbus.ModbusUDPServerInterface(address, port=502, timeout=None)
Parameters
  • address (str) – the ip-address to listen on

  • port (int) – the port to listen on

  • timeout=None (float) – the timeout in seconds

close()

Close UDP socket.

read(bufsize=300)

Read a request from an UDP client.

Parameters

bufsize (int) – buffer size

Returns

the received request

Return type

bytes

write(address, adu)

Write adu.

Parameters
  • address – the target ip-address

  • adu – serializable TCP adu

TLS Client Interface

class htf.communication.modbus.ModbusTLSClientInterface(address, port=502, timeout=1.0, verify=True, connect=True, cafile=None, capath=None, cadata=None)
Parameters
  • address (str) – the ip-address to connect to

  • port (int) – the port

  • timeout (float) – the timeout in seconds

  • verify (bool) – set to False to disable TLS certificate verification

  • connect (bool) – if set to True the socket connects automatically

  • cafile (str) – path to a file of concatenated CA certificates in PEM format

  • capath (str) – path to a directory containing several CA certificates in PEM format

  • cadata (str) – either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates

close()

Close TCP connection.

open()

Open a socket.

read()

Read a TCP request from TCP server.

Returns

buffer, None

Return type

tuple

reconnect()

Close socket and create a new one.

write(adu)

Write adu.

Parameters

adu – serializable TCP adu

TLS Server Interface

class htf.communication.modbus.ModbusTLSServerInterface(address, port=502, timeout=1.0, certfile=None, keyfile=None, password=None)
Parameters
  • address (str) – the ip-address to listen on

  • port (int) – the port to listen on

  • timeout (float) – the timeout in seconds

  • certfile (str) – path to TLS certificate

  • keyfile (str) – path to TLS keyfile

  • password (str) – TLS password

accept()

Accept a new connection.

Returns

connection, address

Return type

tuple

close()

Close TLS socket.

close_connection(connection)

Close TCP connection.

read(connection)

Read a TCP request from TLS client.

Returns

buffer, None

Return type

tuple

write(connection, adu)

Write adu.

Parameters

adu – serializable TCP adu

Clients

Clients are used to query Modbus devices. Users can add own clients using own interfaces.

Base Client

class htf.communication.modbus.ModbusBaseClient(interface, request_parser, response_parser, retries=None, references_start_at_one=True, debuglevel=None)
Parameters
  • interface – an interface to be used for communication

  • request_parser – a parser for requests

  • response_parser – a parser for responses

  • retries=None (int or None) – the number of retries until an exception is raised

  • references_start_at_one=True – if set to True all references start at 1 else 0

  • debuglevel (int or None) – the debuglevel (None disables debug, 1 prints requests and responses and 2 prints introspection)

build_request()

Build and return an instance of the desired request parser.

Returns

request parser

build_response()

Build and return an instance of the desired response parser.

Returns

response parser

close()

Close the interface.

get_device_identification()

Query and return the device identification using Modbus function code 43.14.

Returns

containing key values pairs with the device identifiers

Return type

dict

get_fifo_queue_content(address)

Query and return the fifo content of address using Modbus function code 24.

Parameters

address – the fifo queue pointer address

Returns

list of content from the fifo queue at address

Return type

list

mask_holding_register(reference, and_mask, or_mask)

Mask write single holding register using Modbus function code 22.

Parameters
  • reference (int) – the register reference

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

mask_multiple_holding_registers(reference, quantity, and_mask, or_mask)

Mask write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference

  • quantity (int) – the number of registers to be masked

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

query(adu)

Query adu using the interface and return the decoded response.

Parameters

adu – a serializable adu

Returns

the decoded response if no exception occured

Return type

adu

Raises

ModbusException – in case of an exception response

read()

Read a message from the interface and decode it.

Returns

the decoded adu as is

Return type

adu

Raises

Exception if no answer was received

read_coil(reference)

Read a single coil using Modbus function code 1.

Parameters

reference (int) – the register reference.

Returns

1 if the coil is set and 0 else.

Return type

int

read_coil_bitfield(reference, length)

Read a bitfield from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_coil_bitfield_list(reference, quantity, length)

Read a list of bitfields from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_coil_data(reference, data)

Read data from coils using Modbus function code 1.

Parameters
  • reference (int) – the coil reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_coil_flag(reference)

Read a bit from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_coil_flag_list(reference, quantity)

Read a list of bits from coil memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_coil_nibble(reference)

Read a nibble from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_coil_nibble_list(reference, quantity)

Read a list of nibbles from coil memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_discrete_input(reference)

Read single discrete input using Modbus function code 2.

Parameters

reference (int) – the register reference.

Returns

1 if the discete input is set and 0 else.

Return type

int

read_discrete_input_bitfield(reference, length)

Read a bitfield from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_discrete_input_bitfield_list(reference, quantity, length)

Read a list of bitfields from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_discrete_input_data(reference, data)

Read data from discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the discrete input reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_discrete_input_flag(reference)

Read a bit from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_discrete_input_flag_list(reference, quantity)

Read a list of bits from discrete input memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_discrete_input_nibble(reference)

Read a nibble from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_discrete_input_nibble_list(reference, quantity)

Read a list of nibbles from discrete input memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_extended_memory(memory_number, record_number, record_length)

Query and return extended memory from device using Modbus function code 20.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to start reading from

  • record_length (int) – the length of records

Returns

the read records

Return type

list of int

read_holding_register(reference)

Read a single holding register using Modbus function code 3.

Parameters

reference (int) – the register reference.

Returns

the holding register value

Return type

int

read_holding_register_bdouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_bdouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_bfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_bfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_bitfield(reference, length)

Read a bitfield from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_holding_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_holding_register_data(reference, data)

Read data from holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_holding_register_double21436587(reference)

Read a 21436587-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_double78563412(reference)

Read a 78563412-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_flag(reference)

Read a bit from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_holding_register_flag_list(reference, quantity)

Read a list of bits from holding register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_holding_register_float2143(reference)

Read a 2143-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_float3412(reference)

Read a 3412-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_ldouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_ldouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_lfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_lfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_nibble(reference)

Read a nibble from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_holding_register_nibble_list(reference, quantity)

Read a list of nibbles from holding register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_holding_register_sbint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_string(reference, length)

Read a string from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_holding_register_string_list(reference, quantity, length)

Read a list of strings from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_holding_register_ubint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register(reference)

Read a single input register using Modbus function code 4.

Parameters

reference (int) – the register reference.

Returns

the input register value

Return type

int

read_input_register_bdouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_bdouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_bfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_bfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_bitfield(reference, length)

Read a bitfield from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_input_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_input_register_data(reference, data)

Read data from input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_input_register_double21436587(reference)

Read a 21436587-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_double78563412(reference)

Read a 78563412-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_flag(reference)

Read a bit from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_input_register_flag_list(reference, quantity)

Read a list of bits from input register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_input_register_float2143(reference)

Read a 2143-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_float3412(reference)

Read a 3412-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_ldouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_ldouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_lfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_lfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_nibble(reference)

Read a nibble from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_input_register_nibble_list(reference, quantity)

Read a list of nibbles from input register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_input_register_sbint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_string(reference, length)

Read a string from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_input_register_string_list(reference, quantity, length)

Read a list of strings from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_input_register_ubint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_multiple_coils(reference, quantity)

Read multiple coils using Modbus function code 1.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of coils to be read.

Returns

each element is 1 if the corresponding coil is set and 0 else.

Return type

list of int

read_multiple_discrete_inputs(reference, quantity)

Read multiple discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of discrete inputs to be read.

Returns

each element is 1 if the corresponding discrete input is set and 0 else.

Return type

list of int

read_multiple_holding_registers(reference, quantity)

Read multiple holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the holding register values

Return type

list of int

read_multiple_input_registers(reference, quantity)

Read multiple input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the input register values

Return type

list of int

read_write_multiple_holding_registers(read_reference, read_quantity, write_reference, write_values)

Read/Write multiple holding registers using Modbus function code 23.

Parameters
  • read_reference (int) – the register reference to read from.

  • read_quantity (int) – the number of registers to read.

  • write_reference (int) – the register reference to to write to.

  • write_values (list of int) – the values to be written.

Returns

the read registers

Return type

list of int

write(adu)

Write adu encoded using the interface.

Parameters

adu – a serializable adu

write_coil(reference, value)

Write a single coil using Modbus function code 5.

Parameters
  • reference (int) – the register reference.

  • value (int) – the value to be written.

write_coil_bitfield(reference, value, length)

Write a bitfield to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_coil_bitfield_list(reference, values, length)

Write a list of bitfields to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_coil_data(reference, data)

Write data to coils using Modbus function code 15.

Parameters
  • reference (int) – the coil reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_coil_flag(reference, value)

Write a bit to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_coil_flag_list(reference, values)

Write a list of bits to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_coil_nibble(reference, value)

Write a nibble to coil memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_coil_nibble_list(reference, values)

Write a list of nibbles to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_extended_memory(memory_number, record_number, records)

Write extended memory using Modbus function code 21.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to write to

  • records (list of int) – the records to be written

write_holding_register(reference, value)

Write single holding register using Modbus function code 6.

Parameters
  • reference – the register reference.

  • value – the value to be written into the corresponding register.

write_holding_register_bdouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_bdouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_bfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_bfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_bitfield(reference, value, length)

Write a bitfield to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_holding_register_bitfield_list(reference, values, length)

Write a list of bitfields to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_holding_register_data(reference, data)

Write data to holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_holding_register_double21436587(reference, value)

Write a 21436587-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double21436587_list(reference, values)

Write a list of 21436587-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_double78563412(reference, value)

Write a 78563412-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double78563412_list(reference, values)

Write a list of 78563412-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_flag(reference, value)

Write a bit to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_holding_register_flag_list(reference, values)

Write a list of bits to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_holding_register_float2143(reference, value)

Write a 2143-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float2143_list(reference, values)

Write a list of 2143-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_float3412(reference, value)

Write a 3412-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float3412_list(reference, values)

Write a list of 3412-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_ldouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_ldouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_lfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_lfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_nibble(reference, value)

Write a nibble to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_holding_register_nibble_list(reference, values)

Write a list of nibbles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_holding_register_sbint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143(reference, value)

Write a signed 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587(reference, value)

Write a signed 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587_list(reference, values)

Write a list of signed 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143_list(reference, values)

Write a list of signed 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint3412(reference, value)

Write a signed 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint3412_list(reference, values)

Write a list of signed 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint78563412(reference, value)

Write a signed 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint78563412_list(reference, values)

Write a list of signed 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_string(reference, value, length)

Write a string to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the data value to be written

  • length – the length of the value

write_holding_register_string_list(reference, values, length)

Write a list of strings to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of data values to be written

  • length – the length of the value

write_holding_register_ubint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143(reference, value)

Write a unsigned 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587(reference, value)

Write a unsigned 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587_list(reference, values)

Write a list of unsigned 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143_list(reference, values)

Write a list of unsigned 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint3412(reference, value)

Write a unsigned 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint3412_list(reference, values)

Write a list of unsigned 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint78563412(reference, value)

Write a unsigned 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint78563412_list(reference, values)

Write a list of unsigned 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_multiple_coils(reference, values)

Write multiple coils using Modbus function code 15.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

write_multiple_holding_registers(reference, values)

Write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

Serial RTU Client

class htf.communication.modbus.ModbusSerialRTUClient(com_port, baud=9600, device_address=1, timeout=1.0, retries=None, references_start_at_one=True, request_parser=<class 'htf.communication.modbus.protocol.SerialRTUModbusRequest'>, response_parser=<class 'htf.communication.modbus.protocol.SerialRTUModbusResponse'>, debuglevel=None)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • device_address (int) – the device address (Slave ID)

  • timeout (float) – the timeout in seconds

  • retries=None (int or None) – the number of retries until an exception is raised

  • references_start_at_one=True – if set to True all references start at 1 else 0

  • request_parser – a parser for requests

  • response_parser – a parser for responses

  • debuglevel (int or None) – the debuglevel (None disables debug, 1 prints requests and responses and 2 prints introspection)

build_request()

Build and return an instance of the desired request parser.

Returns

request parser

build_response()

Build and return an instance of the desired response parser.

Returns

response parser

clear_counters_and_diagnostic_register()

Clear counters and diagnostic register using Modbus function code 8.10.

clear_overrun_counter_and_flag()

Clear overrun counter and reset the error flag using Modbus function code 8.20.

close()

Close the interface.

echo(data)

Query data and return echo using Modbus function code 8.0. An exception is raised if the received data differ from the sent data or the request is too long.

Parameters

data (bytes) – The bytes to be sent.

Returns

response

get_bus_character_overrun_count()

Query and return the bus character overrun count from the device using Modbus function code 8.18.

Returns

the bus character overrun count

Return type

int

get_bus_communication_error_count()

Query and return the bus communication error count from the device using Modbus function code 8.12.

Returns

the bus communication error count

Return type

int

get_bus_exception_error_count()

Query and return the bus exception error count from the device using Modbus function code 8.13.

Returns

the bus exception error count

Return type

int

get_bus_message_count()

Query and return the bus message count from the device using Modbus function code 8.11.

Returns

the bus message count

Return type

int

get_busy_count()

Query and return the slave busy count from the device using Modbus function code 8.17.

Returns

the slave busy count

Return type

int

get_busy_status()

Query and return busy status using Modbus function code 11.

Returns

busy_status

Return type

bool

get_communication_event_counter_and_busy_status()

Query and return communication event counter and busy status using Modbus function code 11.

Returns

communication_event_counter (int), busy_status (bool)

Return type

tuple

get_device_identification()

Query and return the device identification using Modbus function code 43.14.

Returns

containing key values pairs with the device identifiers

Return type

dict

get_diagnostic_register()

Query and return the diagnostic register using Modbus function 8.2.

Returns

the content of the diagnostic register

Return type

bytes

get_event_count()

Query and return event count status using Modbus function code 11.

Returns

communication_event_counter

Return type

int

get_event_log()

Query and return the event log using Modbus function code 12.

Returns

busy_status (int), event_count (int), message_count (int), events (list of int)

Return type

tuple

get_exception_status()

Read and return exception status using Modbus function code 7.

Returns

the current exception status

Return type

int

get_fifo_queue_content(address)

Query and return the fifo content of address using Modbus function code 24.

Parameters

address – the fifo queue pointer address

Returns

list of content from the fifo queue at address

Return type

list

get_slave_id()

Query and return the slave id using Modbus function code 17.

Returns

slave-id, running, data

Return type

3-tuple

get_slave_message_count()

Query and return the slave message count from the device using Modbus function code 8.14.

Returns

the slave message count

Return type

int

get_slave_nak_count()

Query and return the slave nak count from the device using Modbus function code 8.16.

Returns

the slave nak count

Return type

int

get_slave_no_response_count()

Query and return the slave no response count from the device using Modbus function code 8.15.

Returns

the slave no response count

Return type

int

mask_holding_register(reference, and_mask, or_mask)

Mask write single holding register using Modbus function code 22.

Parameters
  • reference (int) – the register reference

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

mask_multiple_holding_registers(reference, quantity, and_mask, or_mask)

Mask write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference

  • quantity (int) – the number of registers to be masked

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

query(adu)

Query adu using the interface and return the decoded response.

Parameters

adu – a serializable adu

Returns

the decoded response if no exception occured

Return type

adu

Raises

ModbusException – in case of an exception response

read()

Read a message from the interface and decode it.

Returns

the decoded adu as is

Return type

adu

Raises

Exception if no answer was received

read_coil(reference)

Read a single coil using Modbus function code 1.

Parameters

reference (int) – the register reference.

Returns

1 if the coil is set and 0 else.

Return type

int

read_coil_bitfield(reference, length)

Read a bitfield from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_coil_bitfield_list(reference, quantity, length)

Read a list of bitfields from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_coil_data(reference, data)

Read data from coils using Modbus function code 1.

Parameters
  • reference (int) – the coil reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_coil_flag(reference)

Read a bit from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_coil_flag_list(reference, quantity)

Read a list of bits from coil memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_coil_nibble(reference)

Read a nibble from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_coil_nibble_list(reference, quantity)

Read a list of nibbles from coil memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_discrete_input(reference)

Read single discrete input using Modbus function code 2.

Parameters

reference (int) – the register reference.

Returns

1 if the discete input is set and 0 else.

Return type

int

read_discrete_input_bitfield(reference, length)

Read a bitfield from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_discrete_input_bitfield_list(reference, quantity, length)

Read a list of bitfields from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_discrete_input_data(reference, data)

Read data from discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the discrete input reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_discrete_input_flag(reference)

Read a bit from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_discrete_input_flag_list(reference, quantity)

Read a list of bits from discrete input memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_discrete_input_nibble(reference)

Read a nibble from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_discrete_input_nibble_list(reference, quantity)

Read a list of nibbles from discrete input memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_extended_memory(memory_number, record_number, record_length)

Query and return extended memory from device using Modbus function code 20.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to start reading from

  • record_length (int) – the length of records

Returns

the read records

Return type

list of int

read_holding_register(reference)

Read a single holding register using Modbus function code 3.

Parameters

reference (int) – the register reference.

Returns

the holding register value

Return type

int

read_holding_register_bdouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_bdouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_bfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_bfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_bitfield(reference, length)

Read a bitfield from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_holding_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_holding_register_data(reference, data)

Read data from holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_holding_register_double21436587(reference)

Read a 21436587-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_double78563412(reference)

Read a 78563412-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_flag(reference)

Read a bit from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_holding_register_flag_list(reference, quantity)

Read a list of bits from holding register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_holding_register_float2143(reference)

Read a 2143-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_float3412(reference)

Read a 3412-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_ldouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_ldouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_lfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_lfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_nibble(reference)

Read a nibble from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_holding_register_nibble_list(reference, quantity)

Read a list of nibbles from holding register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_holding_register_sbint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_string(reference, length)

Read a string from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_holding_register_string_list(reference, quantity, length)

Read a list of strings from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_holding_register_ubint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register(reference)

Read a single input register using Modbus function code 4.

Parameters

reference (int) – the register reference.

Returns

the input register value

Return type

int

read_input_register_bdouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_bdouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_bfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_bfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_bitfield(reference, length)

Read a bitfield from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_input_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_input_register_data(reference, data)

Read data from input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_input_register_double21436587(reference)

Read a 21436587-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_double78563412(reference)

Read a 78563412-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_flag(reference)

Read a bit from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_input_register_flag_list(reference, quantity)

Read a list of bits from input register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_input_register_float2143(reference)

Read a 2143-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_float3412(reference)

Read a 3412-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_ldouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_ldouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_lfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_lfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_nibble(reference)

Read a nibble from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_input_register_nibble_list(reference, quantity)

Read a list of nibbles from input register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_input_register_sbint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_string(reference, length)

Read a string from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_input_register_string_list(reference, quantity, length)

Read a list of strings from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_input_register_ubint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_multiple_coils(reference, quantity)

Read multiple coils using Modbus function code 1.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of coils to be read.

Returns

each element is 1 if the corresponding coil is set and 0 else.

Return type

list of int

read_multiple_discrete_inputs(reference, quantity)

Read multiple discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of discrete inputs to be read.

Returns

each element is 1 if the corresponding discrete input is set and 0 else.

Return type

list of int

read_multiple_holding_registers(reference, quantity)

Read multiple holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the holding register values

Return type

list of int

read_multiple_input_registers(reference, quantity)

Read multiple input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the input register values

Return type

list of int

read_write_multiple_holding_registers(read_reference, read_quantity, write_reference, write_values)

Read/Write multiple holding registers using Modbus function code 23.

Parameters
  • read_reference (int) – the register reference to read from.

  • read_quantity (int) – the number of registers to read.

  • write_reference (int) – the register reference to to write to.

  • write_values (list of int) – the values to be written.

Returns

the read registers

Return type

list of int

restart_communications(reset_eventlog=False)

Restart communications using Modbus function code 8.1.

set_device_address(device_address)

Set device address.

Parameters

device_address (int) – the device address to be used for the next requests.

set_listen_only_mode()

Set listen only mode in server using Modbus function code 8.4.

write(adu)

Write adu encoded using the interface.

Parameters

adu – a serializable adu

write_coil(reference, value)

Write a single coil using Modbus function code 5.

Parameters
  • reference (int) – the register reference.

  • value (int) – the value to be written.

write_coil_bitfield(reference, value, length)

Write a bitfield to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_coil_bitfield_list(reference, values, length)

Write a list of bitfields to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_coil_data(reference, data)

Write data to coils using Modbus function code 15.

Parameters
  • reference (int) – the coil reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_coil_flag(reference, value)

Write a bit to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_coil_flag_list(reference, values)

Write a list of bits to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_coil_nibble(reference, value)

Write a nibble to coil memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_coil_nibble_list(reference, values)

Write a list of nibbles to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_extended_memory(memory_number, record_number, records)

Write extended memory using Modbus function code 21.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to write to

  • records (list of int) – the records to be written

write_holding_register(reference, value)

Write single holding register using Modbus function code 6.

Parameters
  • reference – the register reference.

  • value – the value to be written into the corresponding register.

write_holding_register_bdouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_bdouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_bfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_bfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_bitfield(reference, value, length)

Write a bitfield to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_holding_register_bitfield_list(reference, values, length)

Write a list of bitfields to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_holding_register_data(reference, data)

Write data to holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_holding_register_double21436587(reference, value)

Write a 21436587-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double21436587_list(reference, values)

Write a list of 21436587-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_double78563412(reference, value)

Write a 78563412-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double78563412_list(reference, values)

Write a list of 78563412-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_flag(reference, value)

Write a bit to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_holding_register_flag_list(reference, values)

Write a list of bits to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_holding_register_float2143(reference, value)

Write a 2143-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float2143_list(reference, values)

Write a list of 2143-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_float3412(reference, value)

Write a 3412-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float3412_list(reference, values)

Write a list of 3412-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_ldouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_ldouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_lfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_lfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_nibble(reference, value)

Write a nibble to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_holding_register_nibble_list(reference, values)

Write a list of nibbles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_holding_register_sbint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143(reference, value)

Write a signed 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587(reference, value)

Write a signed 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587_list(reference, values)

Write a list of signed 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143_list(reference, values)

Write a list of signed 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint3412(reference, value)

Write a signed 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint3412_list(reference, values)

Write a list of signed 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint78563412(reference, value)

Write a signed 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint78563412_list(reference, values)

Write a list of signed 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_string(reference, value, length)

Write a string to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the data value to be written

  • length – the length of the value

write_holding_register_string_list(reference, values, length)

Write a list of strings to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of data values to be written

  • length – the length of the value

write_holding_register_ubint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143(reference, value)

Write a unsigned 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587(reference, value)

Write a unsigned 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587_list(reference, values)

Write a list of unsigned 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143_list(reference, values)

Write a list of unsigned 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint3412(reference, value)

Write a unsigned 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint3412_list(reference, values)

Write a list of unsigned 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint78563412(reference, value)

Write a unsigned 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint78563412_list(reference, values)

Write a list of unsigned 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_multiple_coils(reference, values)

Write multiple coils using Modbus function code 15.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

write_multiple_holding_registers(reference, values)

Write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

Serial ASCII Client

class htf.communication.modbus.ModbusSerialASCIIClient(com_port, baud=9600, device_address=1, timeout=1.0, retries=None, references_start_at_one=True, ascii_delimiter=b'n', request_parser=<class 'htf.communication.modbus.protocol.SerialASCIIModbusRequest'>, response_parser=<class 'htf.communication.modbus.protocol.SerialASCIIModbusResponse'>, debuglevel=None)
Parameters
  • com_port (str) – the com port to be used

  • baud (int) – the baud rate

  • device_address (int) – the device address (Slave ID)

  • timeout (float) – the timeout in seconds

  • retries=None (int or None) – the number of retries until an exception is raised

  • references_start_at_one=True – if set to True all references start at 1 else 0

  • ascii_delimiter (bytes) – the ascii delimiter to be used

  • request_parser – a parser for requests

  • response_parser – a parser for responses

  • debuglevel (int or None) – the debuglevel (None disables debug, 1 prints requests and responses and 2 prints introspection)

build_request()

Build and return an instance of the desired request parser.

Returns

request parser

build_response()

Build and return an instance of the desired response parser.

Returns

response parser

change_ascii_delimiter(delimiter)

Change ASCII delimiter in the device.

Parameters

delimiter (bytes) – the new ASCII delimiter.

clear_counters_and_diagnostic_register()

Clear counters and diagnostic register using Modbus function code 8.10.

clear_overrun_counter_and_flag()

Clear overrun counter and reset the error flag using Modbus function code 8.20.

close()

Close the interface.

echo(data)

Query data and return echo using Modbus function code 8.0. An exception is raised if the received data differ from the sent data or the request is too long.

Parameters

data (bytes) – The bytes to be sent.

Returns

response

get_bus_character_overrun_count()

Query and return the bus character overrun count from the device using Modbus function code 8.18.

Returns

the bus character overrun count

Return type

int

get_bus_communication_error_count()

Query and return the bus communication error count from the device using Modbus function code 8.12.

Returns

the bus communication error count

Return type

int

get_bus_exception_error_count()

Query and return the bus exception error count from the device using Modbus function code 8.13.

Returns

the bus exception error count

Return type

int

get_bus_message_count()

Query and return the bus message count from the device using Modbus function code 8.11.

Returns

the bus message count

Return type

int

get_busy_count()

Query and return the slave busy count from the device using Modbus function code 8.17.

Returns

the slave busy count

Return type

int

get_busy_status()

Query and return busy status using Modbus function code 11.

Returns

busy_status

Return type

bool

get_communication_event_counter_and_busy_status()

Query and return communication event counter and busy status using Modbus function code 11.

Returns

communication_event_counter (int), busy_status (bool)

Return type

tuple

get_device_identification()

Query and return the device identification using Modbus function code 43.14.

Returns

containing key values pairs with the device identifiers

Return type

dict

get_diagnostic_register()

Query and return the diagnostic register using Modbus function 8.2.

Returns

the content of the diagnostic register

Return type

bytes

get_event_count()

Query and return event count status using Modbus function code 11.

Returns

communication_event_counter

Return type

int

get_event_log()

Query and return the event log using Modbus function code 12.

Returns

busy_status (int), event_count (int), message_count (int), events (list of int)

Return type

tuple

get_exception_status()

Read and return exception status using Modbus function code 7.

Returns

the current exception status

Return type

int

get_fifo_queue_content(address)

Query and return the fifo content of address using Modbus function code 24.

Parameters

address – the fifo queue pointer address

Returns

list of content from the fifo queue at address

Return type

list

get_slave_id()

Query and return the slave id using Modbus function code 17.

Returns

slave-id, running, data

Return type

3-tuple

get_slave_message_count()

Query and return the slave message count from the device using Modbus function code 8.14.

Returns

the slave message count

Return type

int

get_slave_nak_count()

Query and return the slave nak count from the device using Modbus function code 8.16.

Returns

the slave nak count

Return type

int

get_slave_no_response_count()

Query and return the slave no response count from the device using Modbus function code 8.15.

Returns

the slave no response count

Return type

int

mask_holding_register(reference, and_mask, or_mask)

Mask write single holding register using Modbus function code 22.

Parameters
  • reference (int) – the register reference

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

mask_multiple_holding_registers(reference, quantity, and_mask, or_mask)

Mask write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference

  • quantity (int) – the number of registers to be masked

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

query(adu)

Query adu using the interface and return the decoded response.

Parameters

adu – a serializable adu

Returns

the decoded response if no exception occured

Return type

adu

Raises

ModbusException – in case of an exception response

read()

Read a message from the interface and decode it.

Returns

the decoded adu as is

Return type

adu

Raises

Exception if no answer was received

read_coil(reference)

Read a single coil using Modbus function code 1.

Parameters

reference (int) – the register reference.

Returns

1 if the coil is set and 0 else.

Return type

int

read_coil_bitfield(reference, length)

Read a bitfield from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_coil_bitfield_list(reference, quantity, length)

Read a list of bitfields from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_coil_data(reference, data)

Read data from coils using Modbus function code 1.

Parameters
  • reference (int) – the coil reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_coil_flag(reference)

Read a bit from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_coil_flag_list(reference, quantity)

Read a list of bits from coil memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_coil_nibble(reference)

Read a nibble from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_coil_nibble_list(reference, quantity)

Read a list of nibbles from coil memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_discrete_input(reference)

Read single discrete input using Modbus function code 2.

Parameters

reference (int) – the register reference.

Returns

1 if the discete input is set and 0 else.

Return type

int

read_discrete_input_bitfield(reference, length)

Read a bitfield from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_discrete_input_bitfield_list(reference, quantity, length)

Read a list of bitfields from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_discrete_input_data(reference, data)

Read data from discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the discrete input reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_discrete_input_flag(reference)

Read a bit from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_discrete_input_flag_list(reference, quantity)

Read a list of bits from discrete input memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_discrete_input_nibble(reference)

Read a nibble from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_discrete_input_nibble_list(reference, quantity)

Read a list of nibbles from discrete input memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_extended_memory(memory_number, record_number, record_length)

Query and return extended memory from device using Modbus function code 20.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to start reading from

  • record_length (int) – the length of records

Returns

the read records

Return type

list of int

read_holding_register(reference)

Read a single holding register using Modbus function code 3.

Parameters

reference (int) – the register reference.

Returns

the holding register value

Return type

int

read_holding_register_bdouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_bdouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_bfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_bfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_bitfield(reference, length)

Read a bitfield from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_holding_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_holding_register_data(reference, data)

Read data from holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_holding_register_double21436587(reference)

Read a 21436587-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_double78563412(reference)

Read a 78563412-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_flag(reference)

Read a bit from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_holding_register_flag_list(reference, quantity)

Read a list of bits from holding register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_holding_register_float2143(reference)

Read a 2143-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_float3412(reference)

Read a 3412-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_ldouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_ldouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_lfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_lfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_nibble(reference)

Read a nibble from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_holding_register_nibble_list(reference, quantity)

Read a list of nibbles from holding register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_holding_register_sbint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_string(reference, length)

Read a string from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_holding_register_string_list(reference, quantity, length)

Read a list of strings from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_holding_register_ubint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register(reference)

Read a single input register using Modbus function code 4.

Parameters

reference (int) – the register reference.

Returns

the input register value

Return type

int

read_input_register_bdouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_bdouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_bfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_bfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_bitfield(reference, length)

Read a bitfield from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_input_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_input_register_data(reference, data)

Read data from input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_input_register_double21436587(reference)

Read a 21436587-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_double78563412(reference)

Read a 78563412-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_flag(reference)

Read a bit from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_input_register_flag_list(reference, quantity)

Read a list of bits from input register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_input_register_float2143(reference)

Read a 2143-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_float3412(reference)

Read a 3412-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_ldouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_ldouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_lfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_lfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_nibble(reference)

Read a nibble from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_input_register_nibble_list(reference, quantity)

Read a list of nibbles from input register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_input_register_sbint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_string(reference, length)

Read a string from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_input_register_string_list(reference, quantity, length)

Read a list of strings from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_input_register_ubint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint64(reference)

Read a unsigned 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ulint8(reference)

Read a unsigned 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_multiple_coils(reference, quantity)

Read multiple coils using Modbus function code 1.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of coils to be read.

Returns

each element is 1 if the corresponding coil is set and 0 else.

Return type

list of int

read_multiple_discrete_inputs(reference, quantity)

Read multiple discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of discrete inputs to be read.

Returns

each element is 1 if the corresponding discrete input is set and 0 else.

Return type

list of int

read_multiple_holding_registers(reference, quantity)

Read multiple holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the holding register values

Return type

list of int

read_multiple_input_registers(reference, quantity)

Read multiple input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference.

  • quantity (int) – the number of registers to be read.

Returns

the input register values

Return type

list of int

read_write_multiple_holding_registers(read_reference, read_quantity, write_reference, write_values)

Read/Write multiple holding registers using Modbus function code 23.

Parameters
  • read_reference (int) – the register reference to read from.

  • read_quantity (int) – the number of registers to read.

  • write_reference (int) – the register reference to to write to.

  • write_values (list of int) – the values to be written.

Returns

the read registers

Return type

list of int

restart_communications(reset_eventlog=False)

Restart communications using Modbus function code 8.1.

set_device_address(device_address)

Set device address.

Parameters

device_address (int) – the device address to be used for the next requests.

set_listen_only_mode()

Set listen only mode in server using Modbus function code 8.4.

write(adu)

Write adu encoded using the interface.

Parameters

adu – a serializable adu

write_coil(reference, value)

Write a single coil using Modbus function code 5.

Parameters
  • reference (int) – the register reference.

  • value (int) – the value to be written.

write_coil_bitfield(reference, value, length)

Write a bitfield to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_coil_bitfield_list(reference, values, length)

Write a list of bitfields to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_coil_data(reference, data)

Write data to coils using Modbus function code 15.

Parameters
  • reference (int) – the coil reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_coil_flag(reference, value)

Write a bit to coil memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_coil_flag_list(reference, values)

Write a list of bits to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_coil_nibble(reference, value)

Write a nibble to coil memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_coil_nibble_list(reference, values)

Write a list of nibbles to coil memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_extended_memory(memory_number, record_number, records)

Write extended memory using Modbus function code 21.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to write to

  • records (list of int) – the records to be written

write_holding_register(reference, value)

Write single holding register using Modbus function code 6.

Parameters
  • reference – the register reference.

  • value – the value to be written into the corresponding register.

write_holding_register_bdouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_bdouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_bfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_bfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_bitfield(reference, value, length)

Write a bitfield to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bitfield value to be written

  • length – the length of the value

write_holding_register_bitfield_list(reference, values, length)

Write a list of bitfields to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bitfield values to be written

  • length – the length of the value

write_holding_register_data(reference, data)

Write data to holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

write_holding_register_double21436587(reference, value)

Write a 21436587-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double21436587_list(reference, values)

Write a list of 21436587-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_double78563412(reference, value)

Write a 78563412-endian double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_double78563412_list(reference, values)

Write a list of 78563412-endian doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_flag(reference, value)

Write a bit to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the bool value to be written

write_holding_register_flag_list(reference, values)

Write a list of bits to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of bool values to be written

write_holding_register_float2143(reference, value)

Write a 2143-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float2143_list(reference, values)

Write a list of 2143-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_float3412(reference, value)

Write a 3412-endian float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_float3412_list(reference, values)

Write a list of 3412-endian floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_ldouble(reference, value)

Write a double to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the double value to be written

write_holding_register_ldouble_list(reference, values)

Write a list of doubles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of double values to be written

write_holding_register_lfloat(reference, value)

Write a float to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the float value to be written

write_holding_register_lfloat_list(reference, values)

Write a list of floats to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of float values to be written

write_holding_register_nibble(reference, value)

Write a nibble to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the nibble value to be written

write_holding_register_nibble_list(reference, values)

Write a list of nibbles to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of nibble values to be written

write_holding_register_sbint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sbint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sbint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143(reference, value)

Write a signed 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587(reference, value)

Write a signed 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint21436587_list(reference, values)

Write a list of signed 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint2143_list(reference, values)

Write a list of signed 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint3412(reference, value)

Write a signed 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint3412_list(reference, values)

Write a list of signed 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_sint78563412(reference, value)

Write a signed 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_sint78563412_list(reference, values)

Write a list of signed 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint16(reference, value)

Write a signed 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint16_list(reference, values)

Write a list of signed 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint32(reference, value)

Write a signed 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint32_list(reference, values)

Write a list of signed 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint64(reference, value)

Write a signed 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint64_list(reference, values)

Write a list of signed 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_slint8(reference, value)

Write a signed 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the signed int value to be written

write_holding_register_slint8_list(reference, values)

Write a list of signed 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of signed int values to be written

write_holding_register_string(reference, value, length)

Write a string to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the data value to be written

  • length – the length of the value

write_holding_register_string_list(reference, values, length)

Write a list of strings to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of data values to be written

  • length – the length of the value

write_holding_register_ubint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ubint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ubint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143(reference, value)

Write a unsigned 2143-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587(reference, value)

Write a unsigned 21436587-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint21436587_list(reference, values)

Write a list of unsigned 21436587-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint2143_list(reference, values)

Write a list of unsigned 2143-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint3412(reference, value)

Write a unsigned 3412-endian 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint3412_list(reference, values)

Write a list of unsigned 3412-endian 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_uint78563412(reference, value)

Write a unsigned 78563412-endian 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_uint78563412_list(reference, values)

Write a list of unsigned 78563412-endian 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint16(reference, value)

Write a unsigned 16-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint16_list(reference, values)

Write a list of unsigned 16-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint32(reference, value)

Write a unsigned 32-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint32_list(reference, values)

Write a list of unsigned 32-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint64(reference, value)

Write a unsigned 64-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint64_list(reference, values)

Write a list of unsigned 64-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_holding_register_ulint8(reference, value)

Write a unsigned 8-bit integer to holding register memory.

Parameters
  • reference – the reference to write to

  • value – the unsigned int value to be written

write_holding_register_ulint8_list(reference, values)

Write a list of unsigned 8-bit integers to holding register memory.

Parameters
  • reference – the reference to write to

  • values – a list of unsigned int values to be written

write_multiple_coils(reference, values)

Write multiple coils using Modbus function code 15.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

write_multiple_holding_registers(reference, values)

Write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference.

  • values (list of int) – the values to be written.

TCP Client

class htf.communication.modbus.ModbusTCPClient(address, port=502, unit_identifier=0, timeout=1.0, retries=None, references_start_at_one=True, transaction_identifier=0, auto_disconnect=False, request_parser=<class 'htf.communication.modbus.protocol.TCPModbusRequest'>, response_parser=<class 'htf.communication.modbus.protocol.TCPModbusResponse'>, debuglevel=None)
Parameters
  • address (str) – the ip address to connect to

  • port (int) – the port to be used

  • unit_identifier (int) – the unit identifier for Modbus TCP

  • timeout (float) – the timeout in seconds

  • retries=None (int or None) – the number of retries until an exception is raised

  • references_start_at_one=True – if set to True all references start at 1 else 0

  • transaction_identifier (int) – the initial transaction identifier

  • auto_disconnect=False (bool) – if set to True the TCP connection is closed immediately and re-opened on next request

  • request_parser – a parser for requests

  • response_parser – a parser for responses

  • debuglevel (int or None) – the debuglevel (None disables debug, 1 prints requests and responses and 2 prints introspection)

build_request()

Build and return an instance of the desired request parser.

Returns

request parser

build_response()

Build and return an instance of the desired response parser.

Returns

response parser

close()

Close the interface.

get_device_identification()

Query and return the device identification using Modbus function code 43.14.

Returns

containing key values pairs with the device identifiers

Return type

dict

get_fifo_queue_content(address)

Query and return the fifo content of address using Modbus function code 24.

Parameters

address – the fifo queue pointer address

Returns

list of content from the fifo queue at address

Return type

list

get_transaction_identifier()

Create and return a new transaction identifer. Is thread-safe.

Returns

the next transaction identifier

Return type

int

mask_holding_register(reference, and_mask, or_mask)

Mask write single holding register using Modbus function code 22.

Parameters
  • reference (int) – the register reference

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

mask_multiple_holding_registers(reference, quantity, and_mask, or_mask)

Mask write multiple holding registers using Modbus function code 16.

Parameters
  • reference (int) – the register reference

  • quantity (int) – the number of registers to be masked

  • and_mask (int) – the and mask

  • or_mask (int) – the or mask

query(adu)

Query adu using the interface and return the decoded response.

Parameters

adu – a serializable adu

Returns

the decoded response if no exception occured

Return type

adu

Raises

ModbusException – in case of an exception response

read()

Read a message from the interface and decode it.

Returns

the decoded adu as is

Return type

adu

Raises

Exception if no answer was received

read_coil(reference)

Read a single coil using Modbus function code 1.

Parameters

reference (int) – the register reference.

Returns

1 if the coil is set and 0 else.

Return type

int

read_coil_bitfield(reference, length)

Read a bitfield from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_coil_bitfield_list(reference, quantity, length)

Read a list of bitfields from coil memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_coil_data(reference, data)

Read data from coils using Modbus function code 1.

Parameters
  • reference (int) – the coil reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_coil_flag(reference)

Read a bit from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_coil_flag_list(reference, quantity)

Read a list of bits from coil memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_coil_nibble(reference)

Read a nibble from coil memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_coil_nibble_list(reference, quantity)

Read a list of nibbles from coil memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_discrete_input(reference)

Read single discrete input using Modbus function code 2.

Parameters

reference (int) – the register reference.

Returns

1 if the discete input is set and 0 else.

Return type

int

read_discrete_input_bitfield(reference, length)

Read a bitfield from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_discrete_input_bitfield_list(reference, quantity, length)

Read a list of bitfields from discrete input memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_discrete_input_data(reference, data)

Read data from discrete inputs using Modbus function code 2.

Parameters
  • reference (int) – the discrete input reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_discrete_input_flag(reference)

Read a bit from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_discrete_input_flag_list(reference, quantity)

Read a list of bits from discrete input memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_discrete_input_nibble(reference)

Read a nibble from discrete input memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_discrete_input_nibble_list(reference, quantity)

Read a list of nibbles from discrete input memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_extended_memory(memory_number, record_number, record_length)

Query and return extended memory from device using Modbus function code 20.

Parameters
  • memory_number (int) – the memory number (0x0001 to 0xffff)

  • record_number (int) – the record to start reading from

  • record_length (int) – the length of records

Returns

the read records

Return type

list of int

read_holding_register(reference)

Read a single holding register using Modbus function code 3.

Parameters

reference (int) – the register reference.

Returns

the holding register value

Return type

int

read_holding_register_bdouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_bdouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_bfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_bfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_bitfield(reference, length)

Read a bitfield from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_holding_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_holding_register_data(reference, data)

Read data from holding registers using Modbus function code 3.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_holding_register_double21436587(reference)

Read a 21436587-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_double78563412(reference)

Read a 78563412-endian double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_flag(reference)

Read a bit from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_holding_register_flag_list(reference, quantity)

Read a list of bits from holding register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_holding_register_float2143(reference)

Read a 2143-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_float3412(reference)

Read a 3412-endian float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_ldouble(reference)

Read a double from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_holding_register_ldouble_list(reference, quantity)

Read a list of doubles from holding register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_holding_register_lfloat(reference)

Read a float from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_holding_register_lfloat_list(reference, quantity)

Read a list of floats from holding register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_holding_register_nibble(reference)

Read a nibble from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_holding_register_nibble_list(reference, quantity)

Read a list of nibbles from holding register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_holding_register_sbint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sbint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint16(reference)

Read a signed 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint32(reference)

Read a signed 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint64(reference)

Read a signed 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_slint8(reference)

Read a signed 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_holding_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_holding_register_string(reference, length)

Read a string from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_holding_register_string_list(reference, quantity, length)

Read a list of strings from holding register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_holding_register_ubint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ubint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ubint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143(reference)

Read a unsigned 2143-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587(reference)

Read a unsigned 21436587-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint21436587_list(reference, quantity)

Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint2143_list(reference, quantity)

Read a list of unsigned 2143-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint3412(reference)

Read a unsigned 3412-endian 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint3412_list(reference, quantity)

Read a list of unsigned 3412-endian 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_uint78563412(reference)

Read a unsigned 78563412-endian 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_uint78563412_list(reference, quantity)

Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint16(reference)

Read a unsigned 16-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint32(reference)

Read a unsigned 32-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint64(reference)

Read a unsigned 64-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint64_list(reference, quantity)

Read a list of unsigned 64-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_holding_register_ulint8(reference)

Read a unsigned 8-bit integer from holding register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_holding_register_ulint8_list(reference, quantity)

Read a list of unsigned 8-bit integers from holding register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register(reference)

Read a single input register using Modbus function code 4.

Parameters

reference (int) – the register reference.

Returns

the input register value

Return type

int

read_input_register_bdouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_bdouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_bfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_bfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_bitfield(reference, length)

Read a bitfield from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

bitfield

read_input_register_bitfield_list(reference, quantity, length)

Read a list of bitfields from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

bitfield values read from reference

Return type

list of bitfield

read_input_register_data(reference, data)

Read data from input registers using Modbus function code 4.

Parameters
  • reference (int) – the register reference

  • data (oser.ByteStruct) – the type or instance or the decoder for the data

Returns

instance of datatype containing the read data

read_input_register_double21436587(reference)

Read a 21436587-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double21436587_list(reference, quantity)

Read a list of 21436587-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_double78563412(reference)

Read a 78563412-endian double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_double78563412_list(reference, quantity)

Read a list of 78563412-endian doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_flag(reference)

Read a bit from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

bool

read_input_register_flag_list(reference, quantity)

Read a list of bits from input register memory.

Parameters

reference – the reference to read from

Returns

bool values read from reference

Return type

list of bool

read_input_register_float2143(reference)

Read a 2143-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float2143_list(reference, quantity)

Read a list of 2143-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_float3412(reference)

Read a 3412-endian float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_float3412_list(reference, quantity)

Read a list of 3412-endian floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_ldouble(reference)

Read a double from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

double

read_input_register_ldouble_list(reference, quantity)

Read a list of doubles from input register memory.

Parameters

reference – the reference to read from

Returns

double values read from reference

Return type

list of double

read_input_register_lfloat(reference)

Read a float from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

float

read_input_register_lfloat_list(reference, quantity)

Read a list of floats from input register memory.

Parameters

reference – the reference to read from

Returns

float values read from reference

Return type

list of float

read_input_register_nibble(reference)

Read a nibble from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

nibble

read_input_register_nibble_list(reference, quantity)

Read a list of nibbles from input register memory.

Parameters

reference – the reference to read from

Returns

nibble values read from reference

Return type

list of nibble

read_input_register_sbint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sbint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sbint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143(reference)

Read a signed 2143-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587(reference)

Read a signed 21436587-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint21436587_list(reference, quantity)

Read a list of signed 21436587-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint2143_list(reference, quantity)

Read a list of signed 2143-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint3412(reference)

Read a signed 3412-endian 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint3412_list(reference, quantity)

Read a list of signed 3412-endian 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_sint78563412(reference)

Read a signed 78563412-endian 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_sint78563412_list(reference, quantity)

Read a list of signed 78563412-endian 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint16(reference)

Read a signed 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint16_list(reference, quantity)

Read a list of signed 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint32(reference)

Read a signed 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint32_list(reference, quantity)

Read a list of signed 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint64(reference)

Read a signed 64-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint64_list(reference, quantity)

Read a list of signed 64-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_slint8(reference)

Read a signed 8-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

signed int

read_input_register_slint8_list(reference, quantity)

Read a list of signed 8-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

signed int values read from reference

Return type

list of signed int

read_input_register_string(reference, length)

Read a string from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

value read from reference

Return type

data

read_input_register_string_list(reference, quantity, length)

Read a list of strings from input register memory.

Parameters
  • reference – the reference to read from

  • length – the length of the value

Returns

data values read from reference

Return type

list of data

read_input_register_ubint16(reference)

Read a unsigned 16-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint16_list(reference, quantity)

Read a list of unsigned 16-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type

list of unsigned int

read_input_register_ubint32(reference)

Read a unsigned 32-bit integer from input register memory.

Parameters

reference – the reference to read from

Returns

value read from reference

Return type

unsigned int

read_input_register_ubint32_list(reference, quantity)

Read a list of unsigned 32-bit integers from input register memory.

Parameters

reference – the reference to read from

Returns

unsigned int values read from reference

Return type