USB api to access smart card reader

1,134 views
Skip to first unread message

Chang Shin

unread,
Sep 13, 2017, 2:01:54 AM9/13/17
to Chromium-discuss
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)Revision2bd57c7d956c47bc51eff132dd114136ec0a6db7-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

Mohamed Yusoof

unread,
Sep 18, 2018, 1:35:55 PM9/18/18
to Chromium-discuss, changs...@gmail.com
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.
Reply all
Reply to author
Forward
0 new messages