diff --git a/CLAUDE.md b/CLAUDE.md index bf2795d..2c7d049 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -340,9 +340,12 @@ Read this first when picking the project back up. - โš  **A MiniMate's open setup menu wins:** a change sent while it is open is lost when the operator presses Cancel or Save (the menu writes its whole-block copy back). The preview warns; nobody in the menus while the office sends. - - โš  An escaped checksum byte leaves a stray `0x10` in a Series-3 reply's data - (about 1 frame in 85). The settings and waveform reads take exactly what they - asked for; other reads are unaudited for it. + - ~~โš  An escaped checksum byte leaves a stray `0x10` in a Series-3 reply's data + (about 1 frame in 85).~~ **Fixed in the parser (#58, 2026-11-06, measured):** + a checksum of 02/03/04 arrives as `10 X`, and that `10` is never data (7,747 / + 7,747 recorded replies check). It had misread 1C battery/memory (419.84 V) and + the 2C call-home read; the 5A file builder's own compensation is gone with it, + and pre-fix `.a5.pkl` frames are converted on load (pickle version 2). - โš  The Micromate scheduler switch is not in any block SFM reads, so a leftover schedule blocks a change even with the scheduler Off. **Ring path measured the same night:** with THOR's watchdog off, a call-home @@ -475,9 +478,11 @@ Read this first when picking the project back up. retracted 5A model: SUB 71's "offset 0x1004" reads as length 0x0400 escaped, and Blastware escapes `03` in write data. A write whose payload holds a bare 02/03/04/10 may be malformed. One Blastware config-write capture settles it. - ๐Ÿ”‘ **Replies follow the same rule (measured, 748/748):** every 02/03/04/10 escaped, - checksum = SUM8 of the unescaped payload. The "S3 checksums frequently fail" belief - is `S3FrameParser` summing its output with the `10` of `10 02/03/04` still in it. + ๐Ÿ”‘ **Replies follow the same rule (measured, 748/748; 7,747 / 7,747 across every + recording, #58):** every 02/03/04/10 escaped, the checksum too, and checksum = SUM8 + of the unescaped payload. The "S3 checksums frequently fail" belief was + `S3FrameParser` summing its output with the `10` of `10 02/03/04` still in it + (fixed 2026-11-06: `checksum_valid` holds on every recorded reply). ~~**โš  KNOWN BUG โ€” the 5A walk breaks once a unit's buffer crosses 64 KB.**~~ `parse_strt_end_offset()` returns only `(end_key[2] << 8) | end_key[3]`, discarding the key's page byte. An event starting at `0x0111F2A2` and ending @@ -2026,7 +2031,8 @@ A re-analysis in the prior session incorrectly concluded `section[1]` is always and is device-specific. The 2026-04-09 re-analysis confirms `section[1]` was right. **IMPORTANT โ€” `frame.data` has checksum already stripped** by `S3FrameParser._finalise()` -(`raw_payload = body[:-1]`; `data = raw_payload[5:]`). There is NO trailing checksum byte in +(`raw_payload` = the body less its checksum, and less the `10` of an escaped one since #58; +`data = raw_payload[5:]`). There is NO trailing checksum byte in `section`. All relative-from-end offsets must account for this. Battery and memory fields are present in **both** states: diff --git a/docs/instantel_protocol_reference.md b/docs/instantel_protocol_reference.md index 18b4500..8b83583 100644 --- a/docs/instantel_protocol_reference.md +++ b/docs/instantel_protocol_reference.md @@ -11,6 +11,7 @@ | Date | Section | Change | |---|---|---| +| 2026-11-06 | ยง3 (replies), SUB 1C, 2C, 15, 5A file build | โœ… **An escaped checksum is the checksum, not data (#58, measured).** A reply whose checksum is 02, 03 or 04 sends it as `10 X`, and `S3FrameParser` kept that `10` as the frame's last data byte (first seen on BE9441's 1A read, 2026-11-04). **Across every recorded reply** (60 captures, March to October 2026, three units) SUM8 of the unescaped payload is the checksum on **7,747 / 7,747**, widening 2026-10-26 (4)'s 748 / 748. **272** checksums arrived escaped; every one checks as an escape pair, and no checksum ever arrived as a bare 02/03/04. **What the stray byte did:** **SUB 1C** battery and memory are counted from the end, so 12 of 760 recorded status replies read 419.84 V and 251,654,656 bytes (for 6.76 V and 983,026). A **SUB 2C** call-home read came out one byte long and was refused as "monitoring". The **SUB 15 probe reply** (`00 00 00 00 0a โ€ฆ`, the same on BE11529, BE18189 and BE9441) always has an escaped checksum: 230 of the 272, harmless, as nothing reads it. The **5A file builder** had compensated since 2026-04-21 (the "split pair" rule). With the parser fixed, that rule would drop a real `0x10` ending a chunk (one A5 chunk in ten ends in one; none recorded with an escaped checksum as well), so it is removed. The 1A and 09 reads' length trims (2026-11-04) stay as guards. `checksum_valid` now sums the unescaped payload, and every recorded reply checks. | | 2026-11-05 | Appendix D.6.12 (NEW), D.6.11, ยง7.8.9 | โœ… **The unit's own event summary, in every event file.** The embedded event record is the first of a `[length][id][payload]` chain. It holds the vector-sum peak's sample (6,492 / 6,493). Then one 22-byte record per channel, ids `0x32` Tran โ€ฆ `0x35` MicL: min, max, peak sample, **half-period** and a **displacement integral**. Blastware prints them as they are. **ZC frequency** = (rate / 2) / half-period, with the interval rule's words: 25,966 / 25,966 waveform and 253,958 / 253,958 histogram channel values. **Peak displacement** = half the integral: 19,479 / 19,479. Recomputing from the samples had reached 46% and 84%: the unit works at full resolution. **Times of peak** follow the unit's peak sample. That differs from the samples only on **O117I1NK.R70W**, whose stored samples wrap at the trigger by 65,536 counts (Blastware's own table has the same values). Peak acceleration is Blastware's own computation from the stored samples (group D part 1, documented here too). The unit stores its own largest step at `[15:21]` (inferred), which Blastware does not print. ยง7.8.9's "constant, meaning โ“" bytes amended in place. 59 of 88 report fields now match on every DL2 event (47 before group D). | | 2026-11-04 | SUB 1A / 09 reads, SUB 68โ€“74 settings write, the keypad | **SFM's settings write, benched on BE9441 (Brian at the unit; ~12 writes, each with his go).** **Every write** -- trigger 0.04 โ†” 0.05, a note, several fields at once (Project, job number + its report flag, trigger), the alarm 1.0 โ†” 1.5, and a full restore -- was acknowledged on all nine steps (`97 8C 8Eร—5 8D 7D 7C 96 8B 8D`), read back as sent, and **confirmed on the unit's own screen**; the unit ended byte for byte as found. Moved bytes were exactly the field's: trigger f32 at each geophone channel +30 (`+31..+33` moved), **alarm f32 at channel +38** (`+39` moved; the first Series-3 alarm write), job number `[40:42]`, its report bit `[39]` `0x02`, a note's value window. **`[26:28]`** went `01 7f` โ†’ `00 00` on SFM's first write (Blastware's value) and the unit **set `01 7f` again during the next monitoring session**. The **two bytes after the block** went out as `00 00` (Blastware sends a per-unit constant) and were taken. **๐Ÿ”‘ Escaped-checksum artifact:** when a reply's checksum byte is itself escaped (02 / 03 / 04, ~1 frame in 85), `S3FrameParser` keeps the escape's `0x10` and strips only the byte after it, so the frame's data gains one trailing `0x10`. It hit the first live 1A read (frame B 1,026 bytes after the header); the 12 recorded reads never had. SFM's settings read and waveform read now take exactly the length they asked for. **๐Ÿ”‘ The keypad menu wins:** a write sent while the setup menu was open was acknowledged and read back, then **lost when the operator pressed Cancel or Save** -- the menu writes its own copy of the **whole** block back (both times the block returned byte for byte to its state when the menu was opened). A keypad Cancel with nothing pending leaves the block unchanged. **While monitoring**, the 1A read returns the device-info block (SFM refuses, nothing sent), and the opening poll was answered only intermittently (2 of 3 attempts timed out). Code: `minimateplus.protocol.read_compliance_content` / `read_waveform_data_raw`, `micromate.setup_fields`; notes `~/bench-logs/2026-11-04-sfm-settings/`. | | 2026-11-03 (5) | SUB 1A / 71 / 69 (settings read and write) | **The settings block, read and written as content (measured, BE9441's 10-26 recording and BE11529's 2026-04-20 captures).** **Read:** unescape each 1A data frame and take `data[11:]`; every frame but the last starts with one `00` that is not content; dropped, the frames join into **2,090 bytes headed by N = 2090: Series IV's `0x1A` content layout** (12 / 12 reads, Blastware's 4 ร— 512 + 42 and SFM's 1024 + 1024 + 42). The old "stable anchor" `be 80 00 00 00 00` is content `[12:18]` (pre-trigger โˆ’0.25 + stop mode Fixed). **Round trip:** the read after each of Blastware's two 10-26 writes equals the image it had just written, all 2,090 bytes (2 / 2). While monitoring, the read returns the device-info block (`0e 'BE9441' โ€ฆ`, 5 / 5). **`[26:28]`:** Blastware writes `00 00` on all 11 writes; the unit reads `01 7f` after a monitoring session (BE9441 10-26, BE11529 4-20 15:19) and sets it by itself; meaning unknown. **The two bytes after the block** (`[2090:2092]` of the 0x71 image) are Blastware's own per-unit constant -- `7c ea` on all nine of BE11529's writes, `0c e9` on both of BE9441's -- not the block's CRC-16/AUG, and in no reply of BE9441's three-hour session; SFM sends `00 00`. **`0x09` `[200:202]`:** Blastware echoed the unit's `8c 76` on all nine April writes; on 10-26 it read `17 17` and wrote `78 76` (read back so); meaning unknown. **Blastware re-renders the mic trigger level:** on BE11529's first write (4-20 15:19) the unit read 0.005 and 0.01 psi in its two `MicL` channel blocks (3 and 7; Series 3 carries 8 channel blocks of 48 bytes from `[1708]`, the second four prefixed `0x32`) and Blastware wrote 0.004983 and 0.010058 -- the same levels to its 0.1 dB; every other write left them alone. **Every one of the 11 Blastware writes reproduces** from the block before it with only the fields Blastware changed (plus that re-render and, on 10-26, the mic bit of `[25]`). Code: `minimateplus.protocol.assemble_compliance_content`, `read_compliance_content`, `micromate.setup_fields`; tests `tests/test_s3_settings_read.py`, `tests/test_setup_fields.py`. | diff --git a/minimateplus/framing.py b/minimateplus/framing.py index cab24be..4d027c0 100644 --- a/minimateplus/framing.py +++ b/minimateplus/framing.py @@ -534,13 +534,13 @@ STRT_MARKER = b"STRT" def unescape_reply(data: bytes) -> bytes: """A reply's data with each kept escape removed: `10 02/03/04` โ†’ `02/03/04`. - The unit escapes 02, 03, 04 and 10 in its replies exactly as requests do - (checksum included: 7,747 of 7,747 recorded replies, March to October 2026, - #58; the 748 measured on 2026-10-26 were Blastware's requests). S3FrameParser - collapses `10 10` but keeps the `10` of `10 02/03/04` (inner-frame markers to - it) everywhere but the checksum, so its `.data` carries an - extra byte before each 02/03/04 value -- harmless for fields read before the - escape, one byte off for any read after it, or counted from the end.""" + The unit escapes 02, 03, 04 and 10 in its replies exactly as requests do, + the checksum included (748/748 replies, 2026-10-26; 7,747 / 7,747 across every + recording, March to October 2026, #58). S3FrameParser collapses `10 10` but + keeps the `10` of `10 02/03/04` (inner-frame markers to it) everywhere but the + checksum, so its `.data` carries an extra byte before each 02/03/04 value -- + harmless for fields read before the escape, one byte off for any read after it, + or counted from the end.""" out, i = bytearray(), 0 while i < len(data): if data[i] == DLE and i + 1 < len(data) and data[i + 1] in (STX, ETX, 0x04):