Reputation: 166
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
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:
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