mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
configurable gpio devices
This commit is contained in:
@@ -62,6 +62,7 @@ from .drive import DeviceInfo
|
||||
class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
def __init__( # pylint: disable=super-init-not-called
|
||||
self,
|
||||
gpio_device_path: str,
|
||||
target_pin: int,
|
||||
reset_pin: int,
|
||||
|
||||
@@ -75,7 +76,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
self.__init_delay = init_delay
|
||||
self.__init_retries = init_retries
|
||||
|
||||
self.__gpio = Gpio(target_pin, reset_pin, reset_delay)
|
||||
self.__gpio = Gpio(gpio_device_path, target_pin, reset_pin, reset_delay)
|
||||
|
||||
self.__device_info: Optional[DeviceInfo] = None
|
||||
self.__connected = False
|
||||
@@ -97,8 +98,9 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
return {
|
||||
"target_pin": Option(-1, type=valid_gpio_pin),
|
||||
"reset_pin": Option(-1, type=valid_gpio_pin),
|
||||
"gpio_device": Option("/dev/gpiochip0", type=valid_abs_path, unpack_as="gpio_device_path"),
|
||||
"target_pin": Option(-1, type=valid_gpio_pin),
|
||||
"reset_pin": Option(-1, type=valid_gpio_pin),
|
||||
|
||||
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
||||
"init_delay": Option(1.0, type=valid_float_f01),
|
||||
|
||||
@@ -24,7 +24,6 @@ from typing import Optional
|
||||
|
||||
import gpiod
|
||||
|
||||
from .... import env
|
||||
from .... import aiogp
|
||||
|
||||
|
||||
@@ -32,11 +31,13 @@ from .... import aiogp
|
||||
class Gpio:
|
||||
def __init__(
|
||||
self,
|
||||
device_path: str,
|
||||
target_pin: int,
|
||||
reset_pin: int,
|
||||
reset_delay: float,
|
||||
) -> None:
|
||||
|
||||
self.__device_path = device_path
|
||||
self.__target_pin = target_pin
|
||||
self.__reset_pin = reset_pin
|
||||
self.__reset_delay = reset_delay
|
||||
@@ -50,7 +51,7 @@ class Gpio:
|
||||
assert self.__target_line is None
|
||||
assert self.__reset_line is None
|
||||
|
||||
self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH)
|
||||
self.__chip = gpiod.Chip(self.__device_path)
|
||||
|
||||
self.__target_line = self.__chip.get_line(self.__target_pin)
|
||||
self.__target_line.request("kvmd::msd::target", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
|
||||
|
||||
Reference in New Issue
Block a user