1
0
mirror of https://github.com/gryf/linak-ctrl.git synced 2025-12-19 20:28:00 +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:
2021-07-07 17:34:11 +02:00
parent aa5aecb205
commit e9ea91f2c3

View File

@@ -112,6 +112,10 @@ class LinakDevice:
self._dev = usb.core.find(idVendor=LinakDevice.VEND, self._dev = usb.core.find(idVendor=LinakDevice.VEND,
idProduct=LinakDevice.PROD) idProduct=LinakDevice.PROD)
# detach kernel driver, if attached
if self._dev.is_kernel_driver_active(0):
self._dev.detach_kernel_driver(0)
# init device # init device
buf = [0 for _ in range(BUF_LEN)] buf = [0 for _ in range(BUF_LEN)]
buf[0] = MODE_OF_OPERATION # 0x03 Feature report ID = 3 buf[0] = MODE_OF_OPERATION # 0x03 Feature report ID = 3
@@ -123,10 +127,6 @@ class LinakDevice:
# hold a little bit, to make it effect. # hold a little bit, to make it effect.
time.sleep(0.5) 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): def get_position(self, args):
try: try:
while True: while True: