1
0
mirror of https://github.com/gryf/linak-ctrl.git synced 2025-12-19 04:10:18 +01:00

Added initialization part.

Sometimes the usb2lin06 device need to be initialized. Added that part
to the init of LinakDevice class.
This commit is contained in:
2021-06-23 15:35:36 +02:00
parent 7029abd98b
commit 83bd0ac4ea

View File

@@ -14,9 +14,12 @@ REQ_TYPE_GET_INTERFACE = 0xa1
REQ_TYPE_SET_INTERFACE = 0x21
HID_GET_REPORT = 0x01
HID_SET_REPORT = 0x09
INIT = 0x0303
MOVE = 0x0305
GET_STATUS = 0x0304
BUF_LEN = 64
MODE_OF_OPERATION = 0x03
MODE_OF_OPERATION_DEFAULT = 0x04
class Logger:
@@ -109,6 +112,17 @@ class LinakDevice:
self._dev = usb.core.find(idVendor=LinakDevice.VEND,
idProduct=LinakDevice.PROD)
# init device
buf = [0 for _ in range(BUF_LEN)]
buf[0] = MODE_OF_OPERATION # 0x03 Feature report ID = 3
buf[1] = MODE_OF_OPERATION_DEFAULT # 0x04 mode of operation
buf[2] = 0x00 # ?
buf[3] = 0xfb # ?
self._dev.ctrl_transfer(REQ_TYPE_SET_INTERFACE, HID_SET_REPORT, INIT,
0, array.array('B', buf))
# 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)