Intent to Implement: Serial API

631 views
Skip to first unread message

Reilly Grant

unread,
Sep 17, 2018, 7:51:56 PM9/17/18
to blink-dev

Contact emails

rei...@chromium.org


Explainer

https://github.com/reillyeon/serial/blob/explainer/EXPLAINER.md


Spec

https://wicg.github.io/serial


Summary

The Serial API provides an interface for connecting to physical and virtual serial ports. It will share the same chooser-based permissions model as other hardware APIs such as Web Bluetooth and WebUSB. Development of the specification will proceed in parallel to implementation.


Motivation

Operating systems require applications to use different APIs depending on what interface a device exposes. The Serial API fills a gap left by Web Bluetooth and WebUSB where devices which implement a serial port interface are not covered by neither the former (because it does not support Bluetooth Classic) nor the latter (because a system driver has already claimed exclusive access to the device).


Risks

Interoperability and Compatibility

The primary risk of this API is that it will not be implemented by other vendors. It shared a lot with the Web Bluetooth and WebUSB APIs which so far have only been implemented by Chrome. While there have been no public signals from Edge and Safari it is clear from the fact that the original specification was abandoned by Mozilla (and their reaction to similar specifications) that Firefox’s position is negative. Web developers, commenting on the proposal to incubate this specification in the WICG, have displayed overwhelmingly positive support because of the possibilities it opens up for supporting additional hardware devices.


Edge: No signals

Firefox: Negative signals

Safari: No signals

Web developers: Positive signals


Ergonomics

Developers using this API may also be building applications that use other hardware APIs such as Web Bluetooth and WebUSB. Each of these interfaces have differences that reflect the underlying transport however we should be sure that user-facing abstractions such as permissions are handled in a consistent way. Integration with the Permissions API could, for example, permit authors to request permission to access a device across multiple API surfaces, this solving the problem of a device which may be accessible via the Serial API on platforms which include a driver for it, with a fallback to WebUSB on platforms without.


Activation

Developers should be able to take advantage of this API immediately. Those using the chrome.serial API (only available to Chrome Apps) will find it relatively easy to port their applications.


Debuggability

This is a JavaScript interface supported by the existing DevTools debugger.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

This feature will be supported by all platforms except Android WebView.


Is this feature fully tested by web-platform-tests?

No, but it will be.


Link to entry on the feature dashboard

https://www.chromestatus.com/feature/6577673212002304


Requesting approval to ship?

No.

Lucas Garron

unread,
Sep 17, 2018, 8:56:02 PM9/17/18
to Reilly Grant, blink-dev
Do you have any specific plans for UI treatment and content settings yet?

Bluetooth pairing has special case (tab icon only, no content setting or page info listing) that doesn't scale to many permissions, and I would personally like to see focus on the mental model of Page Info as the one-stop-shop for info and management of the current page's permissions.

»Lucas

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAEmk%3DMZAA3cQqnjYvZQzs4L1xWF3%3DbM0aruAsiJW74o%2BqGc_DQ%40mail.gmail.com.

Reilly Grant

unread,
Sep 18, 2018, 12:50:38 PM9/18/18
to lga...@chromium.org, blink-dev
The UI treatment will mirror that of WebUSB. The lack of content settings and page info listings for Web Bluetooth permissions is a bug and will be fixed when persistent permissions are implemented, as they are for WebUSB.
Reilly Grant | Software Engineer | rei...@chromium.org | Google Chrome


amir karimi

unread,
Sep 14, 2023, 7:28:28 AM9/14/23
to blink-dev, Reilly Grant, blink-dev, lga...@chromium.org
Hi,

I hope you are well.

I have been trying o get WebSerial working in my React app. It works fine in ideal conditions. However, if the serial device spams the serial port with a lot of data very fast before serialport.connect() happens, I get "BufferOverrunError".
I increased the buffer size from 255 to 4095 but still it fails. Is there any method to empty the buffer or recover from the error when this happens?

Thanks,

Amir

Reilly Grant

unread,
Sep 25, 2023, 1:54:03 PM9/25/23
to amir karimi, blink-dev, lga...@chromium.org
Errors such as buffer overruns are non-fatal. After the ReadableStream closes with an error the SerialPort's readable attribute is replaced by a new ReadableStream.  

Reilly Grant | Software Engineer | rei...@chromium.org | Google Chrome

Reply all
Reply to author
Forward
0 new messages