Skip to content

Commit

Permalink
Reset receive buffer with send(). (#2343)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Sep 28, 2024
1 parent a6abdab commit a4cf640
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def send(self, data: bytes, addr: tuple | None = None) -> None:
Log.error("Cancel send, because not connected!")
return
Log.debug("send: {}", data, ":hex")
self.recv_buffer = b""
if self.comm_params.handle_local_echo:
self.sent_buffer += data
if self.comm_params.comm_type == CommType.UDP:
Expand Down
2 changes: 1 addition & 1 deletion test/transport/test_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ async def test_connected_multiple(self, client, server, use_port):

client2.send(test_data)
await asyncio.sleep(0.5)
assert server2_connected.recv_buffer == test2_data + test_data
assert server2_connected.recv_buffer == test_data
client2.close()
server.close()
await asyncio.sleep(0.5)
Expand Down

0 comments on commit a4cf640

Please sign in to comment.