diff --git a/src/revpi_middleware/dbus_middleware1/process_image/__init__.py b/src/revpi_middleware/dbus_middleware1/process_image/__init__.py new file mode 100644 index 0000000..73a9bdc --- /dev/null +++ b/src/revpi_middleware/dbus_middleware1/process_image/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: 2025 KUNBUS GmbH +# SPDX-License-Identifier: GPL-2.0-or-later +"""D-Bus interfaces for piControl driver.""" +from .interface_picontrol import InterfacePiControl diff --git a/src/revpi_middleware/dbus_middleware1/process_image/interface_picontrol.py b/src/revpi_middleware/dbus_middleware1/process_image/interface_picontrol.py new file mode 100644 index 0000000..ada732a --- /dev/null +++ b/src/revpi_middleware/dbus_middleware1/process_image/interface_picontrol.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: 2025 KUNBUS GmbH +# SPDX-License-Identifier: GPL-2.0-or-later +"""D-Bus interfaces for piControl.""" +import os +from fcntl import ioctl +from logging import getLogger + +from pydbus.generic import signal + +from ..interface_helper import ResetDriverWatchdog + +log = getLogger(__name__) + + +class InterfacePiControl: + """ + + + + + + + + + """ + + NotifyDriverReset = signal() + + def __init__(self): + self.pi_control = "/dev/piControl0" + + self.wd_reset_driver = ResetDriverWatchdog(self.pi_control) + self.wd_reset_driver.register_call(self.notify_reset_driver) + + def notify_reset_driver(self): + self.NotifyDriverReset() + + def ResetDriver(self): + log.debug("enter InterfacePiControl.ResetDriver") + + try: + fd = os.open(self.pi_control, os.O_WRONLY) + except Exception as e: + log.warning(f"could not open ${self.pi_control} to reset driver") + raise e + + execption = None + try: + # KB_RESET _IO('K', 12 ) // reset the piControl driver including the config file + ioctl(fd, 19212) + log.info("reset piControl driver") + except Exception as e: + log.warning(f"could not reset piControl driver: ${e}") + execption = e + finally: + os.close(fd) + + if execption: + raise execption