esp-web-tools
Version:
Web tools for ESP devices
33 lines (32 loc) • 1.73 kB
TypeScript
/**
* Registry of WebUSB serial drivers.
*
* To add support for another USB-UART bridge:
* 1. Write `src/util/usb-serial/<chip>.ts` exporting a factory
* `(device: USBDevice) => UsbSerialDriver` (see driver.ts): an object that
* claims the interface, programs baud rate / modem lines and, if the chip
* frames its data, strips that framing in `processRead`. Keep the
* protocol maths in small exported pure functions.
* 2. Add an entry to `usbSerialDrivers` below holding the USB filters that
* identify the chip and a lazy `load` that imports the driver file.
* The device picker filters and the device-to-driver matching are generated
* from this list, and `UsbSerialPort` (port.ts) does everything else.
*
* The filters live here, and the driver code is imported lazily, because the
* picker needs the filters up front while the driver code is only needed for
* the device that was picked. That keeps each driver (and port.ts) in its own
* chunk that is fetched on demand.
*
* Order matters: the first definition whose filters match a device wins, so
* put chip specific drivers before the generic CDC-ACM one.
*/
import { type UsbSerialDriverDefinition } from "./driver";
export declare const usbSerialDrivers: UsbSerialDriverDefinition[];
/** Filters for `navigator.usb.requestDevice`. */
export declare const usbSerialFilters: () => USBDeviceFilter[];
export declare const findUsbSerialDriver: (device: USBDevice) => UsbSerialDriverDefinition | undefined;
/**
* Let the user pick a USB serial device and wrap it as a Web Serial port.
* Only the picked device's driver and port.ts are fetched.
*/
export declare const requestUsbSerialPort: () => Promise<SerialPort>;