From a45ac039cca3e9c870c5a5beeaf9b9bd8398f217 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Thu, 18 Jul 2024 20:06:20 +0200 Subject: [PATCH] remove kwargs PDU messagees. --- examples/client_async_calls.py | 2 +- examples/client_calls.py | 2 +- examples/client_custom_msg.py | 13 +++++++------ pymodbus/pdu/bit_read_message.py | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/client_async_calls.py b/examples/client_async_calls.py index 482a9ec406..bf4d66b431 100755 --- a/examples/client_async_calls.py +++ b/examples/client_async_calls.py @@ -137,7 +137,7 @@ async def async_handle_holding_registers(client): assert not rr.isError() # test that call was OK assert rr.registers == [10] * 8 - _logger.info("### write read holding registers, using **kwargs") + _logger.info("### write read holding registers") arguments = { "read_address": 1, "read_count": 8, diff --git a/examples/client_calls.py b/examples/client_calls.py index 50a58bc3d5..c1de95f933 100755 --- a/examples/client_calls.py +++ b/examples/client_calls.py @@ -138,7 +138,7 @@ def handle_holding_registers(client): assert not rr.isError() # test that call was OK assert rr.registers == [10] * 8 - _logger.info("### write read holding registers, using **kwargs") + _logger.info("### write read holding registers") arguments = { "read_address": 1, "read_count": 8, diff --git a/examples/client_custom_msg.py b/examples/client_custom_msg.py index e86f4793b5..6d4cc4588e 100755 --- a/examples/client_custom_msg.py +++ b/examples/client_custom_msg.py @@ -36,7 +36,7 @@ class CustomModbusResponse(ModbusResponse): function_code = 55 _rtu_byte_count_pos = 2 - def __init__(self, values=None, slave=0, transaction=0, protocol=0, skip_encode=False, **_kwargs): + def __init__(self, values=None, slave=0, transaction=0, protocol=0, skip_encode=False): """Initialize.""" ModbusResponse.__init__(self, slave, transaction, protocol, skip_encode) self.values = values or [] @@ -68,7 +68,7 @@ class CustomModbusRequest(ModbusRequest): function_code = 55 _rtu_frame_size = 8 - def __init__(self, address=None, slave=0, transaction=0, protocol=0, skip_encode=False, **_kwargs): + def __init__(self, address=None, slave=0, transaction=0, protocol=0, skip_encode=False): """Initialize.""" ModbusRequest.__init__(self, slave, transaction, protocol, skip_encode) self.address = address @@ -100,12 +100,12 @@ def execute(self, context): class Read16CoilsRequest(ReadCoilsRequest): """Read 16 coils in one request.""" - def __init__(self, address, **kwargs): + def __init__(self, address, count=None, slave=0, transaction=0, protocol=0, skip_encode=False): """Initialize a new instance. :param address: The address to start reading from """ - ReadCoilsRequest.__init__(self, address, 16, **kwargs) + ReadCoilsRequest.__init__(self, address, count=16, slave=slave, transaction=transaction, protocol=protocol, skip_encode=skip_encode) # --------------------------------------------------------------------------- # @@ -123,12 +123,13 @@ async def main(host="localhost", port=5020): # new modbus function code. client.register(CustomModbusResponse) - request = CustomModbusRequest(32, slave=1) + slave=1 + request = CustomModbusRequest(32, slave=slave) result = await client.execute(request) print(result) # inherited request - request = Read16CoilsRequest(32, slave=1) + request = Read16CoilsRequest(32, slave) result = await client.execute(request) print(result) diff --git a/pymodbus/pdu/bit_read_message.py b/pymodbus/pdu/bit_read_message.py index c7a54e679c..9ecfe2fc94 100644 --- a/pymodbus/pdu/bit_read_message.py +++ b/pymodbus/pdu/bit_read_message.py @@ -21,7 +21,7 @@ class ReadBitsRequestBase(ModbusRequest): _rtu_frame_size = 8 - def __init__(self, address, count, slave=0, transaction=0, protocol=0, skip_encode=False, **_kwargs): + def __init__(self, address, count, slave=0, transaction=0, protocol=0, skip_encode=False): """Initialize the read request data. :param address: The start address to read from @@ -75,7 +75,7 @@ class ReadBitsResponseBase(ModbusResponse): _rtu_byte_count_pos = 2 - def __init__(self, values, slave=0, transaction=0, protocol=0, skip_encode=False, **_kwargs): + def __init__(self, values, slave=0, transaction=0, protocol=0, skip_encode=False): """Initialize a new instance. :param values: The requested values to be returned