【问题标题】:WebUSB will not connect because another device is using the same interfaceWebUSB 将无法连接,因为另一个设备正在使用相同的接口
【发布时间】:2019-06-19 05:01:29
【问题描述】:

所以我在运行 claimInterface() 函数时尝试连接到 openEEG

NetworkError:无法声明接口

lsusb 显示这个问题很可能是因为某些 MSI 驱动程序正在同一个驱动程序上运行

lsusb -v -s4 的输出

Bus 002 Device 004: ID 1770:ff00  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1770 
  idProduct          0xff00 
  bcdDevice            1.10
  iManufacturer           1 MSI EPF USB
  iProduct                1 MSI EPF USB
  iSerial                 1 MSI EPF USB
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      57
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0xa630
  (Bus Powered)

Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6001 FT232 USB-Serial (UART) IC
  bcdDevice            6.00
  iManufacturer           1 FTDI
  iProduct                2 FT232R USB UART
  iSerial                 3 A105XV9J
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               90mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2 FT232R USB UART
      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     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

我最初尝试在navigator.usb.requestDevice 上添加 255 作为 classCode,因为文档说我可以这样做,但它们没有相同的 ID,所以这毫无意义。同样,在重新连接后,我只能将 lsusb 输出到 MSI 驱动程序,即使 Chrome 将其拾取并且我得到了 access denied error

这很奇怪,因为我更改了udev规则并在dev/bus/usb中使用了sudo chmod -R 777 *

然后我在文件夹“001”中发现了一个文件,之前我必须手动更改权限,以为它是 MSI 驱动程序,但这次原始文件被删除,代替了名为“007”而不是“005”的文件(可能是因为我尝试了两次插入设备)

所以这一定是 MSI 安全功能的组合?和 OpenEEG 每次加载时都会创建一个新文件?

我能想到的唯一解决方案是删除我不理解的文件并在每次插入时更改权限。这两种方法都非常禁止使用,特别是因为我希望我的网站能够在广泛的范围内工作设备和操作系统的范围

PS:如果相关,请使用 Linux Mint,这是我在本地 node.js 服务器上运行的代码(我认为这不是问题)

    document.addEventListener('DOMContentLoaded', event => {
  let button = document.getElementById('connect')

  button.addEventListener('click', async() => {
    var device
    const VENDOR_ID = 0x0403
    const PRODUCT_ID = 0x6001
    const CLASS_CODE = 255


      device = await navigator.usb.requestDevice({
        filters: [{
          vendorId: VENDOR_ID,
          productId: PRODUCT_ID,
          classCode: CLASS_CODE
        }]
      })

      console.log('opening..')
      await device.open()
      console.log('open!')
      .then(() => device.selectConfiguration(1))
      .then(() => device.claimInterface(0)).catch(error => { console.log(error + 'eeeeeeerrrr ' + device.configuration.interfaces[0].interfaceNumber); });


      console.log(device);
      await device.close().catch(error => { console.log(error + 'eeeeeeerrrr'); });
});


  })

编辑/更新:lsusb 在未连接时不返回任何内容,这两个驱动程序来自同一个输入???????

【问题讨论】:

    标签: javascript linux usb linux-mint webusb


    【解决方案1】:

    当您将设备连接到 USB 端口时,Linux 会加载其驱动程序并为自己声明设备。

    如果您想在其他地方使用它,只需卸载驱动程序:

    $ sudo modprobe -r ftdi_sio
    

    如果您重新启动计算机,驱动程序将再次加载,您必须手动卸载它。如果你想保持卸载,你可以这样做:

    $ echo "ftdi_sio" | sudo tee -a /etc/modules
    

    我可以理解为什么它让你感到困惑,考虑到lsusb 的输出不是那么清楚,但我认为另一个 MSI 驱动程序是用于你计算机上的根 USB 控制器的。如果您删除它,您将无法看到您的端口或连接到它们的任何东西。

    如果卸载驱动程序不能解决您的问题,则可能您没有声明正确的设备。如果您在导航栏上写chrome://device-log/,您可以阅读日志文件了解更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多