#46 修复 CD-ROM 与 FLASH 模式网页无法切换

挂载 MSD 时重启 UDC 确保模式生效
This commit is contained in:
mofeng-git
2024-11-05 17:54:38 +00:00
parent de5cb73b93
commit 72dce4de89
3 changed files with 17 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ class MsdDriveLockedError(MsdOperationError):
class Drive:
def __init__(self, gadget: str, instance: int, lun: int) -> None:
func = f"mass_storage.usb{instance}"
self.__udc_path = os.path.join(f"/sys/kernel/config/usb_gadget", gadget, usb.G_UDC)
self.__profile_func_path = usb.get_gadget_path(gadget, usb.G_PROFILE, func)
self.__profile_path = usb.get_gadget_path(gadget, usb.G_PROFILE)
self.__lun_path = usb.get_gadget_path(gadget, usb.G_FUNCTIONS, func, f"lun.{lun}")
@@ -49,6 +50,9 @@ class Drive:
def get_watchable_paths(self) -> list[str]:
return [self.__lun_path, self.__profile_path]
def get_udc_path(self) -> str:
return self.__udc_path
# =====