python - PyUSB device claimed, detach_kernel_driver return Entity Not Found -


I read and writes bulk from a USB device on Ubuntu using PUSB. However, I have failed to remove it

  import usb.core import usb.util dev = usb.core.find (idVendor = 0xXXXX, idProduct = 0xYYYY) If there is no god: Trying to raise ValueError (try 'device not found'): except dev.detach_kernel_driver (0): print "exception dev.detach_kernel_driver (0)" near dev.set_configuration () print "all full"   

This is the simple script I'm using. I have created the /etc/udev/rules.d/40-basic-rules.rules which contains

SUBSYSTEM == "usb", ENV {DEVTYPE} = = "usb_device", sysfs {idVendor} == "XXXX", sysfs {idProduct} == "YYYY", mode = "0666"

for my proper device.

The script is running as root raises a usb.core.USBError: [Error 16] resource busy error because dev.detach_kernel_driver (0) Exception usb.core.USBError: [Error 2] no unit found

in dmesg I see these messages,

  [638.007886] ] Usb 1 -1: usbfs: Interface 1 Setting 'Python' Claimed by USB-Storage While Config # 1 [643.4,25802] USB 1-1: usbfs: Interface 1 While 'Python' set config # USB- Claim by storage 1 [647.9, 57, 9 32] USB 1 -1: usbfs: Interface 1 has USB-S Claimed by storage while 'Dragon' set config # 1 set   

Coming what I remember to get access to this device?

Your problem, like mine, is that you need to separate the kernel before each interface set_configuration () Here's a code I'm using now (including some scaffolding) to connect to a USB audio device:

  import usb.core import usb.util scarlet = usb.core.find (idVendor = 0x1235) # Focusrite does not scarlet, so: print "not scarlet" c = 1 for config in red: print 'config' in range, C Print 'interface', config.bNumInterfaces for (config.bNumInterfaces): if scarlet.is_kernel_driver_active (i): scarlet.detach_kernel_driver (i) print i c + = 1 scarlet.set_configuration ()    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -