WebUSB never sees device id, listed in Device manager

130 views
Skip to first unread message

Ben Nguyen

unread,
Mar 3, 2019, 6:37:28 PM3/3/19
to WebUSB

I'm using the latest chrome (72) , and I'm opening a local .html file that has example code developed for chrome 65, so not sure if anything has changed in the new version of Chrome that might be preventing it from retrieving the ids. I'm hesitant installing an older/portable version of chrome.


Interestingly, chrome://flags doesn't show anything for webusb, but instead has 'Enable new USB backend default. I also tried ' chrome.exe" --disable-web-security ' but this didn't seem to do anything different.


Is it possible that WebUsb only works if the html comes from an https server?

Devan Lai

unread,
Mar 4, 2019, 10:41:37 PM3/4/19
to WebUSB
Per section 3.1, WebUSB is only allowed in a secure context.

The spec basically says that whether file:/// urls are trustworthy and can be considered secure contexts is up to the user agent. As far as I can tell, Chrome considers file:/// urls as insecure contexts.

For production purposes, you would want to serve the HTML and JS for your WebUSB based site over HTTPS. For local development purposes, Chrome treats http://localhost as secure, so to test a static HTML file, you can spin up a simple HTTP file server with something like:
python -m SimpleHTTPServer

Ben Nguyen

unread,
Mar 5, 2019, 12:14:57 PM3/5/19
to WebUSB
Having the page served definitely made a difference.. now it gets a little further but errors with 'Can't Set Device Interface'.   I've tried changing the Interface number (0,1,2, etc) but no luck.

Since I'm using hardware (FTDI) that is not the same as the examples I'm following*.. I thought I'd flash the FTDI"s external eeprom to a known supported VID/PID combo (2341/8036).  

I also made an INF to force Windows7 to use winusb.sys.

This should work, right?  In all the examples I've seen, the USB is talking to a microcontroller (ex. Atmega) via UART.. which is the same thing I'm trying to do but with an FTDI chip that reports the proper VID/PID.  

Could it be that I'm running Windows 7?
Ben


Devan Lai

unread,
Mar 5, 2019, 1:41:52 PM3/5/19
to WebUSB
Unfortunately, that sample code will not work with your FTDI hardware.
The javascript in the sample effectively implements a USB CDC-ACM USB serial port driver.
FTDI USB-serial chips use a different USB interface that is not compatible with the USB CDC-ACM, so even if it were able to claim the interface correctly, it would not send the correct USB requests to move data.

Ben Nguyen

unread,
Mar 5, 2019, 10:42:39 PM3/5/19
to WebUSB
Thank you Devan!   Is there a list of classes/interfaces that WebUsb supports?

Swapping chips on  my board to something CDC compatible (like the MCP2200) would be quite a bit of work at this point..   but I'll keep an eye out on WebUsb for future designs.  

Cheers,
Ben

Reilly Grant

unread,
Mar 6, 2019, 1:10:40 AM3/6/19
to Ben Nguyen, WebUSB
WebUSB can support FTDI chips. It's just that the sample code you are looking at is for CDC-ACM chips. You need to write (slightly) different code to speak the FTDI protocol.

--
You received this message because you are subscribed to the Google Groups "WebUSB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webusb+un...@chromium.org.
To post to this group, send email to web...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/webusb/487b61be-6613-4fea-8c5e-716ea01d77ef%40chromium.org.

Benjamin Riggs

unread,
Mar 11, 2019, 4:40:49 PM3/11/19
to Ben Nguyen, WebUSB
WebUSB supports any USB but HID (because of OS driver reasons). The code example you linked to implements a USB CDC device.

I'm not familiar with FTDI USB interfaces, but presumably there's some way to make them behave as another kind of USB device, which will require different javascript.

The snippet I posted is what Chrome (and the standard) requires to establish a connection to the device, before any actual data transfers. This is true for any device, regardless of the class (excluding HID).

--
You received this message because you are subscribed to the Google Groups "WebUSB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webusb+un...@chromium.org.
To post to this group, send email to web...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/webusb/487b61be-6613-4fea-8c5e-716ea01d77ef%40chromium.org.


--
Benjamin Riggs
Pronouns: He / Him
Founder & CEO
Entropic Engineering LLC
670 Transfer Rd
St Paul, MN 55114

Benjamin Riggs

unread,
Mar 11, 2019, 4:40:49 PM3/11/19
to Ben Nguyen, WebUSB
Are you doing all of the necessary steps?

Ex:

        let device = await navigator.usb.requestDevice({ filters: [...filters] });

        await device.open();
        if ( device.configuration === null ) {
            await device.selectConfiguration( configuration_id /* probably 1 */);
        }
        await device.claimInterface( interface_id /* probably 0 */);

--
You received this message because you are subscribed to the Google Groups "WebUSB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webusb+un...@chromium.org.
To post to this group, send email to web...@chromium.org.
Reply all
Reply to author
Forward
0 new messages