google-chrome - 无法声明我可以通过 device.configuration.interfaces 看到的唯一接口
问题描述
尝试通过 WebUSB10.14.1
在 Google Chrome 版本中读取 MacOS 上的 USB 条码扫描仪。71.0.3578.98
设备在 requestDevice 对话框中可见Usb211
并成功打开,我在这里使用的代码:
const VENDOR_ID = 0x8888
navigator.usb.requestDevice({ filters: [{ vendorId: VENDOR_ID }] })
.then(selectedDevice => {
device = selectedDevice;
return device.open();
})
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(device.configuration.interfaces[0].interfaceNumber)) # interfaceNumber is 0
.catch(error => { console.log(error); });
当我尝试claimInterface(0)
(这是对象中唯一可用的接口时,它会因错误(或DOMException )device
而失败- 由于最近的更改,这是预期的:https ://groups.google.com/a/chromium.org /forum/#!msg/blink-dev/LZXocaeCwDw/GLfAffGLAAAJAn attempt to claim a USB device interface has been blocked because it implements a protected interface class.
SecurityError
The requested interface implements a protected class.
有没有办法以某种方式“更深入地调试”,因为我看不到只使用可用接口的方法。
谢谢!
解决方案
如果唯一可用的接口被阻止,则无法通过 WebUSB API 使用它。有一个单独的 API WebHID正在开发中,旨在满足在授予对提供 HID 接口的设备的访问权限时的特定要求。
推荐阅读
- python-3.x - 涉及 MulExpression 的 cvxpy 目标函数错误
- c++ - 以获取一致性与宽松一致性在原子负载上旋转
- android - 在 webview 中添加输入后,PopScope 将不起作用吗?
- javascript - 将外部 HTML 加载到页面中,包括 Javascript 并在加载时启动 JS
- python - 生成器函数不返回或打印任何内容
- jquery - Rails,如何在特定页面上显示 jquery-ui-datepicker 日历?
- r - UseMethod(“filter_”)中的错误:没有适用于“filter_”的方法应用于“c('double','numeric')”类的对象
- c# - 使用未知数量的变量格式化字符串
- python - PyFlink - 如何使用指定的文件输入格式(而不是文本格式)读取文件()?
- python - dict理解丢弃元素