Describe the bug
When the trigger adapter is running and loses communication with the trigger box, exceptions occur in the Modbus TCP client but are not caught by the trigger controller. The exceptions surface in the Tornado event loop:
causing a traceback. This occurs on each background update:
Connection to (192.168.0.160, 502) failed: timed out
[E 260513 07:47:35 ioloop:949] Exception in callback <bound method TriggerController._get_all_registers of <livex.trigger.controller.TriggerController object at 0x10aa22e40>>
Traceback (most recent call last):
File "~/.virtualenvs/livex-3.14/lib/python3.14/site-packages/tornado/ioloop.py", line 945, in _run
val = self.callback()
File "~/develop/projects/livex/livex/control/src/livex/trigger/controller.py", line 136, in _get_all_registers
trigger._get_parameters()
~~~~~~~~~~~~~~~~~~~~~~~^^
File "~/develop/projects/livex/livex/control/src/livex/trigger/trigger.py", line 36, in _get_parameters
self.running = read_coil(self.client, self.addr['running_coil'])
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/develop/projects/livex/livex/control/src/livex/util.py", line 21, in read_coil
response = client.read_coils(address, count=1, slave=1)
File "~/.virtualenvs/livex-3.14/lib/python3.14/site-packages/pymodbus/client/mixin.py", line 72, in read_coils
return self.execute(pdu_bit_read.ReadCoilsRequest(address, count, slave=slave))
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/.virtualenvs/livex-3.14/lib/python3.14/site-packages/pymodbus/client/base.py", line 236, in execute
raise ConnectionException(f"Failed to connect[{self!s}]")
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient 192.168.0.160:502]
To Reproduce
Steps to reproduce the behavior:
- Run the trigger adapter in odin-control
- Disconnect the trigger box (power off or network disconnect)
- See the error and traceback in the odin-control output / log
Expected behavior
The exceptions should be handled cleanly in the controller code, report connection loss and manage state accordingly
Describe the bug
When the trigger adapter is running and loses communication with the trigger box, exceptions occur in the Modbus TCP client but are not caught by the trigger controller. The exceptions surface in the Tornado event loop:
causing a traceback. This occurs on each background update:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The exceptions should be handled cleanly in the controller code, report connection loss and manage state accordingly