gpt4 book ai didi

javascript - WebUSB 无法连接,因为另一台设备正在使用相同的接口(interface)

转载 作者:太空宇宙 更新时间:2023-11-04 11:49:00 27 4
gpt4 key购买 nike

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

NetworkError: Unable to claim interface

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 作为类代码,因为文档说我可以这样做,但它们没有相同的 ID,所以这毫无意义。此外,在重新连接后,我只能将 lsusb 输出到 MSI 驱动程序的输出,即使 Chrome 拾取它并且我收到了 access denied 错误

这很奇怪,因为我更改了 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 不返回任何内容这两个驱动程序来自同一输入??????

最佳答案

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

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

$ sudo modprobe -r ftdi_sio

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

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

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

如果卸载驱动程序不能解决您的问题,则可能是您没有申请正确的设备。如果您在导航栏上写 chrome://device-log/

,您可以阅读日志文件找到更多信息

关于javascript - WebUSB 无法连接,因为另一台设备正在使用相同的接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56660333/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com