Skip to content

Instantly share code, notes, and snippets.

@TIS-Arne
Last active August 20, 2019 08:24
Show Gist options
  • Save TIS-Arne/00a00e5cdc7a0d10cc31e50a41179de9 to your computer and use it in GitHub Desktop.
Save TIS-Arne/00a00e5cdc7a0d10cc31e50a41179de9 to your computer and use it in GitHub Desktop.
import usb.core
import sys
SET_CUR = 0x1
GET_CUR = 0x81
usbdev = usb.core.find(idVendor=0x199e)
def writectrl(usbdev, unit, ctrl, value):
USB_ENDPOINT_OUT = 0x00
USB_ENDPOINT_IN = 0x80
USB_RECIP_DEVICE = 0x00
USB_TYPE_CLASS = (0x01 << 5)
USB_TYPE_VENDOR = (0x02 << 5)
usbdev.ctrl_transfer(USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE,
SET_CUR,
ctrl << 8,
unit << 8, chr(value))
usbdev.detach_kernel_driver(0)
writectrl(usbdev, 1, 55, 1)
usbdev.attach_kernel_driver(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment