@springfield/ham-radio-api 18.7.0 → 18.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from "./radio/dcs.js";
17
17
  export * from "./radio/dialog-message.js";
18
18
  export * from "./radio/driver.js";
19
19
  export * from "./radio/driver-provider.js";
20
+ export * from "./radio/framing.js";
20
21
  export * from "./radio/id.js";
21
22
  export * from "./radio/memory-config.js";
22
23
  export * from "./radio/memory-map.js";
@@ -30,6 +31,7 @@ export * from "./radio/protocol.js";
30
31
  export * from "./radio/radio.js";
31
32
  export * from "./radio/schema.js";
32
33
  export * from "./radio/serial-config.js";
34
+ export * from "./radio/session-info.js";
33
35
  export * from "./radio/shared-components.js";
34
36
  export * from "./radio/settings.js";
35
37
  export * from "./radio/tone.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,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AAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AAExC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export * from "./radio/dcs.js";
17
17
  export * from "./radio/dialog-message.js";
18
18
  export * from "./radio/driver.js";
19
19
  export * from "./radio/driver-provider.js";
20
+ export * from "./radio/framing.js";
20
21
  export * from "./radio/id.js";
21
22
  export * from "./radio/memory-config.js";
22
23
  export * from "./radio/memory-map.js";
@@ -30,6 +31,7 @@ export * from "./radio/protocol.js";
30
31
  export * from "./radio/radio.js";
31
32
  export * from "./radio/schema.js";
32
33
  export * from "./radio/serial-config.js";
34
+ export * from "./radio/session-info.js";
33
35
  export * from "./radio/shared-components.js";
34
36
  export * from "./radio/settings.js";
35
37
  export * from "./radio/tone.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,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ressIndicator } from "./progress-indicator.js";
3
+ import type { RadioSessionInfo, RadioWriteOptions } from "./session-info.js";
3
4
  export interface RadioDriver {
4
5
  readRadio(serialPortPath: string, progressIndicator: RadioProgressIndicator): Promise<RadioMemory>;
5
- writeRadio(serialPortPath: string, memory: RadioMemory, progressIndicator: RadioProgressIndicator): Promise<void>;
6
+ writeRadio(serialPortPath: string, memory: RadioMemory, progressIndicator: RadioProgressIndicator, options?: RadioWriteOptions): Promise<void>;
7
+ /** Optional: last session extracts and firmware gate outcome (concrete driver in ham-radio-driver). */
8
+ getLastSessionInfo?(): RadioSessionInfo | undefined;
6
9
  }
7
10
  //# sourceMappingURL=driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/radio/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACnG,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnH"}
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/radio/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACnG,UAAU,CACR,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,WAAW,EACnB,iBAAiB,EAAE,sBAAsB,EACzC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,uGAAuG;IACvG,kBAAkB,CAAC,IAAI,gBAAgB,GAAG,SAAS,CAAC;CACrD"}
@@ -0,0 +1,92 @@
1
+ import type { RadioByteToken } from "./protocol.js";
2
+ /** Width and endianness for typed send/expect placeholders (`$length:u16le+8`, and so on). */
3
+ export type RadioIntegerType = "u8" | "u16le" | "u16be" | "u24le" | "u24be" | "u32le" | "u32be";
4
+ /**
5
+ * Named checksum algorithm. The `"sum8"` preset is shorthand for `{ sum8: {} }`: an 8-bit sum modulo 256
6
+ * with no ones' or twos' complement (catalogue check value `0xDD` for ASCII `"123456789"`).
7
+ */
8
+ export type RadioChecksumPreset = "crc16-xmodem" | "crc16-ibm-3740" | "crc16-kermit" | "crc16-modbus" | "crc16-arc" | "crc8-smbus" | "sum8" | "xor8";
9
+ /** Rocksoft-style CRC parameters (see the public CRC catalogue). */
10
+ export interface RadioCrcParameters {
11
+ width: 8 | 16 | 24 | 32;
12
+ poly: string;
13
+ init: string;
14
+ refIn: boolean;
15
+ refOut: boolean;
16
+ xorOut: string;
17
+ /** When set, the engine self-tests against this catalogue check value at load time. */
18
+ check?: string;
19
+ }
20
+ /**
21
+ * Checksum algorithm for a frame field. Use `{ sum8: { complement: "ones" | "twos" } }` for negated sums;
22
+ * omitted `complement` matches the `"sum8"` preset (plain modulo-256 sum).
23
+ */
24
+ export type RadioChecksumAlgorithm = RadioChecksumPreset | {
25
+ crc: RadioCrcParameters;
26
+ } | {
27
+ sum8: {
28
+ complement?: "ones" | "twos";
29
+ };
30
+ };
31
+ export type RadioFrameConstField = {
32
+ id: string;
33
+ type: "const";
34
+ bytes: RadioByteToken[];
35
+ };
36
+ export type RadioFrameLengthField = {
37
+ id: string;
38
+ type: "length";
39
+ size: 1 | 2 | 3 | 4;
40
+ endianness?: "little" | "big";
41
+ /** Field ids whose encoded sizes are summed (may include this field's own id). */
42
+ counts: string[];
43
+ adjust?: number;
44
+ };
45
+ export type RadioFramePayloadField = {
46
+ id: string;
47
+ type: "payload";
48
+ };
49
+ export type RadioFrameChecksumField = {
50
+ id: string;
51
+ type: "checksum";
52
+ algorithm: RadioChecksumAlgorithm;
53
+ endianness?: "little" | "big";
54
+ covers: string[];
55
+ };
56
+ export type RadioFrameField = RadioFrameConstField | RadioFrameLengthField | RadioFramePayloadField | RadioFrameChecksumField;
57
+ export interface RadioFrameTransformXor {
58
+ type: "xor";
59
+ covers: string[];
60
+ key: RadioByteToken[];
61
+ /** Where the repeating key index starts (default `"span"`). */
62
+ keyStart?: "span" | "frame";
63
+ }
64
+ export type RadioFrameTransform = RadioFrameTransformXor;
65
+ /** Decode options for the frame reader. Encode always computes checksums. */
66
+ export interface RadioFrameDecode {
67
+ /**
68
+ * When true (default), reject frames whose checksum does not match.
69
+ * Set false when radios return a placeholder checksum on replies; encode still writes the computed value.
70
+ */
71
+ verifyChecksum?: boolean;
72
+ /**
73
+ * How to recover after junk before a frame. Default `"header"` discards bytes until the layout header matches.
74
+ */
75
+ resync?: "header" | "none";
76
+ /**
77
+ * Maximum decoded frame size in bytes, counting every layout field (header, length, payload, checksum, footer).
78
+ * Exceeding this value is an error instead of a long read.
79
+ */
80
+ maxFrameBytes?: number;
81
+ /** Drop a received frame that matches the frame just sent (single-wire echo). Default false. */
82
+ discardEcho?: boolean;
83
+ }
84
+ /**
85
+ * Config-level link framing. Steps describe the payload only; the engine wraps sends and unwraps replies.
86
+ */
87
+ export interface RadioFraming {
88
+ layout: RadioFrameField[];
89
+ transforms?: RadioFrameTransform[];
90
+ decode?: RadioFrameDecode;
91
+ }
92
+ //# sourceMappingURL=framing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framing.d.ts","sourceRoot":"","sources":["../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+1 @@
1
+ {"version":3,"file":"framing.js","sourceRoot":"","sources":["../../src/radio/framing.ts"],"names":[],"mappings":""}
@@ -9,5 +9,7 @@ export interface RadioId {
9
9
  model: RadioModelId;
10
10
  name: string;
11
11
  manufacturer: string;
12
+ /** Optional catalog grouping for several firmware-specific configs (same hardware family). */
13
+ family?: string;
12
14
  }
