feat(process_image): Add D-Bus interface for piControl driver
Introduced D-Bus interfaces in `process_image` to interact with the piControl driver. Added `InterfacePiControl` class with methods to reset the driver and signal driver reset events. This improves driver management and integration via D-Bus.
This commit is contained in:
@@ -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
|
||||||
@@ -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:
|
||||||
|
"""
|
||||||
|
<node>
|
||||||
|
<interface name='com.revolutionpi.middleware1.picontrol'>
|
||||||
|
<signal name="NotifyDriverReset">
|
||||||
|
</signal>
|
||||||
|
<method name='ResetDriver'>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
"""
|
||||||
|
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user