A USB API for bringing hardware innovation to the Web


#1

First, a bit of background: the Universal Serial Bus (USB) is the de-facto standard for wired peripherals. Most USB devices implement one of roughly a dozen standard “device classes” which specify a way for the device to advertize the features it supports and commands and data formats for using those features. Standard device classes include keyboard, mice, audio, video and storage devices. Operating systems support such devices using the “class driver” provided by the OS vendor. There is however a long tail of devices that do not fit into one of the standardized device classes. These devices require hardware vendors to write native drivers and SDKs in order for developers to take advantage of them.

I propose a new API, WebUSB which will give hardware manufacturers the ability to skip over all of the platform specific native code and build Javascript SDKs for their devices. This will be good for the web because, instead of waiting for a new kind device to be popular enough that its capabilities are standardized so that browser vendors can define an API, new and innovative hardware can be built for the web from day one.


#2

This sounds great.

I want device vendors to be able to create Javascript modules that speak USB to their devices and export a “safe” Javascript API to arbitrary Web pages. This would let vendors create and update Web APIs for their devices without browser vendors having to be involved — decentralized extensibility, untied from the schedules and priorities of browser vendors and standards bodies.

Your API is probably already adequate for this. An arbitrary page that wants to use a particular device could contain an


#3

Yes, the API is designed to allow and encourage this. A device vendor can create a Javascript module that loads their origin in an <iframe> and uses window.postMessage to communicate between the “application” and “driver.”

Edit: My post was cut off because I used the string <iframe> without escaping the ‘<’ so I’m guessing the same happened to you and we’re on the same page.


#4

Is this the same as the Current USB API if not, well there is one already, I can’t seem to find docs for it, but if you open the console in chrome canary navigator.usb is available, there are some methods there already


#5

Yes, it is. This thread was started to encourage the discussion of the proposal and specification that is currently being prototyped in Chrome.


#6

I’d support moving this proposal to WICG.

We [Intel] are currently going through an internal approval process to be able to participate in full capacity. So it may take some time before we can commit to working on it.


#7

An update on WebUSB:

We have made a lot of progress on the draft specification and welcome additional comments. An initial implementation based on that specification has been completed for Chrome’s desktop platforms (Linux, OS X and Windows). It is currently available behind a runtime flag (–enable-experimental-web-platform-features) and I am preparing to make it available to developers under the Experimental Framework currently under development so that early adopters may try it out with real users.

For developers who want to play around with it on real hardware I have created a fork of the Arduino IDE which converts an Arduino Leonardo or Pro Micro into a WebUSB-enabled device. Anyone using this should have a programming cable on hand as messing with the low-level USB code on your board will put it in a state where the normal programming method no longer works. Demos using these modifications are in the WebUSB specification repository.