Skip to content

probe-web / @probe-web/client / index / Client

Class: Client

Defined in: index.ts:375

A connection to probe-rs over one Transport: lists probes and chips, and attaches to a target to get a Session. Create one with Client.connect; call Client.close when done.

Properties

PropertyModifierTypeDescriptionDefined in
transportreadonly"websocket" | "webusb"Which transport this client uses.index.ts:389

Accessors

crashReason

Get Signature

ts
get crashReason(): string | null;

Defined in: index.ts:380

Why the local worker died, or null while it is alive (always null over WebSocket).

Returns

string | null

Methods

close()

ts
close(): void;

Defined in: index.ts:398

Close the transport: terminates the worker (releasing the USB device and the cross-tab lock) or drops the WebSocket. The client is unusable after.

Returns

void


connect()

ts
static connect(transport): Promise<Client>;

Defined in: index.ts:422

Connect to probe-rs. Loads the wasm module first (once per page).

Over WebSocket this opens the connection to probe-rs serve. Over WebUSB it starts the worker (or uses transport.worker) and watches it, so that if it dies later, calls fail with kind: 'worker-crashed' and the reason (also in Client.crashReason).

Parameters

ParameterType
transportTransport

Returns

Promise<Client>

Example

ts
// probe-rs in this tab, over WebUSB (the probe must already be granted to the page) …
const client = await Client.connect({ kind: 'webusb' });
// … or a native `probe-rs serve`, from any browser or Node
const remote = await Client.connect({ kind: 'websocket', url: 'ws://127.0.0.1:3000', token: 'secret' });

capabilities()

ts
capabilities(): {
  unsupportedEndpoints: string[];
  unsupportedTopics: string[];
};

Defined in: index.ts:447

RPC endpoint and topic paths the connected server does not implement. The WebUSB worker leaves out a few, such as core/disassemble.

Returns

ts
{
  unsupportedEndpoints: string[];
  unsupportedTopics: string[];
}
NameTypeDefined in
unsupportedEndpointsstring[]index.ts:447
unsupportedTopicsstring[]index.ts:447

supports()

ts
supports(path): boolean;

Defined in: index.ts:451

Whether the server implements an RPC endpoint path, e.g. "stack_trace/scopes".

Parameters

ParameterType
pathkeyof Endpoints

Returns

boolean


listProbes()

ts
listProbes(): Promise<DebugProbeEntry[]>;

Defined in: index.ts:459

The probes probe-rs can see. Over WebUSB that is only the probes already granted to the page; over WebSocket, those connected to the server's machine.

Returns

Promise<DebugProbeEntry[]>


listChipFamilies()

ts
listChipFamilies(): Promise<ChipFamily[]>;

Defined in: index.ts:463

Every chip family probe-rs knows, including any added with Client.loadChipFamily.

Returns

Promise<ChipFamily[]>


chipInfo()

ts
chipInfo(name): Promise<ChipData>;

Defined in: index.ts:467

Details (cores, memory map) of one chip by its probe-rs name.

Parameters

ParameterType
namestring

Returns

Promise<ChipData>


loadChipFamily()

ts
loadChipFamily(yaml): Promise<void>;

Defined in: index.ts:474

Teach probe-rs a chip family from target YAML, for chips it does not ship. The YAML can come from a CMSIS pack via @probe-web/client/targets.

Parameters

ParameterType
yamlstring

Returns

Promise<void>


info()

ts
info(opts, onEvent): Promise<void>;

Defined in: index.ts:479

Enumerate what is behind a probe (DP/AP, ROM tables, IDCODEs) with no chip definition.

Parameters

ParameterType
opts{ probe: DebugProbeEntry; protocol?: "Swd" | "Jtag"; speedKhz?: number; connectUnderReset?: boolean; targetSel?: number; scanChain?: number[]; }
opts.probeDebugProbeEntry
opts.protocol?"Swd" | "Jtag"
opts.speedKhz?number
opts.connectUnderReset?boolean
opts.targetSel?number
opts.scanChain?number[]
onEvent(e) => void

Returns

Promise<void>


attach()

ts
attach(opts): Promise<Session>;

Defined in: index.ts:499

Attach to a target through a probe and return a Session for it.

On WebUSB this also takes a cross-tab lock on the probe, because Chrome claims the USB interface per tab: a second tab gets kind: 'probe-in-use-other-tab' rather than an opaque USB failure. The lock is released by Client.close.

Parameters

ParameterType
optsAttachOptions

Returns

Promise<Session>