lglaf.py: Fix "Resource busy" error

Detach kernel driver (cdc_acm) to avoid this error:

    usb.core.USBError: [Errno 16] Resource busy

Deliberately do not call attach_kernel_driver for the detached devices,
it is likely that the user runs lglaf multiple times. The user can
unplug and re-insert their device if they want to re-attach the kernel
driver.
This commit is contained in:
Peter Wu 2016-03-15 22:24:49 +01:00
parent f2792e6374
commit 688e0f3d17

View file

@ -215,6 +215,10 @@ class USBCommunication(Communication):
"has a kernel driver claimed the interface?")
raise e
for intf in cfg:
if self.usbdev.is_kernel_driver_active(intf.bInterfaceNumber):
_logger.debug("Detaching kernel driver for intf %d",
intf.bInterfaceNumber)
self.usbdev.detach_kernel_driver(intf.bInterfaceNumber)
if self._match_interface(intf):
self._set_interface(intf)
assert self.ep_in