Skip to content

Instantly share code, notes, and snippets.

@x42
Created August 17, 2022 19:38
Show Gist options
  • Save x42/401538ab97d2b6dbe151579c5de37bb3 to your computer and use it in GitHub Desktop.
Save x42/401538ab97d2b6dbe151579c5de37bb3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# https://pyusb.github.io/pyusb/ -- python3-usb
import usb.core
## Focusrite(R) Scarlett 18i6
device = usb.core.find(idVendor= 0x1235, idProduct=0x8004)
if device is None:
raise ValueError('Device not found')
try:
device.detach_kernel_driver(0)
except:
pass
def ctrl_cmd(cmd, wValue, wIndex, data):
try:
assert device.ctrl_transfer(0x21, cmd, wValue, wIndex, data) == len(data)
except:
raise ValueError('request failed')
# save current config on the 18i6 to be restored after power-cycles
ctrl_cmd(0x03, 0x005a, 0x3c00, [0xa5])
# vim: set ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment