diff --git a/CLAUDE.md b/CLAUDE.md index bf2795d..ba04dc2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -45,12 +45,12 @@ Read this first when picking the project back up. - **Byte layouts** of every field read from the file: `docs/instantel_protocol_reference.md` Appendix **D.6**. - **Where the decoder stands on `dev`** (2026-11-05, run `20261105-140021`): - **59 of 88 fields match on every event**, up from about 6 before v0.33.0 and - 47 before group D. + **Where the decoder stands on `dev`** (2026-11-06, run `20261106-125854`): + **71 of 88 fields match on every event**, up from about 6 before v0.33.0, + 47 before group D and 59 after it. - Groups A, B, C and D part 1 shipped in v0.34.0 (#50, #51). - - D part 2 (the unit's own summary) is on `dev` and owes the next release - a backfill. + - D part 2 (the unit's own summary) and E (the sensor check) are on `dev` + and owe the next release a backfill. - ๐Ÿ”‘ **Events are keyed unit + time + type:** `UNIQUE(serial, timestamp, record_type)` (#51, Migration 3 in `sfm/database.py`, `dev`). - A waveform and its histogram may share a second: 209 times in prod's @@ -77,6 +77,14 @@ Read this first when picking the project back up. (fitted g 386.2238): 6,522โ€“6,523 / 6,524. The unit stores its own too, which Blastware ignores. The misses are O117I1NK.R70W, whose samples wrap at the trigger, and S353I5PZ.EP0W Vert (open). + - group E (D.6.13): sensor check frequency, ratio, mic amplitude and + result, every record type. Also the unit's own, in each sensor-check + record's header. "Check" is the unit's status code, not a limit SFM can + recompute. + - ๐Ÿ”‘ **The tail of every event file is one record chain** (D.6.13): + event record โ†’ unit summary โ†’ sensor checks โ†’ footer, each + `[length][id][payload]`. It ends exactly at the file's end on all 70,041 + DL2 files, and SFM reads none of it otherwise. - ๐Ÿ”‘ **"Units" means three different things โ€” keep them apart** (reference D.6.6): - **Recorded data:** the mic samples and interval peaks in the file, as @@ -114,8 +122,8 @@ Read this first when picking the project back up. - ~~**D. Blastware's waveform calculations**~~ โœ… done. ZC frequency, displacement and time of peak are the unit's own (D.6.12); acceleration is Blastware's. - - **E. Sensor check results.** Probably records `0x3c` / `0x3d`, which - follow the unit's summary (inferred, D.6.12). + - ~~**E. Sensor check results**~~ โœ… done (D.6.13). Plus the traces of a + unit without a mic, which the trace decoder had been dropping. - **F. Monitor log:** probably not in the event file at all. Lead, not measured: O117I1NK's report prints its log as the event record's start โ€“ stop. diff --git a/docs/instantel_protocol_reference.md b/docs/instantel_protocol_reference.md index 18b4500..64083e9 100644 --- a/docs/instantel_protocol_reference.md +++ b/docs/instantel_protocol_reference.md @@ -11,6 +11,7 @@ | Date | Section | Change | |---|---|---| +| 2026-11-06 | Appendix D.6.13 (NEW), D.3.3, D.6.11, D.6.12 | โœ… **The record chain to the footer, and the sensor check.** Walked from the event record, the chain (event `0x05` โ†’ unit's summary `0x32`โ€“`0x35` โ†’ sensor checks `0x3c`โ€“`0x3f` โ†’ footer `0x0e`) ends exactly at the file's end on all 70,041 DL2 files. The footer is its last record: `00 1a` is its length, `0e` its id. **Each sensor-check record's header holds the unit's results:** channel type `[2]`, status `[4]` (0 = passed), frequency ร— 10 `[5:7]`, ratio ร— 10 `[7:9]` and amplitude mV `[9:11]`. Blastware prints them as they are: 209,943 / 209,943 geophone frequencies and ratios, 69,975 / 69,975 mic frequencies and amplitudes. The result is Passed / Check / Disabled by status and type. The status is the unit's own verdict, its bits not decoded. D.6.12's "`0x3c` / `0x3d`, before and after" retracted in place: one record per channel. **71 of 88 report fields now match on every DL2 event.** | | 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`. | @@ -3466,6 +3467,10 @@ The body is reconstructed from the raw A5 bulk waveform stream frames by strippi The footer terminates the N00 file. Its bytes come directly from the terminator A5 frame's inner content โ€” do NOT reconstruct from event metadata. โœ… **It is the file's last 26 bytes** (2026-11-03): `0e 08` and two valid times end every one of 70,041 DL2 files. + +> ๐Ÿ”‘ **2026-11-06 (measured):** it is the last record of the chain that starts with the event +> record (D.6.13). The two bytes before it, `00 1a`, are its length (26), and `0e` is its id. +> The chain lands exactly on it in all 70,041 DL2 files. - โš  **Do not search for the first `0e 08` + plausible year.** 14 DL2 files also hold an earlier record of that shape, about 1.1 KB before the end, carrying the stop time followed by zeros. - Taking it made a histogram start at its own stop (a day late on BE9558's daily histograms). It also cost a waveform its stop, and with it the trigger time. @@ -3959,12 +3964,12 @@ All four channels match every DL2 histogram. #### D.6.11 Not read from the file yet -*Updated 2026-11-05. 59 of 88 report fields now match on every DL2 event, up from 47 -before group D (run `20261105-140021`, 0 regressions).* +*Updated 2026-11-06. 71 of 88 report fields now match on every DL2 event: 47 before group D, +59 after it, 71 with the sensor check (run `20261106-125854`, 0 regressions).* - **Fields not read yet:** - extended notes - - sensor check results (probably the records after the unit's summary, `0x3c` / `0x3d`; - inferred, D.6.12) + - ~~sensor check results~~ **read, 2026-11-06 (D.6.13)**: the unit's own, in the header of + each sensor-check record - monitor log - ~~the values Blastware computes: ZC frequency, acceleration, displacement, time of peak~~ **Read, 2026-11-04 โ†’ 05 (D.6.12).** Blastware prints the unit's own ZC frequency, @@ -4017,6 +4022,11 @@ channels. The 4 others are O117I1NK (below). **Then records `0x3c` (and on a histogram `0x3d`)**, length 202โ€“212. Not read yet. Probably the sensor check, before and after (inferred, not measured). +> โš  **RETRACTED 2026-11-06 (measured):** "before and after". They are the sensor check, but +> one record per channel: `0x3c` Tran, `0x3d` Vert, `0x3e` Long, `0x3f` MicL, on waveforms and +> histograms alike. My first walk stopped at the first id it did not know. The chain runs on +> to the footer: D.6.13. + **What Blastware prints from them.** It prints the unit's values; it does not recompute them: | Field | Rule | DL2 | @@ -4047,6 +4057,51 @@ full resolution: a stored sample of ยฑ16 counts hides anything from 1 to 31. from sample 4,096 to 4,097, which its own sample table shows. Not explained. Skipping every 4,096-sample boundary fixes this file but breaks another. +#### D.6.13 The record chain to the footer, and the sensor check โœ… 2026-11-06 + +**The whole tail of an event file is one record chain.** Walked from the event record by its +length prefixes, it ends exactly at the file's last byte on **all 70,041 DL2 files**, in two +shapes: + +| Files | Chain | +|---|---| +| 70,033 | `0x05` event record โ†’ `0x32`โ€“`0x35` unit's summary (D.6.12) โ†’ `0x3c`โ€“`0x3f` sensor checks โ†’ `0x0e` footer | +| 8 | the same without `0x35` and `0x3f`: BE16352, which records no mic | + +The **footer** (D.3.3, "the file's last 26 bytes") is the chain's last record: its length +`00 1a` sits just before it, and its first byte, `0e`, is its id. SFM reads nothing in the +chain unless the walk ends exactly at the end of the file. + +**Each sensor-check record** (`0x3c` Tran, `0x3d` Vert, `0x3e` Long, `0x3f` MicL) holds the +check the unit ran: a header with its results, then the trace Blastware draws in its "Sensor +Check" strip (`minimateplus/sensor_check.py`, since 2026-09-15). Payload after the id: + +| bytes | content | +|---|---| +| `[0:2]` | `00 00` | +| `[2]` | channel type: `01` geophone, `02` mic, `00` the check disabled | +| `[3]` | `00` | +| `[4]` | **status**: `00` passed; 1โ€“15 otherwise | +| `[5:7]` | **frequency ร— 10**, uint16 BE (Hz) | +| `[7:9]` | **ratio ร— 10**, uint16 BE (geophones; the mic's reads 10) | +| `[9:11]` | **amplitude, mV**, uint16 BE (the mic's; geophones carry a value too, ~260โ€“700, not printed) | +| `[11:19]` | not identified โ“ | +| `[19:]` | the trace (`sensor_check.py`'s `_HEADER_LEN` = 20 counts the id byte) | + +**What Blastware prints** (`TestFreq`, `TestRatio`, `TestAmplitude`, `TestResults`): + +| Field | Rule | DL2 | +|---|---|---| +| geophone test frequency and ratio | as stored, รท 10 | 209,943 / 209,943 each | +| mic test frequency and amplitude | as stored (frequency รท 10) | 69,975 / 69,975 each | +| result | `Passed` at status 0, `Check` at any other, `Disabled` at channel type 0 (and nothing else printed) | every channel | + +**The status code is the unit's verdict, not a limit SFM can recompute.** Geophones that pass +span 6.7โ€“9.4 Hz and ratio 1.9โ€“6.0, yet K559L6N1's Tran reads `Check` at 8.1 Hz and 3.3. Each +of the four bits occurs across the whole range of frequency, ratio and amplitude, so their +meanings are not decoded. Every mic `Check` in DL2 (691) is status 13 with frequency 0 and +amplitude 0: a mic that did not respond (inferred). + --- *All findings reverse-engineered from live RS-232 bridge captures.*