pyusb: [Errno 16] Resource busy
Hi guys, I’m not sure if i made a mistake… I’m always getting this error and no solution worked for me 😦 My software: Python 2.7.8, libusb 1.0.19-1 and the current PyUSB version from this rep… I’m working on Arch Linux Arm (Raspberry Pi model B) Her’s my udev rule:
UBSYSTEMS=="usb", ATTRS{idVendor}=="04f2", ATTRS{idProduct}=="0402", GROUP=users", MODE="0660"
From https://github.com/itdaniher/WeDoMore/issues/4
And a testcode:
#!/usr/bin/python2
import usb.core
import usb.util
import sys
def getData():
VENDOR_ID = 0x04f2
PRODUCT_ID = 0x0402
DATA_SIZE = 1
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
if device is None:
sys.exit("Could not find Keyboard")
if device.is_kernel_driver_active(0):
try:
device.detach_kernel_driver(0)
print "kernel driver detached"
except usb.core.USBError as e:
sys.exit("Could not detach kernel driver: %s" % str(e))
else:
print "no kernel driver attached"
try:
usb.util.claim_interface(device, 0)
print "claimed device"
except:
sys.exit("Could not claim the device: %s" % str(e))
try:
device.set_configuration()
device.reset()
except usb.core.USBError as e:
sys.exit("Could not set configuration: %s" % str(e))
When I execute my script:
$sudo python2 ./test.py
no kernel driver attached
claimed device
Could not set configuration: [Errno 16] Resource busy
Can you tell me whats wrong? Thanks 😃
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 25 (10 by maintainers)
Commits related to this issue
- detach kernel driver if active Avoids getting a "Resource busy" error due to a kernel driver being associated with the USB device. See: https://github.com/walac/pyusb/issues/76 Signed-off-b... — committed to troth/CryptoAuth-explorations by troth 7 years ago
- detach kernel driver if active Avoids getting a "Resource busy" error due to a kernel driver being associated with the USB device. See: https://github.com/walac/pyusb/issues/76 Signed-off-b... — committed to troth/CryptoAuth-explorations by troth 7 years ago
- detach kernel driver if active Avoids getting a "Resource busy" error due to a kernel driver being associated with the USB device. See: https://github.com/walac/pyusb/issues/76 Signed-off-b... — committed to troth/CryptoAuth-explorations by troth 7 years ago
This should cure most “Resource busy” issues for newbies…
@Aswin21 You need to detach the kernel driver before issuing a
set_configuration
.