summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-09-08 05:43:36 +0300
committerMaxim Devaev <[email protected]>2021-09-08 05:43:36 +0300
commit98ad1145a8782d3b82516dd9f81c86d9e80391c5 (patch)
treeb8f348f0815e8ee72236bf9879af779c95727755 /kvmd/apps
parent939c63fe7daf2ddc9a05c9e0fbeab63cb5c6f0c1 (diff)
string pins
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/__init__.py14
-rw-r--r--kvmd/apps/kvmd/ugpio.py4
2 files changed, 9 insertions, 9 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index facf9c27..c808b6d4 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -30,7 +30,7 @@ import logging.config
from typing import Tuple
from typing import List
from typing import Dict
-from typing import Set
+from typing import Type
from typing import Optional
import pygments
@@ -48,6 +48,7 @@ from ..plugins.atx import get_atx_class
from ..plugins.msd import get_msd_class
from ..plugins.ugpio import UserGpioModes
+from ..plugins.ugpio import BaseUserGpioDriver
from ..plugins.ugpio import get_ugpio_driver_class
from ..yamlconf import ConfigError
@@ -100,7 +101,6 @@ from ..validators.ugpio import valid_ugpio_mode
from ..validators.ugpio import valid_ugpio_view_table
from ..validators.hw import valid_tty_speed
-from ..validators.hw import valid_gpio_pin
from ..validators.hw import valid_otg_gadget
from ..validators.hw import valid_otg_id
from ..validators.hw import valid_otg_ethernet
@@ -267,7 +267,7 @@ def _patch_dynamic( # pylint: disable=too-many-locals
if load_gpio:
driver: str
- drivers: Dict[str, Set[str]] = {} # Name to modes
+ drivers: Dict[str, Type[BaseUserGpioDriver]] = {} # Name to drivers
for (driver, params) in { # type: ignore
"__gpio__": {},
**tools.rget(raw_config, "kvmd", "gpio", "drivers"),
@@ -277,7 +277,7 @@ def _patch_dynamic( # pylint: disable=too-many-locals
driver_type = valid_stripped_string_not_empty(params.get("type", "gpio"))
driver_class = get_ugpio_driver_class(driver_type)
- drivers[driver] = driver_class.get_modes()
+ drivers[driver] = driver_class
scheme["kvmd"]["gpio"]["drivers"][driver] = {
"type": Option(driver_type, type=valid_stripped_string_not_empty),
**driver_class.get_plugin_options()
@@ -294,12 +294,12 @@ def _patch_dynamic( # pylint: disable=too-many-locals
mode: str = params.get("mode", "")
with manual_validated(mode, *path, channel, "mode"):
- mode = valid_ugpio_mode(mode, drivers[driver])
+ mode = valid_ugpio_mode(mode, drivers[driver].get_modes())
scheme["kvmd"]["gpio"]["scheme"][channel] = {
"driver": Option("__gpio__", type=functools.partial(valid_ugpio_driver, variants=set(drivers))),
- "pin": Option(-1, type=valid_gpio_pin),
- "mode": Option("", type=functools.partial(valid_ugpio_mode, variants=drivers[driver])),
+ "pin": Option(None, type=drivers[driver].get_pin_validator()),
+ "mode": Option("", type=functools.partial(valid_ugpio_mode, variants=drivers[driver].get_modes())),
"inverted": Option(False, type=valid_bool),
**({
"busy_delay": Option(0.2, type=valid_float_f01),
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py
index ca04b31f..78d7f4f7 100644
--- a/kvmd/apps/kvmd/ugpio.py
+++ b/kvmd/apps/kvmd/ugpio.py
@@ -77,7 +77,7 @@ class _GpioInput:
) -> None:
self.__channel = channel
- self.__pin: int = config.pin
+ self.__pin: str = config.pin
self.__inverted: bool = config.inverted
self.__driver = driver
@@ -118,7 +118,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
) -> None:
self.__channel = channel
- self.__pin: int = config.pin
+ self.__pin: str = config.pin
self.__inverted: bool = config.inverted
self.__switch: bool = config.switch