I'm writing app for chromebook that has to communicate with specific USB device. The device is present in the list of found devices, that comes from callback:
var VENDOR_ID = 5824, PRODUCT_ID = 1159;
document.getElementById("request-permission").addEventListener('click', function() {
chrome.permissions.request({
permissions: [{
'usbDevices': [{
'vendorId': VENDOR_ID,
"productId": PRODUCT_ID
}]
}]
},
function(result) {
if (result) {
console.log('App was granted the "usbDevices" permission.');
getDevices();
}
}
});
});
function getDevices() {
chrome.usb.getDevices({
vendorId: VENDOR_ID,
productId: PRODUCT_ID
}, function(devices) {
if (chrome.runtime.lastError !== undefined) {
console.warn('chrome.usb.getDevices error: ' + chrome.runtime.lastError.message);
return;
}
if (devices) {
if (devices.length > 0) {
for (var device of devices)
openUsbDevice(device);
}
}
});
}
So I can see my device successfully, but when I'm trying to open it , it fails:
chrome.usb.openDevice(device, function(handle) {
if (chrome.runtime.lastError != undefined) {
console.log('Failed to open device: '+chrome.runtime.lastError.message);
} else {
populateDeviceInfo(handle, function () {
chrome.usb.closeDevice(handle);
});
}
});
And I'm receiving error in console: Failed to open device: Permission to access device was denied
I have all required usb permissions declared in manifest.js:
"permissions" : [
"usb"
],
"optional_permissions" : [{
"usbDevices" : [
{
"productId" : 1159,
"vendorId" : 5824
}
]
}],
I've also tried another api functions, like chrome.usb.findDevices and chrome.usb.requestAccess , but result is the same. At same time my nexus 7 device e.g. is recognised successfully via usb. Any ideas why that can be or guesses how to make my usb device become accessible? I've faced with this only on Acer Chromebook c7 (Chrome OS v.44) and on Mac I hadn't such issue.