Reposting from https://groups.google.com/a/chromium.org/d/topic/chromium-apps/noGfn29Aed8/discussion for public reply.
I'm trying to develop a chrome app to communicate with an HID using the chrome.usb API. I am using these functions.
- chrome.usb.findDevices
- chrome.usb.controlTransfer
What I've tried so far does not work. The info in chrome://device-log/ shows this error message.
USB Event [13:54:01] Failed to open device: Entity not found
I am using right VendorId and ProductId in decimal format, Which I have extracted from device manager info.
Here is the code snippet I am using.
chrome.usb.findDevices(DEVICE_INFO, function (devices) {
if (!devices || !devices.length) {
console.log('device not found');
}
console.log("Devices: " + devices);
console.log(devices[0]);
var TransferData = {
"requestType": "class",
"recipient": "interface",
"direction": "out",
"request": 0xx9,
"value": 0xxx0,
"index": 0,
"data": new Uint8Array([00,05, 47, 76, 66, 48, 47,00]).buffer
};
setTimeout(function () {
chrome.usb.controlTransfer(devices[0], TransferData, function (config) {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError);
} else {
console.log('Data Transfer completed');
}
});
}, 3000);
});