10

Running Chrome 56.0.2924.76 (64-bit) on Windows 10 PRO Version 1511 (OS Build 10586.753). Have enabled experimental-web-platform-features on chrome, running it with flag --disable-webusb-security and as administrator. I try to get USB device list on localhost (using https) with getDevices but I get empty list, although chrome://device-log is showing me plenty of devices. What could be the issue?

navigator.usb.getDevices().then(function(devices){
    console.log(devices);
});
// console outputs []
Tauri28
  • 888
  • 1
  • 18
  • 30

1 Answers1

29

You should use requestDevice() before in order to get access permissions on selected devices.

navigator.usb.requestDevice({filters:[]}).then(function(device){
   console.log(device);
});

After that you'll be able to call getDevices().

Supersharp
  • 29,002
  • 9
  • 92
  • 134
  • From the Google documentation : https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web#get_access_to_usb_devices – Supersharp Feb 03 '17 at 09:04
  • Looks like I did not read it carefully enough because I was following the same article. Thanks. – Tauri28 Feb 03 '17 at 09:52