Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab3bab764a | ||
|
|
0d9eb518d2 | ||
|
|
a818f6a291 | ||
|
|
77fbeb5fe3 | ||
|
|
e6b5dc4d7d | ||
|
|
71bd14156d | ||
|
|
eec88a62b8 | ||
|
|
30bfdd6eff | ||
|
|
fb14a8f7bb | ||
|
|
e9c01ce8d4 | ||
|
|
d2258dad4e | ||
|
|
e050e602c2 | ||
|
|
fc1c7c7936 | ||
|
|
7d0d12079b | ||
|
|
5203aab849 | ||
|
|
5b65718b72 | ||
|
|
483762607e | ||
|
|
d0b66368d5 | ||
|
|
2eb1d25028 | ||
|
|
cc821f9ee3 |
No files matched your search
+78
-1
@@ -4,7 +4,26 @@ All notable changes to seismo-relay are documented here.
|
||||
|
||||
---
|
||||
|
||||
## Unreleased
|
||||
## v0.36.0 — 2026-12-03
|
||||
|
||||
**Micromate events read from the file alone, and three loose ends tied.**
|
||||
|
||||
- **Micromate files (#44, #45).** SFM reads a Thor file's own settings, notes
|
||||
and event time.
|
||||
- Its own Micromate downloads no longer store a sample rate, pre-trigger and
|
||||
record time of 0, blank notes, or a 1970 date.
|
||||
- Every Micromate `.h5` now carries its pre-trigger. It had been 0, report or
|
||||
not.
|
||||
- **MiniMate settings (#48).** The legacy settings decode reads by position,
|
||||
not by a "stable anchor" that was really two settings. It never struck: every
|
||||
DL2 event was recorded in Fixed stop mode.
|
||||
- **Housekeeping.**
|
||||
- A fresh checkout passes the whole test suite on its own.
|
||||
- The `bridges/` bench tools leave the production image.
|
||||
|
||||
⚠ **This release owes a Thor-only backfill (`scripts/backfill_thor_events.py`)
|
||||
and no schema change.** Series-3 data is unchanged, so do **not** run
|
||||
`backfill_sidecars.py`. See *Migration*.
|
||||
|
||||
### Changed
|
||||
- **A fresh checkout passes the whole test suite on its own**
|
||||
@@ -96,11 +115,69 @@ All notable changes to seismo-relay are documented here.
|
||||
other fields are unchanged.
|
||||
- No schema change, no migration. Prod's Micromate events all arrive with
|
||||
a report, so only the `.h5` pre-trigger changes there.
|
||||
- **A MiniMate's settings are read by position, not by the "stable anchor"
|
||||
(#48; `fix/s3-settings-by-position`, merged 2026-12-02).**
|
||||
- **The bug:** the legacy SUB 1A decode found the record mode, sample rate,
|
||||
histogram interval and record time by searching for `be 80 00 00 00 00`.
|
||||
Those bytes are the block's `[12:18]`, the pre-trigger (−0.25 s) and the
|
||||
stop mode (Fixed), not a marker. A unit in Auto stop mode, or with another
|
||||
pre-trigger, has no such bytes, and all four would read None.
|
||||
- **Where that mattered:** `connect()`'s legacy routes, `/device/info`
|
||||
without a serial and the legacy event download, which takes the event's
|
||||
sample rate from it. The serial-routed settings read already read by
|
||||
position.
|
||||
- **Now:** the reply is unescaped and the block found by its own length field
|
||||
N = 2090 (`08 2a`, at unescaped[12] on every recorded reply). The four are
|
||||
read by position, Series IV's `0x1A` layout.
|
||||
- **It never struck:** every DL2 event file's setup copy has stop mode Fixed,
|
||||
70,041 / 70,041, and Blastware's reports agree (7,631 / 7,631).
|
||||
- **Tests:** recorded replies patched to Auto stop and to a −0.5 s
|
||||
pre-trigger now decode (8 new tests; the 7 existing ones are unchanged).
|
||||
Not yet checked on a unit in Auto stop mode.
|
||||
- Operational: none. It is a live-read fix, with no stored data, schema,
|
||||
`TOOL_VERSION` or backfill involved.
|
||||
|
||||
### Protocol / Documentation
|
||||
- **IDF reference, Signature A:** the event's settings record, time and notes,
|
||||
measured; the `be 80…` search retracted. Thor writes `.MLG` files too (seen,
|
||||
not examined).
|
||||
- **Instantel reference and CLAUDE.md:** #48 resolved. The "stable anchor" notes
|
||||
are retracted in place, and DL2's stop modes are counted.
|
||||
|
||||
### Migration
|
||||
|
||||
⚠ **A Thor-only backfill, no schema migration.** Not rehearsed on a prod
|
||||
snapshot.
|
||||
|
||||
**Before you start:**
|
||||
- `TOOL_VERSION` is bumped to **0.36.0**, which gates the Thor regeneration, so
|
||||
no `--force` is needed.
|
||||
- **Back up `seismo_relay.db` first.**
|
||||
|
||||
**Then:**
|
||||
1. **Deploy.** No table changes.
|
||||
- The image no longer holds the `bridges/` code.
|
||||
- The database volume is mounted at `/app/bridges/captures` as before. SFM
|
||||
and the scripts find it there by default.
|
||||
2. **In the `sfm` container, run `python scripts/backfill_thor_events.py
|
||||
--dry-run`**, then the same without `--dry-run`.
|
||||
- The dry run shows how many Thor events will be refreshed.
|
||||
- The real run rewrites each Thor event's sidecar and `.h5`. Each `.h5`
|
||||
gains its pre-trigger in samples (it was 0). Report-paired events take it
|
||||
from the report's value, rounded to 0.01 s.
|
||||
- Their samples, peaks and times do not change.
|
||||
3. ⚠ **Do not run `backfill_sidecars.py` or `backfill_event_shape.py`.**
|
||||
- The Series-3 decode did not change.
|
||||
- The `TOOL_VERSION` bump would make `backfill_sidecars.py` regenerate every
|
||||
Series-3 event (about 8 hours) for nothing.
|
||||
- The Thor samples, which the shape metrics come from, are unchanged.
|
||||
|
||||
**Terra-View** needs no change. One thing it shows moves: a Micromate
|
||||
waveform chart's time axis.
|
||||
- SFM's plot data starts the axis at minus the pre-trigger
|
||||
(`event_hdf5.plot_json_from_hdf5`, `t0_ms = -pretrig_samples × dt`).
|
||||
- With the stored 0, time 0 was the first sample. After the backfill, time 0 is
|
||||
the trigger, as on MiniMate charts.
|
||||
|
||||
## v0.35.0 — 2026-11-16
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Ground-up Python replacement for **Blastware**, Instantel's Windows-only software for
|
||||
managing MiniMate Plus seismographs. Connects over direct RS-232 or cellular modem
|
||||
(Sierra Wireless RV50 / RV55). Current version: **v0.35.0**.
|
||||
(Sierra Wireless RV50 / RV55). Current version: **v0.36.0**.
|
||||
|
||||
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
|
||||
@@ -10,7 +10,7 @@ pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as
|
||||
|
||||
---
|
||||
|
||||
## Where things stand (updated 2026-11-16)
|
||||
## Where things stand (updated 2026-12-03)
|
||||
|
||||
Read this first when picking the project back up.
|
||||
|
||||
@@ -225,6 +225,9 @@ Read this first when picking the project back up.
|
||||
are re-rendered by keypad saves and are not identifiers.
|
||||
⚠ **`0x1A` reads the keypad's edit buffer live** — unsaved values show while
|
||||
someone is in the menu; a discard reverts them.
|
||||
✅ **Fixed 2026-12-01 (#48):** the legacy decode now finds the block by its
|
||||
length field N = 2090 and reads by position; no DL2 event was ever recorded in
|
||||
Auto stop mode (70,041 / 70,041 Fixed). Kept below as history:
|
||||
🔶 **Possible Series III bug, inferred only:** S3's 6-byte "stable anchor"
|
||||
`be 80 00 00 00 00` sits exactly where Series IV keeps pre-trigger (−0.25 s)
|
||||
+ stop mode (Fixed). An S3 unit in Auto stop mode would then lose the
|
||||
@@ -1660,6 +1663,12 @@ frame D's channel block (trigger_level_geo, alarm_level_geo, max_range_geo) unre
|
||||
producing only ~1071 bytes instead of ~2126.
|
||||
|
||||
### SUB 1A — anchor search range
|
||||
> ⚠ **RETRACTED 2026-12-01 (#48):** there is no stable anchor. `be 80 00 00 00 00`
|
||||
> is the block's `[12:18]`: the pre-trigger (−0.25 s) and the stop mode (Fixed).
|
||||
> `_decode_compliance_config_into()` now unescapes the reply, finds the block by
|
||||
> its length field N = 2090 (`08 2a`, at unescaped[12]) and reads mode `[5]`,
|
||||
> rate `[6:8]`, interval `[8:10]` and record time `[18:22]` by position. The text
|
||||
> below is history.
|
||||
|
||||
`_decode_compliance_config_into()` locates fields via the **6-byte stable anchor**
|
||||
`b'\xbe\x80\x00\x00\x00\x00'`. Search range is `cfg[0:150]`.
|
||||
@@ -1731,7 +1740,7 @@ Do NOT use fixed absolute offsets for sample_rate or record_time.
|
||||
| setup_name | ASCII, null-padded, in cfg body |
|
||||
| project / client / operator / sensor_location | ASCII, label-value pairs |
|
||||
|
||||
**True stable anchor: `b'\xbe\x80\x00\x00\x00\x00'` (6-byte suffix), search `cfg[0:150]`.**
|
||||
**True stable anchor: `b'\xbe\x80\x00\x00\x00\x00'` (6-byte suffix), search `cfg[0:150]`.** (⚠ Retracted 2026-12-01, #48: not a constant; see "SUB 1A — anchor search range".)
|
||||
The old "10-byte anchor" `b'\x01\x2c\x00\x00\xbe\x80\x00\x00\x00\x00'` is partially variable:
|
||||
bytes `\x01\x2c` = 300 (5-minute default histogram interval); changes when interval changes.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# seismo-relay `v0.35.0`
|
||||
# seismo-relay `v0.36.0`
|
||||
|
||||
A ground-up replacement for **Blastware** — Instantel's aging Windows-only
|
||||
software for managing seismographs. Supports both the **MiniMate Plus
|
||||
@@ -127,6 +127,14 @@ over direct RS-232 or cellular modem (Sierra Wireless RV50 / RV55).
|
||||
>
|
||||
> ⚠ The deploy owes a backfill (about 8 hours on the NAS) and creates two
|
||||
> empty tables. See the changelog's *Migration*.
|
||||
>
|
||||
> **v0.36.0 (2026-12-03)** reads Micromate events from the file alone (#44,
|
||||
> #45): their settings, notes, time and pre-trigger. It also reads a MiniMate's
|
||||
> settings by position (#48), lets a fresh checkout pass the whole test suite,
|
||||
> and takes the `bridges/` bench tools out of the production image.
|
||||
>
|
||||
> ⚠ The deploy owes a Thor-only backfill (`scripts/backfill_thor_events.py`).
|
||||
> Do not run `backfill_sidecars.py` this time. See the changelog's *Migration*.
|
||||
> See [CHANGELOG.md](CHANGELOG.md) for full version history.
|
||||
|
||||
---
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
| Date | Section | Change |
|
||||
|---|---|---|
|
||||
| 2026-12-01 | §7.6.1, SUB 1A (legacy decode) | ✅ **#48 fixed: the settings are read by position, not by the "stable anchor".** `_decode_compliance_config_into` unescapes the 1A reply, finds the block by its own length field N = 2090 (`08 2a`, at unescaped[12] on all 4 recorded replies), and reads mode `[5]`, sample rate `[6:8]`, histogram interval `[8:10]` and record time `[18:22]` by position: Series IV's `0x1A` layout, as the 2026-11-03 (5) row measured. The anchor `be 80 00 00 00 00` was `[12:18]`, the pre-trigger and the stop mode, so a unit in Auto stop mode would have read all four as None. **How often it could strike (measured 2026-12-01):** every DL2 event file's setup copy has stop mode Fixed, 70,041 / 70,041 (63,500 histograms, 6,541 waveforms), and Blastware's reports agree (7,631 / 7,631 `RecordStopMode` Fixed). Tested on recorded replies patched to Auto stop and to a −0.5 s pre-trigger (`tests/test_s3_compliance_anchor_fields.py`); not yet on a unit in Auto stop. Resolves the 2026-10-17 row below. |
|
||||
| 2026-11-13 | Appendix D.4 (rewritten), D.4.1–D.4.4 | ✅ **The `.MLG` format, measured.** An 18-byte prefix, then 292-byte records `[length 290 LE][id 0e a0 header / 0e 80 log][…][00 00][CRC]`. The CRC is **CRC-16/AUG-CCITT over `[0:288]`, little-endian** (3,329 / 3,329 records, 1,282 files). Fields: times with the year LE, the monitor-log flag word and trigger source LE, the serial, Blastware's text. Also: one file per call-in, how sessions appear, and a Modem Exit that is not a file's last record was a call that left no file. Cross-checked against DL2 event footers: 785 / 785 for BE8081. The old D.4.1–D.4.3 (308-byte header, CRC at the start) are kept, marked retracted. Reader/writer `minimateplus/mlg_file.py`. |
|
||||
| 2026-11-11 | Appendix D.3.3 | ✅ **The footer's last two bytes are a CRC-16/AUG-CCITT** (init `0x1D0F`), big-endian, over the footer record from its length prefix `00 1a` through footer `[0:22]`: 70,041 / 70,041 DL2 files. Found by the `.MLG` session, verified here. Retracts 2026-11-08's "no common CRC-16 fits": every attempt had started at the footer itself. Same CRC family as the Series IV `0x1A` block's and the `.MLG` record's. |
|
||||
| 2026-11-09 | Appendix D.6.15 (NEW), D.6.6, D.6.11 | ✅ **Over range and the mic.** **D.6.15:** a peak past full scale (2,000 units = 32,000 counts; the mic in counts) is Blastware's `OORANGE`, per channel and per histogram interval, from the unit's own summary peaks. The vector sum is `OORANGE` exactly when a geophone is (43 / 43); never on its own (38 / 38 numeric), which retracts D.6.11's open "vector sum alone" case. The `<OORANGE>` line marks the mic over (18 / 18). **D.6.6:** the mic has its own range byte (label + 29): at 1 a count is an eighth, 7 DL2 events SFM read 8× high. The dB offset is **81.938216**: [81.9383, 81.9385] was too high, and every count Blastware printed leaves [81.9382058, 81.9382266]. Blastware's mic unit labels do not hold on every report; some mix dB and psi in one column. **80 of 88 report fields now match on every DL2 event.** |
|
||||
|
||||
+43
-34
@@ -55,6 +55,7 @@ from .protocol import (
|
||||
SUB_WRITE_CONFIRM_C,
|
||||
SUB_TRIGGER_CONFIRM,
|
||||
SUB_MONITOR_STATUS,
|
||||
COMPLIANCE_CONTENT_LEN,
|
||||
)
|
||||
from .transport import SerialTransport, BaseTransport
|
||||
|
||||
@@ -2012,6 +2013,9 @@ def _extract_project_strings(data: bytes) -> Optional[ProjectInfo]:
|
||||
)
|
||||
|
||||
|
||||
# The settings block starts with its own length N = 2090, uint16 BE (#48).
|
||||
_SETTINGS_BLOCK_HEAD = COMPLIANCE_CONTENT_LEN.to_bytes(2, "big") # 08 2a
|
||||
_SETTINGS_BLOCK_SEARCH = 40 # found at unescaped[12] on every recorded reply
|
||||
|
||||
|
||||
def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
|
||||
@@ -2023,20 +2027,20 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
|
||||
|
||||
Confirmed field locations (BE11529 with 3-step read, duplicate detection):
|
||||
- cfg[89] = setup_name: first long ASCII string in cfg[40:250] ✅
|
||||
- ANCHOR = b'\\xbe\\x80\\x00\\x00\\x00\\x00' in cfg[0:150] ✅ (revised 2026-04-07)
|
||||
- anchor - 6 = sample_rate uint16_BE (1024 normal / 2048 fast / 4096 faster)
|
||||
- anchor + 6 = record_time float32_BE
|
||||
- the settings block, found by its length field N = 2090 (`08 2a`) after
|
||||
unescaping, read by position (#48, 2026-12-01; see the comment in the body):
|
||||
mode [5], sample rate [6:8], histogram interval [8:10], record time [18:22]
|
||||
- "Project:" needle → project string
|
||||
- "Client:" needle → client string
|
||||
- "User Name:" needle → operator string
|
||||
- "Seis Loc:" needle → sensor_location string
|
||||
- "Extended Notes" needle → notes string
|
||||
|
||||
Anchor approach is required because a DLE byte in the sample_rate field
|
||||
(4096 = 0x1000 → stored as 10 10 00 in raw S3 frame → unstuffed to 10 00,
|
||||
1 byte shorter than 04 00 or 08 00) causes frame C to be 1 byte shorter
|
||||
for "faster" mode, shifting all subsequent offsets by 1. The 10-byte
|
||||
anchor is stable across all modes.
|
||||
⚠ Retracted 2026-12-01 (#48): the mode, rate, interval and record time were
|
||||
found by the "anchor" `be 80 00 00 00 00`, thought stable across all modes.
|
||||
It is the pre-trigger and the stop mode, so it is absent in Auto stop mode.
|
||||
Escapes are removed first (unescape_reply), so an escaped byte no longer
|
||||
shifts the positions.
|
||||
|
||||
Channel block layout (✅ confirmed 2026-04-02 from 3-11-26 E5 frame 78
|
||||
and 1-2-26 A5 frame 77):
|
||||
@@ -2076,47 +2080,52 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
|
||||
# mode, sample rate or interval moves every field after it by one. BE9441 at
|
||||
# Histogram / 4096 sps / 2 s read 0 sps and a 4098 s interval (2026-10-29).
|
||||
#
|
||||
# Layout after unescaping, measured on every recorded reply (four settings,
|
||||
# two of them Blastware's own writes -- tests/test_s3_compliance_anchor_fields.py):
|
||||
# _anchor - 7 : recording_mode (uint8)
|
||||
# _anchor - 6 : sample_rate (uint16 BE)
|
||||
# _anchor - 4 : histogram_interval_sec (uint16 BE, seconds)
|
||||
# _anchor - 2 : 0x00 0x00 (padding)
|
||||
# _anchor : \xbe\x80\x00\x00\x00\x00
|
||||
# _anchor + 6 : record_time (float32 BE)
|
||||
# The block is the settings block Series 4's 0x1A shares (reference D.6.2,
|
||||
# micromate/setup_block.py), found by its own length field N = 2090 (`08 2a`)
|
||||
# and read by position -- at unescaped[12] on every recorded reply:
|
||||
# [5] recording_mode (uint8)
|
||||
# [6:8] sample_rate (uint16 BE)
|
||||
# [8:10] histogram_interval_sec (uint16 BE, seconds)
|
||||
# [12:16] pre-trigger (float32 BE, negative seconds)
|
||||
# [17] stop mode (0 Fixed)
|
||||
# [18:22] record_time (float32 BE)
|
||||
# ⚠ RETRACTED 2026-12-01 (#48): these were found by the "stable anchor"
|
||||
# `be 80 00 00 00 00`, which is [12:18] -- the pre-trigger (-0.25 s) and the
|
||||
# stop mode (Fixed), not a marker. A unit in Auto stop mode, or with another
|
||||
# pre-trigger, has no such bytes, and all four fields read None. No DL2 event
|
||||
# was recorded in Auto (70,041 / 70,041 Fixed), so it never struck.
|
||||
# ⚠ The old raw layout's "anchor - 7 = constant 0x10" was the escape in front
|
||||
# of `04` at 1024 sps (0x0400); it read right only at that rate.
|
||||
# Everything below this block (channel block, strings) still reads the RAW
|
||||
# bytes: its label-relative offsets were measured on them and are wrong
|
||||
# unescaped. A reply with no anchor (BE9441 answered 1A with its device-info
|
||||
# block while monitoring, 2026-10-29) leaves all four fields None.
|
||||
_ANCHOR = b'\xbe\x80\x00\x00\x00\x00'
|
||||
# unescaped. A reply with no settings block (BE9441 answered 1A with its
|
||||
# device-info block while monitoring, 2026-10-29) leaves all four fields None.
|
||||
logical = unescape_reply(data)
|
||||
_anchor = logical.find(_ANCHOR, 0, 150)
|
||||
_block = logical.find(_SETTINGS_BLOCK_HEAD, 0, _SETTINGS_BLOCK_SEARCH)
|
||||
|
||||
if _anchor < 0:
|
||||
if _block < 0:
|
||||
log.warning(
|
||||
"compliance_config: anchor %s not found in cfg[0:150] (len=%d) "
|
||||
"compliance_config: no settings block (N = 2090) in cfg[0:%d] (len=%d) "
|
||||
"— sample_rate, record_time and recording_mode will be None",
|
||||
_ANCHOR.hex(), len(data),
|
||||
_SETTINGS_BLOCK_SEARCH, len(data),
|
||||
)
|
||||
elif _anchor >= 7 and _anchor + 10 <= len(logical):
|
||||
log.info("_decode_compliance_config_into: anchor at unescaped[%d] data_len=%d",
|
||||
_anchor, len(data))
|
||||
config.recording_mode = logical[_anchor - 7]
|
||||
config.sample_rate = struct.unpack_from(">H", logical, _anchor - 6)[0]
|
||||
config.histogram_interval_sec = struct.unpack_from(">H", logical, _anchor - 4)[0]
|
||||
config.record_time = struct.unpack_from(">f", logical, _anchor + 6)[0]
|
||||
elif _block + 22 <= len(logical):
|
||||
log.info("_decode_compliance_config_into: settings block at unescaped[%d] data_len=%d",
|
||||
_block, len(data))
|
||||
config.recording_mode = logical[_block + 5]
|
||||
config.sample_rate = struct.unpack_from(">H", logical, _block + 6)[0]
|
||||
config.histogram_interval_sec = struct.unpack_from(">H", logical, _block + 8)[0]
|
||||
config.record_time = struct.unpack_from(">f", logical, _block + 18)[0]
|
||||
log.debug(
|
||||
"compliance_config: recording_mode=0x%02X sample_rate=%d histogram_interval=%d s "
|
||||
"record_time=%.3f s (anchor@%d unescaped)",
|
||||
"record_time=%.3f s (block@%d unescaped)",
|
||||
config.recording_mode, config.sample_rate, config.histogram_interval_sec,
|
||||
config.record_time, _anchor,
|
||||
config.record_time, _block,
|
||||
)
|
||||
else:
|
||||
log.warning("compliance_config: anchor at unescaped[%d] is too close to an end "
|
||||
log.warning("compliance_config: settings block at unescaped[%d] is too close to the end "
|
||||
"(len=%d) — mode, rate, interval and record time left None",
|
||||
_anchor, len(logical))
|
||||
_block, len(logical))
|
||||
|
||||
# ── Project strings ───────────────────────────────────────────────────────
|
||||
try:
|
||||
|
||||
@@ -54,7 +54,7 @@ SIDECAR_KIND = "sfm.event"
|
||||
# bumped without a `pip install` re-run — leading to confusing stale
|
||||
# version stamps in sidecars. Bump this constant and CHANGELOG.md
|
||||
# together at release time.
|
||||
TOOL_VERSION = "0.35.0" # file-only decode groups D2, E, F, over range, mic range; gates the backfill regen
|
||||
TOOL_VERSION = "0.36.0" # Thor file settings, notes, time and pretrig_samples (#44, #45); gates the backfill regen
|
||||
|
||||
try:
|
||||
# Best-effort: prefer the installed metadata when it's NEWER than the
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "seismo-relay"
|
||||
version = "0.35.0"
|
||||
version = "0.36.0"
|
||||
description = "Python client and REST server for MiniMate Plus seismographs"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
@@ -98,3 +98,39 @@ def test_a_reply_without_the_settings_block_reads_as_unknown():
|
||||
|
||||
# The write side moved to the shared settings codec in phase 5 (2026-11-03):
|
||||
# tests/test_setup_fields.py reproduces every Blastware write byte for byte.
|
||||
|
||||
|
||||
# ── #48: the "anchor" is two settings, not a marker ───────────────────────────
|
||||
# `be 80 00 00 00 00` is the block's [12:18]: the pre-trigger (-0.25 s, f32 BE)
|
||||
# then [16] and the stop mode [17] (0 = Fixed). A unit in Auto stop mode, or
|
||||
# with another pre-trigger, has no such bytes. The block is found instead by its
|
||||
# own length field N = 2090 (`08 2a`), and its fields read by position: the layout
|
||||
# Series 4's 0x1A shares (reference D.6.2; setup_block.py). No DL2 event was
|
||||
# recorded in Auto stop mode (70,041 / 70,041 Fixed, measured 2026-12-01), so this
|
||||
# tests a reply patched from a real one.
|
||||
|
||||
import struct # noqa: E402
|
||||
|
||||
|
||||
def _patched(i, at, new):
|
||||
"""Reply i with the anchor's bytes [at:at+len(new)] replaced. The anchor holds
|
||||
no 02/03/04, so the raw bytes can be patched in place."""
|
||||
d = bytearray(_settings_replies()[i])
|
||||
a = bytes(d).find(ANCHOR)
|
||||
assert a >= 0
|
||||
d[a + at:a + at + len(new)] = new
|
||||
return bytes(d)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("i", range(4))
|
||||
def test_auto_stop_mode_still_reads_the_settings(i):
|
||||
cc = _decode(_patched(i, 5, b"\x01")) # [17] stop mode = Auto
|
||||
got = (cc.recording_mode, cc.sample_rate, cc.histogram_interval_sec, round(cc.record_time, 2))
|
||||
assert got == EXPECT[i]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("i", range(4))
|
||||
def test_another_pretrigger_still_reads_the_settings(i):
|
||||
cc = _decode(_patched(i, 0, struct.pack(">f", -0.5))) # [12:16] pre-trigger
|
||||
got = (cc.recording_mode, cc.sample_rate, cc.histogram_interval_sec, round(cc.record_time, 2))
|
||||
assert got == EXPECT[i]
|
||||
Reference in new issue
Block a user