Skip to content

Commit

Permalink
Fix client modbus function calls in remote by adding count as keyword…
Browse files Browse the repository at this point in the history
… argument (#2563)

Co-authored-by: phsete <[email protected]>
  • Loading branch information
2 people authored and janiversen committed Feb 7, 2025
1 parent 2915715 commit f9f0299
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pymodbus/datastore/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ def __build_mapping(self):
params["slave"] = self.slave
self.__get_callbacks = {
"d": lambda a, c: self._client.read_discrete_inputs(
a, c, **params
a, count=c, **params
),
"c": lambda a, c: self._client.read_coils(
a, c, **params
a, count=c, **params
),
"h": lambda a, c: self._client.read_holding_registers(
a, c, **params
a, count=c, **params
),
"i": lambda a, c: self._client.read_input_registers(
a, c, **params
a, count=c, **params
),
}
self.__set_callbacks = {
Expand Down
8 changes: 5 additions & 3 deletions test/not_updated/test_remote_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def test_remote_slave_get_values(self):
"""Test getting values from a remote slave context."""
client = mock.MagicMock()
pdu = ReadCoilsResponse(bits=[True] * 10)
client.read_coils = lambda a, b: pdu
client.read_input_registers = lambda a, b: ReadInputRegistersResponse(registers=[10] * 10)
client.read_holding_registers = lambda a, b: ExceptionResponse(0x15)
read_input_reg_res = ReadInputRegistersResponse(registers=[10] * 10)
exception_response = ExceptionResponse(0x15)
client.read_coils = lambda a, count=1: pdu
client.read_input_registers = lambda a, count=1: read_input_reg_res
client.read_holding_registers = lambda a, count=1: exception_response

context = RemoteSlaveContext(client)
context.validate(1, 0, 10)
Expand Down

0 comments on commit f9f0299

Please sign in to comment.