Skip to content

Commit

Permalink
remove kwargs PDU messagees.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Jul 19, 2024
1 parent 18c839b commit 4a2755c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/client_async_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/client_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions examples/client_custom_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)


# --------------------------------------------------------------------------- #
Expand All @@ -126,12 +126,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)

Expand Down
4 changes: 2 additions & 2 deletions pymodbus/pdu/bit_read_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a2755c

Please sign in to comment.