13
15
  //# sourceMappingURL=id.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/radio/id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/radio/id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,4 +1,8 @@
1
1
  import type { RadioMemorySegment } from "./memory-segment.js";
2
+ /** EEPROM ranges that must never be written; overlapping write plans are refused. */
3
+ export interface RadioProtectedRange extends RadioMemorySegment {
4
+ reason?: string;
5
+ }
2
6
  export interface RadioMemoryConfig {
3
7
  chunkSize: number;
4
8
  addressSize: number;
@@ -6,5 +10,6 @@ export interface RadioMemoryConfig {
6
10
  segments: {
7
11
  [segmentName: string]: RadioMemorySegment;
8
12
  };
13
+ protect?: RadioProtectedRange[];
9
14
  }
10
15
  //# sourceMappingURL=memory-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory-config.d.ts","sourceRoot":"","sources":["../../src/radio/memory-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,KAAK,GAAG,QAAQ,CAAC;IACpC,QAAQ,EAAE;QACR,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,CAAC;KAC3C,CAAC;CACH"}
1
+ {"version":3,"file":"memory-config.d.ts","sourceRoot":"","sources":["../../src/radio/memory-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,qFAAqF;AACrF,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,KAAK,GAAG,QAAQ,CAAC;IACpC,QAAQ,EAAE;QACR,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,CAAC;KAC3C,CAAC;IACF,OAAO,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACjC"}
@@ -1,3 +1,4 @@
1
+ import type { RadioIntegerType } from "./framing.js";
1
2
  import type { RadioMemorySegment } from "./memory-segment.js";
2
3
  /**
3
4
  * A byte in a send or expect array.
@@ -5,7 +6,15 @@ import type { RadioMemorySegment } from "./memory-segment.js";
5
6
  * - number 0–255: literal byte
6
7
  * - hex string such as `"0x50"`: literal byte
7
8
  * - single-character string such as `"S"`: ASCII opcode
8
- * - placeholder: `"$address"`, `"$block"`, `"$chunkSize"`, `"$length"`, `"$data"`
9
+ * - `"$data"`: current chunk payload
10
+ * - placeholders: `"$address"`, `"$block"`, `"$chunkSize"`, `"$length"`, `"$session"`
11
+ * - typed placeholders: `"$length:u16le+8"`, `"$address:u24le"` (optional `:type` and signed `+n` / `-n` offset)
12
+ * - extracted session values: `"$var.<name>"` with optional type suffix
13
+ *
14
+ * Untyped `$length`, `$chunkSize` and `$address` keep legacy widths (1 byte and `memoryConfig.addressSize`).
15
+ *
16
+ * In `expect`, a typed `$length` (for example `$length:u16le+4`) is read from the reply and sets how many
17
+ * bytes `$data` covers; it is not compared to the planned chunk length. A later untyped `$length` token must agree.
9
18
  */
10
19
  export type RadioByteToken = number | string;
11
20
  /**
@@ -20,6 +29,13 @@ export interface RadioExpectBytes {
20
29
  export interface RadioExpectUntil {
21
30
  until: RadioByteToken;
22
31
  }
32
+ /**
33
+ * Match the start of a decoded payload whose total length is not fixed (for example a hello version field).
34
+ * Requires config-level `RadioFraming`; use only on framed steps.
35
+ */
36
+ export interface RadioExpectPrefix {
37
+ prefix: RadioByteToken[];
38
+ }
23
39
  /**
24
40
  * Expected serial reply for an exchange.
25
41
  *
@@ -27,8 +43,74 @@ export interface RadioExpectUntil {
27
43
  * - token array: exact multi-byte match, or a framed reply with `$` placeholders
28
44
  * - `{ bytes: N }`: any N bytes
29
45
  * - `{ until: token }`: variable-length reply ending at the delimiter (the delimiter is not included)
46
+ * - `{ prefix: tokens }`: payload must start with the given tokens (framed links only)
30
47
  */
31
- export type RadioExpect = RadioByteToken | RadioByteToken[] | RadioExpectBytes | RadioExpectUntil;
48
+ export type RadioExpect = RadioByteToken | RadioByteToken[] | RadioExpectBytes | RadioExpectUntil | RadioExpectPrefix;
49
+ /**
50
+ * Slice of a decoded exchange payload stored for the rest of the session (`$var.<name>`).
51
+ * When `length` is omitted, bytes from `offset` through the end of the decoded payload are stored.
52
+ */
53
+ export interface RadioExtract {
54
+ offset: number;
55
+ length?: number;
56
+ type: "ascii" | "bytes" | "hex" | RadioIntegerType;
57
+ trim?: "nul";
58
+ }
59
+ /**
60
+ * Re-send policy for an exchange or chunked read/write step.
61
+ * `attempts` is the total number of tries (not retries-after-first); the driver makes a single attempt when `retry` is omitted.
62
+ */
63
+ export interface RadioRetry {
64
+ attempts: number;
65
+ delayMs?: number;
66
+ on?: ("timeout" | "mismatch")[];
67
+ }
68
+ export interface RadioFailWhen {
69
+ prefix: RadioByteToken[];
70
+ message: string;
71
+ }
72
+ /** Per-chunk read-back after an accepted write (when enabled by `RadioWriteOptions.verify`). */
73
+ export interface RadioWriteVerify {
74
+ send: RadioByteToken[];
75
+ expect: RadioExpect;
76
+ timeout?: number;
77
+ }
78
+ export type RadioFirmwareMatch = {
79
+ exact: string[];
80
+ } | {
81
+ prefix: string | string[];
82
+ } | {
83
+ regex: string;
84
+ /**
85
+ * When set, the `regex` must define a named `version` capture group compared against this semver range.
86
+ */
87
+ semver?: string;
88
+ };
89
+ /**
90
+ * Firmware gate checked before the first memory step. Requires a matching exchange `extract` earlier in the same phase.
91
+ * Default mismatch behaviour when `onMismatch` is omitted: read warns, write refuses.
92
+ */
93
+ export interface RadioFirmwareRule {
94
+ variable: string;
95
+ label: string;
96
+ match: RadioFirmwareMatch;
97
+ onMismatch?: {
98
+ write?: "refuse";
99
+ read?: "refuse" | "warn" | "allow";
100
+ };
101
+ message?: string;
102
+ }
103
+ /**
104
+ * Session token emitted as `$session` for every send in a read or write run.
105
+ */
106
+ export interface RadioSession {
107
+ token: {
108
+ length: number;
109
+ value: "random" | RadioByteToken[];
110
+ };
111
+ /** Programming-mode idle limit; used for retry budgeting (not a hard engine timeout). */
112
+ idleTimeoutMs?: number;
113
+ }
32
114
  /**
33
115
  * Packer that converts live CAT replies into a logical memory-map record.
34
116
  * `kenwood-th-f6` parses `MR`/`MNA` CSV into the 32-byte TH-F6 channel image.
@@ -48,10 +130,9 @@ export interface RadioCatMemoryConfig {
48
130
  interCommandDelayMs?: number;
49
131
  }
50
132
  /**
51
- * One serial exchange: send bytes and/or wait for a reply, and/or change baud.
52
- * At least one of `send`, `expect`, or `setBaudRate` must be present.
133
+ * Serial exchange without session `extract`, `retry` or `failWhen` (per-chunk ack sub-exchanges and `RadioOnError` cleanup).
53
134
  */
54
- export interface RadioExchange {
135
+ export interface RadioProtocolExchangeStep {
55
136
  description?: string;
56
137
  send?: RadioByteToken[];
57
138
  expect?: RadioExpect;
@@ -65,10 +146,23 @@ export interface RadioExchange {
65
146
  * enters programming at 9600 then transfers at 57600.
66
147
  */
67
148
  setBaudRate?: number;
149
+ /** When false, send and receive raw bytes (default uses config `framing` when present). */
150
+ framed?: boolean;
151
+ }
152
+ /**
153
+ * One serial exchange: send bytes and/or wait for a reply, and/or change baud.
154
+ * At least one of `send`, `expect`, or `setBaudRate` must be present.
155
+ * `extract`, `retry` and `failWhen` are limited to top-level exchange steps, not `read.ack` or `onError` cleanup.
156
+ */
157
+ export interface RadioExchange extends RadioProtocolExchangeStep {
158
+ /** Exchange-only: copy slices of the decoded payload into `var.<name>`. */
159
+ extract?: Record<string, RadioExtract>;
160
+ retry?: RadioRetry;
161
+ failWhen?: RadioFailWhen[];
68
162
  }
69
163
  /**
70
164
  * Chunked memory read: repeat an exchange across named segments.
71
- * `$data` in `expect` is captured into the memory buffer.
165
+ * `$data` in `expect` is stored into the memory buffer.
72
166
  * Optional `ack` is a second exchange after each chunk (for example an ACK).
73
167
  * Optional `delay` is milliseconds to wait after each accepted chunk (Kenwood
74
168
  * TM-D710A clone at 57600 needs this so the next `R` does not outrun the radio).
@@ -84,10 +178,12 @@ export interface RadioReadStep {
84
178
  segments: string[];
85
179
  send: RadioByteToken[];
86
180
  expect: RadioExpect;
87
- ack?: RadioExchange;
181
+ ack?: RadioProtocolExchangeStep;
88
182
  timeout?: number;
89
183
  delay?: number;
90
184
  ready?: RadioByteToken;
185
+ framed?: boolean;
186
+ retry?: RadioRetry;
91
187
  };
92
188
  }
93
189
  /**
@@ -97,6 +193,8 @@ export interface RadioReadStep {
97
193
  * Optional `chunkSize` overrides `memoryConfig.chunkSize` (UV-5R clone writes 16-byte blocks).
98
194
  * Optional `delay` is milliseconds to wait after each accepted block (UV-5R clone waits 50ms).
99
195
  * Optional `skip` lists inclusive radio-address ranges that must not be uploaded.
196
+ * Optional `alignment` requires chunk start and length to be multiples of that value.
197
+ * Optional `verify` re-reads each chunk when the caller enables verify (see `RadioWriteOptions`).
100
198
  */
101
199
  export interface RadioWriteStep {
102
200
  description?: string;
@@ -108,6 +206,10 @@ export interface RadioWriteStep {
108
206
  chunkSize?: number;
109
207
  delay?: number;
110
208
  skip?: RadioMemorySegment[];
209
+ framed?: boolean;
210
+ retry?: RadioRetry;
211
+ verify?: RadioWriteVerify;
212
+ alignment?: number;
111
213
  };
112
214
  }
113
215
  /**
@@ -125,11 +227,6 @@ export interface RadioCatWriteStep {
125
227
  catWrite: RadioCatMemoryConfig;
126
228
  }
127
229
  export type RadioProtocolStep = RadioExchange | RadioReadStep | RadioWriteStep | RadioCatReadStep | RadioCatWriteStep;
128
- /**
129
- * Exchange-only protocol steps (`send`, `expect`, `setBaudRate`, `delay`, `timeout`).
130
- * Used for {@link RadioOnError} cleanup lists, which must not include read, write, or CAT loop steps.
131
- */
132
- export type RadioProtocolExchangeStep = RadioExchange;
133
230
  /**
134
231
  * Optional cleanup exchanges keyed by memory operation. The driver runs the matching list
135
232
  * best-effort after a protocol step fails or the user cancels; it is not run on success and is
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/radio/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,cAAc,EAAE,GAAG,gBAAgB,GAAG,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G;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACzC,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;CAC3C"}
@@ -1,7 +1,8 @@
1
1
  import type { RadioId } from "./id.js";
2
2
  import type { RadioMemoryConfig } from "./memory-config.js";
3
3
  import type { RadioMemoryMap } from "./memory-map.js";
4
- import type { RadioOnError, RadioProtocolStep } from "./protocol.js";
4
+ import type { RadioFraming } from "./framing.js";
5
+ import type { RadioFirmwareRule, RadioOnError, RadioProtocolStep, RadioSession } from "./protocol.js";
5
6
  import type { RadioSchema } from "./schema.js";
6
7
  import type { RadioDialogMessage } from "./dialog-message.js";
7
8
  import type { RadioSerialConfig } from "./serial-config.js";
@@ -21,6 +22,10 @@ export interface Radio {
21
22
  memoryConfig: RadioMemoryConfig;
22
23
  serialConfig: RadioSerialConfig;
23
24
  readMemory: RadioProtocolStep[];
25
+ /**
26
+ * Write protocol steps. An empty array means read-only: the driver throws `ReadOnlyDriverError` on write
27
+ * (see ham-radio-driver).
28
+ */
24
29
  writeMemory: RadioProtocolStep[];
25
30
  /**
26
31
  * Optional cleanup exchanges after a failed or cancelled read/write. Not run on success;
@@ -38,5 +43,11 @@ export interface Radio {
38
43
  memoryMap?: RadioMemoryMap | {
39
44
  $ref: string;
40
45
  };
46
+ /** When set, wraps every exchange and chunked read/write payload (see ADR 0014). */
47
+ framing?: RadioFraming;
48
+ /** Per-session token for `$session` on framed radios. */
49
+ session?: RadioSession;
50
+ /** Checked before the first memory step; requires a matching `extract` on an earlier exchange. */
51
+ firmware?: RadioFirmwareRule;
41
52
  }
42
53
  //# sourceMappingURL=radio.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,o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,MAAM,eAAe,CAAC;AACtG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;IAChC,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC;;;OAGG;IACH,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,oFAAoF;IACpF,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,yDAAyD;IACzD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Optional fourth argument to `RadioDriver.writeRadio`.
3
+ * When `verify` is `false`, the driver skips per-chunk read-back even if the write step defines `verify`.
4
+ */
5
+ export interface RadioWriteOptions {
6
+ verify?: boolean;
7
+ }
8
+ export type RadioFirmwareGateAction = "pass" | "allow" | "warn" | "refuse";
9
+ /** Result of the last `RadioDriver.readRadio` or `RadioDriver.writeRadio` session. */
10
+ export interface RadioSessionInfo {
11
+ operation: "readMemory" | "writeMemory";
12
+ /** False when the session ended in cancellation or an error before normal completion. */
13
+ completed: boolean;
14
+ /** Values from exchange `extract` steps, keyed by name. */
15
+ extracts: Record<string, string | number | number[]>;
16
+ firmware?: {
17
+ variable: string;
18
+ value?: string;
19
+ label: string;
20
+ matched: boolean;
21
+ action: RadioFirmwareGateAction;
22
+ };
23
+ verify?: {
24
+ enabled: boolean;
25
+ chunksVerified: number;
26
+ };
27
+ }
28
+ //# sourceMappingURL=session-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-info.d.ts","sourceRoot":"","sources":["../../src/radio/session-info.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3E,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,YAAY,GAAG,aAAa,CAAC;IACxC,yFAAyF;IACzF,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,uBAAuB,CAAC;KACjC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=session-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-info.js","sourceRoot":"","sources":["../../src/radio/session-info.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springfield/ham-radio-api",
3
- "version": "18.7.0",
3
+ "version": "18.8.0",
4
4
  "author": "Bryan Hunt",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -22,7 +22,7 @@
22
22
  "test": "vitest run",
23
23
  "commitlint": "commitlint --edit",
24
24
  "format": "oxfmt",
25
- "lint": "oxlint",
25
+ "lint": "oxlint && tsc -p tsconfig.test.json",
26
26
  "lint:fix": "oxlint --fix --fix-suggestions",
27
27
  "release": "semantic-release",
28
28
  "prepare": "husky && yarn build"
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ export * from "./radio/dcs.js";
19
19
  export * from "./radio/dialog-message.js";
20
20
  export * from "./radio/driver.js";
21
21
  export * from "./radio/driver-provider.js";
22
+ export * from "./radio/framing.js";
22
23
  export * from "./radio/id.js";
23
24
  export * from "./radio/memory-config.js";
24
25
  export * from "./radio/memory-map.js";
@@ -32,6 +33,7 @@ export * from "./radio/protocol.js";
32
33
  export * from "./radio/radio.js";
33
34
  export * from "./radio/schema.js";
34
35
  export * from "./radio/serial-config.js";
36
+ export * from "./radio/session-info.js";
35
37
  export * from "./radio/shared-components.js";
36
38
  export * from "./radio/settings.js";
37
39
  export * from "./radio/tone.js";
@@ -1,7 +1,15 @@
1
1
  import type { RadioMemory } from "./memory.js";
2
2
  import type { RadioProgressIndicator } from "./progress-indicator.js";
3
+ import type { RadioSessionInfo, RadioWriteOptions } from "./session-info.js";
3
4
 
4
5
  export interface RadioDriver {
5
6
  readRadio(serialPortPath: string, progressIndicator: RadioProgressIndicator): Promise<RadioMemory>;
6
- writeRadio(serialPortPath: string, memory: RadioMemory, progressIndicator: RadioProgressIndicator): Promise<void>;
7
+ writeRadio(
8
+ serialPortPath: string,
9
+ memory: RadioMemory,
10
+ progressIndicator: RadioProgressIndicator,
11
+ options?: RadioWriteOptions,
12
+ ): Promise<void>;
13
+ /** Optional: last session extracts and firmware gate outcome (concrete driver in ham-radio-driver). */
14
+ getLastSessionInfo?(): RadioSessionInfo | undefined;
7
15
  }
@@ -0,0 +1,113 @@
1
+ import type { RadioByteToken } from "./protocol.js";
2
+
3
+ /** Width and endianness for typed send/expect placeholders (`$length:u16le+8`, and so on). */
4
+ export type RadioIntegerType = "u8" | "u16le" | "u16be" | "u24le" | "u24be" | "u32le" | "u32be";
5
+
6
+ /**
7
+ * Named checksum algorithm. The `"sum8"` preset is shorthand for `{ sum8: {} }`: an 8-bit sum modulo 256
8
+ * with no ones' or twos' complement (catalogue check value `0xDD` for ASCII `"123456789"`).
9
+ */
10
+ export type RadioChecksumPreset =
11
+ | "crc16-xmodem"
12
+ | "crc16-ibm-3740"
13
+ | "crc16-kermit"
14
+ | "crc16-modbus"
15
+ | "crc16-arc"
16
+ | "crc8-smbus"
17
+ | "sum8"
18
+ | "xor8";
19
+
20
+ /** Rocksoft-style CRC parameters (see the public CRC catalogue). */
21
+ export interface RadioCrcParameters {
22
+ width: 8 | 16 | 24 | 32;
23
+ poly: string;
24
+ init: string;
25
+ refIn: boolean;
26
+ refOut: boolean;
27
+ xorOut: string;
28
+ /** When set, the engine self-tests against this catalogue check value at load time. */
29
+ check?: string;
30
+ }
31
+
32
+ /**
33
+ * Checksum algorithm for a frame field. Use `{ sum8: { complement: "ones" | "twos" } }` for negated sums;
34
+ * omitted `complement` matches the `"sum8"` preset (plain modulo-256 sum).
35
+ */
36
+ export type RadioChecksumAlgorithm =
37
+ | RadioChecksumPreset
38
+ | { crc: RadioCrcParameters }
39
+ | { sum8: { complement?: "ones" | "twos" } };
40
+
41
+ export type RadioFrameConstField = {
42
+ id: string;
43
+ type: "const";
44
+ bytes: RadioByteToken[];
45
+ };
46
+
47
+ export type RadioFrameLengthField = {
48
+ id: string;
49
+ type: "length";
50
+ size: 1 | 2 | 3 | 4;
51
+ endianness?: "little" | "big";
52
+ /** Field ids whose encoded sizes are summed (may include this field's own id). */
53
+ counts: string[];
54
+ adjust?: number;
55
+ };
56
+
57
+ export type RadioFramePayloadField = {
58
+ id: string;
59
+ type: "payload";
60
+ };
61
+
62
+ export type RadioFrameChecksumField = {
63
+ id: string;
64
+ type: "checksum";
65
+ algorithm: RadioChecksumAlgorithm;
66
+ endianness?: "little" | "big";
67
+ covers: string[];
68
+ };
69
+
70
+ export type RadioFrameField =
71
+ | RadioFrameConstField
72
+ | RadioFrameLengthField
73
+ | RadioFramePayloadField
74
+ | RadioFrameChecksumField;
75
+
76
+ export interface RadioFrameTransformXor {
77
+ type: "xor";
78
+ covers: string[];
79
+ key: RadioByteToken[];
80
+ /** Where the repeating key index starts (default `"span"`). */
81
+ keyStart?: "span" | "frame";
82
+ }
83
+
84
+ export type RadioFrameTransform = RadioFrameTransformXor;
85
+
86
+ /** Decode options for the frame reader. Encode always computes checksums. */
87
+ export interface RadioFrameDecode {
88
+ /**
89
+ * When true (default), reject frames whose checksum does not match.
90
+ * Set false when radios return a placeholder checksum on replies; encode still writes the computed value.
91
+ */
92
+ verifyChecksum?: boolean;
93
+ /**
94
+ * How to recover after junk before a frame. Default `"header"` discards bytes until the layout header matches.
95
+ */
96
+ resync?: "header" | "none";
97
+ /**
98
+ * Maximum decoded frame size in bytes, counting every layout field (header, length, payload, checksum, footer).
99
+ * Exceeding this value is an error instead of a long read.
100
+ */
101
+ maxFrameBytes?: number;
102
+ /** Drop a received frame that matches the frame just sent (single-wire echo). Default false. */
103
+ discardEcho?: boolean;
104
+ }
105
+
106
+ /**
107
+ * Config-level link framing. Steps describe the payload only; the engine wraps sends and unwraps replies.
108
+ */
109
+ export interface RadioFraming {
110
+ layout: RadioFrameField[];
111
+ transforms?: RadioFrameTransform[];
112
+ decode?: RadioFrameDecode;
113
+ }
package/src/radio/id.ts CHANGED
@@ -10,4 +10,6 @@ export interface RadioId {
10
10
  model: RadioModelId;
11
11
  name: string;
12
12
  manufacturer: string;
13
+ /** Optional catalog grouping for several firmware-specific configs (same hardware family). */
14
+ family?: string;
13
15
  }
@@ -1,5 +1,10 @@
1
1
  import type { RadioMemorySegment } from "./memory-segment.js";
2
2
 
3
+ /** EEPROM ranges that must never be written; overlapping write plans are refused. */
4
+ export interface RadioProtectedRange extends RadioMemorySegment {
5
+ reason?: string;
6
+ }
7
+
3
8
  export interface RadioMemoryConfig {
4
9
  chunkSize: number;
5
10
  addressSize: number;
@@ -7,4 +12,5 @@ export interface RadioMemoryConfig {
7
12
  segments: {
8
13
  [segmentName: string]: RadioMemorySegment;
9
14
  };
15
+ protect?: RadioProtectedRange[];
10
16
  }
@@ -1,3 +1,4 @@
1
+ import type { RadioIntegerType } from "./framing.js";
1
2
  import type { RadioMemorySegment } from "./memory-segment.js";
2
3
 
3
4
  /**
@@ -6,7 +7,15 @@ import type { RadioMemorySegment } from "./memory-segment.js";
6
7
  * - number 0–255: literal byte
7
8
  * - hex string such as `"0x50"`: literal byte
8
9
  * - single-character string such as `"S"`: ASCII opcode
9
- * - placeholder: `"$address"`, `"$block"`, `"$chunkSize"`, `"$length"`, `"$data"`
10
+ * - `"$data"`: current chunk payload
11
+ * - placeholders: `"$address"`, `"$block"`, `"$chunkSize"`, `"$length"`, `"$session"`
12
+ * - typed placeholders: `"$length:u16le+8"`, `"$address:u24le"` (optional `:type` and signed `+n` / `-n` offset)
13
+ * - extracted session values: `"$var.<name>"` with optional type suffix
14
+ *
15
+ * Untyped `$length`, `$chunkSize` and `$address` keep legacy widths (1 byte and `memoryConfig.addressSize`).
16
+ *
17
+ * In `expect`, a typed `$length` (for example `$length:u16le+4`) is read from the reply and sets how many
18
+ * bytes `$data` covers; it is not compared to the planned chunk length. A later untyped `$length` token must agree.
10
19
  */
11
20
  export type RadioByteToken = number | string;
12
21
 
@@ -24,6 +33,14 @@ export interface RadioExpectUntil {
24
33
  until: RadioByteToken;
25
34
  }
26
35
 
36
+ /**
37
+ * Match the start of a decoded payload whose total length is not fixed (for example a hello version field).
38
+ * Requires config-level `RadioFraming`; use only on framed steps.
39
+ */
40
+ export interface RadioExpectPrefix {
41
+ prefix: RadioByteToken[];
42
+ }
43
+
27
44
  /**
28
45
  * Expected serial reply for an exchange.
29
46
  *
@@ -31,8 +48,85 @@ export interface RadioExpectUntil {
31
48
  * - token array: exact multi-byte match, or a framed reply with `$` placeholders
32
49
  * - `{ bytes: N }`: any N bytes
33
50
  * - `{ until: token }`: variable-length reply ending at the delimiter (the delimiter is not included)
51
+ * - `{ prefix: tokens }`: payload must start with the given tokens (framed links only)
34
52
  */
35
- export type RadioExpect = RadioByteToken | RadioByteToken[] | RadioExpectBytes | RadioExpectUntil;
53
+ export type RadioExpect =
54
+ | RadioByteToken
55
+ | RadioByteToken[]
56
+ | RadioExpectBytes
57
+ | RadioExpectUntil
58
+ | RadioExpectPrefix;
59
+
60
+ /**
61
+ * Slice of a decoded exchange payload stored for the rest of the session (`$var.<name>`).
62
+ * When `length` is omitted, bytes from `offset` through the end of the decoded payload are stored.
63
+ */
64
+ export interface RadioExtract {
65
+ offset: number;
66
+ length?: number;
67
+ type: "ascii" | "bytes" | "hex" | RadioIntegerType;
68
+ trim?: "nul";
69
+ }
70
+
71
+ /**
72
+ * Re-send policy for an exchange or chunked read/write step.
73
+ * `attempts` is the total number of tries (not retries-after-first); the driver makes a single attempt when `retry` is omitted.
74
+ */
75
+ export interface RadioRetry {
76
+ attempts: number;
77
+ delayMs?: number;
78
+ on?: ("timeout" | "mismatch")[];
79
+ }
80
+
81
+ export interface RadioFailWhen {
82
+ prefix: RadioByteToken[];
83
+ message: string;
84
+ }
85
+
86
+ /** Per-chunk read-back after an accepted write (when enabled by `RadioWriteOptions.verify`). */
87
+ export interface RadioWriteVerify {
88
+ send: RadioByteToken[];
89
+ expect: RadioExpect;
90
+ timeout?: number;
91
+ }
92
+
93
+ export type RadioFirmwareMatch =
94
+ | { exact: string[] }
95
+ | { prefix: string | string[] }
96
+ | {
97
+ regex: string;
98
+ /**
99
+ * When set, the `regex` must define a named `version` capture group compared against this semver range.
100
+ */
101
+ semver?: string;
102
+ };
103
+
104
+ /**
105
+ * Firmware gate checked before the first memory step. Requires a matching exchange `extract` earlier in the same phase.
106
+ * Default mismatch behaviour when `onMismatch` is omitted: read warns, write refuses.
107
+ */
108
+ export interface RadioFirmwareRule {
109
+ variable: string;
110
+ label: string;
111
+ match: RadioFirmwareMatch;
112
+ onMismatch?: {
113
+ write?: "refuse";
114
+ read?: "refuse" | "warn" | "allow";
115
+ };
116
+ message?: string;
117
+ }
118
+
119
+ /**
120
+ * Session token emitted as `$session` for every send in a read or write run.
121
+ */
122
+ export interface RadioSession {
123
+ token: {
124
+ length: number;
125
+ value: "random" | RadioByteToken[];
126
+ };
127
+ /** Programming-mode idle limit; used for retry budgeting (not a hard engine timeout). */
128
+ idleTimeoutMs?: number;
129
+ }
36
130
 
37
131
  /**
38
132
  * Packer that converts live CAT replies into a logical memory-map record.
@@ -55,10 +149,9 @@ export interface RadioCatMemoryConfig {
55
149
  }
56
150
 
57
151
  /**
58
- * One serial exchange: send bytes and/or wait for a reply, and/or change baud.
59
- * At least one of `send`, `expect`, or `setBaudRate` must be present.
152
+ * Serial exchange without session `extract`, `retry` or `failWhen` (per-chunk ack sub-exchanges and `RadioOnError` cleanup).
60
153
  */
61
- export interface RadioExchange {
154
+ export interface RadioProtocolExchangeStep {
62
155
  description?: string;
63
156
  send?: RadioByteToken[];
64
157
  expect?: RadioExpect;
@@ -72,11 +165,25 @@ export interface RadioExchange {
72
165
  * enters programming at 9600 then transfers at 57600.
73
166
  */
74
167
  setBaudRate?: number;
168
+ /** When false, send and receive raw bytes (default uses config `framing` when present). */
169
+ framed?: boolean;
170
+ }
171
+
172
+ /**
173
+ * One serial exchange: send bytes and/or wait for a reply, and/or change baud.
174
+ * At least one of `send`, `expect`, or `setBaudRate` must be present.
175
+ * `extract`, `retry` and `failWhen` are limited to top-level exchange steps, not `read.ack` or `onError` cleanup.
176
+ */
177
+ export interface RadioExchange extends RadioProtocolExchangeStep {
178
+ /** Exchange-only: copy slices of the decoded payload into `var.<name>`. */
179
+ extract?: Record<string, RadioExtract>;
180
+ retry?: RadioRetry;
181
+ failWhen?: RadioFailWhen[];
75
182
  }
76
183
 
77
184
  /**
78
185
  * Chunked memory read: repeat an exchange across named segments.
79
- * `$data` in `expect` is captured into the memory buffer.
186
+ * `$data` in `expect` is stored into the memory buffer.
80
187
  * Optional `ack` is a second exchange after each chunk (for example an ACK).
81
188
  * Optional `delay` is milliseconds to wait after each accepted chunk (Kenwood
82
189
  * TM-D710A clone at 57600 needs this so the next `R` does not outrun the radio).
@@ -92,10 +199,12 @@ export interface RadioReadStep {
92
199
  segments: string[];
93
200
  send: RadioByteToken[];
94
201
  expect: RadioExpect;
95
- ack?: RadioExchange;
202
+ ack?: RadioProtocolExchangeStep;
96
203
  timeout?: number;
97
204
  delay?: number;
98
205
  ready?: RadioByteToken;
206
+ framed?: boolean;
207
+ retry?: RadioRetry;
99
208
  };
100
209
  }
101
210
 
@@ -106,6 +215,8 @@ export interface RadioReadStep {
106
215
  * Optional `chunkSize` overrides `memoryConfig.chunkSize` (UV-5R clone writes 16-byte blocks).
107
216
  * Optional `delay` is milliseconds to wait after each accepted block (UV-5R clone waits 50ms).
108
217
  * Optional `skip` lists inclusive radio-address ranges that must not be uploaded.
218
+ * Optional `alignment` requires chunk start and length to be multiples of that value.
219
+ * Optional `verify` re-reads each chunk when the caller enables verify (see `RadioWriteOptions`).
109
220
  */
110
221
  export interface RadioWriteStep {
111
222
  description?: string;
@@ -117,6 +228,10 @@ export interface RadioWriteStep {
117
228
  chunkSize?: number;
118
229
  delay?: number;
119
230
  skip?: RadioMemorySegment[];
231
+ framed?: boolean;
232
+ retry?: RadioRetry;
233
+ verify?: RadioWriteVerify;
234
+ alignment?: number;
120
235
  };
121
236
  }
122
237
 
@@ -138,12 +253,6 @@ export interface RadioCatWriteStep {
138
253
 
139
254
  export type RadioProtocolStep = RadioExchange | RadioReadStep | RadioWriteStep | RadioCatReadStep | RadioCatWriteStep;
140
255
 
141
- /**
142
- * Exchange-only protocol steps (`send`, `expect`, `setBaudRate`, `delay`, `timeout`).
143
- * Used for {@link RadioOnError} cleanup lists, which must not include read, write, or CAT loop steps.
144
- */
145
- export type RadioProtocolExchangeStep = RadioExchange;
146
-
147
256
  /**
148
257
  * Optional cleanup exchanges keyed by memory operation. The driver runs the matching list
149
258
  * best-effort after a protocol step fails or the user cancels; it is not run on success and is
@@ -1,7 +1,8 @@
1
1
  import type { RadioId } from "./id.js";
2
2
  import type { RadioMemoryConfig } from "./memory-config.js";
3
3
  import type { RadioMemoryMap } from "./memory-map.js";
4
- import type { RadioOnError, RadioProtocolStep } from "./protocol.js";
4
+ import type { RadioFraming } from "./framing.js";
5
+ import type { RadioFirmwareRule, RadioOnError, RadioProtocolStep, RadioSession } from "./protocol.js";
5
6
  import type { RadioSchema } from "./schema.js";
6
7
  import type { RadioDialogMessage } from "./dialog-message.js";
7
8
  import type { RadioSerialConfig } from "./serial-config.js";
@@ -22,6 +23,10 @@ export interface Radio {
22
23
  memoryConfig: RadioMemoryConfig;
23
24
  serialConfig: RadioSerialConfig;
24
25
  readMemory: RadioProtocolStep[];
26
+ /**
27
+ * Write protocol steps. An empty array means read-only: the driver throws `ReadOnlyDriverError` on write
28
+ * (see ham-radio-driver).
29
+ */
25
30
  writeMemory: RadioProtocolStep[];
26
31
  /**
27
32
  * Optional cleanup exchanges after a failed or cancelled read/write. Not run on success;
@@ -37,4 +42,10 @@ export interface Radio {
37
42
  * May be an inline map or a path/$ref resolved by the registry/module.
38
43
  */
39
44
  memoryMap?: RadioMemoryMap | { $ref: string };
45
+ /** When set, wraps every exchange and chunked read/write payload (see ADR 0014). */
46
+ framing?: RadioFraming;
47
+ /** Per-session token for `$session` on framed radios. */
48
+ session?: RadioSession;
49
+ /** Checked before the first memory step; requires a matching `extract` on an earlier exchange. */
50
+ firmware?: RadioFirmwareRule;
40
51
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Optional fourth argument to `RadioDriver.writeRadio`.
3
+ * When `verify` is `false`, the driver skips per-chunk read-back even if the write step defines `verify`.
4
+ */
5
+ export interface RadioWriteOptions {
6
+ verify?: boolean;
7
+ }
8
+
9
+ export type RadioFirmwareGateAction = "pass" | "allow" | "warn" | "refuse";
10
+
11
+ /** Result of the last `RadioDriver.readRadio` or `RadioDriver.writeRadio` session. */
12
+ export interface RadioSessionInfo {
13
+ operation: "readMemory" | "writeMemory";
14
+ /** False when the session ended in cancellation or an error before normal completion. */
15
+ completed: boolean;
16
+ /** Values from exchange `extract` steps, keyed by name. */
17
+ extracts: Record<string, string | number | number[]>;
18
+ firmware?: {
19
+ variable: string;
20
+ value?: string;
21
+ label: string;
22
+ matched: boolean;
23
+ action: RadioFirmwareGateAction;
24
+ };
25
+ verify?: {
26
+ enabled: boolean;
27
+ chunksVerified: number;
28
+ };
29
+ }