25 Commits
Author SHA1 Message Date
serversdown 30bfdd6eff Merge pull request 'Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone' (#59) from dev into main
Reviewed-on: #59
2026-11-04 18:19:22 -05:00
serversdownandClaude Opus 5.5 c9f41deadd chore(release): v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone
- CHANGELOG: Unreleased -> v0.34.0 — 2026-11-04, with the release theme
  and a Migration section (schema re-key + overnight backfill that moves
  every Series-3 histogram time by one second; rehearsed twice on a copy
  of prod's 2026-09-30 snapshot).
- pyproject.toml, CLAUDE.md, README: 0.34.0 (README gains its status
  entry).
- TOOL_VERSION 0.34.0: the codec changed, so the backfill regenerates.

Verified on dev before this commit: the full decode checker matches
pre-parity dev on every verdict of all 70,112 DL2 events (47 of 88
fields), group D part 1 ran clean on its branch, and the suite has only
the 16 known failures (1,566 passed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-04 17:58:54 -05:00
serversdownandClaude Opus 5.5 9f3434ff2b docs(changelog): Unreleased -- time of peak, vector-sum time and peak acceleration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-04 17:56:58 -05:00
serversdownandClaude Opus 5.5 401d83dc2c merge: a waveform's time of peak, vector-sum time and peak acceleration (group D, part 1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-04 17:54:56 -05:00
serversdownandClaude Opus 5.5 75a1d135ee docs(changelog): Unreleased -- Series-4 parity in SFM (phases 1-5)
Everything by serial for both series, the audited changes (start/stop,
call-home, settings), the MiniMate wire fixes (#46, the 64 KB page, the
settings read as content), the legacy config write retired, the benches.
Operational: additive schema only (device_commands), no TOOL_VERSION bump,
no backfill from this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:29:07 -05:00
serversdownandClaude Opus 5.5 5b342b4d7d merge: feat/series4-sfm-parity -- Series-4 parity in SFM, phases 1-5
Everything by serial for both series (identify, status, settings, events,
download, start/stop, call-home on/off, settings change), live downloads
stored as the watcher stores them, the legacy config write retired.
Phase 4 benched 2026-11-03, phase 5 benched 2026-11-04 on BE9441 and
UM20147.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:26:45 -05:00
serversdownandClaude Opus 5.5 3564c4a744 docs: phase 5 benched on both series (2026-11-04)
Both protocol references, the spec's bench section and CLAUDE.md record
the bench: every settings change acknowledged, read back and confirmed on
the unit's screen, both units restored byte for byte; the escaped-
checksum stray byte (fixed); a MiniMate's open setup menu writes its
whole-block copy back on Cancel or Save, losing a remote change; the
alarm write at channel +38; [26:28] re-set by the unit while monitoring;
the first Micromate setup push with the unit's CRC equal to SFM's; the
Micromate scheduler switch in none of the blocks SFM reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:16:40 -05:00
serversdownandClaude Opus 5.5 c790e20116 fix: bench follow-ups -- the setup-menu warning, observed call-home values, waveform read
From the 2026-11-04 bench:
- A MiniMate settings preview warns that a change is lost if someone is in
  the unit's setup menu: a write sent with the menu open was acknowledged
  and read back, then lost on Cancel or Save -- the menu writes its own
  copy of the whole block back (measured both ways on BE9441).
- The two bytes after the MiniMate settings block went out as 00 00 and
  the unit took them; the preview note says so instead of 'unmeasured'.
- A Micromate call-home plan no longer warns about 0x00 / 0x01: UM20147
  took both, each way, on 11-03 and 11-04, matching its menu.
- read_waveform_data_raw drops the escaped-checksum's stray 0x10, as the
  settings read does (it failed closed: the write's block check refused
  203 bytes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:15:28 -05:00
serversdownandClaude Opus 5.5 55c7b7b5ae feat(codec): the MiniMate alarm level is writable (benched 2026-11-04)
S3_ALARM_WRITE_MEASURED = True.  At the bench on BE9441, with Brian's go,
the alarm went 1.0 -> 1.5 -> 1.0 in/s: each write acknowledged, read back
as sent, and shown in the unit's own setup menu.  The write moved exactly
channel +39 of the three geophone blocks (the f32 at +38), where the
event files put it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:12:58 -05:00
serversdownandClaude Opus 5.5 09f34c2c85 fix(decode): Blastware's g for peak acceleration, fitted to every DL2 value
Every printed acceleration in DL2 bounds Blastware's g; together they
leave [386.2236, 386.2240] in/s^2, and 386.2238 fits 19,475 / 19,479
values.  The other 4 are one odd file (O117I1NK.R70W, whose peak times
are also off) and one sample mismatch.  That is 9.81 m/s^2 (386.2205,
19,423) plus an unexplained offset, as with the mic's fitted dB offset.
The 59 values 9.81 left were all one last digit high.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-04 15:47:13 -05:00
serversdownandClaude Opus 5.5 233289d029 feat(decode): a waveform's time of peak, vector-sum time and peak acceleration
Group D, part 1, measured on 400 DL2 waveforms (2026-11-04):
- time of peak = (first peak sample - pre-trigger samples) / sample
  rate, per channel including the mic: 1,197 / 1,197 geophone values
- the vector sum's time, the same on sqrt(T^2 + V^2 + L^2): 398 / 399
- peak acceleration = the largest |v[i+1] - v[i]| x sample rate / g,
  with Blastware's g = 9.81 m/s^2: 1,190 / 1,197 (the standard 9.80665
  gives 1,073).  Blastware's manuals: 'subtracts two velocity readings
  and divides the result by the elapsed time between them'.

PeakValues gains *_time_of_peak, pvs_time and *_peak_accel_g, filled
for waveforms only.  The checker reports them.  Displacement (84% with
the manuals' half-cycle integral) and ZC frequency (46%) are not shipped
yet -- Blastware does something more there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-04 15:19:53 -05:00
serversdownandClaude Opus 5.5 9992b25fde fix(s3): a settings read takes exactly what each frame was asked for
Bench 2026-11-04, BE9441 live: frame B of a 1A read arrived one byte long,
ending in a lone 0x10.  When a frame's checksum byte is itself escaped
(02 / 03 / 04, about one frame in 85) the parser keeps the escape's 0x10
and strips only the byte after it.  The 12 recorded reads never hit it,
so the assembled block was 2,091 bytes and SFM refused it as 'monitoring'.
read_compliance_content now passes the lengths it asked for (1024, 1024,
42) and that one stray byte is dropped; any other leftover still fails
is_compliance_content.  The trimmed read decodes exactly as the old
decoder read the same reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 13:11:32 -05:00
serversdownandClaude Opus 5.5 2d237be5ef fix(ingest): a live download is held to its record type (#51)
Since #51 a waveform and a histogram recorded in the same second are two
events (UNIQUE(serial, timestamp, record_type)).  persist_download's
'already stored?' checks matched any row at the second and any row under
the letterless Blastware name both twins share, so a live download of
one twin was skipped as stored.  Both checks now hold to the download's
own type, read from its file (STRT[18]; IDFW / IDFH); an untyped row at
that second, or a download whose type does not read, still counts as
stored.  find_event_by_blastware_name takes an optional record_type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 12:34:46 -05:00
serversdown fb14a8f7bb Merge pull request 'Release v0.33.0 — SFM reads Series-3 events from the file alone' (#56) from dev into main
Reviewed-on: #56
2026-11-01 14:33:00 -05:00
serversdown e9c01ce8d4 Merge pull request 'Release v0.32.0 — event times you can trust, and Series 4 mapped' (#54) from dev into main
Reviewed-on: #54
2026-10-27 11:00:59 -04:00
serversdown d2258dad4e Merge pull request 'Release v0.31.0 — report parity + the inverted rescue (0.29.0 → 0.31.0)' (#40) from dev into main
Reviewed-on: #40
2026-09-18 16:46:41 -04:00
serversdown e050e602c2 Merge pull request 'Release v0.29.0 — offset detector + false_trigger_reason + BlastMate serials (0.27.0→0.29.0)' (#36) from dev into main
Reviewed-on: #36
2026-09-07 15:57:37 -04:00
serversdown fc1c7c7936 Merge pull request 'Docs/claude.md corrections' (#35) from dev into main
Reviewed-on: #35
2026-08-29 15:48:33 -04:00
serversdown 7d0d12079b Merge pull request 'v0.27.0 Decoder fixes, offset exploration and testing.' (#34) from dev into main
Reviewed-on: #34
2026-08-28 22:40:34 -04:00
serversdown 5203aab849 Merge pull request 'update to 0.26.0. Big chonking update including 0.23, 0.24, and 0.25 as well.' (#33) from dev into main
Reviewed-on: #33
2026-08-27 13:43:00 -04:00
serversdown 5b65718b72 Merge pull request 'v0.23.0 - ZC freq in events store' (#31) from dev into main
Reviewed-on: #31
2026-08-06 12:12:19 -04:00
serversdown 483762607e Merge pull request 'Update to v0.22.0' (#30) from dev into main
Reviewed-on: #30
2026-07-03 15:35:20 -04:00
serversdown d0b66368d5 Merge pull request 'update to v0.21.1, thor data import successful' (#29) from dev into main
Reviewed-on: #29
2026-06-01 16:54:23 -04:00
serversdown 2eb1d25028 Merge pull request 'v0.20.0 -- Full s3 event parse and PDF creation.' (#28) from dev into main
Reviewed-on: #28
2026-05-28 17:54:31 -04:00
claude cc821f9ee3 hotfix: fix dockerfile on main to fix import bug on prod 2026-05-21 20:42:15 +00:00
23 changed files with 623 additions and 43 deletions

No files matched your search

+209 -1
View File
@@ -4,9 +4,82 @@ All notable changes to seismo-relay are documented here.
--- ---
## Unreleased ## v0.34.0 — 2026-11-04
**SFM reaches Series-4 parity, and reads most of Blastware's report from the
event file alone.**
Two lines of work ship together.
**Series-4 parity** (`feat/series4-sfm-parity`). One device door, by serial,
for both series. Each change is audited, identity-checked, sent once and read
back. Benched on BE9441 and UM20147.
- reads and downloads
- start / stop monitoring
- call-home on / off
- settings changes (preview → send → read back)
It also fixes MiniMate request framing (#46) and the 5A walk across a 64 KB
page.
**The file-only decode, groups A–D.** 47 of Blastware's 88 report fields now
match on every DL2 event, about 6 before v0.33.0. Eight more match on all but
one or two of 6,524 waveforms.
- **Fixed:**
- Sensitive-range events no longer read 8× high
- histograms the waveform codec had claimed, and short histograms with a
loud interval, now decode
- histograms are no longer a day late
- every histogram's start and stop are Blastware's own (#51), not a second
early
- interval frequencies follow the sample rate (#50)
- **New from the file:**
- the job number
- the unit's serial, version, calibration date and battery
- the trigger source and levels
- each interval's frequencies, vector sum and time
- the peak dates and times
- a waveform's time of peak and peak acceleration
- **Events are identified by unit + time + type:** a waveform and its histogram
may share a second.
Prod still overlays a paired ASCII report onto the decode. That overlay is the
plan's step 3 and is not part of this release.
⚠ **This release migrates the events table and owes a backfill that moves every
Series-3 histogram's stored time by one second.** See *Migration*.
### Fixed ### Fixed
- ✅ **MiniMate requests and config writes are framed as Blastware frames them
(#46; `feat/series4-sfm-parity`).**
- Every request escapes 02 / 03 / 04 / 10.
- A config write is an ordinary escaped request carrying a whole block (as
read, plus two bytes). All four blocks are checked before the first frame.
- SFM's frames equal Blastware's in the 2026-04-20 and 2026-10-26 captures.
Benched on BE9441 2026-11-04.
- ✅ **The 5A walk crosses a unit's 64 KB page.** The walk is 32-bit linear
(the CLAUDE.md "KNOWN BUG"); BE9441's page-crossing events rebuild Blastware's
own files byte for byte.
- A one-event download is whole or an error.
- A non-first event's stream has no metadata pages.
- **A MiniMate settings read is assembled as content** (measured at the bench
2026-11-04).
- Unescape each 1A frame and drop the one non-content byte that starts every
frame but the last: 2,090 bytes headed by N = 2090.
- The read takes exactly the length it asked for. When a reply's checksum
byte is itself escaped (about 1 frame in 85), the parser leaves its 0x10 in
the data. It hit the first live read; the recordings never had it. The
waveform-data read now trims it too.
- **A live download is held to its record type (#51):** a same-second
waveform / histogram twin is no longer skipped as "already stored". An untyped
row at that second still counts as stored.
- Smaller wire fixes from the parity benches:
- SUB 0x15's serial is cut at its first NUL.
- 0x1C reads a histogram run as monitoring.
- A MiniMate that boots on connect is waited for.
- A start's read-back waits out the sensor check and wakes the unit.
- A built call-home image is framed once.
- ✅ **#51: events are identified by unit + time + type, and histograms take - ✅ **#51: events are identified by unit + time + type, and histograms take
Blastware's times.** Blastware's times.**
- **The new key.** The events table was `UNIQUE(serial, timestamp)`, one - **The new key.** The events table was `UNIQUE(serial, timestamp)`, one
@@ -135,6 +208,84 @@ All notable changes to seismo-relay are documented here.
change. change.
### Added ### Added
- **Series-4 parity in SFM: everything by serial, for both series**
(`feat/series4-sfm-parity`, merged 2026-11-04; spec
`docs/superpowers/specs/2026-10-20-sfm-series4-parity-design.md`).
- **One door, `DeviceAccess`.**
- A unit is addressed by its serial: UM is Series 4, BE / BA is Series 3.
The unit's own answer is checked before anything is sent.
- A Micromate's line is held between requests and released when idle or
on RADIO RING.
- One connection per unit; 423 while busy.
- **Reads, both series:** `GET /device/info`, `/device/monitor/status`,
`/device/settings`, `/device/events` and `POST /device/events/download`.
- A download is stored as the watcher stores it, through the Blastware /
IDF import path, typed.
- It never overwrites a stored event.
- SFM's MiniMate files carry Blastware's W/H type letter.
- **Changes, both series, each audited** (a `device_commands` row per
attempt), identity-checked, sent once, never retried, read back:
- start / stop monitoring;
- call-home on / off: `GET /device/call_home/state`,
`POST /device/call_home/{enable,disable}`;
- **settings**, `POST /device/settings/change`.
- **Settings, in detail:**
- A preview (dry run) shows old → new and returns a revision; a live
change must carry it, covering the unit's block and the changes asked for.
- Fields: record mode, sample rate, histogram interval, record time,
geophone trigger, the four notes, job number and its report flag, and
(MiniMate) range and alarm.
- Limits are the units' own, from Instantel's manuals, checked on the
block that would result.
- Refused before anything is sent: a monitoring unit, a stale preview, a
Micromate on its factory setup, or one whose schedule would load another
setup. SFM reads `schedule.dat`, read-only.
- **One settings codec for both series** (`micromate/setup_fields.py`): a
MiniMate's settings block is Series IV's `0x1A` layout. All 11 Blastware
compliance writes reproduce from the block before them.
- **The page:**
- units by serial, with the series badge from the unit's own answer;
- the events list and download, start / stop, the Call Home tab;
- the Config tab's Preview → Send → "the unit now holds";
- page JavaScript in `sfm/static/`, tested through Node (no inline JS).
- **Benched on BE9441 and UM20147:** phase 4 on 2026-11-03, phase 5 on
2026-11-04. Every change was acknowledged, read back and confirmed on the
unit's screen; both units were restored byte for byte.
- ⚠ A MiniMate's open setup menu loses a remote change when the operator
presses Cancel or Save (the menu writes its whole-block copy back). The
preview warns.
- ⚠ The Micromate scheduler switch is in no block SFM reads, so a leftover
schedule blocks a change even with the scheduler Off.
- ⚠ **Operational:** additive schema only. SFM creates `device_commands`, or
adds `sent` / `states` to an older one, on first start; this branch does not
touch `events`. No `TOOL_VERSION` bump and no backfill from this branch:
event decoding is unchanged. Production ingest (the watchers) is untouched;
the new device routes are used only from SFM's page and API.
- **A waveform's time of peak, vector-sum time and peak acceleration** (group D,
part 1 of the file-only decode). Measured on DL2 2026-11-04.
- **Time of peak** = (first peak sample − pre-trigger samples) / sample rate,
per channel including the mic.
- **The vector sum's time**: the same, on √(T² + V² + L²).
- **Peak acceleration** = the largest |v[i+1] − v[i]| × sample rate / g, which
the manuals describe as "subtracts two velocity readings and divides the
result by the elapsed time between them".
- Blastware's g is fitted: every printed acceleration in DL2 bounds it, and
together they leave [386.2236, 386.2240] in/s².
- That is 9.81 m/s² (386.2205) plus an offset not explained, as with the
mic's fitted dB offset. The standard 9.80665 m/s² fits 17,806 of
19,479 values; the fitted value fits 19,475.
- **`PeakValues` gains** `*_time_of_peak`, `pvs_time` and `*_peak_accel_g`,
filled for waveforms only.
- **Decode checker:** 52,177 comparisons fixed, 0 regressions. Times of peak
are 6,523 / 6,524 on every channel, peak acceleration 6,522–6,523 / 6,524.
Every miss is in two 2019 files (O117I1NK.R70W on all channels, S353I5PZ
on Vert), not yet explained.
- **Not shipped yet:** peak displacement and ZC frequency. They follow the
manuals' methods (half the largest half-cycle integral; the half-cycle at
the peak), but match only 84% and 46%, so Blastware does something more.
- ⚠ **Codec change:** it rides this release's `TOOL_VERSION` bump and
backfill. No schema change; the new values are not stored in the DB or
the `.h5` yet.
- **A histogram's interval detail: frequencies, vector sums, interval size and - **A histogram's interval detail: frequencies, vector sums, interval size and
stop** (group B of the file-only decode). Measured on DL2 2026-11-03. stop** (group B of the file-only decode). Measured on DL2 2026-11-03.
- **Frequency** = (sample rate / 2) / half-period: 527,915 / 527,915 cells - **Frequency** = (sample rate / 2) / half-period: 527,915 / 527,915 cells
@@ -226,7 +377,24 @@ All notable changes to seismo-relay are documented here.
backfill (`backfill_sidecars.py` then `backfill_event_shape.py`). The new backfill (`backfill_sidecars.py` then `backfill_event_shape.py`). The new
`.h5` attributes are additive. No schema change, no migration. `.h5` attributes are additive. No schema change, no migration.
### Removed
- **`POST /device/config` and `POST /device/config/project` answer 410**,
pointing at `POST /device/settings/change`. Terra-View does not call them.
Removed with them, because they wrote a live unit through the encoder #46
found wrong:
- `MiniMateClient.apply_config`, `set_project_info` and
`_encode_compliance_config`;
- `poc_set_project.py`, and `experiments.py`'s EXP6.
### Protocol / Documentation ### Protocol / Documentation
- **The parity benches in both protocol references:**
- Series III: the settings write measured end to end, the escaped-checksum
stray byte, the keypad menu writing its whole-block copy back, the alarm at
channel +38, and `[26:28]` re-set while monitoring.
- Series IV: the first setup push, with the unit's CRC equal to SFM's; the
schedule read on a real unit; the scheduler switch in none of the blocks.
- Spec and plan: `docs/superpowers/specs/2026-11-03-sfm-phase5-settings-design.md`,
`docs/superpowers/plans/2026-11-03-sfm-phase5-settings.md`.
- **Histogram timing in the protocol reference (D.6.10):** - **Histogram timing in the protocol reference (D.6.10):**
- the histogram's own event record - the histogram's own event record
- the interval-time and peak-time rules - the interval-time and peak-time rules
@@ -291,6 +459,46 @@ All notable changes to seismo-relay are documented here.
- **CLAUDE.md "Where things stand"** now reflects the range fix. - **CLAUDE.md "Where things stand"** now reflects the range fix.
- Docs only: no code change, no migration. - Docs only: no code change, no migration.
### Migration
⚠ **Schema migration and backfill.** Rehearsed twice on a copy of prod's
2026-09-30 snapshot (15,432 events), before and after the parity merge, with
identical results.
**Before you start:**
- `TOOL_VERSION` is bumped to **0.34.0**, which gates the regeneration, so no
`--force` is needed.
- **Back up `seismo_relay.db` first.**
**Then:**
1. **Deploy.** On first start SFM migrates the database by itself.
- The events table is re-keyed `UNIQUE(serial, timestamp, record_type)`
(Migration 3): every row and id is kept and the indexes are rebuilt.
Rehearsal: 0.27 s, every row identical, integrity ok.
- `device_commands` is created.
2. **In the `sfm` container, `python scripts/backfill_sidecars.py`** re-decodes
every event file. ⚠ **Plan an overnight run:** the store holds about 64,000
events after the 2200-day watcher forward, at about 1.5 files/s on the NAS,
so roughly 12 hours.
- **Every Series-3 histogram's time moves forward one second, in place**,
with id and review state kept. Rehearsal: 9,852 moved, 0 refused, no id
lost.
- **The same-second waveform/histogram pairs coexist** (209 in the
snapshot).
- It also creates a row for any store file that never had one (341 in the
snapshot): the known one-time behaviour, not duplicates.
- **Report-less events** pick up every new field. **Report-paired events**
keep the report's overlaid peaks, notes, sample rate and record time.
3. **`python scripts/backfill_event_shape.py --db-path bridges/captures/seismo_relay.db
--store-root bridges/captures/waveforms`** recomputes shape and offset
metrics. Rehearsal: exit 0, `cleared_stale` 0.
**Terra-View** needs no change: it pairs twins by peak values and reads rows by
id. Moving a histogram forward one second can carry an event across a
deployment-window edge.
**Series-4** event times do not move.
## v0.33.0 — 2026-11-01 ## v0.33.0 — 2026-11-01
**SFM reads Series-3 events from the file alone, and proves it against **SFM reads Series-3 events from the file alone, and proves it against
+13 -4
View File
@@ -2,7 +2,7 @@
Ground-up Python replacement for **Blastware**, Instantel's Windows-only software for Ground-up Python replacement for **Blastware**, Instantel's Windows-only software for
managing MiniMate Plus seismographs. Connects over direct RS-232 or cellular modem managing MiniMate Plus seismographs. Connects over direct RS-232 or cellular modem
(Sierra Wireless RV50 / RV55). Current version: **v0.33.0**. (Sierra Wireless RV50 / RV55). Current version: **v0.34.0**.
Stack-level context — which repo owns what, and how the three project versions Stack-level context — which repo owns what, and how the three project versions
pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as
@@ -308,7 +308,7 @@ Read this first when picking the project back up.
menu. ⚠ **Neither series takes a call-home change while monitoring:** a MiniMate menu. ⚠ **Neither series takes a call-home change while monitoring:** a MiniMate
returns its device-info block, and a Micromate acks the write and ignores it. returns its device-info block, and a Micromate acks the write and ignores it.
SFM refuses both up front. SFM refuses both up front.
**Phase 5 built 2026-11-03, bench pending:** change a unit's settings by serial, **Phase 5 built 2026-11-03, benched 2026-11-04:** change a unit's settings by serial,
both series (`POST /device/settings/change`; the Config tab's Preview, then Send). both series (`POST /device/settings/change`; the Config tab's Preview, then Send).
Spec `docs/superpowers/specs/2026-11-03-sfm-phase5-settings-design.md`. Spec `docs/superpowers/specs/2026-11-03-sfm-phase5-settings-design.md`.
- 🔑 **A MiniMate's settings block IS Series IV's `0x1A` layout** (measured): - 🔑 **A MiniMate's settings block IS Series IV's `0x1A` layout** (measured):
@@ -319,8 +319,17 @@ Read this first when picking the project back up.
needs its preview's revision; refused up front: monitoring, a Micromate on needs its preview's revision; refused up front: monitoring, a Micromate on
its factory setup or whose schedule would load another setup. its factory setup or whose schedule would load another setup.
- Retired: `/device/config` (410), `apply_config`, `_encode_compliance_config`. - Retired: `/device/config` (410), `apply_config`, `_encode_compliance_config`.
- ⚠ Not yet sent to a unit. The MiniMate alarm level is read-only until a - **Benched 2026-11-04, both series:** every change acknowledged, read back,
bench write is checked (`S3_ALARM_WRITE_MEASURED`). and confirmed on the unit's screen; both units restored byte for byte. The
MiniMate alarm write is measured and now on.
- ⚠ **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.
- ⚠ 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 **Ring path measured the same night:** with THOR's watchdog off, a call-home
reaches THOR when nobody holds the line, and **is lost when SFM holds it** -- reaches THOR when nobody holds the line, and **is lost when SFM holds it** --
the unit takes SFM's connection for the call, times out and does not retry. the unit takes SFM's connection for the call, times out and does not retry.
+20 -1
View File
@@ -1,4 +1,4 @@
# seismo-relay `v0.33.0` # seismo-relay `v0.34.0`
A ground-up replacement for **Blastware** — Instantel's aging Windows-only A ground-up replacement for **Blastware** — Instantel's aging Windows-only
software for managing seismographs. Supports both the **MiniMate Plus software for managing seismographs. Supports both the **MiniMate Plus
@@ -95,6 +95,25 @@ over direct RS-232 or cellular modem (Sierra Wireless RV50 / RV55).
> >
> ⚠ The deploy owes a backfill; it does not move event times. See the > ⚠ The deploy owes a backfill; it does not move event times. See the
> changelog's *Migration*. > changelog's *Migration*.
>
> **v0.34.0 (2026-11-04)** reaches Series-4 parity and reads most of
> Blastware's report from the event file alone.
> - **Series-4 parity:** one device door by serial for both series, with
> reads, downloads, start/stop, call-home and settings changes, each audited
> and read back. MiniMate request framing is fixed (#46).
> - **The file-only decode:** 47 of Blastware's 88 report fields match on
> every DL2 event, and 8 more on all but one or two.
> - Sensitive-range events are no longer 8× high.
> - Histograms decode correctly and carry Blastware's own times (#51).
> - Interval frequencies follow the sample rate (#50).
> - New from the file: the job number, serial, version, calibration,
> battery, trigger source and levels, interval detail, peak times and
> peak acceleration.
> - **Events are identified by unit + time + type.**
>
> ⚠ The deploy migrates the events table and owes an overnight backfill that
> moves every Series-3 histogram time by one second. See the changelog's
> *Migration*.
> See [CHANGELOG.md](CHANGELOG.md) for full version history. > See [CHANGELOG.md](CHANGELOG.md) for full version history.
--- ---
+1
View File
@@ -11,6 +11,7 @@
| Date | Section | Change | | Date | Section | Change |
|---|---|---| |---|---|---|
| 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 (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. | | 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. |
| 2026-11-03 (3) | Appendix D.6.9 (NEW), D.6.10 | ✅ **Histogram interval detail.** Interval size = uint16 seconds at `k − 40`; stop = footer ts2. Frequency = (sample rate / 2) / half-period, 527,915 / 527,915 cells at 1024 sps and 1,725 / 1,725 at 2048 — **#50 retracted** (a fixed 512 halved 2048-sps frequencies). Blastware's words: `N/A` (half-period 0), `>100` / `>200` (≤ 5 samples), `<1.0`. Per-interval vector sum √PVS²: 63,497 histograms; `OORANGE` when over range with a clamped channel, 17 / 17. 34 of 88 report fields now match on every DL2 event. | | 2026-11-03 (3) | Appendix D.6.9 (NEW), D.6.10 | ✅ **Histogram interval detail.** Interval size = uint16 seconds at `k − 40`; stop = footer ts2. Frequency = (sample rate / 2) / half-period, 527,915 / 527,915 cells at 1024 sps and 1,725 / 1,725 at 2048 — **#50 retracted** (a fixed 512 halved 2048-sps frequencies). Blastware's words: `N/A` (half-period 0), `>100` / `>200` (≤ 5 samples), `<1.0`. Per-interval vector sum √PVS²: 63,497 histograms; `OORANGE` when over range with a clamped channel, 17 / 17. 34 of 88 report fields now match on every DL2 event. |
+33
View File
@@ -2745,6 +2745,39 @@ were wrong.
established** — only one setting was varied. Series III's offsets are a starting established** — only one setting was varied. Series III's offsets are a starting
hypothesis, not a transfer. hypothesis, not a transfer.
#### Bench 2026-11-04: SFM's first setup push (UM20147)
SFM's audited `POST /device/settings/change`, one send per go (Brian at the
unit). Notes: `~/bench-logs/2026-11-04-sfm-settings/`.
**Measured:**
- **The setup push works as THOR's.** Trigger 0.6 → 0.5, then a five-field
change (Location, Client, job number + its report flag, record time), then a
full restore. Each send was THOR's seven frames, acknowledged in THOR's order
(`25 97 8C 7D 7C 8E 8D`), read back as sent, and confirmed in the unit's menu.
The setup block ended byte for byte as found, CRC included.
- **The unit's recomputed CRC equals SFM's** (`with_crc`): after the first push
the stored block equalled SFM's computed image byte for byte, CRC `ea8d`
included.
- **`schedule.dat` read on a real unit** (`0x94` → `0x6B`; `0x48` → descriptor
`04 00 … 01 … 01`, body, all-zero end). UM20147 holds a leftover THOR
schedule: repeat on, 07:00, start monitoring with
`Fay - Commercial Street - Irish Center.mmb`. The unit runs `test2.MMB`, so
SFM blocked the change, as designed.
- 🔑 **The scheduler On/Off switch is in none of the blocks SFM reads.** With
the keypad switch Off, then On (saved), these were byte for byte identical:
`0x08` prefs, `0x2E`, `0x1A`, `0x2C`, `0x41` and `schedule.dat`. The
firmware's `SysPref.bMonitorScheduler` lives elsewhere. THOR's end-of-push
`0x47` pair (`params[7]` 1 then 3; replies `04 00 … 0N … 00 01`) was only
ever captured with the switch On. **Next:** a THOR bridge recording with the
switch Off (parked for the work-hours project).
- **While monitoring**, a settings preview and a live attempt were both refused
on the run state before any block was read (409, nothing sent, 0 write frames).
- **With call-home off, a stop goes straight to idle** (`monitoring` →
`idle`): no calling-home state and no ring.
- Call-home `0x01` ↔ `0x00` was taken again, both ways. The plan's
"unobserved" warning is retired for those values.
## What the THOR manual settles about the ACH session (2026-09-24) ## What the THOR manual settles about the ACH session (2026-09-24)
Source: `manuals/723U0201 THOR Operator Manual Rev 08.pdf` §6.2, §3.6. Source: `manuals/723U0201 THOR Operator Manual Rev 08.pdf` §6.2, §3.6.
@@ -1,7 +1,8 @@
# Phase 5: changing a unit's settings by serial (design) # Phase 5: changing a unit's settings by serial (design)
**Date:** 2026-11-03. **Status:** approved by Brian 2026-11-03; built 2026-11-03 **Date:** 2026-11-03. **Status:** approved by Brian 2026-11-03; built 2026-11-03
(plan `docs/superpowers/plans/2026-11-03-sfm-phase5-settings.md`); bench pending. Phase 5 of (plan `docs/superpowers/plans/2026-11-03-sfm-phase5-settings.md`); **benched 2026-11-04** on both
series (results at the end). Phase 5 of
`docs/superpowers/specs/2026-10-20-sfm-series4-parity-design.md` (row 10, "change `docs/superpowers/specs/2026-10-20-sfm-series4-parity-design.md` (row 10, "change
recording settings"; build phase 5, "setup push: one field first, then several"). recording settings"; build phase 5, "setup push: one field first, then several").
**Branch:** `feat/series4-sfm-parity`. **Branch:** `feat/series4-sfm-parity`.
@@ -342,6 +343,37 @@ intervals 2/5/15/60/300/900 s, and each series' measured mode codes.
3. A several-field "backup unit" change. 3. A several-field "backup unit" change.
4. A dry run while monitoring, expecting the refusal. 4. A dry run while monitoring, expecting the refusal.
## Bench 2026-11-04 (results)
Brian at BE9441 and UM20147, each on its own modem; every send with his go.
Notes: `~/bench-logs/2026-11-04-sfm-settings/`.
- **Both series change correctly.** Each change was acknowledged, read back as
sent, and confirmed on the unit's own screen; both units ended byte for byte as
found.
- BE9441: trigger each way, a note, several fields at once, the alarm, a full
restore.
- UM20147: trigger, several fields (two notes, job number and its flag, record
time), a full restore. The unit's recomputed CRC equalled SFM's.
- **Fixed at the bench (`9992b25`):** the first live MiniMate read came back one
byte long. An escaped checksum byte leaves its `0x10` behind (about 1 frame in
85; the recordings never had it). The read now takes exactly the lengths it
asked for, and so does the waveform read (`c790e20`).
- **🔑 The keypad menu wins.** A MiniMate change sent while its setup menu is
open is acknowledged and read back, then lost when the operator presses Cancel
or Save: the menu writes its copy of the whole block back. SFM cannot see this
happen; the MiniMate preview now warns. Rule for the field-plus-office routine:
nobody in the unit's menus while the office sends.
- **The MiniMate alarm write is measured**, so it is now writable (`55c7b7b`).
- **Refused while recording, both series, nothing sent.** A recording MiniMate
sometimes leaves a preview at "no answer" rather than the refusal.
- **The Micromate scheduler switch is in no block SFM reads.** UM20147 carries a
leftover THOR schedule (Fay setup, 07:00 daily) with the switch Off; SFM blocks
it, a false alarm here. The bench used a scratch-only override.
- Next: a THOR bridge recording to find the switch (parked for work hours).
- Meanwhile, worth considering: let the operator confirm "scheduler off" in the
preview.
## Calls I made (Claude), for Brian to check ## Calls I made (Claude), for Brian to check
- **Series 3 `[26:28]` goes out as `00 00`, as Blastware writes it**, rather than - **Series 3 `[26:28]` goes out as `00 00`, as Blastware writes it**, rather than
+5 -4
View File
@@ -61,7 +61,7 @@ _CHANNELS, _CHANNEL_SIZE, _GEOPHONES = 1708, 48, (0, 1, 2)
_CH_RANGE = 29 # u8: 0 Normal (10 in/s), 1 Sensitive (1.25 in/s) -- Series 3, measured _CH_RANGE = 29 # u8: 0 Normal (10 in/s), 1 Sensitive (1.25 in/s) -- Series 3, measured
_CH_TRIGGER = 30 # f32 BE, in/s for a geophone _CH_TRIGGER = 30 # f32 BE, in/s for a geophone
_CH_UNIT = slice(34, 38) # "in." / "in" (the keypad re-renders it); NOT an identifier _CH_UNIT = slice(34, 38) # "in." / "in" (the keypad re-renders it); NOT an identifier
_CH_ALARM = 38 # f32 BE -- Series 3, read; a write waits for the bench _CH_ALARM = 38 # f32 BE -- Series 3; write measured at the bench 2026-11-04
_FULL_SCALE = {0: 10.0, 1: 1.25} _FULL_SCALE = {0: 10.0, 1: 1.25}
_RANGES = {"normal": 0, "sensitive": 1} _RANGES = {"normal": 0, "sensitive": 1}
@@ -70,9 +70,10 @@ _RANGES = {"normal": 0, "sensitive": 1}
# unknown -- SFM writes what Blastware writes. Series 3 only. # unknown -- SFM writes what Blastware writes. Series 3 only.
S3_BLASTWARE_FIXED = {26: b"\x00\x00"} S3_BLASTWARE_FIXED = {26: b"\x00\x00"}
# A Series-3 alarm-level write has never been seen; the bench measures one, with # Measured at the bench 2026-11-04 (BE9441, Brian's go): 1.0 -> 1.5 -> 1.0 in/s,
# Brian's go, before this turns on. # each acknowledged, read back, and shown in the unit's own setup menu; the write
S3_ALARM_WRITE_MEASURED = False # moved exactly channel +39 of the three geophones (the f32 at +38).
S3_ALARM_WRITE_MEASURED = True
MODES = { MODES = {
3: {"single_shot": 0x00, "continuous": 0x01, "histogram": 0x03, "histogram_continuous": 0x04}, 3: {"single_shot": 0x00, "continuous": 0x01, "histogram": 0x03, "histogram_continuous": 0x04},
+9 -6
View File
@@ -22,6 +22,7 @@ from .opcodes import CROSS_SERIES_COLLISIONS, WRITE_SUBS, OpcodeRefused
from .setup_block import crc_ok from .setup_block import crc_ok
_CONFIRM = 0xFFFF _CONFIRM = 0xFFFF
_CALL_HOME_OBSERVED = (0x00, 0x01, 0x04, 0x05) # content[5] values units have held
# block content sizes THOR's offsets were observed at (all on UM12947 / 11.0CB) # block content sizes THOR's offsets were observed at (all on UM12947 / 11.0CB)
_PREFS_LEN, _TRIGGER_LEN, _SETUP_LEN, _CALL_HOME_LEN = 90, 28, 2092, 126 _PREFS_LEN, _TRIGGER_LEN, _SETUP_LEN, _CALL_HOME_LEN = 90, 28, 2092, 126
@@ -113,9 +114,10 @@ def plan_call_home_enabled(call_home: bytes, enabled: bool) -> WritePlan:
Bit 0 of `[5]` is the enable. 🔶 UM12947 (THOR's unit) read 0x05 enabled / Bit 0 of `[5]` is the enable. 🔶 UM12947 (THOR's unit) read 0x05 enabled /
0x04 disabled, bit 2 set in both; UM20147 reads 0x01 (measured, phase-2 dry 0x04 disabled, bit 2 set in both; UM20147 reads 0x01 (measured, phase-2 dry
run). So on UM20147 "off" writes 0x00, a value no capture shows being run). So on UM20147 "off" writes 0x00 -- measured at the bench 2026-11-03
written: the target value there is unobserved, and the plan's `warnings` (and again 11-04): 0x01 <-> 0x00 acknowledged, read back, and matched in the
say so. `[118:120]` is unit-maintained and THOR echoes it. unit's own menu. A value outside those four still carries a warning.
`[118:120]` is unit-maintained and THOR echoes it.
""" """
if len(call_home) != _CALL_HOME_LEN: if len(call_home) != _CALL_HOME_LEN:
raise ValueError(f"call-home content must be {_CALL_HOME_LEN} B " raise ValueError(f"call-home content must be {_CALL_HOME_LEN} B "
@@ -128,9 +130,10 @@ def plan_call_home_enabled(call_home: bytes, enabled: bool) -> WritePlan:
what = "call-home " + ("enable" if enabled else "disable") what = "call-home " + ("enable" if enabled else "disable")
start = call_home[5] start = call_home[5]
warnings = [] warnings = []
if start not in (0x04, 0x05) or b5 not in (0x04, 0x05): if start not in _CALL_HOME_OBSERVED or b5 not in _CALL_HOME_OBSERVED:
warnings.append(f"content[5] 0x{start:02X} -> 0x{b5:02X}: THOR was only ever " warnings.append(f"content[5] 0x{start:02X} -> 0x{b5:02X}: no unit has been seen "
"seen writing 0x04/0x05 (UM12947); this value is unobserved") "holding this value (0x04/0x05 UM12947 by THOR, 0x00/0x01 UM20147 "
"by SFM); it is unobserved")
if b5 == start: if b5 == start:
warnings.append(f"the unit is already call-home {'enabled' if enabled else 'disabled'}" warnings.append(f"the unit is already call-home {'enabled' if enabled else 'disabled'}"
" -- this write changes nothing") " -- this write changes nothing")
+11
View File
@@ -137,6 +137,17 @@ def sfm_side(raw: bytes) -> SfmSide:
if pv is not None: if pv is not None:
values.update(TranPPV=pv.tran, VertPPV=pv.vert, LongPPV=pv.long, values.update(TranPPV=pv.tran, VertPPV=pv.vert, LongPPV=pv.long,
PeakVectorSum=pv.peak_vector_sum) PeakVectorSum=pv.peak_vector_sum)
# A waveform's peak detail (None on a histogram, so not reported).
for tag, value in (("TranTimeofPeak", pv.tran_time_of_peak),
("VertTimeofPeak", pv.vert_time_of_peak),
("LongTimeofPeak", pv.long_time_of_peak),
("MicLTimeofPeak", pv.micl_time_of_peak),
("PeakVectorSumTimeSum", pv.pvs_time),
("TranPeakAcceleration", pv.tran_peak_accel_g),
("VertPeakAcceleration", pv.vert_peak_accel_g),
("LongPeakAcceleration", pv.long_peak_accel_g)):
if value is not None:
values[tag] = value
if counts["MicL"]: if counts["MicL"]:
values["MicLPSPL dB(L)"] = mic_count_to_db(max(abs(c) for c in counts["MicL"])) values["MicLPSPL dB(L)"] = mic_count_to_db(max(abs(c) for c in counts["MicL"]))
values["MicLPSPL psi(L)"] = pv.micl if pv is not None else None values["MicLPSPL psi(L)"] = pv.micl if pv is not None else None
+43 -1
View File
@@ -52,7 +52,7 @@ SIDECAR_KIND = "sfm.event"
# bumped without a `pip install` re-run — leading to confusing stale # bumped without a `pip install` re-run — leading to confusing stale
# version stamps in sidecars. Bump this constant and CHANGELOG.md # version stamps in sidecars. Bump this constant and CHANGELOG.md
# together at release time. # together at release time.
TOOL_VERSION = "0.33.0" # setup + notes, record type, histogram PVS and mic from the file; gates the backfill regen TOOL_VERSION = "0.34.0" # file-only decode groups A-D, histogram times (#51); gates the backfill regen
try: try:
# Best-effort: prefer the installed metadata when it's NEWER than the # Best-effort: prefer the installed metadata when it's NEWER than the
@@ -794,6 +794,45 @@ def _peaks_from_samples(samples: dict[str, list[int]],
) )
# Blastware's g for peak acceleration, fitted: every printed acceleration in
# DL2 bounds it, and together they leave [386.2236, 386.2240] in/s^2 -- 19,475 /
# 19,479 values fit (the other 4: one odd file, O117I1NK.R70W, and one sample
# mismatch). That is 9.81 m/s^2 (386.2205) plus an offset not explained, as
# with the mic's fitted dB offset; 9.81 gives 19,423, the standard 9.80665 gives
# 17,806 (2026-11-04).
_ACCEL_IPS2_PER_G = 386.2238
def _waveform_peak_detail(pv: PeakValues, samples: dict[str, list[int]], geo_fs_ins: float,
sample_rate: int, pretrig: int) -> None:
"""A waveform's time of peak per channel, the vector sum's time and each
geophone's peak acceleration, on `pv`. Measured on 400 DL2 waveforms
(2026-11-04):
* time of peak = (first peak sample - pre-trigger samples) / sample rate,
1,197 / 1,197; the vector-sum time is the same on sqrt(T^2 + V^2 + L^2),
398 / 399
* peak acceleration = the largest |v[i+1] - v[i]| x sample rate / g,
with Blastware's fitted g -- the manuals: "subtracts two velocity
readings and divides the result by the elapsed time between them"."""
scale = geo_fs_ins / _GEO_INT16_FS
geo = {}
for ch in ("Tran", "Vert", "Long", "MicL"):
c = samples.get(ch) or []
if not c:
continue
i = max(range(len(c)), key=lambda k: abs(c[k]))
setattr(pv, f"{ch.lower()}_time_of_peak", (i - pretrig) / sample_rate)
if ch != "MicL":
geo[ch] = c
step = max((abs(c[k + 1] - c[k]) for k in range(len(c) - 1)), default=0)
setattr(pv, f"{ch.lower()}_peak_accel_g", step * scale * sample_rate / _ACCEL_IPS2_PER_G)
if len(geo) == 3:
n = min(len(c) for c in geo.values())
t, v, l = geo["Tran"], geo["Vert"], geo["Long"]
j = max(range(n), key=lambda k: t[k] * t[k] + v[k] * v[k] + l[k] * l[k])
pv.pvs_time = (j - pretrig) / sample_rate
# STRT[18], the record-type byte (#41): 0x46 on every one of DL2's 6,577 # STRT[18], the record-type byte (#41): 0x46 on every one of DL2's 6,577
# waveform files and 0x0A on every one of its 63,535 histograms (measured # waveform files and 0x0A on every one of its 63,535 histograms (measured
# 2026-10-29). Manual / Event / Combo never occur there, so their bytes are # 2026-10-29). Manual / Event / Combo never occur there, so their bytes are
@@ -1480,6 +1519,9 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
# The geophone full scale is the file's range; Normal when it wasn't read. # The geophone full scale is the file's range; Normal when it wasn't read.
geo_fs = _GEO_FS_BY_RANGE.get(ev.geo_range, _GEO_NORMAL_FS_INS) geo_fs = _GEO_FS_BY_RANGE.get(ev.geo_range, _GEO_NORMAL_FS_INS)
ev.peak_values = _peaks_from_samples(samples, geo_fs) if has_samples else None ev.peak_values = _peaks_from_samples(samples, geo_fs) if has_samples else None
if (is_waveform_body and ev.peak_values is not None and ev.sample_rate
and ev.pretrig_samples is not None):
_waveform_peak_detail(ev.peak_values, samples, geo_fs, ev.sample_rate, ev.pretrig_samples)
if ev.stop_time is None: # a histogram's record stop, else the footer's if ev.stop_time is None: # a histogram's record stop, else the footer's
ev.stop_time = ts2 ev.stop_time = ts2
if hist_records: if hist_records:
+9
View File
@@ -364,6 +364,15 @@ class PeakValues:
vert_zc_above_range: bool = False vert_zc_above_range: bool = False
long_zc_above_range: bool = False long_zc_above_range: bool = False
mic_zc_above_range: bool = False mic_zc_above_range: bool = False
# A waveform's peak detail, from its samples (2026-11-04); None for a histogram.
tran_time_of_peak: Optional[float] = None # s from the trigger; negative = pre-trigger
vert_time_of_peak: Optional[float] = None
long_time_of_peak: Optional[float] = None
micl_time_of_peak: Optional[float] = None
pvs_time: Optional[float] = None # s from the trigger, of the vector-sum peak
tran_peak_accel_g: Optional[float] = None
vert_peak_accel_g: Optional[float] = None
long_peak_accel_g: Optional[float] = None
# ── Project / operator metadata ─────────────────────────────────────────────── # ── Project / operator metadata ───────────────────────────────────────────────
+21 -5
View File
@@ -185,14 +185,26 @@ class ImageRefused(ValueError):
# tests/test_s3_settings_read.py. # tests/test_s3_settings_read.py.
COMPLIANCE_CONTENT_LEN = 2090 COMPLIANCE_CONTENT_LEN = 2090
# SFM's 1A read: (offset = the content length asked for, page) per data frame.
_COMPLIANCE_READ_STEPS = ((0x0400, 0x00), (0x0400, 0x04), (0x002A, 0x08))
def assemble_compliance_content(frames: "list[bytes]") -> bytes: def assemble_compliance_content(frames: "list[bytes]", lengths: "Optional[tuple]" = None) -> bytes:
"""Join a 1A read's data frames (each S3Frame.data, kept escapes and all, in """Join a 1A read's data frames (each S3Frame.data, kept escapes and all, in
order) into the logical settings block. Judges nothing: a monitoring unit's order) into the logical settings block. Judges nothing: a monitoring unit's
device-info answer assembles too -- `is_compliance_content` tells them apart.""" device-info answer assembles too -- `is_compliance_content` tells them apart.
`lengths`: the content each frame was asked for (SFM's read: 1024, 1024, 42).
Each frame then gives exactly that. Measured at the bench 2026-11-04 (BE9441):
when a frame's checksum byte is itself escaped (02 / 03 / 04), the parser keeps
the escape's 0x10 and strips only the byte after it, so the frame arrives one
byte long, ending in a lone 0x10. That one byte is dropped; any other leftover
is kept, and the block then fails is_compliance_content."""
parts = [unescape_reply(bytes(f))[11:] for f in frames] parts = [unescape_reply(bytes(f))[11:] for f in frames]
return b"".join(p[1:] for p in parts[:-1]) + (parts[-1] if parts else b"") parts = [p[1:] for p in parts[:-1]] + parts[-1:]
if lengths is not None and len(lengths) == len(parts):
parts = [p[:n] if p[n:] == b"\x10" else p for p, n in zip(parts, lengths)]
return b"".join(parts)
def is_compliance_content(block: bytes) -> bool: def is_compliance_content(block: bytes) -> bool:
@@ -621,6 +633,10 @@ class MiniMateProtocol:
data_rsp = self._recv_one(expected_sub=rsp_sub) data_rsp = self._recv_one(expected_sub=rsp_sub)
raw = unescape_reply(data_rsp.data)[11:] # unescaped, as read_event_index raw = unescape_reply(data_rsp.data)[11:] # unescaped, as read_event_index
# An escaped checksum byte leaves its 0x10 behind (bench 2026-11-04; see
# assemble_compliance_content): one stray byte beyond what was asked is dropped.
if len(raw) == length + 1 and raw[-1:] == b"\x10":
raw = raw[:-1]
log.debug("read_waveform_data_raw: got %d bytes", len(raw)) log.debug("read_waveform_data_raw: got %d bytes", len(raw))
return raw return raw
@@ -1074,11 +1090,11 @@ class MiniMateProtocol:
self._send(build_bw_frame(SUB_COMPLIANCE, 0, bytes([0, 0, 0, 0, 0, 0, 0, 0x64, 0, 0]))) self._send(build_bw_frame(SUB_COMPLIANCE, 0, bytes([0, 0, 0, 0, 0, 0, 0, 0x64, 0, 0])))
self._recv_one(expected_sub=rsp_sub) self._recv_one(expected_sub=rsp_sub)
frames = [] frames = []
for offset, page in ((0x0400, 0x00), (0x0400, 0x04), (0x002A, 0x08)): for offset, page in _COMPLIANCE_READ_STEPS:
self._send(build_bw_frame(SUB_COMPLIANCE, offset, self._send(build_bw_frame(SUB_COMPLIANCE, offset,
bytes([0, 0, page, 0, 0, 0, 0, 0x64, 0, 0]))) bytes([0, 0, page, 0, 0, 0, 0, 0x64, 0, 0])))
frames.append(self._recv_one(expected_sub=rsp_sub).data) frames.append(self._recv_one(expected_sub=rsp_sub).data)
return assemble_compliance_content(frames) return assemble_compliance_content(frames, lengths=tuple(o for o, _ in _COMPLIANCE_READ_STEPS))
# ── Write commands (SUBs 68–83) ─────────────────────────────────────────── # ── Write commands (SUBs 68–83) ───────────────────────────────────────────
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "seismo-relay" name = "seismo-relay"
version = "0.33.0" version = "0.34.0"
description = "Python client and REST server for MiniMate Plus seismographs" description = "Python client and REST server for MiniMate Plus seismographs"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [ dependencies = [
+12 -3
View File
@@ -854,7 +854,8 @@ class SeismoDb:
).fetchone() ).fetchone()
return dict(row) if row else None return dict(row) if row else None
def find_event_by_blastware_name(self, serial: str, filename: str) -> Optional[dict]: def find_event_by_blastware_name(self, serial: str, filename: str,
record_type: Optional[str] = None) -> Optional[dict]:
"""The row stored under `filename`'s Blastware name, or None. """The row stored under `filename`'s Blastware name, or None.
A Blastware name encodes the serial and the event's second A Blastware name encodes the serial and the event's second
@@ -865,6 +866,10 @@ class SeismoDb:
itself and the letterless form -- not the other letter, since in itself and the letterless form -- not the other letter, since in
Histogram+Continuous a waveform can trigger in the second a histogram Histogram+Continuous a waveform can trigger in the second a histogram
starts. Any other name ("imported.bw") matches nothing. starts. Any other name ("imported.bw") matches nothing.
`record_type`: only a row of that type -- or an untyped one, which may be
this event -- matches (#51: a same-second waveform / histogram twin shares
the letterless name). Compared ignoring case.
""" """
if blastware_filename_time(filename) is None: if blastware_filename_time(filename) is None:
return None return None
@@ -874,10 +879,14 @@ class SeismoDb:
else: else:
forms = (name, name + "W", name + "H") forms = (name, name + "W", name + "H")
with self._connect() as conn: with self._connect() as conn:
typed, args = "", (serial, *forms)
if record_type is not None:
typed = " AND (record_type IS NULL OR UPPER(record_type) = UPPER(?))"
args = (*args, record_type)
row = conn.execute( row = conn.execute(
f"SELECT * FROM events WHERE serial = ? AND UPPER(blastware_filename) IN " f"SELECT * FROM events WHERE serial = ? AND UPPER(blastware_filename) IN "
f"({', '.join('?' * len(forms))}) ORDER BY rowid LIMIT 1", f"({', '.join('?' * len(forms))}){typed} ORDER BY rowid LIMIT 1",
(serial, *forms), args,
).fetchone() ).fetchone()
return dict(row) if row else None return dict(row) if row else None
+7 -2
View File
@@ -69,7 +69,12 @@ _S3_SETTINGS_STEPS = ((0x68, "event index (as read)"), (0x73, "confirm B"),
(0x82, "trigger block (as read)"), (0x83, "trigger confirm"), (0x82, "trigger block (as read)"), (0x83, "trigger confirm"),
(0x69, "waveform data (as read)"), (0x74, "confirm C"), (0x72, "confirm A")) (0x69, "waveform data (as read)"), (0x74, "confirm C"), (0x72, "confirm A"))
_S3_TAIL_WARNING = ("the two bytes after the settings block go out as 00 00 (Blastware sends " _S3_TAIL_WARNING = ("the two bytes after the settings block go out as 00 00 (Blastware sends "
"its own constant; effect unmeasured)") "its own constant; the unit took it at the bench 2026-11-04)")
# Measured at the bench 2026-11-04 (BE9441): 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.
_S3_MENU_WARNING = ("if someone is in this unit's setup menu, this change is lost when they "
"leave it (Cancel or Save writes the menu's copy back)")
S3_RUN_STATES = {0x00: "idle", 0x10: "monitoring", 0x0B: "monitoring"} S3_RUN_STATES = {0x00: "idle", 0x10: "monitoring", 0x0B: "monitoring"}
@@ -525,7 +530,7 @@ class Series3Adapter:
for sub, what in _S3_SETTINGS_STEPS] for sub, what in _S3_SETTINGS_STEPS]
return {"action": "settings write", "blocked": list(st["blocked"]), "steps": steps, return {"action": "settings write", "blocked": list(st["blocked"]), "steps": steps,
"fields": field_rows(st["setup"], st["image"], 3, st["changes"]), "fields": field_rows(st["setup"], st["image"], 3, st["changes"]),
"revision": st["revision"], "warnings": [_S3_TAIL_WARNING]} "revision": st["revision"], "warnings": [_S3_MENU_WARNING, _S3_TAIL_WARNING]}
def send() -> dict: def send() -> dict:
b = st["blocks"] b = st["blocks"]
+33 -6
View File
@@ -134,16 +134,43 @@ def _overlay_s4_record(ev: Any, record: dict) -> None:
ev.project_info.sensor_location = location ev.project_info.sensor_location = location
def _download_record_type(dl: DownloadedEvent) -> Optional[str]:
"""The download's own record type -- "Waveform" / "Histogram", as every stored
row has it -- from its file: a Series-3 file's STRT[18], a Series-4 name's
IDFW / IDFH. None when it does not read (then any row at its second counts)."""
if dl.series == 4:
ext = dl.filename.rsplit(".", 1)[-1].upper()
return {"IDFW": "Waveform", "IDFH": "Histogram"}.get(ext)
if not dl.bw_bytes:
return None
try:
from minimateplus.event_file_io import decode_blastware_bytes
return decode_blastware_bytes(dl.bw_bytes).record_type
except Exception: # noqa: BLE001 -- a check, not a decode
return None
def _same_type(row_type: Optional[str], mine: Optional[str]) -> bool:
"""An untyped row, or a download whose type does not read, matches
conservatively: it may be this event."""
return row_type is None or mine is None or row_type.casefold() == mine.casefold()
def persist_download(dl: DownloadedEvent, *, store: Any, db: Any) -> EventDownload: def persist_download(dl: DownloadedEvent, *, store: Any, db: Any) -> EventDownload:
# Never merge: a row for (serial, timestamp) means the event is stored, and # Never merge: a row for (serial, timestamp, record type) means the event is
# whoever stored it first keeps it. No store call, no insert, no sidecar. # stored, and whoever stored it first keeps it. No store call, no insert, no
# sidecar. The type matters since #51: a waveform and a histogram recorded in
# the same second (Histogram + Continuous) are two events.
kind = _download_record_type(dl)
if dl.timestamp is not None: if dl.timestamp is not None:
rows = db.query_events(serial=dl.serial, from_dt=dl.timestamp, to_dt=dl.timestamp, limit=1) rows = db.query_events(serial=dl.serial, from_dt=dl.timestamp, to_dt=dl.timestamp, limit=10)
rows = [r for r in rows if _same_type(r.get("record_type"), kind)]
if rows: if rows:
return _already_stored(dl, rows[0]) return _already_stored(dl, rows[0])
# A histogram's row is stored at its file's time, a second before the unit's # The Blastware name encodes the event's second (a second guard; before #51 a
# on most (#51), so the time above misses it; its Blastware name does not. # histogram's row sat a second off the unit's time). Both twins share the
row = db.find_event_by_blastware_name(dl.serial, dl.filename) # letterless name, so it too is held to the type.
row = db.find_event_by_blastware_name(dl.serial, dl.filename, record_type=kind)
if row is not None: if row is not None:
return _already_stored(dl, row) return _already_stored(dl, row)
if dl.series == 4: if dl.series == 4:
+27
View File
@@ -495,3 +495,30 @@ def test_a_histogram_without_its_record_falls_back_to_the_footer_and_says_so():
assert ev.timestamp_source == "footer" assert ev.timestamp_source == "footer"
assert ev.timestamp.second == 25 # the footer's start, a second early assert ev.timestamp.second == 25 # the footer's start, a second early
assert any("histogram event record" in p for p in ev.decode_problems) assert any("histogram event record" in p for p in ev.decode_problems)
# ── Group D, part 1: time of peak, vector-sum time, peak acceleration ───────
# Measured on 400 DL2 waveforms (2026-11-04):
# time of peak = (peak sample - pre-trigger samples) / sample rate: 1,197 / 1,197
# vector-sum time, the same on sqrt(T^2 + V^2 + L^2): 398 / 399
# peak acceleration = largest |v[i+1] - v[i]| x rate / g, with Blastware's g
# fitted to [386.2236, 386.2240] in/s^2 by every DL2 value: 19,475 / 19,479
@pytest.mark.parametrize("rel,times,pvs_time,accel", [
(f"{_SF}/T189HUD6.QE0W",
{"tran": 0.004, "vert": 0.001, "long": 0.024, "micl": 0.003}, 0.016, (0.027, 0.013, 0.027)),
("decode-checker-10-29-26/R352HIUI.F40W",
{"tran": 0.000, "vert": 0.000, "long": 0.000, "micl": 0.005}, 0.000, (1.617, 0.278, 0.318)),
])
def test_waveform_peak_detail_comes_from_the_samples(rel, times, pvs_time, accel):
pv = read_blastware_file(_FIX / rel).peak_values
for ch, t in times.items():
assert abs(getattr(pv, f"{ch}_time_of_peak") - t) <= 0.0005 + 1e-9, (ch, getattr(pv, f"{ch}_time_of_peak"))
assert abs(pv.pvs_time - pvs_time) <= 0.0005 + 1e-9
for got, want in zip((pv.tran_peak_accel_g, pv.vert_peak_accel_g, pv.long_peak_accel_g), accel):
assert abs(got - want) <= 0.0005 + 1e-9, (got, want)
def test_a_histogram_has_no_waveform_peak_detail():
pv = read_blastware_file(_FIX / "decode-checker-10-29-26/T004JTRF.ME0H").peak_values
assert (pv.tran_time_of_peak, pv.pvs_time, pv.tran_peak_accel_g) == (None, None, None)
+14 -2
View File
@@ -39,8 +39,9 @@ def test_event_type_comes_from_the_bytes():
def test_report_fields_stay_blank(): def test_report_fields_stay_blank():
s = sfm_side((FIX / "T1905KDW.5F0W").read_bytes()) s = sfm_side((FIX / "T1905KDW.5F0W").read_bytes())
# (BatteryLevel and Calibration are read since 2026-11-03: test_the_setup_fields_match_blastware) # (BatteryLevel and Calibration are read since 2026-11-03, peak acceleration
for tag in ("TranZCFreq", "TranPeakAcceleration", "TranTestResults"): # since 2026-11-04: test_the_setup_fields_match_blastware, test_waveform_peak_detail_*)
for tag in ("TranZCFreq", "TranPeakDisplacement", "TranTestResults"):
assert s.values.get(tag) is None assert s.values.get(tag) is None
@@ -343,3 +344,14 @@ def test_histogram_times_match_blastware(path):
for f in (("HistogramStartDate", "HistogramStartTime", "HistogramStopTime", "intervals.Time") for f in (("HistogramStartDate", "HistogramStartTime", "HistogramStopTime", "intervals.Time")
+ tuple(t for t in _PEAK_TIMES if t in ref.scalars)): + tuple(t for t in _PEAK_TIMES if t in ref.scalars)):
assert res[f].verdict == "match", (f, res[f]) assert res[f].verdict == "match", (f, res[f])
@pytest.mark.parametrize("path", [FIX / "R352HIUI.F40W",
FIX.parent / "setup-fields-11-03-26" / "T189HUD6.QE0W"])
def test_waveform_peak_detail_matches_blastware(path):
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
for f in ("TranTimeofPeak", "VertTimeofPeak", "LongTimeofPeak", "MicLTimeofPeak",
"PeakVectorSumTimeSum", "TranPeakAcceleration", "VertPeakAcceleration",
"LongPeakAcceleration"):
assert res[f].verdict == "match", (f, res[f])
+8
View File
@@ -231,3 +231,11 @@ def test_push_config_raw_writes_a_logical_block_with_a_literal_escape_byte_intac
c.push_config_raw(b["event_index"], block, b["trigger"], b["waveform"]) c.push_config_raw(b["event_index"], block, b["trigger"], b["waveform"])
sent = b"".join(_payload(f)[16:] for f in t.sent if _payload(f)[2] == 0x71) sent = b"".join(_payload(f)[16:] for f in t.sent if _payload(f)[2] == 0x71)
assert sent == block + b"\x00\x00" assert sent == block + b"\x00\x00"
# Bench 2026-11-04 (BE9441): a write sent while the unit's setup menu was open was
# acknowledged and read back -- and then lost when the operator pressed Cancel or
# Save: the menu writes its own copy of the WHOLE block back. The preview says so.
def test_the_preview_warns_that_an_open_setup_menu_loses_the_change():
r = change(FakeMiniMateClient(), {"geo_trigger_ips": 0.05}, dry_run=True)
assert any("setup menu" in w and "lost" in w for w in r.plan["warnings"])
+42
View File
@@ -499,3 +499,45 @@ def test_a_letterless_stored_name_still_matches_a_lettered_download(sdm):
store, db = sdm store, db = sdm
_stored_as(store, db, "K441LTOK.QZ0") _stored_as(store, db, "K441LTOK.QZ0")
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0H")["blastware_filename"] == "K441LTOK.QZ0" assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0H")["blastware_filename"] == "K441LTOK.QZ0"
# #51 (dev, 2026-11-03): a waveform and a histogram recorded in the same second
# are two events (UNIQUE(serial, timestamp, record_type)). A live download of one
# must not be skipped because its twin is stored -- not by the time, and not by a
# letterless Blastware name both twins share. An untyped row at that second still
# counts as stored (conservatively: it may be this event).
def _stored_twin(store, db, name, record_type):
ev, rec = store.save_imported_bw((HIST_FIX / "K441LTOK.QZ0").read_bytes(),
source_path=Path(name), serial_hint=None,
bw_report_text=(HIST_FIX / "K441LTOK_QZ0_ASCII.TXT").read_bytes())
ev.record_type = record_type
db.insert_events([ev], serial="BE9441", waveform_records={ev._waveform_key.hex(): rec},
device_family="series3")
@pytest.mark.parametrize("twin_name", ["K441LTOK.QZ0W", "K441LTOK.QZ0"]) # call-in / direct name
def test_a_live_histogram_is_stored_beside_its_same_second_waveform_twin(sdm, twin_name):
store, db = sdm
_stored_twin(store, db, twin_name, "Waveform")
dl = _hist_download("K441LTOK.QZ0", "01110000", datetime.datetime(2026, 10, 26, 16, 6, 35))
dl.filename = "K441LTOK.QZ0H" # a live download carries the letter (s3.py: with_type_letter)
out = persist_download(dl, store=store, db=db)
assert out.inserted is True
assert sorted(r["record_type"] for r in db.query_events(serial="BE9441")) == ["Histogram", "Waveform"]
def test_an_untyped_row_at_that_second_still_counts_as_stored(sdm):
store, db = sdm
_stored_twin(store, db, "K441LTOK.QZ0", None)
out = persist_download(_hist_download("K441LTOK.QZ0", "01110000",
datetime.datetime(2026, 10, 26, 16, 6, 35)), store=store, db=db)
assert out.inserted is False and out.detail["already_stored"] is True
def test_the_name_lookup_can_be_held_to_a_record_type(sdm):
store, db = sdm
_stored_twin(store, db, "K441LTOK.QZ0", "Waveform")
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0H", record_type="Histogram") is None
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0", record_type="waveform") is not None
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0") is not None
+12 -2
View File
@@ -193,12 +193,22 @@ def test_steps_cannot_be_reassigned():
def test_call_home_off_from_an_unobserved_start_value_carries_a_warning(): def test_call_home_off_from_an_unobserved_start_value_carries_a_warning():
r = bytearray(_call_home_reads()[0]) r = bytearray(_call_home_reads()[0])
r[5] = 0x01 # UM20147 reads 0x01, not THOR's 0x04/0x05 r[5] = 0x03 # a value no unit has been seen holding
plan = plan_call_home_enabled(bytes(r), False) plan = plan_call_home_enabled(bytes(r), False)
assert any("unobserved" in w and "0x01 -> 0x00" in w for w in plan.warnings) assert any("unobserved" in w and "0x03 -> 0x02" in w for w in plan.warnings)
assert plan.describe()["warnings"] and plan.describe()["warnings"] == list(plan.warnings) assert plan.describe()["warnings"] and plan.describe()["warnings"] == list(plan.warnings)
@pytest.mark.parametrize("start,enabled", [(0x01, False), (0x00, True)])
def test_um20147s_values_are_observed_since_the_bench(start, enabled):
# Bench 2026-11-03 (UM20147): 0x01 -> 0x00 and 0x00 -> 0x01 both acknowledged, read
# back, and matched in the unit's own menu (and again 2026-11-04).
r = bytearray(_call_home_reads()[0])
r[5] = start
plan = plan_call_home_enabled(bytes(r), enabled)
assert not any("unobserved" in w for w in plan.warnings)
def test_call_home_on_when_already_on_says_it_changes_nothing(): def test_call_home_on_when_already_on_says_it_changes_nothing():
r = next(x for x in _call_home_reads() if x[5] == 0x05) r = next(x for x in _call_home_reads() if x[5] == 0x05)
plan = plan_call_home_enabled(r, True) plan = plan_call_home_enabled(r, True)
+50
View File
@@ -99,3 +99,53 @@ def test_read_compliance_content_refuses_a_missing_frame():
with pytest.raises(mp.ProtocolError): with pytest.raises(mp.ProtocolError):
proto.read_compliance_content() proto.read_compliance_content()
assert len(t.sent) == 3 # probe, B, C -- and no D after C went unanswered assert len(t.sent) == 3 # probe, B, C -- and no D after C went unanswered
# Bench 2026-11-04 (BE9441, live): frame B of a 1A read came back one byte long,
# ending in a lone 0x10 -- the kept escape of a checksum byte that was itself
# escaped (02 / 03 / 04: about one frame in 85); the parser strips only the byte
# after it. The 12 recorded reads never hit it. The read knows how much it asked
# for, so it takes exactly that; a leftover other than that one 0x10 is kept, and
# the block then fails is_compliance_content.
def test_a_frame_with_an_escaped_checksums_stray_byte_is_trimmed_to_what_was_asked():
sfm_read = READS[8] # SFM's own 1024 + 1024 + 42 pattern
good = assemble_compliance_content(sfm_read, lengths=(1024, 1024, 42))
assert good == assemble_compliance_content(sfm_read) and is_compliance_content(good)
stray = [sfm_read[0] + b"\x10", sfm_read[1], sfm_read[2]]
assert len(assemble_compliance_content(stray)) == 2091 # what the bench saw
assert assemble_compliance_content(stray, lengths=(1024, 1024, 42)) == good
def test_a_leftover_that_is_not_the_stray_escape_is_not_trimmed():
sfm_read = READS[8]
odd = [sfm_read[0] + b"\x55", sfm_read[1], sfm_read[2]]
assert not is_compliance_content(assemble_compliance_content(odd, lengths=(1024, 1024, 42)))
# The same artifact on the waveform-data read a settings write echoes back: it asks
# for 0xCA = 202 bytes; one extra trailing 0x10 is the escaped checksum's DLE.
# (Unfixed, it fails closed: the write's own block check refuses 203 bytes.)
class _Replies:
def __init__(self, data):
self._data = data
self.sent = []
def __call__(self, frame):
self.sent.append(frame)
def _waveform_proto(data_reply: bytes):
from types import SimpleNamespace
p = mp.MiniMateProtocol(object())
p._send = _Replies(None)
replies = [SimpleNamespace(data=bytes(11)), SimpleNamespace(data=bytes(11) + data_reply)]
p._recv_one = lambda expected_sub=None, **kw: replies.pop(0)
return p
def test_the_waveform_read_drops_an_escaped_checksums_stray_byte():
block = (200).to_bytes(2, "big") + bytes(range(198)) + b"\x17\x17" # N = 200, plus its 2 tail bytes
assert _waveform_proto(block).read_waveform_data_raw() == block
assert _waveform_proto(block + b"\x10").read_waveform_data_raw() == block
assert _waveform_proto(block + b"\x55").read_waveform_data_raw() == block + b"\x55" # anything else is kept
+10 -4
View File
@@ -196,11 +196,17 @@ def test_field_not_offered_for_the_series():
_refused(S4_BLOCK, 4, {"no_such_field": 1}) _refused(S4_BLOCK, 4, {"no_such_field": 1})
def test_alarm_is_read_only_until_measured(): def test_the_alarm_is_writable_since_the_bench():
assert sf.S3_ALARM_WRITE_MEASURED is False # Bench 2026-11-04, BE9441: 1.0 -> 1.5 -> 1.0, each acknowledged, read back and
_refused(S3_BLOCK, 3, {"geo_alarm_ips": 1.0}) # shown in the unit's own setup menu; the write moved exactly channel +39 of the
# three geophones (the f32 at +38).
assert sf.S3_ALARM_WRITE_MEASURED is True
assert check_changes(S3_BLOCK, 3, {"geo_alarm_ips": 1.5}) == {"geo_alarm_ips": 1.5}
alarm = next(d for d in editable_fields(S3_BLOCK, 3) if d["field"] == "geo_alarm_ips") alarm = next(d for d in editable_fields(S3_BLOCK, 3) if d["field"] == "geo_alarm_ips")
assert alarm["readonly"] is True assert alarm["readonly"] is False
out = encode_setup(S3_BLOCK, 3, {"geo_alarm_ips": 1.5})
assert [i for i in range(2090) if out[i] != S3_BLOCK[i] and i not in (26, 27)] == [1747, 1795, 1843]
_refused(S4_BLOCK, 4, {"geo_alarm_ips": 1.5}) # still Series 3 only
def _with_unit(block: bytes, unit: bytes) -> bytes: def _with_unit(block: bytes, unit: bytes) -> bytes: