Skip to content

Commit

Permalink
Cancel send if no connection. (#2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Mar 8, 2024
1 parent b3883ce commit 2e0cf9c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ def send(self, data: bytes, addr: tuple | None = None) -> None:
:param data: non-empty bytes object with data to send.
:param addr: optional addr, only used for UDP server.
"""
if not self.transport:
Log.error("Cancel send, because not connected!")
return
Log.debug("send: {}", data, ":hex")
if self.comm_params.handle_local_echo:
self.sent_buffer += data
Expand Down

0 comments on commit 2e0cf9c

Please sign in to comment.