summaryrefslogtreecommitdiff
path: root/kvmd/validators
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-08-28 17:01:35 +0300
committerDevaev Maxim <[email protected]>2020-08-30 19:08:49 +0300
commit9b14e8b3e2ce319e90703fddd3c470304f5dd4f5 (patch)
tree3d4de11727b061f01549c6380ba591ab6cf8d163 /kvmd/validators
parent7ce7a6d03526fb7c5d5acb8801e6340a6003ce6e (diff)
user gpio
Diffstat (limited to 'kvmd/validators')
-rw-r--r--kvmd/validators/hw.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/kvmd/validators/hw.py b/kvmd/validators/hw.py
index 82d1221a..e37eeda8 100644
--- a/kvmd/validators/hw.py
+++ b/kvmd/validators/hw.py
@@ -23,6 +23,7 @@
from typing import Any
from . import check_in_list
+from . import check_string_in_list
from . import check_re_match
from .basic import valid_number
@@ -43,6 +44,14 @@ def valid_gpio_pin_optional(arg: Any) -> int:
return int(valid_number(arg, min=-1, name="optional GPIO pin"))
+def valid_gpio_mode(arg: Any) -> str:
+ return check_string_in_list(arg, "GPIO mode", ["input", "output"])
+
+
+def valid_gpio_channel(arg: Any) -> str:
+ return check_re_match(arg, "GPIO channel", r"^[a-zA-Z_][a-zA-Z0-9_-]*$")[:255]
+
+
def valid_otg_gadget(arg: Any) -> str:
return check_re_match(arg, "OTG gadget name", r"^[a-z_][a-z0-9_-]*$")[:255]