Skip to content

Commit 8905979

Browse files
authored
Do not filter using unit id in the received response (#1076)
processIncomingPacket() can be told to ignore unit ids other than the specified one or accept all packets by specifying id 0 or 0xff. The modbus client would extract the unit id from the incoming data packet and use that for filtering. At best this is a no-op: the incoming unit id will match itself. At worst it makes us drop responses: if the data is fragmented each fragment was incorrectly parsed to extract a unit id. Remove the incoming unit id check at this stage. This change is behavior preserving if the response is not fragmented and fixes riptideio#688 if it is fragmented.
1 parent 9304a92 commit 8905979

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pymodbus/client/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ def _data_received(self, data):
380380
"""Get response, check for valid message, decode result."""
381381
txt = f"recv: {hexlify_packets(data)}"
382382
_logger.debug(txt)
383-
unit = self.framer.decode_data(data).get("unit", 0)
384-
self.framer.processIncomingPacket(data, self._handle_response, unit=unit)
383+
self.framer.processIncomingPacket(data, self._handle_response, unit=0)
385384

386385
def _handle_response(self, reply, **kwargs): # pylint: disable=unused-argument
387386
"""Handle the processed response and link to correct deferred."""

0 commit comments

Comments
 (0)