Skip to content

Commit f9f0299

Browse files
hoesentoetphsete
authored andcommitted
Fix client modbus function calls in remote by adding count as keyword argument (#2563)
Co-authored-by: phsete <philteb@gmx.de>
1 parent 2915715 commit f9f0299

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pymodbus/datastore/remote.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ def __build_mapping(self):
7474
params["slave"] = self.slave
7575
self.__get_callbacks = {
7676
"d": lambda a, c: self._client.read_discrete_inputs(
77-
a, c, **params
77+
a, count=c, **params
7878
),
7979
"c": lambda a, c: self._client.read_coils(
80-
a, c, **params
80+
a, count=c, **params
8181
),
8282
"h": lambda a, c: self._client.read_holding_registers(
83-
a, c, **params
83+
a, count=c, **params
8484
),
8585
"i": lambda a, c: self._client.read_input_registers(
86-
a, c, **params
86+
a, count=c, **params
8787
),
8888
}
8989
self.__set_callbacks = {

test/not_updated/test_remote_datastore.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ def test_remote_slave_get_values(self):
5050
"""Test getting values from a remote slave context."""
5151
client = mock.MagicMock()
5252
pdu = ReadCoilsResponse(bits=[True] * 10)
53-
client.read_coils = lambda a, b: pdu
54-
client.read_input_registers = lambda a, b: ReadInputRegistersResponse(registers=[10] * 10)
55-
client.read_holding_registers = lambda a, b: ExceptionResponse(0x15)
53+
read_input_reg_res = ReadInputRegistersResponse(registers=[10] * 10)
54+
exception_response = ExceptionResponse(0x15)
55+
client.read_coils = lambda a, count=1: pdu
56+
client.read_input_registers = lambda a, count=1: read_input_reg_res
57+
client.read_holding_registers = lambda a, count=1: exception_response
5658

5759
context = RemoteSlaveContext(client)
5860
context.validate(1, 0, 10)

0 commit comments

Comments
 (0)