probe-web / @probe-web/serial / SerialConnection
Class: SerialConnection
Defined in: index.ts:165
An open serial port with a read loop. Received bytes go to onData; the connection ends on close(), on unplug, or on a fatal read error (closed resolves with the reason).
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
port | readonly | SerialPortLike | undefined | The underlying port. | index.ts:167 |
closed | readonly | Promise<string> | undefined | Resolves once the connection has ended, with the reason (closed, port closed, device disconnected, read error: …). | index.ts:169 |
bytesIn | public | number | 0 | Bytes received so far. | index.ts:174 |
bytesOut | public | number | 0 | Bytes written so far. | index.ts:176 |
Methods
open()
static open(
port,
options,
onData
): Promise<SerialConnection>;Defined in: index.ts:187
Open port with options (8N1, no flow control unless set) and start reading; each received chunk is passed to onData.
Parameters
| Parameter | Type |
|---|---|
port | SerialPortLike |
options | SerialOpenOptions |
onData | (bytes) => void |
Returns
Promise<SerialConnection>
write()
write(data, ending?): Promise<void>;Defined in: index.ts:222
Write bytes, or text followed by ending.
Parameters
| Parameter | Type | Default value |
|---|---|---|
data | string | Uint8Array<ArrayBufferLike> | undefined |
ending | LineEnding | 'none' |
Returns
Promise<void>
setSignals()
setSignals(signals): Promise<void>;Defined in: index.ts:235
Set the DTR/RTS control lines. Throws if the port does not support control signals.
Parameters
| Parameter | Type |
|---|---|
signals | { dataTerminalReady?: boolean; requestToSend?: boolean; } |
signals.dataTerminalReady? | boolean |
signals.requestToSend? | boolean |
Returns
Promise<void>
resetViaRts()
resetViaRts(pulseMs?): Promise<void>;Defined in: index.ts:245
Pulse the target's reset through the bridge's RTS line, the wiring used by ESP devkits (RTS → EN, DTR → IO0). DTR stays deasserted so the chip boots the application rather than the ROM download mode.
Parameters
| Parameter | Type | Default value |
|---|---|---|
pulseMs | number | 100 |
Returns
Promise<void>
close()
close(): Promise<void>;Defined in: index.ts:252
Stop reading and close the port; SerialConnection.closed resolves with closed.
Returns
Promise<void>