removed UsbDeviceController() class

This commit is contained in:
Maxim Devaev
2022-03-31 04:25:37 +03:00
parent 94dca7d7c6
commit c4ca7011bf
3 changed files with 22 additions and 36 deletions

View File

@@ -22,8 +22,6 @@
import os
from .logging import get_logger
from . import env
@@ -38,20 +36,3 @@ def find_udc(udc: str) -> str:
elif udc not in candidates:
raise RuntimeError(f"Can't find selected UDC: {udc}")
return udc # fe980000.usb
class UsbDeviceController:
def __init__(self, udc: str) -> None:
self.__udc = udc
self.__state_path = ""
def find(self) -> None:
udc = find_udc(self.__udc)
self.__state_path = os.path.join(f"{env.SYSFS_PREFIX}/sys/class/udc", udc, "state")
get_logger().info("Using UDC %s", udc)
def can_operate(self) -> bool:
assert self.__state_path
with open(self.__state_path, "r") as state_file:
# https://www.maxlinear.com/Files/Documents/an213_033111.pdf
return (state_file.read().strip().lower() == "configured")