summaryrefslogtreecommitdiff
path: root/kvmd/plugins/ugpio/hidrelay.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-10 09:31:05 +0300
committerDevaev Maxim <[email protected]>2020-09-10 09:31:05 +0300
commit9cb5582565aa2301a238ca382a32dc80106f6c15 (patch)
treeb0e06d9cb15c88f72a8a42e0c02a97a7b0965663 /kvmd/plugins/ugpio/hidrelay.py
parent967afb2d9a0f4a94026ec612801b6291db5c6a72 (diff)
only available gpio modes
Diffstat (limited to 'kvmd/plugins/ugpio/hidrelay.py')
-rw-r--r--kvmd/plugins/ugpio/hidrelay.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/kvmd/plugins/ugpio/hidrelay.py b/kvmd/plugins/ugpio/hidrelay.py
index 85d2f808..b7f88cb8 100644
--- a/kvmd/plugins/ugpio/hidrelay.py
+++ b/kvmd/plugins/ugpio/hidrelay.py
@@ -24,6 +24,7 @@ import asyncio
import contextlib
from typing import Dict
+from typing import Set
from typing import Optional
import hid
@@ -39,6 +40,7 @@ from ...validators.basic import valid_float_f01
from ...validators.os import valid_abs_path
from . import GpioDriverOfflineError
+from . import UserGpioModes
from . import BaseUserGpioDriver
@@ -73,8 +75,12 @@ class Plugin(BaseUserGpioDriver):
"state_poll": Option(5.0, type=valid_float_f01),
}
+ @classmethod
+ def get_modes(cls) -> Set[str]:
+ return set([UserGpioModes.OUTPUT])
+
def register_input(self, pin: int) -> None:
- _ = pin
+ raise RuntimeError(f"Unsupported mode 'input' for pin={pin} on {self}")
def register_output(self, pin: int, initial: Optional[bool]) -> None:
self.__initials[pin] = initial
@@ -153,7 +159,7 @@ class Plugin(BaseUserGpioDriver):
def __check_pin(self, pin: int) -> bool:
ok = (0 <= pin <= 7)
if not ok:
- get_logger(0).warning("Unsupported pin for %s on %s: %d", self, self.__device_path, pin)
+ get_logger(0).warning("Unsupported pin=%d for %s on %s", pin, self, self.__device_path)
return ok
@contextlib.contextmanager