Handle USBError to prevent 'Resource Busy' error

This commit is contained in:
Felipe Martin 2017-01-17 23:31:03 +01:00
parent 4cefd2a594
commit 5fc68092d8
1 changed files with 6 additions and 1 deletions

View File

@ -84,7 +84,12 @@ class Luxafor:
if device is None:
raise Exception('Device was not found.')
device.set_configuration()
try:
device.set_configuration()
except usb.core.USBError:
# Prevent Resource busy errors
device.detach_kernel_driver(0)
device.set_configuration()
self.device = device