Skip to content

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

PropertyModifierTypeDefault valueDescriptionDefined in
portreadonlySerialPortLikeundefinedThe underlying port.index.ts:167
closedreadonlyPromise<string>undefinedResolves once the connection has ended, with the reason (closed, port closed, device disconnected, read error: …).index.ts:169
bytesInpublicnumber0Bytes received so far.index.ts:174
bytesOutpublicnumber0Bytes written so far.index.ts:176

Methods

open()

ts
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

ParameterType
portSerialPortLike
optionsSerialOpenOptions
onData(bytes) => void

Returns

Promise<SerialConnection>


write()

ts
write(data, ending?): Promise<void>;

Defined in: index.ts:222

Write bytes, or text followed by ending.

Parameters

ParameterTypeDefault value
datastring | Uint8Array<ArrayBufferLike>undefined
endingLineEnding'none'

Returns

Promise<void>


setSignals()

ts
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

ParameterType
signals{ dataTerminalReady?: boolean; requestToSend?: boolean; }
signals.dataTerminalReady?boolean
signals.requestToSend?boolean

Returns

Promise<void>


resetViaRts()

ts
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

ParameterTypeDefault value
pulseMsnumber100

Returns

Promise<void>


close()

ts
close(): Promise<void>;

Defined in: index.ts:252

Stop reading and close the port; SerialConnection.closed resolves with closed.

Returns

Promise<void>