Access USB devices via WebUSB.

Synopsis

usb <subcommand> [options]

Description

Talks to USB devices through the browser's WebUSB API: enumerate, open, configure, and transfer data.

Options

list List currently-granted devices.

request [--vid 0x.. --pid 0x.. --class N --serial S] Open the device picker; prints a handle.

open <handle> / close <handle> Open or close a device.

reset <handle> Reset a device.

select-config <handle> <value> Select a configuration.

claim <handle> <interface> / release <handle> <interface> Claim or release an interface.

control-in <handle> <length> [setup flags] Control transfer, device to host.

control-out <handle> [setup flags] Control transfer, host to device (payload from stdin).

transfer-in <handle> <endpoint> <length> Bulk/interrupt transfer, device to host.

transfer-out <handle> <endpoint> Bulk/interrupt transfer, host to device (payload from stdin).

--request-type standard|class|vendor (default vendor); --recipient device|interface|endpoint|other (default device); --request N --value N --index N

--raw Emit raw bytes for *-in transfers (default: hex dump).

Examples

$ usb request

Open the browser's USB device picker.

$ usb list

List devices already granted to this origin.

$ usb transfer-in <handle> 1 64

Read up to 64 bytes from endpoint 1.

Notes

Requires WebUSB support and a user gesture for the device picker. Transfers are capped at 4194304 bytes (4 MiB).

See Also

hid, serial, esptool