diff --git a/CLAUDE.md b/CLAUDE.md index f8cea4c..cc2eeda 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ pair โ€” lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as --- -## Where things stand (updated 2026-11-03) +## Where things stand (updated 2026-11-05) Read this first when picking the project back up. @@ -45,10 +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-03, run `20261103-213557`): - **47 of 88 fields match on every event**, up from about 6 before v0.33.0. - Everything below on `dev` shares one release and one backfill. Groups A, B - and C are done, which also fixed #50 and #51. + **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. + - 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. - ๐Ÿ”‘ **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 @@ -66,6 +68,14 @@ Read this first when picking the project back up. - group B (`dev`, D.6.9): interval frequencies, vector sums, size, stop - group C (`dev`, D.6.10): histogram start and stop from the histogram's own event record, interval times, and the peak dates and times + - group D (D.6.12): ZC frequency on every record type, peak displacement, + times of peak and the vector-sum time. + - These are **the unit's own values**, stored in the file right after + the event record. Blastware prints them; recomputing from the samples + reached only 46% and 84%. + - Peak acceleration is Blastware's own computation (fitted g 386.2238), + 6,522โ€“6,523 / 6,524. The misses are O117I1NK.R70W, whose samples wrap + at the trigger, and S353I5PZ.EP0W Vert (open). - ๐Ÿ”‘ **"Units" means three different things โ€” keep them apart** (reference D.6.6): - **Recorded data:** the mic samples and interval peaks in the file, as @@ -100,10 +110,14 @@ Read this first when picking the project back up. - ~~**B. Histogram interval detail**~~ โœ… done on `dev`. Frequencies (#50), per-interval PVS, interval size, stop. - ~~**C. #51 timing**~~ โœ… done on `dev`. - - **D. Blastware's waveform calculations:** ZC frequency, acceleration, - displacement, time of peak. - - **E. Sensor check results.** - - **F. Monitor log:** probably not in the event file at all. + - ~~**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). + - **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. - ๐Ÿ”ถ **#48 is still open.** The event file's setup block puts the pre-trigger where the 1A "stable anchor" `be 80 00 00 00 00` sits. In the file, though, it is **each event's own pre-trigger**, not the setting: 253โ€“256 samples at diff --git a/docs/instantel_protocol_reference.md b/docs/instantel_protocol_reference.md index 97214a2..52fa279 100644 --- a/docs/instantel_protocol_reference.md +++ b/docs/instantel_protocol_reference.md @@ -11,6 +11,7 @@ | Date | Section | Change | |---|---|---| +| 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 not stored; it is Blastware's computation (group D part 1, documented here too). ยง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`. | | 2026-11-03 (4) | Appendix D.6.10 (NEW), D.6.11 | โœ… **Histogram timing from its own event record (#51).** `00 28 05 00` `04 00` `fe f5` [start][stop]: Blastware's Histogram Start and Stop on 63,490 / 63,490 each; exactly one per histogram, start 0โ€“1 s after the footer's ts1. Interval time = its end (start + (i + 1) ร— interval, capped at the stop), 2,308,524 / 2,308,524 rows; a peak's date/time = its interval's. Retracted: "histograms stay on ts1" (it held only while SFM's events were unique on serial + time; now unit + time + type). 47 of 88 report fields match on every DL2 event. | @@ -2277,6 +2278,13 @@ labels "unknown", after the notes and channel blocks. | `[M+10:M+18]` | **stop**, same format | = the footer's `ts2` on 7,836; one second before it on 99 โœ… | | `[M+18:M+40]` | `[+18]` `00` (7,933/7,935), `[+22:24]` `00 00`, `[+26:34]` eight `00`, `[+36]` `00`, `[+37:39]` `16 32`, `[+39]` `00` | constant; meaning โ“ | +> โš  **AMENDED 2026-11-05 (measured on DL2):** the record is the first of a chain of +> `[length uint16 BE][id][payload]` records. `00 28 05` is length 40 and id `0x05`, so the +> next record starts at `M + 36`. `[M+22:M+26]` is the vector-sum peak's sample, a uint32 BE +> (its high bytes are the `00 00` above). The bytes from `[+36]` are the next record's lead, +> `00 16 32`: the unit's per-channel summary. Layout and what Blastware prints from it: +> Appendix D.6.12. + **Relations** (7,935/7,935): footer `ts1` (session start) โ‰ค trigger โ‰ค stop; and `(stop - trigger) - record time` lies in โˆ’3 โ€ฆ +6 s. @@ -3935,12 +3943,16 @@ All four channels match every DL2 histogram. #### D.6.11 Not read from the file yet -*Updated 2026-11-03. 47 of 88 report fields now match on every DL2 event.* +*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).* - **Fields not read yet:** - extended notes - - the values Blastware computes: ZC frequency, acceleration, displacement, time of peak - - sensor check results + - sensor check results (probably the records after the unit's summary, `0x3c` / `0x3d`; + inferred, D.6.12) - monitor log +- ~~the values Blastware computes: ZC frequency, acceleration, displacement, time of peak~~ + **Read, 2026-11-04 โ†’ 05 (D.6.12).** Only acceleration is Blastware's own computation; the + other three are the unit's, stored in the file. - **Open cases:** - about 20 one-minute histograms with a mic peak an interval or two off - Blastware prints `OORANGE` when an event's vector sum alone exceeds the range, with no @@ -3955,6 +3967,69 @@ All four channels match every DL2 histogram. - histogram interval detail: frequencies (#50), vector sums, interval size, stop (D.6.9) - histogram start, stop, interval and peak times (#51, D.6.10) +#### D.6.12 Peak detail โ€” the unit's own event summary โœ… 2026-11-05 + +**The embedded event record (ยง7.8.9, D.6.10) is the first of a chain** of +`[length uint16 BE][id][payload]` records: the next one starts `length + 2` bytes after a +record's lead. `00 28 05` is length 40 and id `0x05`. Measured on the 6,493 DL2 waveforms and +63,500 histograms that have a Blastware report. + +**The event record**, offsets from its marker `M` as in ยง7.8.9: + +| bytes | content | +|---|---| +| `[M+22:M+26]` | the vector-sum peak's sample, uint32 BE: SFM's own vector-sum peak on 6,492 / 6,493 (the other is O117I1NK, below) | +| `[M+18:M+22]`, `[M+26:M+36]` | not identified โ“ | + +**Then one record per channel**, length 22: ids `0x32` Tran, `0x33` Vert, `0x34` Long, +`0x35` MicL. A unit without a mic has no `0x35` (6 DL2 files). + +| payload | content | +|---|---| +| `[0]` | `00` on all 25,966 waveform channels | +| `[1:3]` | min, int16 BE: geophones in decoder units of 16 counts (0.005 in/s at Normal), the mic in counts | +| `[3:5]` | max, the same | +| `[5:9]` | the peak's sample, uint32 BE | +| `[9:11]` | **half-period**, samples, uint16 BE | +| `[11:15]` | **displacement integral**, uint32 BE, in units ร— samples | +| `[15:21]` | not identified: not the sum of the squares or of the magnitudes โ“ | + +On a waveform, min, max and peak sample are the decoded samples' own on 25,962 / 25,966 +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). + +**What Blastware prints from them.** It prints the unit's values; it does not recompute them: + +| Field | Rule | DL2 | +|---|---|---| +| ZC frequency, every record type | (rate / 2) / half-period. "N/A" at 0; `>100` (`>200` at 2048 sps, `>400` at 4096) at 5 samples or fewer; `<1.0` when the half-period exceeds rate / 2. The histogram interval rule (D.6.9) | waveforms 25,966 / 25,966 channel values (15,844 numbers); histograms 253,958 / 253,958 (104,000 numbers) | +| Peak displacement (waveform) | half the integral: integral ร— 16 counts ร— in/s per count (the range's, D.6.4) รท rate รท 2, in inches | 19,479 / 19,479 | +| Time of peak (waveform) | (peak sample โˆ’ pre-trigger samples) รท rate | as the samples' own, except O117I1NK, where Blastware prints the summary's | +| Vector-sum time (waveform) | the same, from the event record's sample | 6,492 / 6,493 from the samples; O117I1NK prints the record's | +| Peak acceleration (waveform) | **not stored**. Blastware computes the largest \|v[i+1] โˆ’ v[i]\| ร— rate รท g, with its g fitted to [386.2236, 386.2240] in/sยฒ by every DL2 value (9.81 m/sยฒ is 386.2205; the standard 9.80665 fits 17,806) | 19,475 / 19,479 | + +**Why recomputing failed.** ZC frequency recomputed from the samples matched 46% (the +half-cycle at the peak), and 80% with each crossing interpolated at ยฑ16 counts. Displacement +matched 84% (half the largest half-cycle integral, the manuals' method). The unit works at +full resolution: a stored sample of ยฑ16 counts hides anything from 1 to 31. + +**O117I1NK.R70W (2019): clipped, and its samples wrap.** +- **The wrap:** at the trigger (sample 254), every stored sample is off by exactly 65,536 + counts (4,096 on the mic). Tran reads +26,832 where the summary's min is โˆ’38,704 (โˆ’12.1 in/s). +- **Blastware decodes the same:** its own sample table has the same wrapped values (Tran + 8.385 in/s). +- **It prints the summary:** `OORANGE`, and time of peak 0.000 on all four channels and on + the vector sum. +- **Its accelerations** equal the summary's max โˆ’ min in one sample step: 48.28, 46.93 and + 49.12 g, all exact. One file. Inferred: Blastware's acceleration sees the summary's extreme + at its peak sample. SFM does not do this. + +**S353I5PZ.EP0W Vert (open).** Blastware's acceleration (0.027 g) skips one 80-count step, +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. + --- *All findings reverse-engineered from live RS-232 bridge captures.*