Renamed all occurrences of 'picontrol' to 'PiControl' in the D-Bus interface definitions, method calls, and test cases for consistency and adherence to naming conventions. This ensures uniformity across the codebase and resolves potential naming-related issues.
52 lines
1.5 KiB
Python
52 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, picontrol_device: str, config_rsc: str):
|
|
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
|