summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-04-18 12:15:43 +0300
committerMaxim Devaev <[email protected]>2022-04-18 12:15:43 +0300
commite83764c501ee64a2ba513d071031b7d2320d7b10 (patch)
tree89a06a8534a6ced6e81286915072dbdcdceff477 /kvmd/apps
parentae4509f23425e7c7c2f36c5e4895fe57c6662e46 (diff)
optional serial number
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/__init__.py6
-rw-r--r--kvmd/apps/otg/__init__.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index 1fc801ae..6d7fa295 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -488,9 +488,9 @@ def _get_config_scheme() -> Dict:
"otg": {
"vendor_id": Option(0x1D6B, type=valid_otg_id), # Linux Foundation
"product_id": Option(0x0104, type=valid_otg_id), # Multifunction Composite Gadget
- "manufacturer": Option("PiKVM"),
- "product": Option("Composite KVM Device"),
- "serial": Option("CAFEBABE"),
+ "manufacturer": Option("PiKVM", type=valid_stripped_string),
+ "product": Option("Composite KVM Device", type=valid_stripped_string),
+ "serial": Option("CAFEBABE", type=valid_stripped_string, if_none=None),
"device_version": Option(-1, type=functools.partial(valid_number, min=-1, max=0xFFFF)),
"usb_version": Option(0x0200, type=valid_otg_id),
"max_power": Option(250, type=functools.partial(valid_number, min=50, max=500)),
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index 11058a7b..44b1bd84 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -195,7 +195,7 @@ class _GadgetConfig:
_write(join(self.__meta_path, f"{func}@meta.json"), json.dumps({"func": func, "name": name}))
-def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
+def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements,too-many-branches
# https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt
# https://www.isticktoit.net/?p=1383
@@ -231,7 +231,8 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_mkdir(lang_path)
_write(join(lang_path, "manufacturer"), config.otg.manufacturer)
_write(join(lang_path, "product"), config.otg.product)
- _write(join(lang_path, "serialnumber"), config.otg.serial)
+ if config.otg.serial is not None:
+ _write(join(lang_path, "serialnumber"), config.otg.serial)
profile_path = join(gadget_path, usb.G_PROFILE)
_mkdir(profile_path)