Skip to content

Commit ad94519

Browse files
authored
#221 tcp read complete frame based on length field in the mbap header (#251)
1 parent 829cddc commit ad94519

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pymodbus/transaction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def _recv(self, expected_response_length):
169169
expected_response_length = self._calculate_exception_length()
170170
continue
171171
if isinstance(self.client.framer, ModbusSocketFramer):
172-
break
172+
length = struct.unpack(">H", result[4:6])[0] -1 # Ommit UID, which is included in header size
173+
expected_response_length = self.client.framer._ModbusSocketFramer__hsize + length
174+
173175
r = self.client._recv(expected_response_length - len(result))
174176
if not r:
175177
# If no response being recived there is no point in conitnuing

0 commit comments

Comments
 (0)