Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pymodbus/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _calculate_exception_length(self):
return self.base_adu_size + 2 # Fcode(1), ExceptionCode(1)
return None

def _validate_response(self, request, response, exp_resp_len):
def _validate_response(self, request, response, exp_resp_len, is_udp=False):
"""Validate Incoming response against request.

:param request: Request sent
Expand All @@ -118,7 +118,7 @@ def _validate_response(self, request, response, exp_resp_len):
):
return False

if "length" in mbap and exp_resp_len:
if "length" in mbap and exp_resp_len and not is_udp:
return mbap.get("length") == exp_resp_len
return True

Expand Down Expand Up @@ -161,7 +161,9 @@ def execute(self, request): # noqa: C901
else:
full = False
c_str = str(self.client)
is_udp = False
if "modbusudpclient" in c_str.lower().strip():
is_udp = True
full = True
if not expected_response_length:
expected_response_length = 1024
Expand All @@ -173,7 +175,8 @@ def execute(self, request): # noqa: C901
)
while retries > 0:
valid_response = self._validate_response(
request, response, expected_response_length
request, response, expected_response_length,
is_udp=is_udp
)
if valid_response:
if (
Expand Down