Google Chrome WebUSB API error while trying to claim interface

白昼怎懂夜的黑 提交于 2019-12-08 16:49:11

问题


I'm trying to use Google Chrome webUSB api to access a card reader connected to my computer via USB.

Following the instructions here, everything is okay up until I try to claim the interface which gives me an error:

"Failed to claim interface 0: Device or resource busy"

It appears that my OS (linux mint) has accessed this device and doesn't allow the operator to have access.

Any suggestions how to overcome this?

EDIT:

When I unbind the driver, I get the following error:

"Failed to claim interface 0: No such file or directory"

Also here is the output of lsusb -v for this device:

Bus 001 Device 012: ID 0ca6:a050 Castles Technology Co., Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0ca6 Castles Technology Co., Ltd
  idProduct          0xa050 
  bcdDevice            0.00
  iManufacturer           1 Linux 2.6.32.9 with dwc_otg_pcd
  iProduct                2 EFT-POS Terminal
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           67
    bNumInterfaces          2
    bConfigurationValue     2
    iConfiguration          3 EFT-POS Terminal
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              4 CDC Abstract Control Model (ACM)
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x000a  1x 10 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 
      iInterface              5 CDC ACM Data
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

回答1:


"No such file or directory" (error code ENOENT) usually indicates that the interface number provided does not exist however from the descriptors this is clearly not the case and Chrome would reject the promise returned by claimInterface with "The interface number provided is not supported by the device in its current configuration." if it thought the interface number were invalid before submitting the request to the kernel.

I notice, however, that the single configuration supported by this device is given a bConfigurationValue of 2. It is possible that when the driver was unbound the system unconfigured the device and now Chrome's knowledge of the current configuration of the device is out of sync with the system. If you find the device in /sys/bus/usb/devices and print the file bConfigurationValue it will tell you the true current configuration of the device, which I am guessing will be 0.

There is unfortunately currently no way to fix this mismatch through the WebUSB API however restarting Chrome after unbinding the kernel driver will allow it to read this file at the correct time and not be out of sync.

If this works for you please file a bug at crbug.com/new and we can work out the best way to avoid this problem in the future.



来源:https://stackoverflow.com/questions/45520008/google-chrome-webusb-api-error-while-trying-to-claim-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!