mirror of
https://github.com/gryf/linak-ctrl.git
synced 2025-12-19 12:18:05 +01:00
Detach kernel driver before doing anything with device.
Initialization of the device must be done after device is detached from kernel, otherwise exception will be thrown about device is busy message.
This commit is contained in:
@@ -112,6 +112,10 @@ class LinakDevice:
|
||||
self._dev = usb.core.find(idVendor=LinakDevice.VEND,
|
||||
idProduct=LinakDevice.PROD)
|
||||
|
||||
# detach kernel driver, if attached
|
||||
if self._dev.is_kernel_driver_active(0):
|
||||
self._dev.detach_kernel_driver(0)
|
||||
|
||||
# init device
|
||||
buf = [0 for _ in range(BUF_LEN)]
|
||||
buf[0] = MODE_OF_OPERATION # 0x03 Feature report ID = 3
|
||||
@@ -123,10 +127,6 @@ class LinakDevice:
|
||||
# hold a little bit, to make it effect.
|
||||
time.sleep(0.5)
|
||||
|
||||
# detach kernel driver, if attached
|
||||
if self._dev.is_kernel_driver_active(0):
|
||||
self._dev.detach_kernel_driver(0)
|
||||
|
||||
def get_position(self, args):
|
||||
try:
|
||||
while True:
|
||||
|
||||
Reference in New Issue
Block a user