otg: init_delay

This commit is contained in:
Devaev Maxim
2019-09-24 11:39:20 +03:00
parent cfe0c07543
commit 5d437c58e3
2 changed files with 17 additions and 9 deletions

View File

@@ -193,6 +193,7 @@ def _get_config_scheme() -> Dict:
"force_users": Option([], type=valid_users_list), "force_users": Option([], type=valid_users_list),
# Dynamic content # Dynamic content
}, },
"external": { "external": {
"type": Option(""), "type": Option(""),
}, },
@@ -249,7 +250,11 @@ def _get_config_scheme() -> Dict:
"product": Option("Composite KVM Device"), "product": Option("Composite KVM Device"),
"serial_number": Option("CAFEBABE"), "serial_number": Option("CAFEBABE"),
"udc": Option(""), "udc": Option(""),
"acm": Option(True, type=valid_bool), "init_delay": Option(3.0, type=valid_float_f01),
"acm": {
"enabled": Option(True, type=valid_bool),
},
}, },
"ipmi": { "ipmi": {

View File

@@ -20,16 +20,16 @@
# ========================================================================== # # ========================================================================== #
import time
import argparse
from os import listdir from os import listdir
from os import mkdir from os import mkdir
from os import makedirs
from os import symlink from os import symlink
from os import rmdir from os import rmdir
from os import unlink from os import unlink
from os.path import join from os.path import join
import argparse
from typing import List from typing import List
from typing import Optional from typing import Optional
@@ -59,7 +59,7 @@ def _find_udc(udc: str) -> str:
def _check_config(config: Section) -> None: def _check_config(config: Section) -> None:
if ( if (
not config.otg.acm not config.otg.acm.enabled
and config.kvmd.hid.type != "otg" and config.kvmd.hid.type != "otg"
and config.kvmd.msd.type != "otg" and config.kvmd.msd.type != "otg"
): ):
@@ -89,11 +89,12 @@ def _cmd_start(config: Section) -> None:
_write(join(lang_path, "serialnumber"), config.otg.serial_number) _write(join(lang_path, "serialnumber"), config.otg.serial_number)
config_path = join(gadget_path, "configs/c.1") config_path = join(gadget_path, "configs/c.1")
makedirs(join(config_path, "strings/0x409")) mkdir(config_path)
_write(join(gadget_path, "configs/c.1/strings/0x409/configuration"), "Config 1: ECM network") mkdir(join(config_path, "strings/0x409"))
_write(join(gadget_path, "configs/c.1/MaxPower"), "250") _write(join(config_path, "strings/0x409/configuration"), "Config 1: ECM network")
_write(join(config_path, "MaxPower"), "250")
if config.otg.acm: if config.otg.acm.enabled:
func_path = join(gadget_path, "functions/acm.usb0") func_path = join(gadget_path, "functions/acm.usb0")
mkdir(func_path) mkdir(func_path)
symlink(func_path, join(config_path, "acm.usb0")) symlink(func_path, join(config_path, "acm.usb0"))
@@ -126,6 +127,8 @@ def _cmd_start(config: Section) -> None:
_write(join(gadget_path, "UDC"), udc) _write(join(gadget_path, "UDC"), udc)
time.sleep(config.otg.init_delay)
def _cmd_stop(config: Section) -> None: def _cmd_stop(config: Section) -> None:
# https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt # https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt