From 303f04abafd7252a1d776b6820ac47026469d898 Mon Sep 17 00:00:00 2001 From: MAKOMO Date: Fri, 20 Sep 2024 09:01:34 +0200 Subject: [PATCH 1/3] change semantic of connected property to just check if socket exists without calling connect --- pymodbus/client/serial.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymodbus/client/serial.py b/pymodbus/client/serial.py index c48e9f43b..5ed564a52 100644 --- a/pymodbus/client/serial.py +++ b/pymodbus/client/serial.py @@ -208,9 +208,9 @@ def __init__( # pylint: disable=too-many-arguments self.silent_interval = round(self.silent_interval, 6) @property - def connected(self): - """Connect internal.""" - return self.connect() + def connected(self) -> bool: + """Check if socket exists.""" + return self.socket is not None def connect(self) -> bool: """Connect to the modbus serial server.""" From b18ed43752a67c168b8a6a55eb8a3de7d19a5c76 Mon Sep 17 00:00:00 2001 From: MAKOMO Date: Fri, 20 Sep 2024 09:01:57 +0200 Subject: [PATCH 2/3] improve documentation of connected property --- pymodbus/client/tcp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymodbus/client/tcp.py b/pymodbus/client/tcp.py index ca40ae92a..96490d14b 100644 --- a/pymodbus/client/tcp.py +++ b/pymodbus/client/tcp.py @@ -160,7 +160,7 @@ def __init__( @property def connected(self) -> bool: - """Connect internal.""" + """Check if socket exists.""" return self.socket is not None def connect(self): From 73b01d2af2d220fb5095b210e63ce902a51b2530 Mon Sep 17 00:00:00 2001 From: MAKOMO Date: Fri, 20 Sep 2024 09:17:36 +0200 Subject: [PATCH 3/3] remove whitespaces --- pymodbus/client/serial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymodbus/client/serial.py b/pymodbus/client/serial.py index 5ed564a52..967c89c15 100644 --- a/pymodbus/client/serial.py +++ b/pymodbus/client/serial.py @@ -210,7 +210,7 @@ def __init__( # pylint: disable=too-many-arguments @property def connected(self) -> bool: """Check if socket exists.""" - return self.socket is not None + return self.socket is not None def connect(self) -> bool: """Connect to the modbus serial server."""