简体   繁体   English

WebUSB:请求的接口实现一个受保护的类

[英]WebUSB: The requested interface implements a protected class

I'm trying to use a card reader ( https://www.ewent-online.com/tcpdf/pdf/ew/p/EW1052/ ) to read a Health Card. 我正在尝试使用读卡器( https://www.ewent-online.com/tcpdf/pdf/ew/p/EW1052/ )来读取健康卡。

This is the code (copy-pasted from the official doc: https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web ): 这是代码(从官方文档复制粘贴: https : //developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web ):

var device;

navigator['usb'].requestDevice({ filters: [] })
.then(selectedDevice => {
    device = selectedDevice;
    return device.open(); // Begin a session.
})
.then(() => device.selectConfiguration(1)) // Select configuration #1 forhe device.
.then(() => device.claimInterface(0)) // Request exclusive control over     interface #2.
.then(() => device.controlTransferOut({
    requestType: 'class',
    recipient: 'interface',
    request: 0x22,
    value: 0x01,
    index: 0x00}
)) // Ready to receive data
.then(() => device.transferIn(5, 64)) // Waiting for 64 bytes of data from endpoint #5.
.then(result => {
    let decoder = new window['TextDecoder']();
    console.log('Received: ' + decoder.decode(result.data));
})
.catch(error => {
    console.log(error);
});

The error is here: 错误在这里:

device.claimInterface(0)

For some reason i can't access at the class. 由于某种原因,我无法在全班学习。 I can't figure out hot to make it work, i have read alla stackoverflow related thread without found a solution. 我无法解决问题,我已经阅读了所有与stackoverflow相关的线程,但没有找到解决方案。

Thanks in advance! 提前致谢!

Your device implements the USB CCID class, which is on the list of classes protected by Chrome as announced in the post below. 您的设备实现了USB CCID类,该类位于受Chrome保护的类列表中,如以下博文所述。 Interfaces implementing these classes cannot be claimed through WebUSB. 不能通过WebUSB声明实现这些类的接口。

https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/LZXocaeCwDw/GLfAffGLAAAJ https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/LZXocaeCwDw/GLfAffGLAAAJ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM