From 0a16ea982627dd23875adb6930cdfbc70aa2b3d8 Mon Sep 17 00:00:00 2001 From: Pascal Speck Date: Mon, 7 Aug 2023 13:19:17 +0200 Subject: [PATCH 1/2] bugfix local echo handling on sync clients --- pymodbus/transaction.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pymodbus/transaction.py b/pymodbus/transaction.py index 796ca95ed..a28d7c5a8 100644 --- a/pymodbus/transaction.py +++ b/pymodbus/transaction.py @@ -310,10 +310,7 @@ def _transact(self, packet, response_length, full=False, broadcast=False): 'to "WAITING FOR REPLY"' ) self.client.state = ModbusTransactionState.WAITING_FOR_REPLY - if ( - hasattr(self.client, "handle_local_echo") - and self.client.handle_local_echo is True - ): + if self.client.comm_params.handle_local_echo is True: if self._recv(size, full) != packet: return b"", "Wrong local echo" result = self._recv(response_length, full) From b6ed8835b4a467f504188ab7b3b24abfbe16c801 Mon Sep 17 00:00:00 2001 From: Pascal Speck Date: Mon, 7 Aug 2023 13:39:29 +0200 Subject: [PATCH 2/2] fix tests --- test/test_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_transaction.py b/test/test_transaction.py index abf0b01a6..2dfbcca8b 100755 --- a/test/test_transaction.py +++ b/test/test_transaction.py @@ -163,11 +163,11 @@ def test_execute(self, mock_time): trans._recv = mock.MagicMock( # pylint: disable=protected-access side_effect=iter([b"abcdef", b"deadbe", b"123456"]) ) - client.handle_local_echo = True + client.comm_params.handle_local_echo = True trans.retry_on_empty = False trans.retry_on_invalid = False assert trans.execute(request).message == "[Input/Output] Wrong local echo" - client.handle_local_echo = False + client.comm_params.handle_local_echo = False # retry on invalid response trans.retry_on_invalid = True