diff options
Diffstat (limited to 'kvmd/plugins/hid/_mcu')
-rw-r--r-- | kvmd/plugins/hid/_mcu/__init__.py | 5 | ||||
-rw-r--r-- | kvmd/plugins/hid/_mcu/gpio.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py index 45302ba1..4846b90b 100644 --- a/kvmd/plugins/hid/_mcu/__init__.py +++ b/kvmd/plugins/hid/_mcu/__init__.py @@ -46,6 +46,7 @@ from ....validators.basic import valid_bool from ....validators.basic import valid_int_f0 from ....validators.basic import valid_int_f1 from ....validators.basic import valid_float_f01 +from ....validators.os import valid_abs_path from ....validators.hw import valid_gpio_pin_optional from .. import BaseHid @@ -113,6 +114,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- self, phy: BasePhy, + gpio_device_path: str, reset_pin: int, reset_inverted: bool, reset_delay: float, @@ -133,7 +135,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- self.__noop = noop self.__phy = phy - self.__gpio = Gpio(reset_pin, reset_inverted, reset_delay) + self.__gpio = Gpio(gpio_device_path, reset_pin, reset_inverted, reset_delay) self.__events_queue: "multiprocessing.Queue[BaseEvent]" = multiprocessing.Queue() @@ -149,6 +151,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- @classmethod def get_plugin_options(cls) -> Dict: return { + "gpio_device": Option("/dev/gpiochip0", type=valid_abs_path, unpack_as="gpio_device_path"), "reset_pin": Option(-1, type=valid_gpio_pin_optional), "reset_inverted": Option(False, type=valid_bool), "reset_delay": Option(0.1, type=valid_float_f01), diff --git a/kvmd/plugins/hid/_mcu/gpio.py b/kvmd/plugins/hid/_mcu/gpio.py index 0fb4dfd0..f52bf854 100644 --- a/kvmd/plugins/hid/_mcu/gpio.py +++ b/kvmd/plugins/hid/_mcu/gpio.py @@ -30,18 +30,18 @@ import gpiod from ....logging import get_logger -from .... import env - # ===== class Gpio: def __init__( self, + device_path: str, reset_pin: int, reset_inverted: bool, reset_delay: float, ) -> None: + self.__device_path = device_path self.__reset_pin = reset_pin self.__reset_inverted = reset_inverted self.__reset_delay = reset_delay @@ -53,7 +53,7 @@ class Gpio: if self.__reset_pin >= 0: assert self.__chip is None assert self.__reset_line is None - self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH) + self.__chip = gpiod.Chip(self.__device_path) self.__reset_line = self.__chip.get_line(self.__reset_pin) self.__reset_line.request("kvmd::hid::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(self.__reset_inverted)]) |