Modbus — The Modbus Testing Framework
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 bytesfault insertion
possibility to extend client and device simulator with own commands
The Modbus implementation is capable of testing Modbus clients and servers.
Examples
Simulating a Modbus-Device
import htf
from htf.modbus import ModbusTCPDevice, ModbusTCPClient
ADDRESS = 'localhost'
PORT = 10502 # must be able to run for non-root users
@htf.fixture(scope='class', name='device')
def create_device_simulator():
device = ModbusTCPDevice(ADDRESS, port=PORT)
yield device
device.close()
@htf.fixture(scope='test', name='client')
def create_client():
client = ModbusTCPClient(ADDRESS,
port=PORT,
references_start_at_one=False,
auto_disconnect=False,
debuglevel=0) # set debuglevel to 1 or 2
yield client
client.close()
class ModbusTCPTests:
"""
This tests shows how to simulate a modbus device and how to use the client to
query it via TCP/IP.
"""
def test_holding_registers(self, device, client, assertions):
registers = client.read_multiple_holding_registers(0, 8)
assertions.assert_equal(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)
assertions.assert_equal(registers, [0, 1, 0, 1, 1, 0, 1, 0])
device.write_multiple_holding_registers(address, [1, 1, 0, 0, 1, 0, 1, 0])
registers = client.read_multiple_holding_registers(address, 8)
assertions.assert_equal(registers, [1, 1, 0, 0, 1, 0, 1, 0])
def test_input_registers(self, device, client, assertions):
device.write_multiple_input_registers(0, list(range(10)))
registers = client.read_multiple_input_registers(0, 10)
assertions.assert_equal(registers, list(range(10)))
registers = device.read_multiple_input_registers(0, 10)
assertions.assert_equal(registers, list(range(10)))
device.write_multiple_input_registers(10, list(range(20, 31)))
registers = client.read_multiple_input_registers(5, 15)
assertions.assert_equal(registers, list(range(5, 10)) + list(range(20, 30)))
for i in range(10):
r = client.read_input_register(i)
assertions.assert_equal(r, i)
r = device.read_input_register(i)
assertions.assert_equal(r, i)
for i in range(10, 20):
r = client.read_input_register(i)
assertions.assert_equal(r, i+10)
r = device.read_input_register(i)
assertions.assert_equal(r, i + 10)
device.write_input_register(2323, 1)
r = client.read_input_register(2323)
assertions.assert_equal(r, 1)
if __name__ == '__main__':
htf.main()
Special Modbus Data Structures
import htf
import oser
from datetime import datetime
from htf.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())
@htf.fixture(scope='class', name='device')
def create_device_simulator():
device = ModbusTCPDevice(ADDRESS, port=PORT)
yield device
device.close()
@htf.fixture(scope='test', name='client')
def create_client():
client = ModbusTCPClient(ADDRESS,
port=PORT,
references_start_at_one=False,
auto_disconnect=False,
debuglevel=0) # set debuglevel to 1 or 2
yield client
client.close()
class ModbusDataStructureTests:
"""
This test shows how to read and write own data structures using Modbus.
"""
def test_datetime_data_structure(self, device, client, assertions):
"""
A DateTime data type can be read from input registers at address 23.
"""
now = datetime.now()
device.write_input_register_data(23, DateTime(now))
current_date_struct = client.read_input_register_data(23, DateTime)
assertions.assert_equal(current_date_struct.year, now.year)
assertions.assert_equal(current_date_struct.month, now.month)
assertions.assert_equal(current_date_struct.day, now.day)
assertions.assert_equal(current_date_struct.hour, now.hour)
assertions.assert_equal(current_date_struct.minute, now.minute)
assertions.assert_equal(current_date_struct.second, now.second)
print("device date time is:", current_date_struct.get())
if __name__ == '__main__':
htf.main()
Interfaces
Interfaces are used to implement communication. The user may add other interfaces if needed.
Serial RTU Client Interface
- class htf.modbus.ModbusSerialRTUClientInterface(com_port: str | None = None, baud: int = 9600, bytesize: int = 8, parity: str = 'E', stopbits: int = 1, rtscts: bool = False, timeout: int | float = 1.0, response_parser: ByteStruct | BitStruct | ByteType | BitType = <class 'htf.modbus.protocol.SerialRTUModbusResponse'>)
- Parameters:
com_port – the com port to be used
baud – the baud rate
bytesize – number of bits in a byte
parity – serial.PARITY_NONE, serial.PARITY_ODD or serial.PARITY_EVEN
stopbits – number of stopbits (1, 1.5 or 2)
rtscts – if True use flow control
timeout – the timeout in seconds
response_parser – the parser to parse responses
- read() Tuple[bytes, None]
Read Modbus serial RTU responses from server.
- Returns:
a tuple containing buffer,
None
- write(adu: SerialRTUModbusRequest) None
Write
adu
.- Parameters:
adu – serializable RTU adu
Serial RTU Server Interface
- class htf.modbus.ModbusSerialRTUServerInterface(com_port: str | None = None, baud: int = 9600, bytesize: int = 8, parity: str = 'E', stopbits: int = 1, rtscts: bool = False, timeout: int | float = 1.0, response_parser: ByteStruct | BitStruct | ByteType | BitType = <class 'htf.modbus.protocol.SerialRTUModbusRequest'>)
- Parameters:
com_port – the com port to be used
baud – the baud rate
bytesize – number of bits in a byte
parity – serial.PARITY_NONE, serial.PARITY_ODD or serial.PARITY_EVEN
stopbits – number of stopbits (1, 1.5 or 2)
rtscts – if True use flow control
timeout – the timeout in seconds
response_parser – the parser to parse responses
- read() Tuple[bytes, None]
Read Modbus serial RTU requests from client.
- Returns:
a tuple containing buffer,
None
- write(adu: SerialRTUModbusRequest) None
Write
adu
.- Parameters:
adu – serializable RTU adu
Serial ASCII Client Interface
- class htf.modbus.ModbusSerialASCIIClientInterface(com_port: str | None = None, baud: int = 9600, bytesize: int = 8, parity: str = 'E', stopbits: int = 1, rtscts: bool = False, timeout: int | float = 1.0, response_parser: ByteStruct | BitStruct | ByteType | BitType = <class 'htf.modbus.protocol.SerialASCIIModbusResponse'>)
- Parameters:
com_port – the com port to be used
baud – the baud rate
bytesize – number of bits in a byte
parity – serial.PARITY_NONE, serial.PARITY_ODD or serial.PARITY_EVEN
stopbits – number of stopbits (1, 1.5 or 2)
rtscts – if True use flow control
timeout – the timeout in seconds
response_parser – the parser to parse responses
- change_ascii_delimiter(delimiter: bytes) None
Change LF character to
delimiter
.- Parameters:
delimiter – bytes of length 1 containing the new ASCII delimiter
- read() Tuple[bytes, None]
Read Modbus serial ASCII responses from server. Read until line feed character.
- Returns:
a tuple containing buffer,
None
- write(adu: SerialASCIIModbusRequest) None
Write
adu
.- Parameters:
adu – serializable RTU adu
Serial ASCII Server Interface
- class htf.modbus.ModbusSerialASCIIServerInterface(com_port: str | None = None, baud: int = 9600, bytesize: int = 8, parity: str = 'E', stopbits: int = 1, rtscts: bool = False, timeout: int | float = 1.0, response_parser: ByteStruct | BitStruct | ByteType | BitType = <class 'htf.modbus.protocol.SerialASCIIModbusRequest'>)
- Parameters:
com_port – the com port to be used
baud – the baud rate
bytesize – number of bits in a byte
parity – serial.PARITY_NONE, serial.PARITY_ODD or serial.PARITY_EVEN
stopbits – number of stopbits (1, 1.5 or 2)
rtscts – if True use flow control
timeout – the timeout in seconds
response_parser – the parser to parse responses
- change_ascii_delimiter(delimiter: bytes) None
Change LF character to
delimiter
.- Parameters:
delimiter – bytes of length 1 containing the new ASCII delimiter
- read() Tuple[bytes, None]
Read serial ASCII Modbus requests from client.
- Returns:
a tuple containing buffer,
None
- write(adu: SerialASCIIModbusRequest) None
Write
adu
.- Parameters:
adu – serializable RTU adu
TCP Client Interface
- class htf.modbus.ModbusTCPClientInterface(address: str, port: int = 502, timeout: int | float = 1.0, connect: bool = True)
- Parameters:
address – the ip-address to connect to
port – the port
timeout – the timeout in seconds
connect – if set to
True
the socket connects automatically
- read() Tuple[bytes | None, None]
Read a TCP request from TCP server.
- Returns:
a tuple containing buffer,
None
- write(adu: TCPModbusRequest) None
Write
adu
.- Parameters:
adu – serializable TCP adu
TCP Server Interface
- class htf.modbus.ModbusTCPServerInterface(address: str, port: int = 502, timeout: int | float = 1.0)
- Parameters:
address – the ip-address to listen on
port – the port to listen on
timeout – the timeout in seconds
- accept() Tuple[socket, Any]
Accept a new connection.
- Returns:
a tuple containing connection, address
- read(connection: socket) bytes
Read a TCP request from TLS client.
- Returns:
a tuple containing buffer,
None
- write(connection: socket, adu: TCPModbusRequest) None
Write
adu
.- Parameters:
adu – serializable TCP adu
UDP Client Interface
- class htf.modbus.ModbusUDPClientInterface(address: str, port: int = 502, timeout: int | float = 1.0)
- Parameters:
address – the ip-address to connect to
port – the port
timeout – the timeout in seconds
- read() Tuple[bytes | None, None]
Read a TLS request from TLS server.
- Returns:
a tuple containing buffer,
None
- write(adu: TCPModbusRequest) None
Write
adu
.- Parameters:
adu – serializable TCP adu
UDP Server Interface
- class htf.modbus.ModbusUDPServerInterface(address: str, port: int = 502, timeout: Tuple[int, float] | None = None)
- Parameters:
address – the ip-address to listen on
port – the port to listen on
timeout=None – the timeout in seconds
- read(bufsize: int = 300) Tuple[bytes, Any]
Read a request from an UDP client.
- Parameters:
bufsize – buffer size
- Returns:
the received request
- write(address: str, adu: TCPModbusRequest) None
Write
adu
.- Parameters:
address – the target ip-address
adu – serializable TCP adu
TLS Client Interface
- class htf.modbus.ModbusTLSClientInterface(address: str, port: int = 502, timeout: int | float = 1.0, verify: bool = True, connect: bool = True, cafile: str | None = None, capath: str | None = None, cadata: str | None = None)
- Parameters:
address – the ip-address to connect to
port – the port
timeout – the timeout in seconds
verify – set to
False
to disable TLS certificate verificationconnect – if set to
True
the socket connects automaticallycafile – path to a file of concatenated CA certificates in PEM format
capath – path to a directory containing several CA certificates in PEM format
cadata – either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates
- read() Tuple[bytes | None, None]
Read a TCP request from TCP server.
- Returns:
a tuple containing buffer,
None
- write(adu: TCPModbusRequest) None
Write
adu
.- Parameters:
adu – serializable TCP adu
TLS Server Interface
- class htf.modbus.ModbusTLSServerInterface(address: str, port: int = 502, timeout: int | float = 1.0, certfile: str | None = None, keyfile: str | None = None, password: str | None = None)
- Parameters:
address – the ip-address to listen on
port – the port to listen on
timeout – the timeout in seconds
certfile – path to TLS certificate
keyfile – path to TLS keyfile
password – TLS password
- accept() Tuple[socket, Any]
Accept a new connection.
- Returns:
a tuple containing connection, address
- read(connection: socket) bytes
Read a TCP request from TLS client.
- Returns:
a tuple containing buffer,
None
- write(connection: socket, adu: TCPModbusRequest) None
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.modbus.ModbusBaseClient(interface: ModbusBaseInterface, request_parser: Type[SerialRTUModbusRequest] | Type[SerialASCIIModbusRequest] | Type[TCPModbusRequest], response_parser: Type[SerialRTUModbusResponse] | Type[SerialASCIIModbusResponse] | Type[TCPModbusResponse], retries: int | None = None, references_start_at_one: bool = True, debuglevel: int | None = None)
- Parameters:
interface – an interface to be used for communication
request_parser – a parser for requests
response_parser – a parser for responses
retries=None – the number of retries until an exception is raised
references_start_at_one=True – if set to
True
all references start at1
else0
debuglevel – the debuglevel (
None
disables debug,1
prints requests and responses and2
prints introspection)
- build_request() SerialRTUModbusRequest | SerialASCIIModbusRequest | TCPModbusRequest
Build and return an instance of the desired request parser.
- Returns:
request parser
- build_response() SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Build and return an instance of the desired response parser.
- Returns:
response parser
- get_device_identification() Dict[int, bytes]
Query and return the device identification using Modbus function code 43.14.
- Returns:
containing key values pairs with the device identifiers
- get_fifo_queue_content(address: int) List[int]
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
- mask_holding_register(reference: int, and_mask: int, or_mask: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Mask write single holding register using Modbus function code 22.
- Parameters:
reference – the register reference
and_mask – the and mask
or_mask – the or mask
- mask_multiple_holding_registers(reference: int, quantity: int, and_mask: int, or_mask: int) None
Mask write multiple holding registers using Modbus function code 16.
- Parameters:
reference – the register reference
quantity – the number of registers to be masked
and_mask – the and mask
or_mask – the or mask
- query(adu: SerialRTUModbusRequest | SerialASCIIModbusRequest | TCPModbusRequest) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Query
adu
using the interface and return the decoded response. This method is thread-safe.- Parameters:
adu – a serializable adu
- Returns:
the decoded response if no exception occurred
- Return type:
adu
- Raises:
ModbusException – in case of an exception response
- read() SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int) int
Read a single coil using Modbus function code 1.
- Parameters:
reference – the register reference.
- Returns:
1
if the coil is set and0
else.
- read_coil_bitfield(reference: int, length: int) int
Read a bitfield from coil memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_coil_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from coil memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_coil_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from coils using Modbus function code 1.
- Parameters:
reference – the coil reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_coil_flag(reference: int) bool
Read a bit from coil memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_coil_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from coil memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_coil_nibble(reference: int) int
Read a nibble from coil memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_coil_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from coil memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_discrete_input(reference: int) int
Read single discrete input using Modbus function code 2.
- Parameters:
reference – the register reference.
- Returns:
1
if the discrete input is set and0
else.
- read_discrete_input_bitfield(reference: int, length: int) int
Read a bitfield from discrete input memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_discrete_input_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from discrete input memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_discrete_input_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from discrete inputs using Modbus function code 2.
- Parameters:
reference – the discrete input reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_discrete_input_flag(reference: int) bool
Read a bit from discrete input memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_discrete_input_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from discrete input memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_discrete_input_nibble(reference: int) int
Read a nibble from discrete input memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_discrete_input_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from discrete input memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_extended_memory(memory_number: int, record_number: int, record_length: int) List[int]
Query and return extended memory from device using Modbus function code 20.
- Parameters:
memory_number – the memory number (0x0001 to 0xffff)
record_number – the record to start reading from
record_length – the length of records
- Returns:
the read records
- read_holding_register(reference: int) int
Read a single holding register using Modbus function code 3.
- Parameters:
reference – the register reference.
- Returns:
the holding register value
- read_holding_register_bdouble(reference: int) float
Read a double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_bdouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_bfloat(reference: int) float
Read a float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_bfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_bitfield(reference: int, length: int) int
Read a bitfield from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_holding_register_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from holding registers using Modbus function code 3.
- Parameters:
reference – the register reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_holding_register_double21436587(reference: int) float
Read a 21436587-endian double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_double21436587_list(reference: int, quantity: int) List[float]
Read a list of 21436587-endian doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_double78563412(reference: int) float
Read a 78563412-endian double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_double78563412_list(reference: int, quantity: int) List[float]
Read a list of 78563412-endian doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_flag(reference: int) bool
Read a bit from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_holding_register_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_holding_register_float2143(reference: int) float
Read a 2143-endian float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_float2143_list(reference: int, quantity: int) List[float]
Read a list of 2143-endian floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_float3412(reference: int) float
Read a 3412-endian float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_float3412_list(reference: int, quantity: int) List[float]
Read a list of 3412-endian floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_ldouble(reference: int) float
Read a double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_ldouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_lfloat(reference: int) float
Read a float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_lfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_nibble(reference: int) int
Read a nibble from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint16(reference: int) int
Read a signed 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint32(reference: int) int
Read a signed 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint64(reference: int) int
Read a signed 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint8(reference: int) int
Read a signed 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint2143(reference: int) int
Read a signed 2143-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint21436587(reference: int) int
Read a signed 21436587-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint21436587_list(reference: int, quantity: int) List[int]
Read a list of signed 21436587-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint2143_list(reference: int, quantity: int) List[int]
Read a list of signed 2143-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint3412(reference: int) int
Read a signed 3412-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint3412_list(reference: int, quantity: int) List[int]
Read a list of signed 3412-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint78563412(reference: int) int
Read a signed 78563412-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint78563412_list(reference: int, quantity: int) List[int]
Read a list of signed 78563412-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint16(reference: int) int
Read a signed 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint32(reference: int) int
Read a signed 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint64(reference: int) int
Read a signed 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint8(reference: int) int
Read a signed 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_string(reference: int, length: int) bytes
Read a string from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
bytes value read from
reference
- read_holding_register_string_list(reference: int, quantity: int, length: int) List[bytes]
Read a list of strings from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of bytes values read from
reference
- read_holding_register_ubint16(reference: int) int
Read an unsigned 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint32(reference: int) int
Read an unsigned 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint64(reference: int) int
Read an unsigned 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint8(reference: int) int
Read an unsigned 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint2143(reference: int) int
Read an unsigned 2143-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint21436587(reference: int) int
Read an unsigned 21436587-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint21436587_list(reference: int, quantity: int) List[int]
Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint2143_list(reference: int, quantity: int) List[int]
Read a list of unsigned 2143-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint3412(reference: int) int
Read an unsigned 3412-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint3412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 3412-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint78563412(reference: int) int
Read an unsigned 78563412-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint78563412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint16(reference: int) int
Read an unsigned 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint32(reference: int) int
Read an unsigned 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint64(reference: int) int
Read an unsigned 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint8(reference: int) int
Read an unsigned 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register(reference: int) int
Read a single input register using Modbus function code 4.
- Parameters:
reference – the register reference.
- Returns:
the input register value
- read_input_register_bdouble(reference: int) float
Read a double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_bdouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_bfloat(reference: int) float
Read a float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_bfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_bitfield(reference: int, length: int) int
Read a bitfield from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_input_register_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from input registers using Modbus function code 4.
- Parameters:
reference – the register reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_input_register_double21436587(reference: int) float
Read a 21436587-endian double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_double21436587_list(reference: int, quantity: int) List[float]
Read a list of 21436587-endian doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_double78563412(reference: int) float
Read a 78563412-endian double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_double78563412_list(reference: int, quantity: int) List[float]
Read a list of 78563412-endian doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_flag(reference: int) bool
Read a bit from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_input_register_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_input_register_float2143(reference: int) float
Read a 2143-endian float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_float2143_list(reference: int, quantity: int) List[float]
Read a list of 2143-endian floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_float3412(reference: int) float
Read a 3412-endian float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_float3412_list(reference: int, quantity: int) List[float]
Read a list of 3412-endian floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_ldouble(reference: int) float
Read a double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_ldouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_lfloat(reference: int) float
Read a float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_lfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_nibble(reference: int) int
Read a nibble from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint16(reference: int) int
Read a signed 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint32(reference: int) int
Read a signed 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint64(reference: int) int
Read a signed 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint8(reference: int) int
Read a signed 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint2143(reference: int) int
Read a signed 2143-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint21436587(reference: int) int
Read a signed 21436587-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint21436587_list(reference: int, quantity: int) List[int]
Read a list of signed 21436587-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint2143_list(reference: int, quantity: int) List[int]
Read a list of signed 2143-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint3412(reference: int) int
Read a signed 3412-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint3412_list(reference: int, quantity: int) List[int]
Read a list of signed 3412-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint78563412(reference: int) int
Read a signed 78563412-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint78563412_list(reference: int, quantity: int) List[int]
Read a list of signed 78563412-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint16(reference: int) int
Read a signed 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint32(reference: int) int
Read a signed 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint64(reference: int) int
Read a signed 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint8(reference: int) int
Read a signed 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_string(reference: int, length: int) bytes
Read a string from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
bytes value read from
reference
- read_input_register_string_list(reference: int, quantity: int, length: int) List[bytes]
Read a list of strings from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of bytes values read from
reference
- read_input_register_ubint16(reference: int) int
Read an unsigned 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint32(reference: int) int
Read an unsigned 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint64(reference: int) int
Read an unsigned 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint8(reference: int) int
Read an unsigned 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_uint2143(reference: int) int
Read an unsigned 2143-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_uint21436587(reference: int) int
Read an unsigned 21436587-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_uint21436587_list(reference: int, quantity: int) List[int]
Read a list of unsigned 21436587-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_uint2143_list(reference: int, quantity: int) List[int]
Read a list of unsigned 2143-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_uint3412(reference: int) int
Read an unsigned 3412-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_uint3412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 3412-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_uint78563412(reference: int) int
Read an unsigned 78563412-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_uint78563412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 78563412-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ulint16(reference: int) int
Read an unsigned 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ulint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ulint32(reference: int) int
Read an unsigned 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ulint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ulint64(reference: int) int
Read an unsigned 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ulint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ulint8(reference: int) int
Read an unsigned 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ulint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_multiple_coils(reference: int, quantity: int) List[int]
Read multiple coils using Modbus function code 1.
- Parameters:
reference – the register reference.
quantity – the number of coils to be read.
- Returns:
a list of coil states where each element is
1
if the corresponding coil is set and0
else.
- read_multiple_discrete_inputs(reference: int, quantity: int) List[int]
Read multiple discrete inputs using Modbus function code 2.
- Parameters:
reference – the register reference.
quantity – the number of discrete inputs to be read.
- Returns:
a list of discrete inputs where each element is
1
if the corresponding discrete input is set and0
else.
- read_multiple_holding_registers(reference: int, quantity: int) List[int]
Read multiple holding registers using Modbus function code 3.
- Parameters:
reference – the register reference.
quantity – the number of registers to be read.
- Returns:
the holding register values
- read_multiple_input_registers(reference: int, quantity: int) List[int]
Read multiple input registers using Modbus function code 4.
- Parameters:
reference – the register reference.
quantity – the number of registers to be read.
- Returns:
the input register values
- read_write_multiple_holding_registers(read_reference: int, read_quantity: int, write_reference: int, write_values: List[int]) List[int]
Read/Write multiple holding registers using Modbus function code 23.
- Parameters:
read_reference – the register reference to read from.
read_quantity – the number of registers to read.
write_reference – the register reference to to write to.
write_values – the values to be written.
- Returns:
the read registers
- write(adu: SerialRTUModbusRequest | SerialASCIIModbusRequest | TCPModbusRequest) None
Write
adu
encoded using the interface.- Parameters:
adu – a serializable adu
- write_coil(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a single coil using Modbus function code 5.
- Parameters:
reference – the register reference.
value – the value to be written.
- write_coil_bitfield(reference: int, value: int, length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a bitfield to coil memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
length – the length of the value
- write_coil_bitfield_list(reference: int, values: List[int], length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of bitfields to coil memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
length – the length of the value
- write_coil_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write data to coils using Modbus function code 15.
- Parameters:
reference – the coil reference.
data – the type or instance or the decoder for the data
- write_coil_flag(reference: int, value: bool) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[bool]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a nibble to coil memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_coil_nibble_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of nibbles to coil memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_extended_memory(memory_number: int, record_number: int, records: List[int]) None
Write extended memory using Modbus function code 21.
- Parameters:
memory_number – the memory number (0x0001 to 0xffff)
record_number – the record to write to
records – the records to be written
- write_holding_register(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a double to holding register memory.
- Parameters:
reference – the reference to write to
value – the float value to be written
- write_holding_register_bdouble_list(reference: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of doubles to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of float values to be written
- write_holding_register_bfloat(reference: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: int, length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a bitfield to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
length – the length of the value
- write_holding_register_bitfield_list(reference: int, values: List[int], length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of bitfields to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
length – the length of the value
- write_holding_register_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write data to holding registers using Modbus function code 16.
- Parameters:
reference – the register reference.
data – the type or instance or the decoder for the data
- write_holding_register_double21436587(reference: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a 21436587-endian double to holding register memory.
- Parameters:
reference – the reference to write to
value – the float value to be written
- write_holding_register_double21436587_list(reference: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of 21436587-endian doubles to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of float values to be written
- write_holding_register_double78563412(reference: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a 78563412-endian double to holding register memory.
- Parameters:
reference – the reference to write to
value – the float value to be written
- write_holding_register_double78563412_list(reference: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of 78563412-endian doubles to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of float values to be written
- write_holding_register_flag(reference: int, value: bool) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[bool]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a double to holding register memory.
- Parameters:
reference – the reference to write to
value – the float value to be written
- write_holding_register_ldouble_list(reference: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of doubles to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of float values to be written
- write_holding_register_lfloat(reference: int, value: float) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, values: List[float]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a nibble to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_nibble_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of nibbles to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_sbint16(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 16-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sbint16_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 16-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_sbint32(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sbint32_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 32-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_sbint64(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sbint64_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 64-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_sbint8(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 8-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sbint8_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 8-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_sint2143(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 2143-endian 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sint21436587(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 21436587-endian 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sint21436587_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_sint2143_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_sint3412(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 3412-endian 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sint3412_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_sint78563412(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 78563412-endian 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_sint78563412_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_slint16(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 16-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_slint16_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 16-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_slint32(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_slint32_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 32-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_slint64(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_slint64_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 64-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_slint8(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a signed 8-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_slint8_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of signed 8-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_string(reference: int, value: bytes, length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a string to holding register memory.
- Parameters:
reference – the reference to write to
value – the bytes value to be written
length – the length of the value
- write_holding_register_string_list(reference: int, values: List[bytes], length: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of strings to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of bytes values to be written
length – the length of the value
- write_holding_register_ubint16(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 16-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ubint16_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 16-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ubint32(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ubint32_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 32-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ubint64(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ubint64_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 64-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ubint8(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 8-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ubint8_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 8-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_uint2143(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 2143-endian 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_uint21436587(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 21436587-endian 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_uint21436587_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_uint2143_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_uint3412(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 3412-endian 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_uint3412_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_uint78563412(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 78563412-endian 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_uint78563412_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 int values to be written
- write_holding_register_ulint16(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 16-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ulint16_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 16-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ulint32(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 32-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ulint32_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 32-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ulint64(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 64-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ulint64_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 64-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_holding_register_ulint8(reference: int, value: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write an unsigned 8-bit integer to holding register memory.
- Parameters:
reference – the reference to write to
value – the int value to be written
- write_holding_register_ulint8_list(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write a list of unsigned 8-bit integers to holding register memory.
- Parameters:
reference – the reference to write to
values – a list of int values to be written
- write_multiple_coils(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write multiple coils using Modbus function code 15.
- Parameters:
reference – the register reference.
values – the values to be written.
- write_multiple_holding_registers(reference: int, values: List[int]) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Write multiple holding registers using Modbus function code 16.
- Parameters:
reference – the register reference.
values – the values to be written.
Serial RTU Client
- class htf.modbus.ModbusSerialRTUClient(com_port: str, baud: int = 9600, bytesize: int = 8, parity: str = 'E', stopbits: int = 1, rtscts: bool = False, device_address: int = 1, timeout: int | float = 1.0, retries: int | None = None, references_start_at_one: bool = True, request_parser: ~typing.Type[~htf.modbus.protocol.SerialRTUModbusRequest] | ~typing.Type[~htf.modbus.protocol.SerialASCIIModbusRequest] | ~typing.Type[~htf.modbus.protocol.TCPModbusRequest] = <class 'htf.modbus.protocol.SerialRTUModbusRequest'>, response_parser: ~typing.Type[~htf.modbus.protocol.SerialRTUModbusResponse] | ~typing.Type[~htf.modbus.protocol.SerialASCIIModbusResponse] | ~typing.Type[~htf.modbus.protocol.TCPModbusResponse] = <class 'htf.modbus.protocol.SerialRTUModbusResponse'>, debuglevel: int | None = None)
- Parameters:
com_port – the com port to be used
baud – the baud rate
bytesize – number of bits in a byte
parity – serial.PARITY_NONE, serial.PARITY_ODD or serial.PARITY_EVEN
stopbits – number of stopbits (1, 1.5 or 2)
rtscts – if True use flow control
device_address – the device address (Slave ID)
timeout – the timeout in seconds
retries=None – the number of retries until an exception is raised
references_start_at_one=True – if set to
True
all references start at1
else0
request_parser – a parser for requests
response_parser – a parser for responses
debuglevel – the debuglevel (
None
disables debug,1
prints requests and responses and2
prints introspection)
- build_request() SerialRTUModbusRequest | SerialASCIIModbusRequest | TCPModbusRequest
Build and return an instance of the desired request parser.
- Returns:
request parser
- build_response() SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Build and return an instance of the desired response parser.
- Returns:
response parser
- clear_counters_and_diagnostic_register() None
Clear counters and diagnostic register using Modbus function code 8.10.
- clear_overrun_counter_and_flag() None
Clear overrun counter and reset the error flag using Modbus function code 8.20.
- echo(data: bytes) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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 – The bytes to be sent.
- Returns:
response
- get_bus_character_overrun_count() int
Query and return the bus character overrun count from the device using Modbus function code 8.18.
- Returns:
the bus character overrun count
- get_bus_communication_error_count() int
Query and return the bus communication error count from the device using Modbus function code 8.12.
- Returns:
the bus communication error count
- get_bus_exception_error_count() int
Query and return the bus exception error count from the device using Modbus function code 8.13.
- Returns:
the bus exception error count
- get_bus_message_count() int
Query and return the bus message count from the device using Modbus function code 8.11.
- Returns:
the bus message count
- get_busy_count() int
Query and return the slave busy count from the device using Modbus function code 8.17.
- Returns:
the slave busy count
- get_busy_status() bool
Query and return busy status using Modbus function code 11.
- Returns:
busy_status
- get_communication_event_counter_and_busy_status() Tuple[int, bool]
Query and return communication event counter and busy status using Modbus function code 11.
- Returns:
a tuple containing communication_event_counter (int), busy_status (bool)
- get_device_identification() Dict[int, bytes]
Query and return the device identification using Modbus function code 43.14.
- Returns:
containing key values pairs with the device identifiers
- get_diagnostic_register() bytes
Query and return the diagnostic register using Modbus function 8.2.
- Returns:
the content of the diagnostic register
- get_event_count() int
Query and return event count status using Modbus function code 11.
- Returns:
communication_event_counter
- get_event_log() Tuple[int, int, int, List[int]]
Query and return the event log using Modbus function code 12.
- Returns:
a tuple containing busy_status (int), event_count (int), message_count (int), events (list of int)
- get_exception_status() int
Read and return exception status using Modbus function code 7.
- Returns:
the current exception status
- get_fifo_queue_content(address: int) List[int]
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
- get_slave_id() Tuple[int, bool, bytes]
Query and return the slave id using Modbus function code 17.
- Returns:
a tuple containing slave-id, running, data
- get_slave_message_count() int
Query and return the slave message count from the device using Modbus function code 8.14.
- Returns:
the slave message count
- get_slave_nak_count() int
Query and return the slave nak count from the device using Modbus function code 8.16.
- Returns:
the slave nak count
- get_slave_no_response_count() int
Query and return the slave no response count from the device using Modbus function code 8.15.
- Returns:
the slave no response count
- mask_holding_register(reference: int, and_mask: int, or_mask: int) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Mask write single holding register using Modbus function code 22.
- Parameters:
reference – the register reference
and_mask – the and mask
or_mask – the or mask
- mask_multiple_holding_registers(reference: int, quantity: int, and_mask: int, or_mask: int) None
Mask write multiple holding registers using Modbus function code 16.
- Parameters:
reference – the register reference
quantity – the number of registers to be masked
and_mask – the and mask
or_mask – the or mask
- query(adu: SerialRTUModbusRequest | SerialASCIIModbusRequest | TCPModbusRequest) SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
Query
adu
using the interface and return the decoded response. This method is thread-safe.- Parameters:
adu – a serializable adu
- Returns:
the decoded response if no exception occurred
- Return type:
adu
- Raises:
ModbusException – in case of an exception response
- read() SerialRTUModbusResponse | SerialASCIIModbusResponse | TCPModbusResponse
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: int) int
Read a single coil using Modbus function code 1.
- Parameters:
reference – the register reference.
- Returns:
1
if the coil is set and0
else.
- read_coil_bitfield(reference: int, length: int) int
Read a bitfield from coil memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_coil_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from coil memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_coil_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from coils using Modbus function code 1.
- Parameters:
reference – the coil reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_coil_flag(reference: int) bool
Read a bit from coil memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_coil_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from coil memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_coil_nibble(reference: int) int
Read a nibble from coil memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_coil_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from coil memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_discrete_input(reference: int) int
Read single discrete input using Modbus function code 2.
- Parameters:
reference – the register reference.
- Returns:
1
if the discrete input is set and0
else.
- read_discrete_input_bitfield(reference: int, length: int) int
Read a bitfield from discrete input memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_discrete_input_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from discrete input memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_discrete_input_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from discrete inputs using Modbus function code 2.
- Parameters:
reference – the discrete input reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_discrete_input_flag(reference: int) bool
Read a bit from discrete input memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_discrete_input_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from discrete input memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_discrete_input_nibble(reference: int) int
Read a nibble from discrete input memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_discrete_input_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from discrete input memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_extended_memory(memory_number: int, record_number: int, record_length: int) List[int]
Query and return extended memory from device using Modbus function code 20.
- Parameters:
memory_number – the memory number (0x0001 to 0xffff)
record_number – the record to start reading from
record_length – the length of records
- Returns:
the read records
- read_holding_register(reference: int) int
Read a single holding register using Modbus function code 3.
- Parameters:
reference – the register reference.
- Returns:
the holding register value
- read_holding_register_bdouble(reference: int) float
Read a double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_bdouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_bfloat(reference: int) float
Read a float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_bfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_bitfield(reference: int, length: int) int
Read a bitfield from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_holding_register_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from holding registers using Modbus function code 3.
- Parameters:
reference – the register reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_holding_register_double21436587(reference: int) float
Read a 21436587-endian double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_double21436587_list(reference: int, quantity: int) List[float]
Read a list of 21436587-endian doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_double78563412(reference: int) float
Read a 78563412-endian double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_double78563412_list(reference: int, quantity: int) List[float]
Read a list of 78563412-endian doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_flag(reference: int) bool
Read a bit from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_holding_register_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_holding_register_float2143(reference: int) float
Read a 2143-endian float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_float2143_list(reference: int, quantity: int) List[float]
Read a list of 2143-endian floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_float3412(reference: int) float
Read a 3412-endian float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_float3412_list(reference: int, quantity: int) List[float]
Read a list of 3412-endian floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_ldouble(reference: int) float
Read a double from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_ldouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_lfloat(reference: int) float
Read a float from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_holding_register_lfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_holding_register_nibble(reference: int) int
Read a nibble from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint16(reference: int) int
Read a signed 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint32(reference: int) int
Read a signed 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint64(reference: int) int
Read a signed 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sbint8(reference: int) int
Read a signed 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sbint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint2143(reference: int) int
Read a signed 2143-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint21436587(reference: int) int
Read a signed 21436587-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint21436587_list(reference: int, quantity: int) List[int]
Read a list of signed 21436587-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint2143_list(reference: int, quantity: int) List[int]
Read a list of signed 2143-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint3412(reference: int) int
Read a signed 3412-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint3412_list(reference: int, quantity: int) List[int]
Read a list of signed 3412-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_sint78563412(reference: int) int
Read a signed 78563412-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_sint78563412_list(reference: int, quantity: int) List[int]
Read a list of signed 78563412-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint16(reference: int) int
Read a signed 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint32(reference: int) int
Read a signed 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint64(reference: int) int
Read a signed 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_slint8(reference: int) int
Read a signed 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_slint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_string(reference: int, length: int) bytes
Read a string from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
bytes value read from
reference
- read_holding_register_string_list(reference: int, quantity: int, length: int) List[bytes]
Read a list of strings from holding register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of bytes values read from
reference
- read_holding_register_ubint16(reference: int) int
Read an unsigned 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint32(reference: int) int
Read an unsigned 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint64(reference: int) int
Read an unsigned 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ubint8(reference: int) int
Read an unsigned 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ubint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint2143(reference: int) int
Read an unsigned 2143-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint21436587(reference: int) int
Read an unsigned 21436587-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint21436587_list(reference: int, quantity: int) List[int]
Read a list of unsigned 21436587-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint2143_list(reference: int, quantity: int) List[int]
Read a list of unsigned 2143-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint3412(reference: int) int
Read an unsigned 3412-endian 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint3412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 3412-endian 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_uint78563412(reference: int) int
Read an unsigned 78563412-endian 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_uint78563412_list(reference: int, quantity: int) List[int]
Read a list of unsigned 78563412-endian 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint16(reference: int) int
Read an unsigned 16-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint32(reference: int) int
Read an unsigned 32-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint64(reference: int) int
Read an unsigned 64-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_holding_register_ulint8(reference: int) int
Read an unsigned 8-bit integer from holding register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_holding_register_ulint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from holding register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register(reference: int) int
Read a single input register using Modbus function code 4.
- Parameters:
reference – the register reference.
- Returns:
the input register value
- read_input_register_bdouble(reference: int) float
Read a double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_bdouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_bfloat(reference: int) float
Read a float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_bfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_bitfield(reference: int, length: int) int
Read a bitfield from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
int value read from
reference
- read_input_register_bitfield_list(reference: int, quantity: int, length: int) List[int]
Read a list of bitfields from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_data(reference: int, data: ByteStruct | ByteType | Type[ByteStruct] | Type[ByteType]) ByteStruct | ByteType
Read data from input registers using Modbus function code 4.
- Parameters:
reference – the register reference
data – the type or instance or the decoder for the data
- Returns:
instance of
datatype
containing the read data
- read_input_register_double21436587(reference: int) float
Read a 21436587-endian double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_double21436587_list(reference: int, quantity: int) List[float]
Read a list of 21436587-endian doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_double78563412(reference: int) float
Read a 78563412-endian double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_double78563412_list(reference: int, quantity: int) List[float]
Read a list of 78563412-endian doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_flag(reference: int) bool
Read a bit from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
bool value read from
reference
- read_input_register_flag_list(reference: int, quantity: int) List[bool]
Read a list of bits from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of bool values read from
reference
- read_input_register_float2143(reference: int) float
Read a 2143-endian float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_float2143_list(reference: int, quantity: int) List[float]
Read a list of 2143-endian floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_float3412(reference: int) float
Read a 3412-endian float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_float3412_list(reference: int, quantity: int) List[float]
Read a list of 3412-endian floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_ldouble(reference: int) float
Read a double from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_ldouble_list(reference: int, quantity: int) List[float]
Read a list of doubles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_lfloat(reference: int) float
Read a float from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
float value read from
reference
- read_input_register_lfloat_list(reference: int, quantity: int) List[float]
Read a list of floats from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of float values read from
reference
- read_input_register_nibble(reference: int) int
Read a nibble from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_nibble_list(reference: int, quantity: int) List[int]
Read a list of nibbles from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint16(reference: int) int
Read a signed 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint32(reference: int) int
Read a signed 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint64(reference: int) int
Read a signed 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sbint8(reference: int) int
Read a signed 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sbint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint2143(reference: int) int
Read a signed 2143-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint21436587(reference: int) int
Read a signed 21436587-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint21436587_list(reference: int, quantity: int) List[int]
Read a list of signed 21436587-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint2143_list(reference: int, quantity: int) List[int]
Read a list of signed 2143-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint3412(reference: int) int
Read a signed 3412-endian 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint3412_list(reference: int, quantity: int) List[int]
Read a list of signed 3412-endian 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_sint78563412(reference: int) int
Read a signed 78563412-endian 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_sint78563412_list(reference: int, quantity: int) List[int]
Read a list of signed 78563412-endian 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint16(reference: int) int
Read a signed 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint16_list(reference: int, quantity: int) List[int]
Read a list of signed 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint32(reference: int) int
Read a signed 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint32_list(reference: int, quantity: int) List[int]
Read a list of signed 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint64(reference: int) int
Read a signed 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint64_list(reference: int, quantity: int) List[int]
Read a list of signed 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_slint8(reference: int) int
Read a signed 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_slint8_list(reference: int, quantity: int) List[int]
Read a list of signed 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_string(reference: int, length: int) bytes
Read a string from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
- Returns:
bytes value read from
reference
- read_input_register_string_list(reference: int, quantity: int, length: int) List[bytes]
Read a list of strings from input register memory.
- Parameters:
reference – the reference to read from
length – the length of the value
quantity – the number of elements to read
- Returns:
list of bytes values read from
reference
- read_input_register_ubint16(reference: int) int
Read an unsigned 16-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint16_list(reference: int, quantity: int) List[int]
Read a list of unsigned 16-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint32(reference: int) int
Read an unsigned 32-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint32_list(reference: int, quantity: int) List[int]
Read a list of unsigned 32-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint64(reference: int) int
Read an unsigned 64-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint64_list(reference: int, quantity: int) List[int]
Read a list of unsigned 64-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference
- read_input_register_ubint8(reference: int) int
Read an unsigned 8-bit integer from input register memory.
- Parameters:
reference – the reference to read from
- Returns:
int value read from
reference
- read_input_register_ubint8_list(reference: int, quantity: int) List[int]
Read a list of unsigned 8-bit integers from input register memory.
- Parameters:
reference – the reference to read from
quantity – the number of elements to read
- Returns:
list of int values read from
reference