diff --git a/examples/client_async_calls.py b/examples/client_async_calls.py index bf4d66b43..6456006f5 100755 --- a/examples/client_async_calls.py +++ b/examples/client_async_calls.py @@ -137,6 +137,11 @@ async def async_handle_holding_registers(client): assert not rr.isError() # test that call was OK assert rr.registers == [10] * 8 + await client.write_registers(1, [10], slave=SLAVE) + rr = await client.read_holding_registers(1, 1, slave=SLAVE) + assert not rr.isError() # test that call was OK + assert rr.registers == [10] + _logger.info("### write read holding registers") arguments = { "read_address": 1, diff --git a/pymodbus/client/mixin.py b/pymodbus/client/mixin.py index e7e5c137b..45f563a0c 100644 --- a/pymodbus/client/mixin.py +++ b/pymodbus/client/mixin.py @@ -322,11 +322,11 @@ def write_coils( ) def write_registers( - self, address: int, values: list[int] | int, slave: int = 1, skip_encode: bool = False) -> T: + self, address: int, values: list[int], slave: int = 1, skip_encode: bool = False) -> T: """Write registers (code 0x10). :param address: Start address to write to - :param values: List of values to write, or a single value to write + :param values: List of values to write :param slave: (optional) Modbus slave ID :param skip_encode: (optional) do not encode values :raises ModbusException: diff --git a/test/sub_function_codes/test_register_write_messages.py b/test/sub_function_codes/test_register_write_messages.py index 1ec6f4202..8d702fb77 100644 --- a/test/sub_function_codes/test_register_write_messages.py +++ b/test/sub_function_codes/test_register_write_messages.py @@ -122,6 +122,10 @@ async def test_write_multiple_register_request(self): result = await request.execute(context) assert result.function_code == request.function_code + request = WriteMultipleRegistersRequest(0x00, [0x00]) + result = await request.execute(context) + assert result.function_code == request.function_code + # -----------------------------------------------------------------------# # Mask Write Register Request # -----------------------------------------------------------------------#