Skip to content

@freeharmony-sdk/remote/read

The read alone, without the USB package: for an application, a browser page among them, that reaches the remote through a transport of its own and hands the read an object that answers its requests.

The read's own limit on retries, offered beside the read so that a caller of the read alone finds it here. The value lives once, in the USB package, beside the loop it bounds.

ConfigHeader

interface ConfigHeader {
  readonly family: Family;
  readonly endAddr: number;
  readonly format: number;
  /** Container length in bytes, end marker included. */
  readonly length: number;
}

What the first bytes of a configuration state: which container it is, where it ends, its format word, and the length that gives.

Uses Family.

DEFAULT_CHUNK_BYTES

const DEFAULT_CHUNK_BYTES = 16384

The bytes asked for in one request when ReadOptions.chunkBytes does not say, 16 KiB.

HEADER_PROBE

const HEADER_PROBE = 16

Enough bytes to hold the magic, end_addr and the format word.

isSilence

function isSilence(err: unknown): boolean

A reply that never came, as opposed to one that came back wrong.

Two shapes, because the command layer reports silence differently depending on where it happens: exchange says "no reply to command 0x10 within 3 polls" and readFlash says "flash read returned 0 of 256 bytes". Both mean the same thing here.

MAX_WINDOW_RETRIES

const MAX_WINDOW_RETRIES = 2

How many extra goes one window gets before the read fails.

parseHeader

function parseHeader(head: Uint8Array, profile: RemoteProfile): ConfigHeader

Read the container header and work out how long the whole thing is.

The magic is checked against every known family rather than against GSPM alone, so a container from an architecture not read yet still gets a sensible length instead of a refusal.

Uses RemoteProfile, ConfigHeader.