Access serial ports via Web Serial.

Synopsis

serial <subcommand> [options]

Description

Talks to serial devices (microcontrollers, USB-serial adapters) through the browser's Web Serial API.

Options

list List currently-granted ports.

request [--vid 0x.. --pid 0x..] Open the port picker; prints a handle.

open <handle> [--baud N] [--data-bits N] [--stop-bits N] [--parity none|even|odd] [--flow-control none|hardware] [--buffer-size N] Open a port.

close <handle> Close a port.

read <handle> [--bytes N] [--until <hex>] [--timeout-ms N] [--hex] Read bytes.

write <handle> Write stdin bytes to the port.

signals <handle> get Print control input signals.

signals <handle> set [--dtr on|off] [--rts on|off] [--break on|off] Set control output signals.

Examples

$ serial request

Open the browser's serial port picker.

$ serial open <handle> --baud 115200

Open a port at 115200 baud.

$ echo hi | serial write <handle>

Write bytes to an open port.

$ serial read <handle> --hex

Read bytes and print them as a hex dump.

Notes

Requires Web Serial support and a user gesture for the device picker. Reads/writes are capped at 4194304 bytes (4 MiB). Used by esptool for flashing ESP32/ESP8266 chips.

See Also

usb, hid, esptool