Skip to content

Commit

Permalink
Improve logging in Modbus class
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jan 7, 2025
1 parent 1d58c35 commit 6736536
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/lvmecp/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ async def write(self, value: int | bool):
)
else:
self.modbus.register_cache[self.name] = value
log.debug(
f"Written value {value} to register {self.name!r} "
f"({self.mode}-{self.address})."
)


class Modbus(dict[str, ModbusRegister]):
Expand Down Expand Up @@ -261,7 +265,6 @@ async def connect(self):
raise RuntimeError("Timed out waiting for lock to be released.")

hp = f"{self.host}:{self.port}"
log.debug(f"Trying to connect to modbus server on {hp}")

did_connect: bool = False

Expand All @@ -276,8 +279,6 @@ async def connect(self):
if not did_connect and self.lock.locked():
self.lock.release()

log.debug(f"Connected to {hp}.")

# Schedule a task to release the lock after 5 seconds. This is a safeguard
# in case something fails and the connection is never closed and the lock
# not released.
Expand All @@ -289,7 +290,6 @@ async def disconnect(self):
try:
if self.client:
self.client.close()
log.debug(f"Disonnected from {self.host}:{self.port}.")

finally:
if self.lock.locked():
Expand Down

0 comments on commit 6736536

Please sign in to comment.