Updated `InterfaceRevpiConfig` to require a bus parameter, ensuring proper initialization. Introduced a constructor in `DbusInterface` to store the bus instance. Signed-off-by: Sven Sager <s.sager@kunbus.com>
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
"""D-Bus interfaces for piControl."""
|
|
from logging import getLogger
|
|
|
|
from pydbus.generic import signal
|
|
|
|
from .process_image_helper import PiControlIoctl, ResetDriverWatchdog
|
|
from ..dbus_helper import DbusInterface
|
|
|
|
log = getLogger(__name__)
|
|
|
|
|
|
class InterfacePiControl(DbusInterface):
|
|
"""
|
|
<node>
|
|
<interface name='com.revolutionpi.middleware1.PiControl'>
|
|
<signal name="NotifyDriverReset">
|
|
</signal>
|
|
<method name='ResetDriver'>
|
|
</method>
|
|
</interface>
|
|
</node>
|
|
"""
|
|
|
|
NotifyDriverReset = signal()
|
|
|
|
def __init__(self, bus, picontrol_device: str, config_rsc: str):
|
|
super().__init__(bus)
|
|
|
|
self.picontrol_device = picontrol_device
|
|
self.config_rsc = config_rsc
|
|
|
|
self.wd_reset_driver = ResetDriverWatchdog(self.picontrol_device)
|
|
self.wd_reset_driver.register_call(self.notify_reset_driver)
|
|
|
|
def cleanup(self):
|
|
self.wd_reset_driver.stop()
|
|
|
|
def notify_reset_driver(self):
|
|
self.NotifyDriverReset()
|
|
|
|
def ResetDriver(self):
|
|
log.debug("enter InterfacePiControl.ResetDriver")
|
|
|
|
try:
|
|
picontrol_ioctl = PiControlIoctl(self.picontrol_device)
|
|
picontrol_ioctl.ioctl(PiControlIoctl.IOCTL_RESET_DRIVER)
|
|
log.info("reset piControl driver")
|
|
except Exception as e:
|
|
log.warning(f"could not reset piControl driver: ${e}")
|
|
raise e
|