javascript - 使用 webusb 声明 HID 设备

标签 javascript hid webusb

我似乎无法使用 webusb 声明隐藏接口(interface)。我正在尝试编写 yubikey OATH 包装器

navigator.usb.requestDevice({filters: filters}).then(...);

USBDevice {usbVersionMajor: 2, usbVersionMinor: 0, usbVersionSubminor: 0, deviceClass: 0, deviceSubclass: 0, …}configuration: USBConfiguration {configurationValue: 1, configurationName: null, interfaces: Array(2)}configurations: [USBConfiguration]deviceClass: 0deviceProtocol: 0deviceSubclass: 0deviceVersionMajor: 3deviceVersionMinor: 4deviceVersionSubminor: 9manufacturerName: "Yubico"opened: falseproductId: 273productName: "Yubikey NEO OTP+CCID"serialNumber: "0005610818"usbVersionMajor: 2usbVersionMinor: 0usbVersionSubminor: 0vendorId: 4176__proto__: USBDevice // ykey contains the device now USBDevice {usbVersionMajor: 2, usbVersionMinor: 0, usbVersionSubminor: 0, deviceClass: 0, deviceSubclass: 0, …}

ykey.open(...).then(...);
ykey.claimInterface(0)

Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined} Uncaught (in promise) DOMException: Unable to claim interface.

我怀疑这是一个与 chrome.usb api 类似的问题。我是否应该编写一个 udev 规则来不使用该设备上的 usbhid 驱动程序来实现此目的?

最佳答案

摘自 IRC 对话,Reilly提到过

The HID driver must not be loaded, so a udev rule is the way to go.

The restriction comes from the OS because when the HID driver is loaded that interface is "claimed" so Chrome can't claim it for itself.

关于javascript - 使用 webusb 声明 HID 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45701516/

相关文章:

javascript - 单击关闭按钮后未显示 Google 一键登录 UI

javascript - AngularJS - 使用 $locationProvider 删除哈希#

windows - 多个 HID 输入报告

javascript - 通过代码隐藏将数据传递给 <area> 标签内的 <href> 标签

javascript - MVC 中的 JQuery - 使用 getJson 将表单数据作为数组发送

c# - 连接到数字秤(Mettler Toledo PS90)作为 HID 仅当电缆首次连接到计算机时运行 On Report

windows - 如何使用 Windows PC 作为蓝牙隐藏?

javascript - Serial API 中 navigator.serial 和 SerialPort 的功能是否未实现?

javascript - 在 Electron 应用程序中访问 USB 内存棒失败,错误代码为 : No device selected exception

javascript - 使用 WebUSB 从串行设备读取整个响应