Sup*_*arp 3 javascript html5 winusb smartcard-reader google-chrome-app
我想制作一款可以访问USB智能卡读卡器(HID Global OmniKey 3121)的Chrome应用程序.
有人曾经成功做过吗?
不幸的是,我看不到它的使用usb.getDevices.
script.js(由index.html调用,后者本身由background.js 调用onLaunched):
//dom elements
var findBtn = document.querySelector( "button#find-btn" )
var deviceInfo = document.querySelector( "p#device-info" )
//{click}
findBtn.addEventListener( "click", findDevice )
/*
* Try to find HID OmniKey 3x21
*/
function findDevice ()
{
var options = {
filters: [
{
vendorId: 1899, //OmniKey AG
productId: 12321 //CardMan 3121 but PID=0x3021
}
]
}
chrome.usb.getDevices( options, function ( devices )
{
console.log( devices )
deviceInfo.innerHTML = JSON.stringify( devices[0] )
} )
}
Run Code Online (Sandbox Code Playgroud)
设备在清单中声明,并在"扩展程序"页面中由Chrome识别.
提前感谢您的帮助.
编辑
这是我的manifest.json:
{
"manifest_version": 2,
"name": "Card Reader",
"description": "Smartcard reader",
"version": "0.0.2",
"minimum_chrome_version": "43",
"app": {
"background": {
"scripts": [ "js/background.js" ]
}
},
"permissions": [
"usb",
{
"usbDevices": [
{
"vendorId": 1057,
"productId": 1633
},
{
"vendorId": 1133,
"productId": 49271
},
{
"vendorId": 1899,
"productId": 12321
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
3个允许的设备是:
只有鼠标被usb.getDevices或识别usb.findDevices.仅列出鼠标usb.getUserSelectedDevices.
使用HID Global的本机驱动程序时,Chrome无法识别该设备.
解决方法是使用备用USB驱动程序,例如zadig.akeo.ie的Zadig安装程序提供的驱动程序:
我在HID Device上开了一个案例,但是他们的技术支持还没有理解这个问题(他们不知道什么是Chrome平台...)并将我重定向到Google.
我在谷歌开了一个案子,但他们回答我我应该在StackOverflow上发帖!他们似乎并不介意他们的平台无法识别标准USB智能卡设备,尽管在Windows设备管理器中可见...
更新
HID技术支持表示他们的驱动程序将在2016年之前支持该平台.Goolge支持仍然是... inapt.
Windows 7-10更新
在Windows 7和10上,我不需要安装通用驱动程序.相反,我只需在Windows设备管理器中编辑智能卡读卡器,然后选择以前的驱动程序.它将恢复为Windows Generic USB CCID驱动程序,该驱动程序可与我的传统PC/SC Winscard应用程序和我的Chrome应用程序一起使用.