【问题标题】:Google Chrome WebUSB API error while trying to claim interface尝试声明接口时出现 Google Chrome WebUSB API 错误
【发布时间】:2017-08-05 08:47:12
【问题描述】:

我正在尝试使用 Google Chrome webUSB api 访问通过 USB 连接到我的计算机的读卡器。

按照说明here,一切正常,直到我尝试声明给我错误的接口:

“未能声明接口 0:设备或资源忙”

我的操作系统 (linux mint) 似乎已访问此设备,并且不允许操作员访问。

有什么建议可以解决这个问题吗?

编辑:

当我解除绑定驱动程序时,我收到以下错误:

“声明接口0失败:没有这样的文件或目录”

这也是这个设备的 lsusb -v 的输出:

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

【问题讨论】:

  • 第一个错误是预期的,因为绑定了内核驱动程序。其次,我需要更多地了解该设备。你能发布来自lsusb -v的完整描述符吗?
  • @ReillyGrant 很长,我在问题的编辑部分放入。

标签: javascript google-chrome webusb


【解决方案1】:

“没有这样的文件或目录”(错误代码 ENOENT)通常表示提供的接口号不存在,但是从描述符中显然不是这种情况,Chrome 会拒绝由 claimInterface 返回的承诺,并带有“提供的接口号设备在其当前配置中不支持。”如果在向内核提交请求之前认为接口号无效。

但是,我注意到,此设备支持的单一配置的 bConfigurationValue 为 2。可能是当驱动程序解除绑定时,系统取消了对设备的配置,现在 Chrome 知道了设备的当前配置与系统不同步。如果您在/sys/bus/usb/devices 中找到设备并打印文件bConfigurationValue,它将告诉您设备的真实当前配置,我猜是0。

遗憾的是,目前无法通过 WebUSB API 修复这种不匹配,但是在取消绑定内核驱动程序后重新启动 Chrome 将允许它在正确的时间读取此文件并且不会不同步。

如果这对您有用,请在crbug.com/new 提交错误,我们可以制定出在未来避免此问题的最佳方法。

【讨论】:

  • bConfigurationValue/sys/bus/usb/devices 下仍然是 2。我重新启动 Chrome 并再次尝试,除了配置 2 之外的任何内容都会给我配置超出范围的错误。但这一次,错误改回:Failed to claim interface 0: Device or resource busy 虽然设备已经解除绑定。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-04-21
  • 1970-01-01
  • 1970-01-01
  • 2016-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多