Skip to content

Commit 90f9169

Browse files
authored
Revert "Recall socket recv until get a complete response. (#143)" (#178)
This reverts commit 661c816.
1 parent 661c816 commit 90f9169

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

pymodbus/transaction.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _set_adu_size(self):
6868

6969
def _calculate_response_length(self, expected_pdu_size):
7070
if self.base_adu_size == -1:
71-
return None
71+
return 1024
7272
else:
7373
return self.base_adu_size + expected_pdu_size
7474

@@ -79,26 +79,21 @@ def execute(self, request):
7979
retries = self.retries
8080
request.transaction_id = self.getNextTID()
8181
_logger.debug("Running transaction %d" % request.transaction_id)
82-
83-
expected_response_length = None
8482
if hasattr(request, "get_response_pdu_size"):
8583
response_pdu_size = request.get_response_pdu_size()
86-
if response_pdu_size:
87-
expected_response_length = self._calculate_response_length(response_pdu_size)
84+
expected_response_length = self._calculate_response_length(response_pdu_size)
85+
else:
86+
expected_response_length = 1024
8887

8988
while retries > 0:
9089
try:
9190
self.client.connect()
9291
self.client._send(self.client.framer.buildPacket(request))
93-
94-
result = self.client._recv(expected_response_length or 1024)
95-
while result and expected_response_length and len(result) < expected_response_length:
96-
result += self.client._recv(expected_response_length - len(result))
92+
result = self.client._recv(expected_response_length)
9793

9894
if not result and self.retry_on_empty:
9995
retries -= 1
10096
continue
101-
10297
if _logger.isEnabledFor(logging.DEBUG):
10398
_logger.debug("recv: " + " ".join([hex(byte2int(x)) for x in result]))
10499
self.client.framer.processIncomingPacket(result, self.addTransaction)

0 commit comments

Comments
 (0)