From e9ea91f2c32e67317a9491b215208c8406ee8853 Mon Sep 17 00:00:00 2001 From: gryf Date: Wed, 7 Jul 2021 17:34:11 +0200 Subject: [PATCH] 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. --- linak_ctrl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linak_ctrl.py b/linak_ctrl.py index 6649f6b..2d13f33 100755 --- a/linak_ctrl.py +++ b/linak_ctrl.py @@ -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: