Chrome.usb to acces smart card reader from chrome browser

503 views
Skip to first unread message

Chang Shin

unread,
Sep 6, 2017, 7:26:20 PM9/6/17
to Chromium-Extensions-Announce
Hello all,

I am seeking some help and direction.  Using a Chrome.usb API to access ACS USB smart card reader.

chrome.usb.claimInterface(openedDevice has this error message:
Error in response to usb.claimInterface: Error claiming interface.

How can I fix it?


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  }
        ]
    }
]

}

Regards,
Chang Shin
Reply all
Reply to author
Forward
0 new messages