最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Failed to claim interface 0: Device or resource busy - Stack Overflow

programmeradmin2浏览0评论

I am trying to municate with usb device using WEBUSB API. BUT when I am trying to claim Interface it shows

"DOMException: Unable to claim interface"

the bConfigurationvalue is 1 and interface number is 0. I am adding the output of mand lsusb -v below

~$ lsusb -v
Bus 001 Device 005: ID 0930:6544 Toshiba Corp. TransMemory-Mini / Kingston DataTraveler 2.0 Stick (2GB)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0930 Toshiba Corp.
  idProduct          0x6544 TransMemory-Mini / Kingston DataTraveler 2.0 Stick (2GB)
  bcdDevice            1.00
  iManufacturer           1 TOSHIBA 
  iProduct                2 TransMemory     
  iSerial                 3 C412F52D6C84CFC0A0012AEF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              200mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

Why does it shows the device or resources busy. How to claim the interface?.

I am trying to municate with usb device using WEBUSB API. BUT when I am trying to claim Interface it shows

"DOMException: Unable to claim interface"

the bConfigurationvalue is 1 and interface number is 0. I am adding the output of mand lsusb -v below

~$ lsusb -v
Bus 001 Device 005: ID 0930:6544 Toshiba Corp. TransMemory-Mini / Kingston DataTraveler 2.0 Stick (2GB)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0930 Toshiba Corp.
  idProduct          0x6544 TransMemory-Mini / Kingston DataTraveler 2.0 Stick (2GB)
  bcdDevice            1.00
  iManufacturer           1 TOSHIBA 
  iProduct                2 TransMemory     
  iSerial                 3 C412F52D6C84CFC0A0012AEF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              200mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

Why does it shows the device or resources busy. How to claim the interface?.

Share Improve this question edited Dec 7, 2017 at 14:19 Muhammad Omer Aslam 23.8k9 gold badges46 silver badges69 bronze badges asked Dec 7, 2017 at 12:26 Shijo JosephShijo Joseph 1152 silver badges8 bronze badges 1
  • Added code indentation you should try to make your question readable with formatting tools take some time to read the docs – Muhammad Omer Aslam Commented Dec 7, 2017 at 14:19
Add a ment  | 

2 Answers 2

Reset to default 3

The device is shown as busy because this is a USB Mass Storage class device and Linux will automatically load a kernel driver when it is connected that claims interface 0.

You can manually unbind the USB device driver with the following mand:

echo -n "1-1:1.0" > /sys/bus/usb/drivers/usb-storage/unbind

"1-1:1.0" specifies the device and interface that the usb-storage driver should unbind from. "1-1" means bus 1, port 1 and "1.0" means configuration 1, interface 0. This information is printed in the kernel log when the device is connected like this,

usb-storage 1-1:1.0: USB Mass Storage device detected

The bus and port number for your device will likely differ.

While this should allow you to use this device with WebUSB it is not likely useful as a long term solution because of the manual steps involved. WebUSB is designed for devices without built-in operating system drivers.

I had a problem with a device and found the usb_modeswitch mand useful. Given the vendor and product id the device can be reset. E.g.:

usb_modeswitch -v 0x1d50 -p 0x60e3 --reset-usb
发布评论

评论列表(0)

  1. 暂无评论