I am trying to make a script (on linux) that can turn a light in my mouse on or off.
This is the code I have so far:
import usb.core
import usb.util
import sys
interface = 0
dev = usb.core.find(idVendor=0x1532, idProduct=0x0017)
def main():
if dev is None:
print "device not found"
else:
print "device found"
if dev.is_kernel_driver_active(interface) is True:
print "but we need to detach kernel driver"
dev.detach_kernel_driver(interface)
print "claiming device"
usb.util.claim_interface(dev, interface)
print "release claimed interface"
usb.util.release_interface(dev, interface)
print "now attaching the kernel driver again"
dev.attach_kernel_driver(interface)
print "all done"
return 0
if __name__ == '__main__':
main()
This works fine but if I try to do a: dev.set_configuration()
after the claim_interface(dev, interface)
the script returns the error: usb.core.USBError: Resource busy
Why is it still busy after I have detached its kernel driver?