1
1
---
2
2
title : Read from and write to a serial port
3
- subhead : The Serial API allows websites to communicate with serial devices.
3
+ subhead : The Web Serial API allows websites to communicate with serial devices.
4
4
authors :
5
5
- beaufortfrancois
6
6
date : 2020-08-12
7
- updated : 2021-01-25
7
+ updated : 2021-02-03
8
8
hero : hero.jpg
9
9
thumbnail : thumbnail.jpg
10
10
alt : |
11
11
Old modems, routers, network equipment. Serial, phone, audio, ethernet connectors.
12
12
description : |
13
- The Serial API bridges the web and the physical world by allowing websites to communicate with serial devices.
13
+ The Web Serial API bridges the web and the physical world by allowing websites to communicate with serial devices.
14
14
tags :
15
15
- blog # blog is a required tag for the article to show up in the blog.
16
16
- capabilities
@@ -20,21 +20,21 @@ feedback:
20
20
---
21
21
22
22
{% Aside 'success' %}
23
- The Serial API, part of the [ capabilities project] ( /fugu-status/ ) , launched in
24
- Chrome  ; 89.
23
+ The Web Serial API, part of the [ capabilities project] ( /fugu-status/ ) , launched
24
+ in Chrome  ; 89.
25
25
{% endAside %}
26
26
27
- ## What is the Serial API? {: #what }
27
+ ## What is the Web Serial API? {: #what }
28
28
29
29
A serial port is a bidirectional communication interface that allows sending and
30
30
receiving data byte by byte.
31
31
32
- The Serial API provides a way for websites to read from and write to a serial
33
- device with JavaScript. Serial devices are connected either through a serial
34
- port on the user's system or through removable USB and Bluetooth devices that
35
- emulate a serial port.
32
+ The Web Serial API provides a way for websites to read from and write to a
33
+ serial device with JavaScript. Serial devices are connected either through a
34
+ serial port on the user's system or through removable USB and Bluetooth devices
35
+ that emulate a serial port.
36
36
37
- In other words, the Serial API bridges the web and the physical world by
37
+ In other words, the Web Serial API bridges the web and the physical world by
38
38
allowing websites to communicate with serial devices, such as microcontrollers
39
39
and 3D printers.
40
40
@@ -77,21 +77,21 @@ communication between the website and the device that it is controlling.
77
77
78
78
</div >
79
79
80
- ## Using the Serial API {: #use }
80
+ ## Using the Web Serial API {: #use }
81
81
82
82
### Feature detection {: #feature-detection }
83
83
84
- To check if the Serial API is supported, use:
84
+ To check if the Web Serial API is supported, use:
85
85
86
86
``` js
87
87
if (" serial" in navigator ) {
88
- // The Serial API is supported.
88
+ // The Web Serial API is supported.
89
89
}
90
90
```
91
91
92
92
### Open a serial port {: #open-port }
93
93
94
- The Serial API is asynchronous by design. This prevents the website UI from
94
+ The Web Serial API is asynchronous by design. This prevents the website UI from
95
95
blocking when awaiting input, which is important because serial data can be
96
96
received at any time, requiring a way to listen to it.
97
97
@@ -164,7 +164,7 @@ options are optional and have convenient [default values].
164
164
165
165
### Read from a serial port {: #read-port }
166
166
167
- Input and output streams in the Serial API are handled by the Streams API.
167
+ Input and output streams in the Web Serial API are handled by the Streams API.
168
168
169
169
{% Aside %}
170
170
If streams are new to you, check out [ Streams API
@@ -487,22 +487,23 @@ const [appReadable, devReadable] = port.readable.tee();
487
487
488
488
## Dev Tips {: #dev-tips }
489
489
490
- Debugging the Serial API in Chrome is easy with the internal page, ` chrome://device-log `
491
- where you can see all serial device related events in one single place.
490
+ Debugging the Web Serial API in Chrome is easy with the internal page,
491
+ ` chrome://device-log ` where you can see all serial device related events in one
492
+ single place.
492
493
493
494
<figure class =" w-figure " >
494
- <img src =" ./device-log-page-screenshot.jpg " class =" w-screenshot " alt =" Screenshot of the internal page for debugging the Serial API. " >
495
- <figcaption class =" w-figcaption " >Internal page in Chrome for debugging the Serial API.</figcaption >
495
+ <img src =" ./device-log-page-screenshot.jpg " class =" w-screenshot " alt =" Screenshot of the internal page for debugging the Web Serial API. " >
496
+ <figcaption class =" w-figcaption " >Internal page in Chrome for debugging the Web Serial API.</figcaption >
496
497
</figure >
497
498
498
499
## Codelab {: #codelab }
499
500
500
- In the [ Google Developer codelab] , you'll use the Serial API to interact with a
501
- [ BBC micro: bit ] board to show images on its 5x5 LED matrix.
501
+ In the [ Google Developer codelab] , you'll use the Web Serial API to interact
502
+ with a [ BBC micro: bit ] board to show images on its 5x5 LED matrix.
502
503
503
504
## Browser support {: #browser-support }
504
505
505
- The Serial API is available on all desktop platforms (Chrome OS, Linux, macOS,
506
+ The Web Serial API is available on all desktop platforms (Chrome OS, Linux, macOS,
506
507
and Windows) in Chrome 89.
507
508
508
509
## Polyfill {: #polyfill }
@@ -514,28 +515,28 @@ been claimed by a built-in device driver.
514
515
515
516
## Security and privacy {: #security-privacy }
516
517
517
- The spec authors have designed and implemented the Serial API using the core
518
+ The spec authors have designed and implemented the Web Serial API using the core
518
519
principles defined in [ Controlling Access to Powerful Web Platform Features] ,
519
520
including user control, transparency, and ergonomics. The ability to use this
520
521
API is primarily gated by a permission model that grants access to only a single
521
522
serial device at a time. In response to a user prompt, the user must take active
522
523
steps to select a particular serial device.
523
524
524
525
To understand the security tradeoffs, check out the [ security] and [ privacy]
525
- sections of the Serial API Explainer.
526
+ sections of the Web Serial API Explainer.
526
527
527
528
## Feedback {: #feedback }
528
529
529
530
The Chrome team would love to hear about your thoughts and experiences with the
530
- Serial API.
531
+ Web Serial API.
531
532
532
533
### Tell us about the API design
533
534
534
535
Is there something about the API that doesn't work as expected? Or are there
535
536
missing methods or properties that you need to implement your idea?
536
537
537
- File a spec issue on the [ Serial API GitHub repo] [ issues ] or add your thoughts
538
- to an existing issue.
538
+ File a spec issue on the [ Web Serial API GitHub repo] [ issues ] or add your
539
+ thoughts to an existing issue.
539
540
540
541
### Report a problem with the implementation
541
542
@@ -549,7 +550,7 @@ sharing quick and easy repros.
549
550
550
551
### Show support
551
552
552
- Are you planning to use the Serial API? Your public support helps the Chrome
553
+ Are you planning to use the Web Serial API? Your public support helps the Chrome
553
554
team prioritize features and shows other browser vendors how critical it is to
554
555
support them.
555
556
0 commit comments