Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify handle_local_echo. #1674

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ async def async_execute(self, request=None):
"""Execute requests asynchronously."""
request.transaction_id = self.transaction.getNextTID()
packet = self.framer.buildPacket(request)
Log.debug("send: {}", packet, ":hex")
self.transport_send(packet)
req = self._build_response(request.transaction_id)
if self.params.broadcast_enable and not request.slave_id:
Expand Down Expand Up @@ -217,7 +216,6 @@ def callback_data(self, data: bytes, addr: tuple = None) -> int:

returns number of bytes consumed
"""
Log.debug("recv: {} addr={}", data, ":hex", addr)
self.framer.processIncomingPacket(data, self._handle_response, slave=0)
return len(data)

Expand Down
11 changes: 3 additions & 8 deletions pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,15 @@ def data_received(self, data: bytes):

:param data: non-empty bytes object with incoming data.
"""
Log.debug("recv: {}", data, ":hex")
if self.comm_params.handle_local_echo and self.sent_buffer == data:
self.sent_buffer = b""
return
self.recv_buffer += data
cut = self.callback_data(self.recv_buffer)
self.recv_buffer = self.recv_buffer[cut:]
self.datagram_received(data, None)

def datagram_received(self, data: bytes, addr: tuple):
"""Receive datagram (UDP connections)."""
Log.debug("recv: {} addr={}", data, ":hex", addr)
if self.comm_params.handle_local_echo and self.sent_buffer == data:
Log.debug("recv skipping (local_echo): {} addr={}", data, ":hex", addr)
self.sent_buffer = b""
return
Log.debug("recv: {} addr={}", data, ":hex", addr)
self.recv_buffer += data
cut = self.callback_data(self.recv_buffer, addr=addr)
self.recv_buffer = self.recv_buffer[cut:]
Expand Down