Skip to content

Commit 2e0cf9c

Browse files
authored
Cancel send if no connection. (#2103)
1 parent b3883ce commit 2e0cf9c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pymodbus/transport/transport.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ def send(self, data: bytes, addr: tuple | None = None) -> None:
379379
:param data: non-empty bytes object with data to send.
380380
:param addr: optional addr, only used for UDP server.
381381
"""
382+
if not self.transport:
383+
Log.error("Cancel send, because not connected!")
384+
return
382385
Log.debug("send: {}", data, ":hex")
383386
if self.comm_params.handle_local_echo:
384387
self.sent_buffer += data

0 commit comments

Comments
 (0)