chiahao
chiahao

Reputation: 166

How chrome.usb.bulkTransfer read from DigitalPersona fingerprint reader?

I tried to read fingerprint from the DigitalPersona fingerprint reader.

Followed the api app_usb#bulk_transfers, I wrote the code:

//ignore the findDevice() part

var transferInfo = {
    "direction": "in",
    "endpoint": 3, //don't know where to find device protocol, 3 is a random number.
    "length": 318
}
chrome.usb.bulkTransfer(connectionHandle, transferInfo, function(event){
    console.log("got " + event.data.byteLength + " bytes");
});

but my result is "got 0 bytes". Why?

Upvotes: 2

Views: 928

Answers (1)

Supersharp
Supersharp

Reputation: 31199

To get the correct endpoint, you should call the chrome.usb.getConfiguration function.

The result will be an object with a property called interfaces.

If you enumerate the interfaces found, you'll find for each one a property called endpoints, which enumerates the available ones.

Choose the endpoint according to the communication channel you want:

  • in / out
  • bulk / interrupt / ...

Then, fetch its address property to populate the GenericTransferInfo endpoint attribute for the bulkTransfer function call.

var transferInfo = {
    "direction": "in",
    "endpoint": 132, //value of "address" for the bulkTransfer/in endpoint
    "length": 318
}

Upvotes: 1

Related Questions