esp-web-tools
Version:
Web tools for ESP devices
42 lines (41 loc) • 1.79 kB
TypeScript
import type { LineConfig, UsbSerialDriver } from "./driver";
/** Fill defaults and validate Web Serial options, like native Web Serial. */
export declare const toLineConfig: (options: SerialOptions) => LineConfig;
/**
* Web Serial `SerialPort` on top of a WebUSB device, for any registered
* driver. Implements the surface esptool-js, the Improv SDK and the console
* use. It is not structurally identical to the DOM `SerialPort` type.
*
* Behaviours that mirror native Web Serial (and that those consumers rely on):
* - `readable` hands out a fresh stream after the previous one was cancelled,
* and a read that was in flight at cancel time is delivered to the next
* stream so no bytes get lost.
* - Zero-length USB packets are skipped, never enqueued.
* - DTR and RTS are deasserted after `open()`.
*/
export declare class UsbSerialPort {
private readonly _device;
private readonly _createDriver;
private _driver?;
private _endpoints?;
private _options?;
private _readable;
private _writable;
private _pendingRead?;
private _signals;
private _break;
constructor(_device: USBDevice, _createDriver: (device: USBDevice) => UsbSerialDriver);
private get _bufferSize();
get readable(): ReadableStream<Uint8Array> | null;
get writable(): WritableStream<Uint8Array> | null;
/** Read one non-empty, driver-processed chunk from the IN endpoint. */
private _read;
open(options: SerialOptions): Promise<void>;
close(): Promise<void>;
forget(): Promise<void>;
getInfo(): SerialPortInfo;
/** Change line settings (baud rate, ...) of an open port. */
reconfigure(options: SerialOptions): Promise<void>;
setSignals(signals: SerialOutputSignals): Promise<void>;
private _requireDriver;
}