Discussion:
[chromium-discuss] USB api to access smart card reader
Chang Shin
2017-09-12 14:48:27 UTC
Permalink
Hello all,

I am seeking some help and direction. Using a Chrome.usb API to access ACS
USB smart card reader. I got usb,clainInterfaces error:
Error in response to usb.claimInterface: Error claiming interface.
I got the same error on chrome 60 too.

After the error, the device-log show this error message:

USBEvent[09:41:35] *Failed to claim interface: Access denied (insufficient
permissions)*

USBUser[09:41:27] USB device added: vendor=1839 "ACS", product=37068 "CCID
USB Reader", serial="", guid=e404ae52-f84c-4c18-b516-27ac816533ab

Here are the codes:

1. chrome.usb.getDevices( DEVICE_INFO, function(devices) {

{device: 0, manufacturerName: "ACS", productId: 37068, productName: "CCID
USB Reader", serialNumber: "",

2. chrome.usb.openDevice(devices[0], function(connection) {

{handle: 1, productId: 37068, vendorId: 1839}

3. chrome.usb.listInterfaces(openedDevice, function(interfaces) {

{alternateSetting: 0, endpoints: Array(3), extra_data: ArrayBuffer,
interfaceClass: 11, *interfaceNumber: 0*, 
}

endPoint = interfaces[0].endpoints[0];

{address: 129, direction: "in", extra_data: ArrayBuffer, maximumPacketSize:
8, pollingInterval: 16, 
} var interfaceNumber =
interfaces[0].interfaceNumber;

claimInterface(interfaceNumber);

4.
function claimInterface(interfaceNumber) {
console.log("claimInterface() is called,",interfaceNumber);
console.log(openedDevice);

// interfaceNumber is always zero
//Error in response to usb.claimInterface: Error claiming interface.
chrome.usb.claimInterface(openedDevice, interfaceNumber,function() {
if ( ! chrome.runtime.lastError) {
//console.log("claimInterface.",claimInterfaces);
//callback(foundDevice);
console.log(chrome.runtime.lastError);
} else {
console.log(chrome.runtime.lastError);
throw chrome.runtime.lastError.message;
}
});
}


manifest.json file
{
"name": "Acs Card Reader",
"description": "Chang Shin, Macate",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "add-icon-16.png", "128": "add-icon-128.png" },
"permissions": ["usb","hid",
{
"usbDevices": [
{ "vendorId": 1839, "productId": 37068 }
]
}
]

}


Here is the chrome version information:

Google Chrome61.0.3163.79 (Official Build) (64-bit)Revision
2bd57c7d956c47bc51eff132dd114136ec0a6db7-refs/branch-heads/3163@{#1092}OSMac
OS XJavaScriptV8 6.1.534.32Flash26.0.0.151 /Library/Internet
Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.pluginUser AgentMozilla/5.0
(Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/61.0.3163.79 Safari/537.36Command Line/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome --no-startup-window
--flag-switches-begin --enable-experimental-web-platform-features
--flag-switches-endExecutable Path/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome

Chang Shin
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
Mohamed Yusoof
2018-09-17 12:26:56 UTC
Permalink
Hello Chang,

I am trying to acheive same, I want to read the data from ACS USB smart
card reader. please let us know if you are able to read data using ACS USB
smart card reader, is it possible to share the sample code to try with it.

Thanks.
Post by Chang Shin
Hello all,
I am seeking some help and direction. Using a Chrome.usb API to access
Error in response to usb.claimInterface: Error claiming interface.
I got the same error on chrome 60 too.
USBEvent[09:41:35] *Failed to claim interface: Access denied
(insufficient permissions)*
USBUser[09:41:27] USB device added: vendor=1839 "ACS", product=37068
"CCID USB Reader", serial="", guid=e404ae52-f84c-4c18-b516-27ac816533ab
1. chrome.usb.getDevices( DEVICE_INFO, function(devices) {
{device: 0, manufacturerName: "ACS", productId: 37068, productName: "CCID
USB Reader", serialNumber: "",
2. chrome.usb.openDevice(devices[0], function(connection) {
{handle: 1, productId: 37068, vendorId: 1839}
3. chrome.usb.listInterfaces(openedDevice, function(interfaces) {
{alternateSetting: 0, endpoints: Array(3), extra_data: ArrayBuffer,
interfaceClass: 11, *interfaceNumber: 0*, 
}
endPoint = interfaces[0].endpoints[0];
{address: 129, direction: "in", extra_data: ArrayBuffer,
maximumPacketSize: 8, pollingInterval: 16, 
} var interfaceNumber =
interfaces[0].interfaceNumber;
claimInterface(interfaceNumber);
4.
function claimInterface(interfaceNumber) {
console.log("claimInterface() is called,",interfaceNumber);
console.log(openedDevice);
// interfaceNumber is always zero
//Error in response to usb.claimInterface: Error claiming interface.
chrome.usb.claimInterface(openedDevice, interfaceNumber,function() {
if ( ! chrome.runtime.lastError) {
//console.log("claimInterface.",claimInterfaces);
//callback(foundDevice);
console.log(chrome.runtime.lastError);
} else {
console.log(chrome.runtime.lastError);
throw chrome.runtime.lastError.message;
}
});
}
manifest.json file
{
"name": "Acs Card Reader",
"description": "Chang Shin, Macate",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "add-icon-16.png", "128": "add-icon-128.png" },
"permissions": ["usb","hid",
{
"usbDevices": [
{ "vendorId": 1839, "productId": 37068 }
]
}
]
}
Google Chrome61.0.3163.79 (Official Build) (64-bit)Revision
OS XJavaScriptV8 6.1.534.32Flash26.0.0.151 /Library/Internet
Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.pluginUser AgentMozilla/5.0
(Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/61.0.3163.79 Safari/537.36Command Line/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome --no-startup-window
--flag-switches-begin --enable-experimental-web-platform-features
--flag-switches-endExecutable Path/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome
Chang Shin
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
Continue reading on narkive:
Loading...