question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Errno 16] Resource busy

See original GitHub issue

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 😃

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

18reactions
Sam-Hallcommented, Jul 4, 2015

This should cure most “Resource busy” issues for newbies…

for cfg in device:
  for intf in cfg:
    if device.is_kernel_driver_active(intf.bInterfaceNumber):
      try:
        device.detach_kernel_driver(intf.bInterfaceNumber)
      except usb.core.USBError as e:
        sys.exit("Could not detatch kernel driver from interface({0}): {1}".format(intf.bInterfaceNumber, str(e)))
1reaction
walaccommented, Jun 14, 2015

@Aswin21 You need to detach the kernel driver before issuing a set_configuration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I keep getting "usb.core.USBError: [Errno 16] Resource busy ...
I keep getting "usb.core.USBError: [Errno 16] Resource busy" when trying to read from a USB device using pyusb.
Read more >
What is error "IOError: [Errno 16] Device or resource busy"?
It means that your software can't access it because something else is, or has claimed it. It's not always fully accurate. It really...
Read more >
Pyusb "USBError: [Errno 16] Resource busy" - Google Groups
Pyusb "USBError: [Errno 16] Resource busy". 815 views.
Read more >
How to interpret Galaxy Error (OSError: [Errno 16] Device or ...
My guess is that your Galaxy distribution is located on a NFS filesystem and the Galaxy temp directory is also located on this...
Read more >
[Errno 16] Device or resource busy: '/dev/sdb' - TrueNAS
[EFAULT] Failed to wipe disk sdb: [Errno 16] Device or resource busy: '/dev/sdb' With this as extra info: Error: Traceback (most recent call ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found