- Reference D.6.15 (new): over range -- a peak past 2,000 units (the mic in counts) is OORANGE, per channel and per histogram interval; the vector sum is OORANGE exactly when a geophone is (43 / 43), never on its own (38 / 38); the <OORANGE> line marks the mic over (18 / 18). - D.6.6: the mic's own range byte (an eighth at 1; 7 events read 8x high); the dB offset corrected in place to 81.938216 (every printed count leaves [81.9382058, 81.9382266]); the unit labels that do not hold, and the mixed columns. - D.6.11, CLAUDE.md: 80 of 88 report fields match on every DL2 event (run 20261109-144544, 0 regressions); the two causes left (the vector sum's last digit on 4 twins, 4 accelerations); the 'vector sum alone' case retracted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
141 KiB
CLAUDE.md — seismo-relay
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.34.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
~/CLAUDE.md.
Where things stand (updated 2026-11-05)
Read this first when picking the project back up.
-
🔑 Prod still leans on Blastware's ASCII report, and that is scaffolding.
- How it works today: when a
_ASCII.TXTreport arrives with a Blastware file,WaveformStore.save_imported_bwoverlays its peaks, notes, sample rate and record time onto SFM's decode (event_file_io.apply_report_to_event). - Only events without a report run on the decoder alone: all DL2 events before 2025, and everything SFM downloads itself.
- Why that matters: the overlay made SFM trustworthy from day one. It also hid how much the decoder could not yet do; until the checker (below) there was no full list of what Blastware reports.
- The goal is full function without Blastware (Brian, 2026-10-29). The
README roadmap has four steps:
- the checker ✅
- complete the file-only decode, one field group at a time
- switch ingest so reports are kept only for checking (retire the overlay)
- stop the watchers forwarding reports
- Until step 3, prod keeps the report as truth wherever one exists.
- How it works today: when a
-
🔑 The Series-3 decode checker (2026-10-29; v0.33.0).
- Goal: SFM produces everything Blastware reports, from the event file
alone (spec and plan in
docs/superpowers/). - Running it:
scratch/check_s3_decode.py ~/dl2-archive/files ~/dl2-archive/xmldecodes each event from its bytes only (no filename, no report). It compares every field, sample and interval with Blastware's_XML.XML: 70,042 events, 2016–2026, ~22 min at--jobs 4. - Output (
summary.md,details.json,changes.md) goes to~/dl2-archive/checker-runs/and is never committed. - The rule: every mismatch is SFM's bug unless a carve-out with evidence covers it.
- Byte layouts of every field read from the file:
docs/instantel_protocol_reference.mdAppendix D.6.
Where the decoder stands on
dev(2026-11-09, run20261109-144544): 80 of 88 fields match on every event, up from about 6 before v0.33.0, 47 before group D and 59 after it. Every other field matches or is accepted under a carve-out with its evidence.- Groups A, B, C and D part 1 shipped in v0.34.0 (#50, #51).
- D part 2 (the unit's own summary), E (the sensor check), F (the monitor
log), over range and the mic fixes are on
devand owe the next release a backfill. - Left: 16 values in two causes -- the vector sum's last digit on 4 waveform/histogram twins, and 4 accelerations (reference D.6.11).
- 🔑 Events are keyed unit + time + type:
UNIQUE(serial, timestamp, record_type)(#51, Migration 3 insfm/database.py,dev).- A waveform and its histogram may share a second: 209 times in prod's 2026-09-30 store.
- Any lookup "by event" must include the type.
- An untyped event still dedups against an untyped row.
- Rehearsed on a copy of the prod snapshot: rows and ids kept, 9,852 histograms moved +1 s in place.
- ✅ Match on every event:
- sample rate, record time, pre-trigger, notes and event type (v0.33.0)
- geophone range, job number, event times (6,524 / 6,524) and histogram
start dates (63,518 / 63,518) —
dev - group A (
dev, reference D.6.8): serial, version, calibration, battery, trigger source, geo and mic trigger levels, stop mode, mic type - group B (
dev, D.6.9): interval frequencies, vector sums, size, stop - group C (
dev, D.6.10): histogram start and stop from the histogram's own event record, interval times, and the peak dates and times - group D (D.6.12): ZC frequency on every record type, peak displacement,
times of peak and the vector-sum time.
- These are the unit's own values, stored in the file right after the event record. Blastware prints them; recomputing from the samples reached only 46% and 84%.
- Peak acceleration is Blastware's own computation from the samples (fitted g 386.2238): 6,522–6,523 / 6,524. The unit stores its own too, which Blastware ignores. The misses are O117I1NK.R70W, whose samples wrap at the trigger, and S353I5PZ.EP0W Vert (open).
- group E (D.6.13): sensor check frequency, ratio, mic amplitude and result, every record type. Also the unit's own, in each sensor-check record's header. "Check" is the unit's status code, not a limit SFM can recompute.
- group F (D.6.14): the Monitor Log line. It is the footer's start and stop plus words from the footer's flag word (Modem Exit, Timer Stop, Keyboard Exit…), character for character on 69,983 / 69,983.
- 🔑 The tail of every event file is one record chain (D.6.13):
event record → unit summary → sensor checks → footer, each
[length][id][payload]. It ends exactly at the file's end on all 70,041 DL2 files, and SFM reads none of it otherwise. - 🔑 "Units" means three different things — keep them apart (reference
D.6.6):
- Recorded data: the mic samples and interval peaks in the file, as raw counts with no unit.
- Report units: dB(L) or psi(L) in a report.
- A Blastware report uses that PC's Blastware preference at the moment
it wrote the report; carve-out
units-is-a-display-preference. - SFM's report uses SFM's own fixed choice.
- A Blastware report uses that PC's Blastware preference at the moment
it wrote the report; carve-out
- Unit peaks: the unit's own summary, in its keypad Microphone Units setting. Shown on its screen, in Blastware's event list, and in the 0C record.
- Where the unit stores that setting is not measured yet; a keypad test on a bench unit would show it.
- ✅ Geophone samples are exact on 6,524 / 6,524 waveforms in every
year (
dev; v0.33.0 had 6,491, its 33 others being Sensitive-range events read 8× high). - ✅ Histograms decode to Blastware's own interval table on every DL2
file: Tran / Vert / Long interval peaks have 0 mismatches (
dev).- The codec is now chosen by STRT[18]. The waveform codec had been claiming 2018 5 s histograms.
- The sub-minute layout check now tests peak ≤ PVS ≤ √3·peak.
- Blastware's "Number of Intervals" is the monitoring time ÷ the interval: a carve-out, 8 events.
- ✅ Histogram PVS = the stored per-interval PVS²: 69,989 / 70,042. Mic: one count = 0.25 Pa (an eighth at mic range 1, the mic block's label + 29), dB offset 81.938216 (2026-11-09; 81.9384 was too high).
- ✅ Over range (D.6.15): a peak past 2,000 units (32,000 counts; the
mic in counts) is Blastware's
OORANGE, per channel and per interval; the vector sum isOORANGEexactly when a geophone is, never on its own. - 🔑 Blastware's mic unit labels don't hold on every report (D.6.6): the
peak carries its own
<Units>, a sample table's cells say its unit, and a few reports mix dB and psi in one column (carve-outmic-units-mixed). - ❌ Open:
- the vector sum's last digit on 4 waveform/histogram twins: Blastware's value is ~1.5 ppm lower, cause unknown (no factor applied)
- 4 accelerations (D.6.12)
- ⬜ Not read yet, in the order proposed (2026-11-03):
A. Setup fields✅ done ondev.B. Histogram interval detail✅ done ondev. Frequencies (#50), per-interval PVS, interval size, stop.C. #51 timing✅ done ondev.D. Blastware's waveform calculations✅ done. ZC frequency, displacement and time of peak are the unit's own (D.6.12); acceleration is Blastware's.E. Sensor check results✅ done (D.6.13). Plus the traces of a unit without a mic, which the trace decoder had been dropping.F. Monitor log✅ done (D.6.14): in the footer after all.
- 🔶 #48 is still open. The event file's setup block puts the pre-trigger
where the 1A "stable anchor"
be 80 00 00 00 00sits. In the file, though, it is each event's own pre-trigger, not the setting: 253–256 samples at 1024 sps, alternating on the same unit on the same day, and reported that way by Blastware. So the files say little about whether the live 1A read loses its anchor (reference D.6.2).
- Goal: SFM produces everything Blastware reports, from the event file
alone (spec and plan in
-
The Series-4 LIVE wire protocol is reverse-engineered end to end (2026-09-25).
docs/micromate_protocol_reference.mdis the Series-4 Rosetta Stone, sibling toinstantel_protocol_reference.md. A Micromate answers Series III command frames — three framing differences: responses have no leadingDLE(a bareSTX),payload[1]is0xC5(Blastware firmware) or0x03(Thor firmware) rather than0x10, and the data length is a uint16 BE atpayload[8:10](as a byte it under-readsSUB 0x1Aby 47x). Read path, event chain, setups, scheduler, monitoring control and per-event delete are all mapped — and as of 2026-10-14 so is the inbound call-home session. There are no protocol unknowns left.⚠ No command has ever been originated against a unit by this project. Every write was performed by THOR while we recorded. That line is worth keeping.Retracted 2026-10-25: the first commands this project originated against a Micromate were0x96/0x97(start / stop monitoring) to UM20147 on 2026-10-25, sent by SFM at the bench with Brian's go for each send — 4 sends, each acked and read back, each audited. (This line was always about Series 4: theminimateplusstack has sent Series-III writes — start/stop, config push, erase, call-home config — since April 2026.) Every other Micromate write (call-home, setup push, delete, scheduler) is still THOR-only, never sent by us. Details:docs/micromate_protocol_reference.md→ The first commands this project originated against a Micromate. Series-4 write path, phase 2 is done (2026-10-22): the write encoder, a send-side opcode gate and write plans for start/stop, call-home enable and the setup rewrite, reproduced byte for byte against THOR's captured frames.bridges/mm_dry_run.pyprints a write's planned frames from a live unit's reads (run on UM20147: sizes equal UM12947's).MicromateProtocol._sendrefuses every write opcode except one start/stop plan at a time throughexecute(), on a connection with a fresh Micromate reply, and refuses0xA2always. The only transmit path for a write isexecute(), reached only from SFM's serial-named start/stop routes throughsfm/device_access(identity, state, audit, read-back, never retried); the Series-3minimateplusstack and raw-socket bench bridges are outside the gate. The reproduction's breadth is one distinct input per block (the five pushes share the same name, prefs and trigger block). -
✅
micromate/HAS a live client (2026-10-02).framing.py,protocol.py,client.py+ models, 119 tests, mirroring theminimateplus/stack and reusing itstransport.pyunchanged. Connect over TCP or serial, identify a unit, read state/clock/battery/memory, list setups, walk the event chain and download + decode events. Read-only — every write remains mapped-but-unimplemented, deliberately. Verified on hardware across both firmware lines (UM1294711.0CB, UM2014711.0BD) and both transports (USB CDC-ACM and an RX55 over cellular), byte-identical. ⚠ The gap is config decoding, not the protocol:0x1A(2,103 B) has about a dozen fields read;0x2C,0x2E,0x08,0x01are fetched and undecoded. Finishing it needs a bench session varying one setting at a time, as was done for Series III — not desk work. -
Config decoding: first keypad pass done (2026-10-17). 47 snapshots of UM20147 while settings were changed on its keypad; every byte that moved is accounted for.
0x1Acontent now reads: record mode[5](01Waveform,02Manual,03Histogram,04Combo), sample rate[6:8], histogram interval[8:10]s, pre-trigger[12:16]f32 negative s, stop mode[17], record time[18:22]f32, auto-stop[23], active-sensor and trigger-source bitmasks[25]/[29](0x07geo,0x08mic), trigger level at channel+30(geo in/s, mic psi). Full table, grades and method indocs/micromate_protocol_reference.md→ The0x1Afield map from a keypad pass. 🔑0x1Aends in a CRC-16/AUG-CCITT overcontent[0:2088], stored BE at[2090:2092]— 47/47 plus a second unit. Thor's write omits it (the unit computes it), so it is a read-side integrity check, not a write obligation. ✅ Wired in:micromate.setup_block.crc_ok()(2026-10-19). ⚠ The six channel blocks are 3 geophones + the active mic (block 4) + the stored linear / sound-level mic setups (5, 6). Read the mic from block 4 and branch on its+4:8code (2linear,9SLM); labels and unit strings are re-rendered by keypad saves and are not identifiers. ⚠0x1Areads the keypad's edit buffer live — unsaved values show while someone is in the menu; a discard reverts them. 🔶 Possible Series III bug, inferred only: S3's 6-byte "stable anchor"be 80 00 00 00 00sits exactly where Series IV keeps pre-trigger (−0.25 s)- stop mode (Fixed). An S3 unit in Auto stop mode would then lose the
anchor and decode no mode / rate / interval / record time. One BW capture
in Auto mode settles it — see the 2026-10-17 row in
instantel_protocol_reference.md. Harness:scratch/mm_config_diff.py watch(now per-session snapshot labels and a built-in CRC check). ⚠sg dialout -c "..."is still needed to open/dev/ttyACM0from shells started before thedialoutmembership. ⚠ When diffing, get the operator's own account of what was pressed before labelling a run — twice on 10-17 a run was attributed to the setting that had been asked for, and both were wrong. Not yet mapped: job number, scaled distance, GPS, aux I/O, SLM options, four unknown head runs, channel+46:48. 2026-10-19 — setup loading done, plus prefs. Loading a.MMBreplaces the active config byte-for-byte (3 loads; only differing fields move, no load marker). Also measured: job number[40:42]+ report flags[39](0x02job no.,0x08scaled distance,0x01unknown); distance[30:34]metres and charge weight[34:38]kg, converted with the firmware's own constants ft ÷ 3.2808 and lb ÷ 2.21 (not 2.2046 — convert back with 2.21 or 45 lb displays as 44.89); notes at[122+64n]/[144+64n](the reference's0x8Aand0x06BCwere 16-byte slips, corrected in place). 🔑0x08is the preferences block, not an event index — display units live there (content[31]), and switching them moves nothing in0x1A. 🔑 One checksum rule covers0x1A,0x08and0x2E:content[0:2]= N, CRC-16/AUG-CCITT over[0:N-2], stored at[N:N+2].0x2Chas none.0x2Csession timeout lives at[118:120]in an unknown encoding; modem baud is in none of the six blocks. ⚠ Never write modem baud or modem type remotely — the remote link is the modem port; a mismatch strands the unit until a site visit. "Monitor While Calling Home" is Thor/Blastware-only, so it waits for a THOR round. Next on config: that THOR round (a many-differences setup + the0x2Cfields). ✅MicromateClient.get_setup()decodes all of the above (2026-10-19) —micromate/setup_block.py, measured fields only, checksum-verified, 69 tests on 15 real fixtures (tests/fixtures/micromate-setup/, force- added).bridges/mm_client_check.pyprints it; Brian matched every line against UM20147's screen. ✅ SFM speaks Series 4 by serial (phase 1a, 2026-10-20):/device/info,/device/monitor/statusand/device/settingstakeserialand return one shared shape for both series throughsfm/device_access/. Micromate lines are held open (one call-up, keep-alive 60 s, idle hang-up 5 min, released on RADIO RING); MiniMates still reconnect per request. Withoutserialthe legacy Series-3 path is unchanged. ✅ Phase 1b (2026-10-21) lists and downloads events by serial for both series -- the MiniMate list comes from headers only (no 5A), and a download is checked and stored in SFM's DB (db_event_id). Bench-checked on UM20147: 5 events, a waveform that verified, a histogram, one call-up for the whole sequence.⚠ The MiniMate header walk is unproven on a unit; a MiniMate bench check is owed before the branch merges.2026-10-25, first MiniMate bench run (BE9441, serial cable): the header walk listed 20 events correctly, and the check found four bugs, all fixed and tested on its logged bytes.
- Every non-first event SFM assembled was 2 bytes short. The body
builder assumed the 0x1002/0x1004 metadata pages in every 5A stream; it
now reads each A5 reply's echoed address. This also affected legacy
get_eventsandach_server.pyfiles. Blastware's own files were not affected. - A reboot mid-download stored a partial event as a success. A strict
5A stream now raises on any early end. The reboot itself was ours: the 5A
request had a bare
0x02checksum, which the unit reads as STX. A 5A checksum in {02, 03, 04, 10} is now DLE-escaped (re-run 2026-10-26). - The unit boots when its port opens and ignores a POLL sent before the
Operating Systembanner. Startup now waits for it. - The 0x15 serial is a C string (
"BE9441\x00?").
Series-3 downloads are now checked against the unit's own 0C peaks before being stored. Re-run 2026-10-26: every event that does not cross a 64 KB page downloaded whole and verified (events 0, 1, 3, 4, 10).
The two that cross one (events 2, 19) are refused by name.Later the same day the page bug was fixed (see the ✅ FIXED entry below): a fresh 8 events, 4 of them crossing a page, all downloaded byte-identical to Blastware's own files. Stale id gives 409, a repeat givesalready_stored, also against Blastware's imported copy. Evening 2026-10-26 (measured): a 71 KB histogram (139 requests, two 64 KB crossings) downloaded byte-identical to Blastware's, and SFM stopped the unit through the new audited path (acked, read back idle). That neededd990466: the 0x1C flag reads 0x0B during a histogram run (only 0x10 had been measured), and the status decode had to unescape before counting from the end. Start too (2026-10-27 00:12): idle → monitoring, verified -- once a start's read-back waited out the ~30 s sensor check and re-sent the wake (9886422,ca5c401; a monitoring MiniMate answers nothing until woken, and nothing during its sensor check). Still owed before merge: #47 from dev, andpersist_downloadaligned with dev's waveform-time restamp (spec). - stop mode (Fixed). An S3 unit in Auto stop mode would then lose the
anchor and decode no mode / rate / interval / record time. One BW capture
in Auto mode settles it — see the 2026-10-17 row in
-
Phase 1c: the SFM webapp by serial (2026-10-29), built; bench pass owed.
sfm/sfm_webapp.htmlhas a Serial field beside host/port. With one, the Live tabs use the serial-based routes for both series: identify, status (now with the unit's clock and event count), settings (read-only), the event list with a Download per row (checked, stored, then opened from the store), and audited start/stop (asks first, one send, shows the ChangeResult as it is). Hang up appears for a Series 4. Every series-specific control follows the unit's own/device/infoanswer, never the typed serial, and drops the moment the serial, host or port is edited. Config and call-home writes are off for both series (phases 5 and 4); Diagnostics is enabled only for a confirmed Series 3. Without a serial every read behaves as before. The page keeps every routing and button rule in one block of pure functions between/* <device-routing> */markers, run through Node bytests/test_webapp_device_routing.py(skipped whennodeis absent); a static test fails if a/device/URL is built anywhere else. Server side: the legacy Series-3 writes and erase --POST /device/config(and/config/project),/events/erase,/rescue(when it disables ACH or erases),POST /device/call_home-- read the unit's serial (or reuse the oneconnect()read) and refuse 409, nothing sent, unless it is Series 3 and, whenserial=was given, that unit. 0xA2 is CONFIRM ERASE on a MiniMate and ends a call-home on a Micromate. The stop tools (legacymonitor/start|stop,stop_monitoring_blind,_slow_drip,_spam) are exempt: 0x96/0x97 mean the same on both series, and the blind tools must reach a unit too wedged to answer. Bench pass done 2026-10-29 (both series, each on its own modem): 16 findings in the spec (Left open by the 1c bench) -- the S3 settings decode reads escaped bytes (#1), S3 downloads skip the file reader (#8), the S3 start read-back does not reconnect after the modem drops the line (#9), an auditsent: null(#15), and page polish. Batch 1 fixed (2026-10-29): #1 (b320a53, settings read after unescaping: mode −7, rate −6, interval −4, record time +6), #9 (ce441a0, one reconnect for the read-back), #8 (9492e49, downloads stored throughsave_imported_bw; since 2026-11-02 everything comes from the file -- peaks, vector sum, mic and the range it was recorded at -- and the unit's 0C summary is only the download check). #2 came with thedevmerge. #15 retracted --sentNULL is "unknown", by design. Final review fixes:dbd8a91(wake before the reconnect's identity read),3a1d34a("already stored" by Blastware name too),a72d3a9(the 1A write encoder refuses a patch that would not read back -- its offsets are 1024-sps raw ones, #46). Phase 4 built 2026-11-02, benched 2026-11-03: call-home on/off by serial for both series (GET /device/call_home/state,POST /device/call_home/{enable,disable}, the page's Call Home tab). The MiniMate frame is Blastware's byte for byte (tests/test_s3_call_home_bw_frames.py, the 4-20-26 captures). On both units, idle, the no-op, off and on writes were all verified and agreed with the unit's 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. SFM refuses both up front. 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). Specdocs/superpowers/specs/2026-11-03-sfm-phase5-settings-design.md.- 🔑 A MiniMate's settings block IS Series IV's
0x1Alayout (measured): the 1A read assembles to 2,090 bytes headed by N = 2090, and all 11 Blastware compliance writes reproduce from the block before them. One codec serves both series:micromate/setup_fields.py. - Limits are the units' own, from Instantel's manuals (Brian). A live send needs its preview's revision; refused up front: monitoring, a Micromate on its factory setup or whose schedule would load another setup.
- Retired:
/device/config(410),apply_config,_encode_compliance_config. - Benched 2026-11-04, both series: every change acknowledged, read back, 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
0x10in 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
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.
While THOR polls a unit, SFM gets no reply and does not disturb THOR.
✅ Line hold decided (Brian, 2026-10-29): keep it as is for now; the
long-term fix is SFM handling auto call-ins itself. The ring-path merge gate
is settled. THOR's log:
C:\THORDATA\Logs\. Next: a short fix plan for the findings, then phases 4 and 5.
- 🔑 A MiniMate's settings block IS Series IV's
-
✅ Phase 3: start / stop monitoring by serial (2026-10-23) — built, reviewed, and bench-verified on UM20147 (2026-10-25). Start acked in 0.46 s and read back as monitoring at the first 2 s poll (during the sensor check); stop acked in 0.12 s, then
0x49read a new value0x01for ~18 s (inferred: the unit's call-home attempts after a stop — refused as unmeasured until settled) before idle; a stop while idle is a harmless 10 ms no-op. The Series-3 path is unproven on a unit (MiniMate bench check owed). Both series go through one safety core,sfm/device_access/change.py: a fresh identity read, the run state (calling home or never measured is refused),dry_run(the exact frames, nothing sent), a row in the newdevice_commandsaudit table (GET /db/device_commands;sentsays whether a frame went out,stateskeeps every read), one send never retried, then a read-back. The HTTP status is an allow-list -- only a dry run, a skip or a send read back as made is a 200 -- and a failure after the send says so and names its audit record. -
🔑 ACH / call-home, captured end to end (2026-10-14). A Micromate signals
RADIO RING; two paths exist and timing decides which: if anything already holds the modem's single TCP session the ring rides that connection, otherwise the modem dials out to a listener. THOR'sUnitWatchDogTimerreconnects continuously, so THOR usually holds that slot — which is why probes and relays see silence. That is contention, not a fault. ⚠⚠SUB 0xA2ends a call-home on Series IV and is CONFIRM ERASE on Series III — same opcode, same0x5Dresponse, opposite consequence.minimateplusandmicromateshare a transport; dispatch on series before that byte reaches a wire. ⚠ "Monitor While Calling Home" silently blocks erase, and THOR reports the session successful anyway. A receiver therefore cannot rely on erase to manage storage — the server-side high-water mark is load-bearing. ⚠bridges/mm_ach_server.pyimplements the listener path only; it needs to also hold outbound connections and watch for the ring. -
Bench tooling for device diagnosis (2026-09-25).
bridges/mm_probe.pydistinguishes the four faults THOR reports identically as "disconnected" (refused / connect timeout / connected but no reply / replied) and names what to try next.bridges/mm_link.pyis a stand-in for a cellular modem with a decoded log and fault injection.scratch/mm_frame_parse.pyexists becauseS3FrameParsercannot see Micromate responses at all — it scans forDLE+STX, which never appears in Series-4 traffic. -
A Micromate's USB-A host port drives FTDI and CDC-ACM only — no Prolific, in either firmware line. TMI buys both Sabrent (FTDI) and Benfei (PL2303) cables and they are indistinguishable by eye. A PL2303 cable leaves a unit with no working modem port at all; identify by
lsusbVID,0403vs067b. This accounted for a unit that could not be deployed. -
Series-3 decode is verified per-sample at scale (v0.27.0). The full DL2 archive decodes 14,338 / 14,338 paired files exactly against their preserved Blastware ASCII exports — 1,249 waveform + 13,089 histogram, 45 units, files back to 2018. ⚠ Corrected 2026-10-29: the 14,338 pairs are all events from 2025–26 (five more carry a 1995 clock); DL2 kept ASCII reports only from 2025. 🔑 Its
Sent/<stem>_<ext>_XML.XMLfiles are Blastware's full event report — every report field plus every sample — for 70,042 events back to 2016, local copy~/dl2-archive/xml.scratch/verify_bw_fields_against_xml.pychecks file-only fields against them. That is 11x the ground truth the prod store carried, and it supersedes the old "per-sample on 11%, peak-only on 89%" caveat. Harness:scratch/verify_against_ascii.py(note its saturation carve-out — BW clamps clipped events, the decoder reports true counts). Independent corroboration of the 32000-count scale: 19,244 healthy channel-events sit at a pre-trigger floor of exactly 0.000 (62.7%), 94.5% within ±1 quantisation unit, median +0.0000 — no zero-point bias. -
Series-4 (Thor / Micromate) is now verified per-sample (2026-09-10). 1,057,536 / 1,057,536 geo samples across all 153 genuine Thor waveform files reproduce Thor's own CSV export exactly; IDFH peaks are within 2% on 858/858 (median -0.004%). The ground truth was in the corpus all along — Thor writes
CSV/<name>.IDFW.csvbeside each binary with a per-sample four-column block. Harness:scratch/verify_thor_against_csv.py. Four bugs, all fixed: geo LSB was0.0003(display rounding of the real0.000310308, so every sample read 3.3% low); the IDFH segment validator required a zero counter high byte, capping every histogram at 250 intervals; record mode00 00(raw int16) was unhandled, silently dropping each channel's first 512 samples; and the body-offset search matched00 02 00inside record headers, decoding a rotation-shifted body. IDFW is no longer pinned todecode_waveform_legacy. Series-3 re-verified unchanged at 14,338/14,338 after the shared-codec change. -
Mic-disabled (3-channel) units are a distinct shape (2026-09-10). Verified on a second corpus (
~/thor-csv-req, UM11402/UM12947/UM20147): 139/139 waveforms per-sample exact, 877/877 histograms within 2%. Two structural differences: the shorter header puts the waveform record chain head at0x0dba(below the old_BODY_SCAN_FLOORof0x0E00, so it was invisible and Vert came up exactly 512 short), and the histogram interval record is 56 bytes, not 72 —16 × n_channels + 8, derived per segment from the cumulative interval counter, never assumed. -
40 NNblocks are not capped at NN=8 (2026-09-11).data_block_len()rejectedNN > 0x08, a guard with no evidence behind it — the corpora available when it was written only used NN ∈ {1,2,3,4,8}. Loud UM12947 events use NN up to 196, and since the walker stops at the first unrecognised tag rather than raising, this surfaced as silently short channels. Verified on 167 UM12947 waveforms: length mismatches 22 → 0, 1,476,242/1,476,249 samples exact. -
Production IDFW is now 575/575 — zero truncations, zero decode failures, median PPV error −0.0007% across 8 units (was 41 truncated + 1 failing, −3.3%). Across all three ground-truth corpora: 459 files, 3,807,158/3,807,165 samples exact; the 7 stragglers differ by one 4th-decimal tick and are Thor's own rounding — no single linear LSB can reproduce every printed value (the constraints are infeasible by 7e-5 relative), so do NOT retune
_GEO_LSB_IPS. -
✅ FIXED 2026-10-26 (
887e75d) — was: "KNOWN BUG — the 5A walk breaks once a unit's buffer crosses 64 KB." Kept below as history. The fix came from a recording of Blastware downloading all 8 of BE9441's events, 4 crossing a page (tests/fixtures/minimate-bench-10-26-26-blastware/):- Every MiniMate request DLE-escapes 02, 03, 04 and 10, payload and checksum alike
(748/748 re-encode).
build_bw_framehad escaped only 0x10. - A 5A request is an ordinary request carrying a LENGTH and a 4-byte linear ADDRESS. The walk: the event's start, +0x200 carrying into the page byte, then TERM at the next boundary for the remainder.
- The old model misread the same bytes. The "offset 0x1002" is length 0x0200 escaped; the "metadata pages at 0x1002/0x1004" are event 0's chunks at 0x0200 and 0x0400; the 16-bit counter could not leave its page.
- Verified on BE9441, live: all 8 events, including 4 page crossings, downloaded
whole and matched the unit's own peaks.
⚠ Sections below that describe "partial DLE stuffing", "11-byte params", "offset_hi
0x10 raw" and "metadata pages 0x1002/0x1004" are that misreading. They are retracted
here, not deleted.
Review follow-ups (2026-10-26): the walk's chunk cap is now sized from STRT (a
caller's 128 cut every event past ~66 KB; 2,545 of 63,500 archived histograms are
bigger); a STRT claiming less than one chunk or more than 4 MiB is refused as a
misread; a TERM is sent only for a true tail. Still open, none measured: an event
ending exactly on a chunk step sends a zero-length TERM (as the old code did; 1 in
512, never seen); with no STRT the legacy walk still reads
max_chunksblind. 🔶 Inferred only, do not act on it without a capture:build_bw_write_frame("raw except BW_CMD", "DLE-aware checksum") carries the same fingerprints as the retracted 5A model: SUB 71's "offset 0x1004" reads as length 0x0400 escaped, and Blastware escapes03in write data. A write whose payload holds a bare 02/03/04/10 may be malformed. One Blastware config-write capture settles it. 🔑 Replies follow the same rule (measured, 748/748): every 02/03/04/10 escaped, checksum = SUM8 of the unescaped payload. The "S3 checksums frequently fail" belief isS3FrameParsersumming its output with the10of10 02/03/04still in it.⚠ KNOWN BUG — the 5A walk breaks once a unit's buffer crosses 64 KB.parse_strt_end_offset()returns only(end_key[2] << 8) | end_key[3], discarding the key's page byte. An event starting at0x0111F2A2and ending at0x0112_1010therefore readsend_offset = 0x1010— behind its own start. The chunk loop then exits before fetching anything and TERM computes a negativeoffset_word, whichstruct.pack(">H", ...)rejects: the/device/eventswalk 500s. Reproduced on BE12599 (2026-09-19), which had 78 KB stored and had rolled into page0x12. Why it hid so long: every 5A capture the walk was verified against came from a freshly-erased BE11529 — all three confirmed TERM examples inframing.py(0x1ABE,0x21F2,0x417E) sit inside page0x11. Prod is unaffected: it ingests complete files via BW ACH, never this walk. Fixing it has two layers — the arithmetic (if end < start: end += 0x10000) stops the crash and bounds the loop correctly; carrying the page byte through the chunk requests (params[1]0x11 -> 0x12, counter rolling over) needs a BW capture of a spanning event first. Do not ship layer one alone without a loud truncation warning — a silently short event is the failure mode this codec has been bitten by repeatedly. Narrowed 2026-10-26 (BE9441, measured): - The one-event download now refuses a spanning event by name (502), before any chunk.
- STRT carries the full 32-bit end key, so the page is there to use.
- A read-only test walk carrying the page byte got a proper reply for the
first chunk in the next page (
01 12 01 2c). The second chunk, params… 01 12 03 2c, got none: a raw0x03inside the params. - Pages after
0x11have counters with02/03/04bytes. Page0x11has none, because event 1 skips0x0000–0x05FF. - How Blastware encodes those bytes is the one unknown left. The capture to
take: Blastware downloading BE9441 event 2 (
0111c92c) or 19 (0118a4ca) through the recording bridge. Blastware's own files for both are fixtures (tests/fixtures/minimate-bench-10-25-26/blastware/), as byte-exact targets.
- Every MiniMate request DLE-escapes 02, 03, 04 and 10, payload and checksum alike
(748/748 re-encode).
-
Open, not blocking:
14 sensitive-range files show an exact 8x (= 10.0/1.25) units discrepancy(resolved ondev2026-11-02: the range is read from the file, reference D.6.4);scripts/backfill_sidecars.py --forcealso inserts DB rows for store files that have none (one-time per store) and the dry-run does not report that count. -
After any codec change, regenerate the store —
backfill_sidecars.pythenbackfill_event_shape.py, DB backup first. Stored.h5files do not update themselves. No--forceneeded as long asTOOL_VERSIONwas bumped (it gates regeneration). ⚠ On the office NAS this takes ~2 hours (~1.5 files/sec vs 85/sec on the dev box — gzip-4 insfm/event_hdf5.pyagainst a Synology CPU). Budget it up front. v0.27.0 does NOT owe prod a backfill — verified: the partial-final-block fix changes 0 of the 10,215 histograms in the prod store (the 4 recovered files are archive-only and were never ingested). ✅ The v0.30.0 Series-4 backfill HAS been run on prod (2026-09-25). Every stored Series-4 geophone value was ~3.3% low until then; that is corrected and the job does not need repeating. -
The "offset" hardware fault has its own journal --
docs/offset_investigation.md. 5 of 45 units (11%), and the fault is persistent — it stays until the geophone is serviced. Detect it withscratch/offset_scan3.py: the resting floor in the pre-trigger window, required to hold across pre/middle/end. Never score only the dominant-peak axis and never use the mean — both produce false recoveries (see the retraction banner in the journal). Instantel's autozero procedure and its 2027-2069 acceptance window are recorded there too. Best open lead isSUB 0x0E(unimplemented), which may carry those very numbers.
When new information about a protocol is discovered, record it in the matching reference in addition to this document:
| series | document |
|---|---|
| Series III (MiniMate Plus / BlastMate) | docs/instantel_protocol_reference.md |
| Series IV (Micromate / THOR) | docs/micromate_protocol_reference.md |
| Thor IDF file format | docs/idf_protocol_reference.md |
Both protocol references carry retractions in place rather than deleting what turned out to be wrong — that convention has already saved re-deriving the same mistakes twice, so keep it.
Changelog & release convention
Feature branches do NOT touch CHANGELOG.md. Write the entry on dev, as
part of finishing the merge, under ## Unreleased. Cut the version on dev in a
dedicated release commit when you are ready to ship to main.
- The changelog is written on
dev, never on a feature branch. With several branches in flight they all edit the same few lines at the top of the file and conflict every time. Writing it once, after the merge, also lets it describe what actually landed — including anything that changed during conflict resolution. - ⚠ The merge is not finished until
## Unreleasedis updated. Same sitting, not "later" — that is the one failure mode of writing it after the fact. Reconstruct from the branch's own commit messages:git log --oneline dev..<branch>before you merge, orgit log --oneline <merge-base>..<branch>after. - No preamble under
## Unreleased— just the### Added/### Changed/### Fixedlists. The themed opening paragraph gets written at release time, when the whole release is visible and can be named honestly. A theme written when the first item landed is stale by the third. - ⚠ State the operational consequence on any entry touching the codec, the
waveform store, or the DB — including when it is "none." "requires
backfill_sidecars.py+backfill_event_shape.py, ~2 h on the NAS", "TOOL_VERSIONbumped", "no schema change, no migration". Silence is ambiguous; "none" is information. This repo's changelog is how future-you learns whether a deploy costs two hours. - Releases are cut on judgement, not on a schedule or a merge.
Unreleasedis the staging area for whatever is going into the next release; when enough has accumulated to be worth shipping, it gets a number and a date. Nothing about a merge todevtriggers a release. - Cutting a release is its own
chore(release): vX.Y.Z — <theme>commit ondev, renaming## Unreleased→## vX.Y.Z — YYYY-MM-DDand touching:CHANGELOG.md,pyproject.toml, the version line inCLAUDE.mdandREADME.md, andminimateplus/event_file_io.py(TOOL_VERSION) when the codec changed — that constant gates.h5regeneration. maincarries only released versions. No## Unreleasedsection there; it lands via thedev→mainPR.mainlaggingdevby a version is normal.
Architecture: three-tier conceptual model
⚠ SUPERSEDED 2026-10-27 by Terra-View's
docs/adr/0003-stack-components-and-names.md. The SFM / SDM split below is retired.
- SFM is the whole seismograph module: the call-in server, the adapters, decoding, the store, per-event measurements and the API. "SDM" is not used as a name any more.
- The codec library stays pure, as described in tier 3. That rule survives unchanged.
- Lab tools (
bridges/bench tools,scratch/,seismo_lab.py) are experimental and are to leave the production image. One that becomes a real production tool is ported intosfm/, rebuilt onsfm/device_access.- The call-in server (today's
bridges/ach_server.pyandbridges/mm_ach_server.py) becomes SFM's front door, after the staged proof in the ADR.- The repo becomes
sfmafterfeat/series4-sfm-paritymerges.The text below is history, kept in place per this repo's retraction convention.
seismo-relay is a suite of cooperating components, not a single app.
The three tiers below are the canonical mental model — the current
directory layout doesn't fully reflect them yet (some of what is
conceptually SDM lives under sfm/ today), but new code should be
placed and named according to this model.
1. SFM — the device-side (active connection to physical units)
Replaces Blastware's talk-to-the-meter role. Lives where a connection to a physical seismograph is open.
In scope:
minimateplus/{transport,framing,protocol,client}.py— wire protocolseismo_lab.py— diagnostic GUI (a thick client for SFM)- The
/device/*HTTP endpoints insfm/server.py—/device/info,/device/events,/device/monitor/*,/device/call_home, etc. Anything that opens a connection at the moment of the request. - Future: a Thor / Micromate live client (mirror
minimateplus/) - Future: a control surface Terra-View can launch into — see the README's Roadmap.
Does NOT own a database. Outputs Event objects. Has a "spun up when
needed" runtime profile rather than "always on".
2. SDM — the data-side (storage, ingest, and serving)
The new name for the receiving-and-storing role. Originally called SFM
because the FastAPI service started life as a thin device proxy, but
the actual role has migrated heavily toward data management. For now
the directory remains sfm/ — renaming requires touching ~30-50
files in seismo-relay + ~10-15 in terra-view + a Docker volume
migration; deferred until the codebase is quiet enough to do it as a
clean refactor.
In scope:
sfm/database.py(SeismoDb)sfm/waveform_store.py,sfm/event_hdf5.py- The
/db/*HTTP endpoints —events,units,monitor_log,sessions,false_triggermutations - The
/db/import/*ingest endpoints —blastware_file(series3),idf_file(series4); anything that receives events FROM somewhere scripts/backfill_sidecars.py,scripts/check_bw_report_preservation.py, and similar data-maintenance tools- The
.sfm.jsonsidecars and.h5files in the waveform store - The shape that Terra-View consumes (Terra-View should never need to reach into SFM/device-side endpoints to populate its UI)
Always-on, scaled for storage/serving, has the DB and waveform store.
3. Codec library — pure data interpretation (used by both sides)
Neither SFM nor SDM — a shared library both depend on.
In scope:
minimateplus/{waveform_codec,histogram_codec,event_file_io,bw_ascii_report,blastware_file}.pymicromate/{idf_ascii_report,idf_file}.py
These modules take bytes (off the wire on the SFM side, or from a
forwarded file on the SDM side) and return Event objects. They
should not import from sfm/, must not touch a DB, and have no I/O
beyond reading files passed as arguments. Keep them pure — both
tiers can then depend on them without circularity.
Thor IDF binary codec (updated 2026-09-10)
micromate/idf_file.read_idf_file() decodes both Thor IDFW
(waveform) and IDFH (histogram) binaries. Verified per-sample
against Thor's own CSV exports — see
scratch/verify_thor_against_csv.py.
- IDFW uses the series-3 record-chain
decode_waveform_v2(). The body offset is not fixed: it is<chain-head record> + 7, found by_find_waveform_body_offset()anchoring on record headers. All 153/153 genuine Thor waveform files decode per-sample exact (1,057,536/1,057,536 samples). - IDFH segment header is
[len_be][0a 00 00 00][counter_be][05 3f], wherecounteris a uint16 cumulative interval index — it must not be constrained to a zero high byte (that capped histograms at 250 intervals). Intervals whosemin > maxon all channels are unwritten slots carrying a ±full-scale seed and are skipped. 858/858 files land within 2% of Thor's PPV (median -0.004%). - Geo LSB is
0.000310308in/s per count (full scale 10.0 in/s = 32226.05 counts). Series-3's 32000-count scale does NOT apply. - Record modes are
02 00deltas (14 B header),01 00absolute,00 03raw 12-bit, and00 00raw int16 (all 10 B headers).01 00and00 00are also valid as the implicit segment-0 preamble.
⚠ Thor's histogram PPV has a 0.0050 in/s display floor. 41.4% of prod IDFH sidecars report a component PPV exceeding their own vector sum — impossible. On quiet files our decode is more accurate than the reference; do not "fix" the decoder to match it.
The two outlier BE9439_* files in the Thor example corpus are
actually Series III Blastware binaries that share the .IDFW/.IDFH
filename convention by accident. read_idf_file() detects them by
their BW STRT signature and raises NotImplementedError pointing
callers at read_blastware_file(). See
docs/idf_protocol_reference.md for full field layouts.
Practical consequences
When deciding where new code goes, ask:
- Does it need a connection to a device? → SFM
- Does it operate on stored events / sidecars / DB rows? → SDM
- Does it interpret bytes into structured data, with no I/O of its own? → codec lib
Terra-View is downstream of SDM for data, and (per the roadmap) will eventually invoke into SFM's device-control endpoints to provide a "connect to unit" experience.
Project layout
minimateplus/ ← Python client library (primary focus)
transport.py ← SerialTransport, TcpTransport
framing.py ← DLE codec, frame builders, S3FrameParser
protocol.py ← MiniMateProtocol — wire-level read/write methods
client.py ← MiniMateClient — high-level API (connect, get_events, …)
models.py ← DeviceInfo, EventRecord, ComplianceConfig, …
waveform_codec.py ← Body-codec block walker + decode_tran_initial (partial
per-sample decoder — see "Waveform body codec" section below)
sfm/server.py ← FastAPI REST server exposing device data over HTTP
sfm/sfm_webapp.html ← the SFM page; its JavaScript is in sfm/static/ (no inline JS,
sfm/static/ ← a stack-wide rule since 2026-11-02): device_routing.js holds the
DOM-free rules (Node-tested), sfm_webapp.js the page glue
seismo_lab.py ← Tkinter GUI (Bridge + Analyzer + Console tabs)
bridges/
mm_probe.py ← name the fault behind a dead unit (4 verdicts, read-only)
mm_link.py ← bench stand-in for a cellular modem, with fault injection
ach_mitm.py ← TCP relay for recording a Series-3 ACH session
docs/
instantel_protocol_reference.md ← Series III protocol spec ("the Rosetta Stone")
micromate_protocol_reference.md ← Series IV protocol spec + THOR's measured behaviour
idf_protocol_reference.md ← Thor IDF file format
CHANGELOG.md ← version history
Current implementation state (v0.14.3)
Full read pipeline + write pipeline + erase pipeline + monitor log + call home config working end-to-end over TCP/cellular:
| Step | SUB | Status |
|---|---|---|
| POLL / startup handshake | 5B | ✅ |
| Serial number | 15 | ✅ |
| Full config (firmware, calibration date, etc.) | FE | ✅ |
| Compliance config (record time, sample rate, geo thresholds) | 1A | ✅ |
| Event index | 08 | ✅ |
| Event header / first key | 1E | ✅ |
| Waveform header | 0A | ✅ |
| Waveform record (peaks, timestamp, project) | 0C | ✅ |
| Bulk waveform stream (event-time metadata + full waveform) | 5A | ✅ (2026-10-26: a LENGTH read at a 32-bit ADDRESS, every 02/03/04/10 escaped — the model in the rest of this cell is retracted, see "✅ FIXED 2026-10-26") byte-perfect against BW captures (v0.14.3, 2026-05-05) — STRT-bounded chunk walk + correct event-N probe counter + DLE-stuffed 0x10 bytes in params + concatenate-only file body assembly. All 17 5A request frames in the 5-1-26 3-sec capture reproduce byte-for-byte. |
| Event advance / next key | 1F | ✅ |
| Write commands (push config to device) | 68–83 | ✅ new v0.8.0 |
| Erase all events | 0xA3 → 0x1C → 0x06 → 0xA2 | ✅ new v0.9.0 |
| Monitor log entries (partial 0x2C records) | 0A browse | ✅ new v0.10.0 |
| Auto Call Home config (read + write) | 2C → 7E → 7F | ✅ new v0.12.3 |
get_events() sequence per event: 1E → 0A → 1E(arm token=0xFE) → 0C → 1F(arm) → POLL×3 → 5A → 1F(browse)
(see "Correct iteration pattern" section below for full detail)
push_config_raw() write sequence: 68→73 | 71×3→72 | 82→83 | 69→74→72
delete_all_events() erase sequence: 0xA3 → 0x1C → 0x06 → 0xA2
Waveform body codec — FULLY DECODED (2026-05-11 late)
✅ The codec is fully cracked
Every block type, every channel, every fixture event decodes byte-exact against BW's ASCII export. 47,364 ADC samples verified, zero errors. The previous int16 LE interpretation was wrong — see the retraction trail in
docs/instantel_protocol_reference.md §7.6.1.Authoritative implementation:
minimateplus/waveform_codec.py(decode_waveform_v2()). Clean working notes:docs/waveform_codec_re_status.md.NOTE:
client.py:_decode_a5_waveformstill uses the broken legacy int16 LE decoder. Wiringdecode_waveform_v2into the.h5sidecar path is the obvious next follow-up. Until that lands,.h5samples remain wrong — but the codec itself is fully solved.
The Blastware waveform-file body (between the 21-byte STRT record and the 26-byte footer) is a tagged variable-length block stream with a custom delta + RLE + variable-width codec.
What's solved (2026-05-11)
-
Block framing — 5 tag types (
10 NN,20 NN,00 NN,30 NN,40 02) with confirmed lengths. Implementation:walk_body()inminimateplus/waveform_codec.py. -
Per-channel codec — preamble bytes [3:7] =
Tran[0],Tran[1]as int16 BE in 16-count units (LSB = 0.005 in/s). Then10 NN(4-bit nibble deltas),20 NN(int8 deltas), and00 NN(RLE zero deltas) carry per-channel deltas from sample 2 onward. -
Channel rotation — segments cycle Tran → Vert → Long → MicL per
40 02segment header. Each segment carries ~512 sample-sets of ONE channel. The initial body (before the first40 02) is the implicit Tran segment. -
Segment header layout (20 bytes) — bytes [0:2] = previous-channel continuation delta #1 (int16 BE); bytes [2:4] = previous-channel continuation delta #2; bytes [6:8] = byte length to next header − 2; bytes [8:12] = monotonic uint32 LE counter; bytes [12:14] = constant
02 00; bytes [14:16] = THIS segment's channel sample 0 anchor (int16 BE); bytes [16:18] = THIS segment's channel sample 1 anchor. -
decode_waveform_v2()returns full per-channel sample dicts. Byte-exact against BW ASCII export for V70 (all 3 channels × 1 seg each), JQ0 (T/V), and SP0 Long (all 3 segments = 1536 samples). -
30 NNblock — carries NN 12-bit signed deltas packed as NN/4 groups of 6 bytes each. Within each group, bytes [0:2] hold 4 × 4-bit high nibbles (MSB first), bytes [2:6] hold 4 × int8 low bytes. Each delta =sign_extend_12((high_nibble << 8) | low_byte). Block length =NN × 1.5 + 2bytes. ✅ confirmed against all 1430 NNblocks in the fixture bundle. 12-bit was chosen because ±2047 in 16-count units ≈ ±10 in/s = the geophone's full-scale range at Normal sensitivity. -
Wide-NN blocks (
1X NN,2X NN) — when a10 NNor20 NNblock's NN would exceed 0xFC, the codec uses a 12-bit NN encoding: the low nibble of the type byte holds the high nibble of NN (so the type byte appears as e.g.0x11instead of0x10). Effective NN =((type_byte & 0x0F) << 8) | nn_byte. Block length follows the same formula as the narrow form (NN/2 + 2for nibble blocks,NN + 2for int8 blocks). Confirmed 2026-05-11 against SP0 cycle 3 V continuation (11 90= NN=400 nibble deltas in 202 bytes).
⚠ SUPERSEDED 2026-08-25 — the body is a RECORD CHAIN
Everything in this section below about 40 NN segment headers, tagless
headers, variable header widths and channel rotation describes a model that
is wrong. The body is a chain of self-delimiting per-channel records:
off+2 len uint16 BE -> next_record = off + 2 + len
off+4 chan_id 0x46 Tran / 0x47 Vert / 0x48 Long / 0x49 MicL / 0x06 = END
off+8 mode 02 00 = deltas+anchors (14B hdr)
01 00 = ABSOLUTE values (10B hdr)
00 03 = raw 12-bit absolute, NO TAGS (10B hdr)
40 NN is an ordinary int16 BE data block (2*NN + 2), never a header. The
"variable prefix" of 0/2/4/6/8 bytes was walker drift, exactly
4 - (old_stop - true_record_start).
All four channels now come out equal length in 1388/1388 files (was 156/1388); ASCII sample-count exact 75/75, fully exact 73/75; device PPV on a live decode 1306/1306 waveform, 4458/4459 histogram.
The old model survives as decode_waveform_legacy because
micromate/idf_file.py pins it for Thor IDFW body-offset search.
Framing cases added 2026-05-11 → 2026-08-25
Four more block-framing cases, each of which had been causing silent
channel truncation — walk_body ends its loop on an unrecognised tag
and decode_waveform_v2 returns whatever channels it got, so an
unhandled tag surfaces as short channels with no error raised. Found by
diffing 75 production events against their preserved Blastware ASCII
exports (<store>/<serial>/<file>_ASCII.TXT).
- Wide-NN RLE
0X NN— the 12-bit NN encoding documented above for1X/2Xalso applies to the00 NNRLE tag. A narrow run maxes out at NN=0xFC, so a quiet stretch longer than 252 samples must use the wide form (e.g.01 0c= 268 repeats). 30 NNis not capped at NN=0x10 — data-section blocks reach at least NN=0x18. TheNN × 1.5 + 2length formula was already right; only the guard was wrong.40 NNsegment headers are variable width — NN is the count of int16 BE continuation deltas for the PREVIOUS channel, so the header is2*NN + 16bytes and every field after the deltas shifts by2*NN.40 01(18 B) and40 03(22 B) both occur alongside the common40 02(20 B).- Tagless segment headers — a header can appear with no
40 NNtag at all: just the 14-byte tail[field2:2][len:2][channel_id:4][marker:2][anchors:4]. This is the NN=0 case (previous channel needed no continuation deltas).
The header "counter" is really a channel id. The 4-byte field long
documented as a "monotonic uint32 LE counter" is
[channel_id][00][00][segment_index], with 0x46=Tran 0x47=Vert
0x48=Long 0x49=MicL — verified on 1697/1697 segment headers
across the corpus, zero disagreements. decode_waveform_v2 now takes
the channel from this field rather than from rotation position; a single
missed or extra header (exactly what tagless headers caused) desyncs
rotation and corrupts every channel after it.
Corpus result, end to end through the production path: exact 37 → 72, truncated 23 → 3, full-length value errors 15 → 0.
Histogram codec — multi-interval blocks (2026-08-26)
Sub-minute histogram intervals are packed several to a block, so every block still covers exactly one minute:
| interval | intervals/block | stride |
|---|---|---|
| 1 min | 1 | 32 (the standard big-endian block) |
| 15 s | 4 | 92 |
| 2 s | 30 | 612 |
⚠ CORRECTED in v0.32.0 (#47/#49), recorded here 2026-11-02. The records are big-endian, starting at byte 5. Each holds a uint16 peak and a uint16 half-period per channel, then the interval's PVS² as a uint32 BE. Record = 4 × channels + 4 bytes: 20 with the mic, 16 without.
stride = 12 + n × record. The little-endian reading below was the same words shifted by one byte. Its "2-word tail" is the PVS² (reference D.6.5).
stride = 12 + n * 20. Block = [00][segment][ctr uint16 LE][0a][00],
then n x 20-byte records of 8 x uint16 LITTLE-endian values
(T_peak, T_halfp, V_peak, V_halfp, L_peak, L_halfp, M_peak, M_halfp)
plus a 2-word tail whose first word is 0000 on every real interval,
then a 6-byte block trailer.
⚠ The standard 32-byte block is BIG-endian; this variant is LITTLE-endian. (Retracted: both are big-endian; see the box above.)
Recovers 415 files (216 on BE18193, 199 on BE9440) that decoded to
nothing. Ground truth BE9440/K440L3AQ.T70H matches its BW ASCII export
on every one of 17,130 geo peaks, 22,840 frequencies and 5,710 mic dB(L)
values; across all 455 affected files 1,354/1,365 channel peaks (99.2%)
match the device-reported PPV.
Histogram codec — corrected 2026-08-25
The histogram block is uniformly big-endian, and the stream's final block has its own tail signature. Two long-standing errors:
- Peaks and half-periods are
uint16big-endian, notuint8+ an "annotation" byte.T_peakis[5:7],T_halfperiod[7:9],V_peak[9:11], and so on; onlyblock_ctrat[2:4]is LE. The old model silently clipped any peak above 1.275 in/s — the final interval ofBE18193/T193LQ9K.OE0Hreads 8.270 in/s in BW's export and decoded as 0.590. The "annotation" byte was the half-period's high byte, which is why it was non-zero exactly on the sub-Hz intervals BW renders as<1.0. - The marker is
block[4]alone. Testing[4:6]as a uint16 LE marker forcedblock[5] == 0, which is what capped the peak at one byte in the first place. - The last block of the stream carries tail
9c 06 00 42instead of1e 0a 00 00, with arbitrary bytes at[21:23]. Rejecting it dropped the final interval of nearly every histogram — frequently the one holding the event peak, so the file's PPV read low. [21:25]is the interval's PVS² as a uint32 BE (v0.33.0, reference D.6.5). The "arbitrary bytes" above are probably its high half (inferred).
Verified against 1211 production histograms paired with their BW ASCII exports: 1211/1211 decode exactly (interval count plus every per-interval peak), and 842,442 per-interval frequency comparisons match with zero mismatches. Before: 1 of 1196.
What's NOT solved
-
~
MicL channel conversion to dB(L) — the codec emits MicL as raw ADC counts (same format as geo channels), but BW's ASCII export shows mic in dB(L) withSolved in v0.33.0. One count = 0.25 Pa, and dB(L) = 81.938216 + 20·log10(|count|), an offset measured from Blastware's printed values (reference D.6.6; 81.9384 until 2026-11-09).6 dB quantization steps. Need to map ADC counts → dB(L) for direct comparison; likelydB = 20*log10(|counts|) + offsetor similar. -
Variable-prefix segment descriptors — 3 of the 75 ground-truth production events still truncate. The walk reaches a segment header whose channel-id field is preceded by a variable-width prefix (2, 4 or 6 bytes observed; the standard tagless form always has 4), carrying an
01 00marker instead of02 00. The marker is not simply an anchor count —01 00records appear with both 2- and 4-byte anchor fields in the same file. Examples:BE12599/N599LPNB.JF0W@1155,BE12599/N599LPWJ.980W@849,BE9558/K558LOF2.820W@1485. (The series-3 histogram codec was fixed 2026-08-25 — see below.) -
Micromate (UM-series) IDF decode is ~1000× low— FIXED 2026-09-10.UM11402_20260406130113.IDFWnow decodes Tran 1.1168 / Vert 4.3220 / Long 0.9135, matching the device report exactly. Root cause was the body-offset search landing inside a record header plus the unhandled00 00record mode, not anything UM-specific. -
Thor IDF per-count LSB— RESOLVED 2026-09-10. The 0.983 ratio was exactly0.0003 / 0.000310308. Thor's geo LSB is 0.000310308 in/s per count (full scale 10.0 in/s = 32226.05 counts), pinned to ±6e-11 by intersecting 991,415 rounding constraints from Thor's own exports and corroborated by the ±full-scale seed (±32226) left in unwritten IDFH interval slots. Series-3's 32000-count scale does not carry over. Note10.0/32226is very slightly wrong — seedocs/idf_protocol_reference.md.
Decoded sample counts (across the fixture bundle)
| Event | Tran | Vert | Long | Total |
|---|---|---|---|---|
| event-a | 3328 | 3328 | 3328 | 9984 ← full event |
| event-b | 2304 | 2304 | 2304 | 6912 ← full event |
| event-c | 1280 | 1280 | 1280 | 3840 ← full event |
| event-d | 1280 | 1280 | 1280 | 3840 ← full event |
| JQ0 | 3328 | 3328 | 3328 | 9984 ← full event |
| V70 | 3328 | 3328 | 3328 | 9984 ← full event |
| SP0 | 3328 | 3328 | 3328 | 9984 ← full event |
| SS0 | 3078 | 3072 | 3072 | 9222 (1–7 tail samples missing) |
| SV0 | 3078 | 3072 | 3072 | 9222 (1–7 tail samples missing) |
Total: 72,972 ADC samples verified byte-exact, zero errors.
7 of 9 fixture events decode end-to-end across all three geo channels. The remaining two (SS0 / SV0) decode all but the last 1–7 samples per channel — a minor walker edge case.
Production-code status (updated 2026-05-11 late)
client.py:_decode_a5_waveform now uses the verified codec via
waveform_codec.decode_a5_frames() — which calls
blastware_file.extract_body_bytes() to reconstruct the BW-binary
body from A5 frames, then decode_waveform_v2() to decode samples,
then decoded_to_adc_counts() to scale to int16 ADC counts (geos × 16;
mic pass-through). The .h5 sidecars SFM produces now contain
correct samples for any event without walker edge cases.
Geo full scale is 32000 ADC counts, NOT 32768 (fixed 2026-08-25).
One decoder unit = 16 ADC counts = exactly 0.005 in/s, so
10.000 in/s / (0.005/16) = 32000. Consumers must use
sfm.event_hdf5._GEO_INT16_FS / event_file_io._GEO_INT16_FS (both
32000). Dividing by 32768 reads every geophone sample 2.34% low —
that was a live bug in both modules until 2026-08-25. Mic is
unaffected (it back-solves its scale from the device-reported peak).
The original int16 LE decoder is preserved as
_decode_a5_waveform_LEGACY for reference but is not called.
MicL → dB(L) conversion utility:
waveform_codec.mic_count_to_db(count) — count=±1 → ±81.94 dB;
count=813 → 140.14 dB (matches BW display).
Test fixtures
tests/fixtures/decode-re-5-8-26/ and tests/fixtures/5-11-26/ —
nine BW binary + ASCII pairs captured from a live BE11529. The
5-11-26 high-amplitude bundle (PPV 6–7 in/s) is what cracked the Tran
codec; the V70 (mic-heavy) + JQ0 (Vert-heavy) pair cracked the 00 NN
RLE rule.
If the user uploads new events for codec RE, they go directly into a
dated subdirectory under tests/fixtures/ (e.g. tests/fixtures/5-18-26/).
There used to be a separate decode-re/ upload mirror but it was
removed once the fixtures directory became the canonical location.
Protocol fundamentals
DLE framing
BW→S3 (our requests): [ACK=0x41] [STX=0x02] [stuffed payload+chk] [ETX=0x03]
S3→BW (device replies): [DLE=0x10] [STX=0x02] [stuffed payload+chk] [bare ETX=0x03]
- DLE stuffing rule: any literal
0x10byte in the payload is doubled on the wire (0x10→0x10 0x10). This includes the checksum byte. - Inner-frame terminators: large S3 responses (A4, E5) contain embedded sub-frames
using
DLE+ETXas inner terminators. The outer parser treatsDLE+ETXinside a frame as literal data — the bare ETX is the ONLY real frame terminator. - Response SUB rule:
response_SUB = 0xFF - request_SUB(no known exceptions — earlier note claiming1C→6Ewas WRONG;1C→0xE3confirmed across 338 frames in 4-8-26 captures) - Two-step read pattern: every read command is sent twice — probe step (
offset=0x00, get length) then data step (offset=DATA_LENGTH, get payload). All data lengths are hardcoded constants, not read from the probe response.
De-stuffed payload header
BW→S3 (request):
[0] CMD 0x10
[1] flags 0x00
[2] SUB command byte
[3] 0x00 always zero
[4] 0x00 always zero
[5] OFFSET 0x00 for probe step; DATA_LENGTH for data step
[6-15] params (key, token, etc. — see helpers in framing.py)
S3→BW (response):
[0] CMD 0x00
[1] flags 0x10
[2] SUB response sub byte
[3] PAGE_HI
[4] PAGE_LO
[5+] data
Critical protocol gotchas (hard-won — do not re-derive)
SUB 5A — bulk waveform stream — NON-STANDARD frame format
⚠ RETRACTED 2026-10-26 (measured): it is a standard frame. The payload is
[10 00 5A 00][length BE][address BE 4][zeros 6]with a SUM8 checksum, and every 02/03/04/10 is DLE-escaped (s3_stuff,build_5a_request). "offset_hi 0x10 raw" was the length 0x0200 escaped (10 02 00). The "DLE-aware checksum" is SUM8 of the unescaped payload. The "partial stuffing" carve-outs were the escape rule seen half. All 540 of Blastware's 5A requests rebuild byte for byte (tests/test_5a_blastware_walk.py). The text below is history.
Always use build_5a_frame() for SUB 5A. Never use build_bw_frame() for SUB 5A.
build_bw_frame produces WRONG output for 5A for two reasons:
-
offset_hi = 0x10must NOT be DLE-stuffed. Blastware sends the offset field raw.build_bw_framewould stuff it to10 10on the wire — the device silently ignores the frame.build_5a_framewrites it as a bare10. -
DLE-aware checksum. When computing the checksum,
10 XXpairs in the stuffed section contribute onlyXXto the running sum; lone bytes contribute normally. This differs from the standard SUM8-of-destuffed-payload that all other commands use. -
Params region uses partial DLE stuffing (CONFIRMED 2026-05-05). The device's de-stuffing rule for bytes inside the params region is:
10 10→ de-stuffs to1010 02 / 03 / 04→ kept literal (these are inner-frame markers)10 Xfor other X → de-stuffs to justX(drops the leading0x10)
Therefore any
0x10byte in the logical params that is followed by a byte NOT in{0x02, 0x03, 0x04, 0x10}MUST be doubled on the wire (10 X→10 10 X) so the device's de-stuffer reproduces the original10 Xpair. This applies most commonly to counters with0x10in the high byte (e.g. counter=0x1000produces logical params bytes... 10 00 ..., which BW encodes on the wire as... 10 10 00 ...). Without this stuffing the device interprets counter=0x1000as0x0000and returns the probe response (which contains a copy of the file header + STRT record). That STRT block then gets embedded in the assembled file body at offset0x1016, and Blastware refuses to open the file — see the v0.14.3 entry inCHANGELOG.md.0x10bytes inoffset_hi(body[5]) are still written RAW — only the params region has this stuffing requirement. The metadata-page params for counter0x1002/0x1004survive without stuffing because10 02and10 04fall in the "kept literal" carve-out.
Both differences (1) and (2) confirmed by reproducing Blastware's exact wire bytes from the 1-2-26 BW TX capture (10 frames). Difference (3) confirmed against the 5-1-26 "bwcap3sec" capture (17 frames, all match byte-for-byte after fix).
SUB 5A — chunk counter formula (REWRITTEN 2026-05-01 — see 5-1-26 captures)
⚠ SUPERSEDED 2026-10-26: a chunk is addressed by a full 32-bit address, stepping +0x200 across page boundaries; no event-1 special case (see
read_bulk_waveform_stream).
⚠️ Everything that came before this rewrite was WRONG in important ways. The previous formula
max(key4[2:4], 0x0400) + (chunk_num - 1) * 0x0400happened to work for events at start_key=0 because the device responds to whatever counter you ask for — but it caused a 5× over-read past the actual event, picking up post-event circular-buffer garbage that corrupts the reconstructed file for any event > ~1 sec of waveform. The captures inbridges/captures/4-27-26/and5-1-26/comcheck/show BW reads only ~12-16 chunks for the same events SFM was reading 37+ chunks for. See "TERM frame" and "STRT end_offset" sections below for the actual mechanism.
Chunk addressing is just absolute device-buffer addresses.
params[0]=0x00, params[1:5] is a 4-byte absolute device flash-buffer address (= the
"key" of that location), params[5:11] are zeros. The device returns 0x0200 (= 512) bytes
starting at that address. Increments between consecutive chunks are 0x0200 (NOT 0x0400)
— this matches the chunk payload size. The previous "0x0400 step" worked by accident: BW
asks for half-size chunks; SFM was asking for double-size chunks, both with the same-named
"counter" field, but the value is just an address pointer the device honors as-is.
The chunk pattern depends on whether the event sits at start_key=0 or not.
Event 1 case — start_key[2:4] == 0x0000 (first event after erase / wrap)
1. Probe at counter=0x0000 (params[1:5] = full key, returns STRT record)
2. Read 2 fixed metadata pages: counter=0x1002, counter=0x1004
(these are GLOBAL session metadata — read ONCE per
Blastware session, not per event; contain the
Project/Client/User Name/Seis Loc strings)
3. Sample chunks: counter=0x0600, 0x0800, …, by 0x0200 increment,
up to but not including end_offset (rounded down to
0x0200 boundary)
4. TERM frame (see TERM formula below)
The reason 0x0046..0x0600 is skipped for event 1 is unknown — likely some pre-event
firmware reserved area for the first slot in a freshly-erased buffer. Harmless to skip.
Event 2+ case — start_key[2:4] != 0x0000 (continuation events)
1. First chunk at counter = start_key[2:4] (this IS the probe — response
contains STRT at byte 17)
2. Sample chunks: counter += 0x0200 each, up to but
not including end_offset
3. TERM frame
start_key here is the off=0x46 WAVEHDR record key returned by 1F (e.g. 01112238),
NOT the off=0x2C boundary key that immediately precedes it. An earlier draft of this
doc described event-N as "probe at start + 0x46" — that formula came from naming the
boundary key as start_key. In the iteration walk, cur_key passed to
read_bulk_waveform_stream is always the off=0x46 key (the partial-record skip path in
get_events re-runs 1F to advance past boundary records before invoking 5A), so the
probe counter is just cur_key[2:4] with no extra offset. Adding +0x46 caused the
probe to overshoot, miss the STRT record at byte 17 of the response, fall back to the
max_chunks=128 cap, and walk ~110 chunks of post-event garbage — observed in
SFM 5-4-26 capture before the fix.
Confirmed across:
- 5-1-26 "copy 2nd address" BW capture: probe counter=0x2238, key=01112238, STRT@17 end=0x417E.
- 5-4-26 BW 2-sec event capture: probe counter=0x2238, key=01112238, TERM offset_word=0x0146 → end=0x417E.
No metadata pages — those have already been read during event 1 in the same Blastware session, and BW caches them. Note that the metadata-page reads happen ONCE per Blastware-session-on-the-device, not once per event, so an SFM session that downloads several events should read 0x1002/0x1004 only once at the start.
History (do not re-derive)
- Original:
_CHUNK1_COUNTER = 0x1004hardcoded (Blastware capture artifact — WRONG). - 2026-04-06:
chunk_num * 0x0400(worked for key 01110000 only). - 2026-04-24:
key4[2:4] + (chunk_num-1) * 0x0400(fixed non-zero offsets, broke key 01110000). - 2026-04-26:
max(key4[2:4], 0x0400) + (chunk_num-1) * 0x0400(broken — over-read past event end). - 2026-05-01: Increments are 0x0200 not 0x0400; absolute addresses inside event range; bounded
by STRT end_key, not by
max_chunkscap or device-side timeout. - 2026-05-04: Removed spurious
+0x0046from event-N probe counter.cur_keyfrom 1F is already the off=0x46 WAVEHDR key, so adding +0x46 would have placed the probe one WAVEHDR past the actual event start. This caused probe responses to lack a STRT record (noend_offsetparsed →0xFFFFfallback →max_chunks=128cap), walking ~110 chunks of post-event circular-buffer garbage. Fixed in protocol.pyread_bulk_waveform_stream.
SUB 5A — STRT record encodes end_offset (NEW 2026-05-01)
⚠ SUPERSEDED 2026-10-26: the end is the FULL 32-bit
end_key(parse_strt_end_key), read after removing the reply's escape bytes. The 16-bitend_offsetbelow was the 64 KB page bug, and misread any end whose low bytes held an escaped 02/03/04.
The first A5 response (probe response, or the first chunk for event 2+) contains a STRT
record at byte offset 17 of the data field. Layout:
data[17:21] "STRT" magic
data[21:23] ff fe sentinel
data[23:27] end_key ← 4-byte key of where this event ENDS
data[27:31] start_key ← 4-byte key of where this event STARTS
data[31:33] uint16 BE ?? sample-count or total bytes (varies; not yet decoded)
data[33:35] uint16 BE ??
data[35] 0x46 record type (waveform full record)
…
end_offset = (end_key[2] << 8) | end_key[3] is the authoritative event-end pointer.
SFM must extract this from the first A5 response and use it to bound the chunk loop and
encode the TERM frame. The device will happily respond to chunk requests past end_offset
(returning post-event circular-buffer contents) — that's the over-read bug.
Verified across 3 events:
| Capture | start_key | end_key | end_offset | event size |
|---|---|---|---|---|
| 4-27-26 "open 2sec" / "copy event to disk" | 01110000 |
01111ABE |
0x1ABE |
6,846 B |
| 5-1-26 "copy 3sec" / Download All event 1 | 01110000 |
011121F2 |
0x21F2 |
8,690 B |
| 5-1-26 "copy 2nd address" / DA event 2 | 011121F2 |
0111417E |
0x417E (event 2 span 0x1F8C = 8,076 B) |
SUB 5A — TERM frame formula (FINALIZED 2026-05-01)
⚠ SUPERSEDED 2026-10-26: TERM is
build_5a_request(next_boundary, end - next_boundary): a read of the remainder at the next 32-bit boundary. "offset_word" is that length; "params[2:4]" are the address's low bytes. The tables below still hold as numbers.
The TERM frame fetches the partial last chunk and the file footer. It is not a simple
"goodbye" frame — its response payload contains the bytes between the last full 0x0200-aligned
chunk and end_offset, and is required for reconstructing the Blastware file format.
last_chunk_counter = address of last full 0x0200-byte chunk read
next_boundary = last_chunk_counter + 0x0200
TERM offset_word = end_offset - next_boundary
TERM params[0] = key[0] (= 0x01 on every observed device)
TERM params[1] = key[1] (= 0x11)
TERM params[2] = (next_boundary >> 8) & 0xFF
TERM params[3] = next_boundary & 0xFF
TERM params[4:10] = zeros
build_5a_frame(offset_word, params) (10-byte params, NOT 11)
The device reconstructs requested_address = (params[2] << 8) | offset_word = end_offset
and replies with (end_offset - next_boundary) bytes from next_boundary — the residual
between the last 0x0200 boundary and the actual event end. Append the TERM response data
to the chunk stream like any other A5 frame; it carries the final waveform tail + footer.
Verified across 3 events:
| end_offset | last chunk | next_boundary | TERM offset_word | TERM params[2:4] |
|---|---|---|---|---|
0x1ABE |
0x1800 |
0x1A00 |
0x00BE ✓ |
1A 00 ✓ |
0x21F2 |
0x1E00 |
0x2000 |
0x01F2 ✓ |
20 00 ✓ |
0x417E |
0x3E38 |
0x4038 |
0x0146 ✓ |
40 38 ✓ |
The previous code's hard-coded offset_word = 0x005A and term_counter = last + 0x0400
are wrong; the device's response under that path is a tiny 101-byte device-side terminator
(arrived only after we walked the entire post-event buffer), not the proper file footer.
SUB 5A — fixed metadata pages 0x1002 and 0x1004 (NEW 2026-05-01)
⚠ RETRACTED 2026-10-26 (measured): these are not fixed global pages. They are the first event's own chunks at addresses 0x0200 and 0x0400, which escape to
10 02 00and10 04 00on the wire. A non-first event has no such reads because it does not start at 0x0000. Their strings are still read as described below.
Two chunk addresses are GLOBAL device/session metadata, not event-specific:
counter=0x1002— first metadata pagecounter=0x1004— second metadata page
These are at fixed absolute addresses in the device's flash buffer. They contain the session-start compliance setup (Project/Client/User Name/Seis Loc/Extended Notes ASCII strings). Under the v0.14.0+ walk these strings are read directly from the metadata pages, not from the sample-chunk stream.
BW reads them ONCE per Blastware session (during event 1's download) and caches them. For SFM, that means:
- Once per call-home / once per
MiniMateClient.connect()is enough. - Subsequent events in the same session don't need to re-fetch them.
- Their content does not change when iterating events; only when the user opens Compliance Setup → Apply on the device or sends a SUB 71 compliance write.
The full byte-for-byte layout of the metadata pages has not been mapped — _decode_a5_metadata_into
locates the ASCII strings via label scans (Project:, Client:, User Name:, Seis Loc:,
Extended Notes) which works correctly across observed captures. Future work could
dump the structural layout if more session-global fields need to be extracted.
SUB 5A — params are 11 bytes for chunk frames, 10 for termination
⚠ RETRACTED 2026-10-26: every 5A request has the standard 10 params bytes (address + 6 zeros). The "11th byte" was the length's low byte, read as params.
bulk_waveform_params() returns 11 bytes (extra trailing 0x00). The 11th byte was
confirmed from the BW wire capture. bulk_waveform_term_params() returns 10 bytes.
Do not swap them.
SUB 5A — event-time metadata source (FINALIZED 2026-05-05)
⚠ AMENDED 2026-10-26: the strings come from the first event's chunks at 0x0200 and 0x0400, not from "global pages read once per session" (see the retraction above).
The metadata strings come from the two fixed metadata pages at counter 0x1002 and
0x1004 (see "SUB 5A — fixed metadata pages 0x1002 and 0x1004" above). These pages
are GLOBAL session metadata — read once per Blastware/SFM session, not per event.
"Project:" → project description
"Client:" → client name ← NOT in the 0C record
"User Name:" → operator name ← NOT in the 0C record
"Seis Loc:" → sensor location ← NOT in the 0C record
"Extended Notes"→ notes
IMPORTANT — these strings are session-start config, NOT per-event:
Project / Client / User Name / Seis Loc reflect the compliance setup from when the
monitoring session first started, not the individual event's per-event metadata. The
authoritative per-event project name is stored in the 210-byte 0C waveform record.
_decode_a5_metadata_into therefore only sets project from the 5A metadata pages
when 0C didn't already supply one.
"Client:", "User Name:", "Seis Loc:", and "Extended Notes" are NOT present in the 0C record — the metadata pages are the sole source for those fields and they are set unconditionally.
Deprecated knobs (do not re-introduce)
The read_bulk_waveform_stream() function still accepts these legacy kwargs for
backward compatibility, but they are no-ops under the v0.14.0+ walk:
stop_after_metadata=True— used to scan the chunk stream forb"Project:"and stop one chunk later as a workaround for the missing end_offset bound. Obsolete: the loop is now deterministically bounded byend_offsetparsed from the STRT record at data[17] of the probe response, with the partial tail fetched by the TERM frame.extra_chunks_after_metadata— same era, same reason. No-op.
If you find code or docs referencing "A5 frame 7" as the source of metadata strings,
that's an old-walk artifact (the broken 0x0400-step formula occasionally caught the
0x1002 metadata page at sample-chunk fi=7). Update to reference the dedicated metadata
pages instead.
SUB 5A — end-of-stream (FINALIZED 2026-05-01)
⚠ AMENDED 2026-10-26: a reply's
page_keyis not a page. It is the echoed length plus an escape byte the parser keeps: all 532 chunk replies read0x0010and the 8 TERMs0x0000/0x0001. The walk relies on it only for the mid-stream terminator check, and now sends TERM only for a tail (< 0x200).
Under the v0.14.0+ STRT-bounded walk the stream ends cleanly:
… last full chunk at counter < end_offset
TERM request (offset_word = end_offset - next_boundary,
params address (next_boundary))
TERM response (page_key = 0x0000 or 0x0001, data = the residual
end_offset - next_boundary bytes including the file footer)
No timeout-based detection, no "1-byte teaser," no max_chunks cap. The chunk loop
exits when counter + 0x0200 > end_offset; the TERM frame fetches the tail.
Chunk recv timeout is 10 s, not the default 120 s. Chunks arrive within ~1 s each.
Using 120 s would cause a ~2-minute stall on any unexpected timeout. The _recv_one
call in the chunk loop passes timeout=10.0 explicitly.
Typical chunk count under the v0.14.0+ walk (BE11529, 1024 sps over TCP/cellular):
| Event duration | Sample chunks | Metadata pages | TERM | Total A5 frames |
|---|---|---|---|---|
| 2-sec (event 1) | ~12 | 2 | 1 | ~15 |
| 3-sec (event 1) | 13 | 2 | 1 | 16 |
| 2-sec (continuation) | 15 | 0 | 1 | 16 |
| 3-sec (continuation) | ~14 | 0 | 1 | ~15 |
For comparison, the deprecated 0x0400-step walk produced ~37 chunks for a 2-sec
event with chunks 17-37 containing post-event circular-buffer garbage. Do not
re-introduce that walk under any circumstances.
SUB 5A — fi==9 hardcoded skip (FIXED 2026-04-06)
_decode_a5_waveform() previously had elif fi == 9: continue — a leftover from the
9-frame original blast capture where frame 9 was assumed to be a terminator. Removed.
TERM detection in the file builder uses frame.page_key != 0x0010 (sample marker),
not frame index — see blastware_file.py.
SUB 1E / 1F — event iteration null sentinel and token position (FIXED, do not re-introduce)
token_params bug (FIXED): The token byte was at params[6] (wrong). Both 3-31-26 and
4-3-26 BW TX captures confirm it belongs at params[7] (raw: 00 00 00 00 00 00 00 fe 00 00).
With the wrong position the device ignores the token and 1F returns null immediately.
1F token depends on context: In browse mode (no 5A), use all-zero params (browse=True).
In download mode (get_events with 5A), use token=0xFE (browse=False) — this is required to
arm the device's 5A bulk stream state machine. The earlier "empirical" test showing token=0xFE
returns null was done WITHOUT the 1E(arm) step; that test is invalid. BW always uses 1F(0xFE)
in download mode. count_events uses browse=True (no 5A needed).
0A context requirement: advance_event() (1F) only returns a valid next-event key
when a preceding read_waveform_header() (0A) call has established device waveform
context for the current key. Call 0A before every event in the loop, not just the first.
Calling 1F cold (after only 1E, with no 0A) returns the null sentinel regardless of how
many events are stored.
1F response layout: The next event's key IS at data_rsp.data[11:15] (= payload[16:20]).
Confirmed from 4-3-26 browse-mode S3 captures:
1F after 0A(key0=01110000): data[11:15]=0111245a data[15:19]=00001e36 ← valid
1F after 0A(key1=0111245a): data[11:15]=01114290 data[15:19]=00000046 ← valid
1F null sentinel: data[11:15]=00000000 data[15:19]=00000000 ← done
Null sentinel: data8[4:8] == b"\x00\x00\x00\x00" (= data_rsp.data[15:19])
works for BOTH 1E trailing (offset to next event key) and 1F response (null key
echo) — in both cases, all zeros means "no more events."
1E response layout: data_rsp.data[11:15] = event 0's actual key; data_rsp.data[15:19]
= sample-count offset to the next event key (key1 = key0 + this offset). If offset == 0,
there is only one event.
Correct iteration pattern (confirmed empirically with live device, 2+ events):
count_events (browse mode only, no 5A):
1E(all zeros) → key0, trailing0 ← trailing0 non-zero if event 1 exists
0A(key0) ← REQUIRED: establishes device context
1F(all zeros / browse=True) → key1 ← use all-zero params
0A(key1) ← REQUIRED before each advance
1F(all zeros) → null ← done
get_events (download mode, with 5A):
1E(all zeros) → key0, trailing0 ← trailing0 non-zero if event 1 exists
0A(key0) ← REQUIRED: establishes device context
1E(token=0xFE) ← REQUIRED: arms device for 5A; CONFIRMED 4-2-26 + 4-3-26
0C(key0) ← read waveform record
1F(token=0xFE) → [discard key] ← REQUIRED: arms 5A bulk stream state machine
POLL × 3 ← REQUIRED: 3 full POLL cycles before 5A (BW frames 68-73)
5A(key0) ← bulk stream; key0 used even though 1F already advanced
1F(all zeros / browse=True) → key1 ← USE THIS for loop iteration (browse=True returns correct key)
0A(key1)
1E(token=0xFE) ← re-arm for next event's 5A
0C(key1)
1F(token=0xFE) → [discard key] ← arm 5A
POLL × 3
5A(key1)
1F(browse=True) → null ← done
IMPORTANT — conditional browse 1F (UPDATED 2026-04-06):
1F(token=0xFE) (browse=False) BEFORE POLL+5A arms the device's bulk stream state machine.
Its returned key is cached as arm_key4 in get_events().
1F(browse=True) AFTER 5A is ONLY sent when 5A succeeded. If 5A timed out or failed,
sending browse 1F disrupts the device's internal state — subsequent 5A probes for the next
event get no response (confirmed empirically: calling browse 1F after a failed 5A causes the
next event's 5A probe to also time out with 0 bytes received).
In the failure path, arm_key4 from 1F(download) is used as a best-effort next-key hint:
- If
arm_key4 != cur_key: use it to advance the loop without any 1F call - If
arm_key4 == cur_key(device stuck, typical for second+ events when 5A fails): abort
The diagnostic bytes_fed counter on S3FrameParser (incremented in every feed() call,
reset by reset()) makes it possible to distinguish "no bytes at all" from "bytes received
but no complete frame assembled" in 5A probe timeouts — both show up as 120s timeouts in
the log but have very different root causes.
The 1E(token=0xFE) arm step is required (FIXED 2026-04-06): The device silently ignores all 5A probe frames unless a second SUB 1E with token=0xFE has been issued between 0A and 0C. This step is present in EVERY download cycle in both the 4-2-26 and 4-3-26 BW TX captures.
1F must come BEFORE 5A (FIXED 2026-04-06): BW always calls 1F (advance event) before starting the 5A bulk stream. 5A still uses the pre-advance key — the device streams the waveform for the key that was set up with 0A+1E-arm+0C even after 1F has moved the internal pointer to the next event.
POLL × 3 required before 5A (FIXED 2026-04-06):
BW sends exactly 3 complete POLL (SUB 5B) probe+data cycles between the last 1F and the
first 5A probe frame. Confirmed from 4-2-26 BW TX capture frames 68-73. Without these
POLLs the device does not respond to the 5A probe. Use proto.poll() (not startup() —
startup() drains the boot string, which is only needed on initial connect).
advance_event(browse=True) sends all-zero params; advance_event() default (browse=False)
sends token=0xFE and is NOT used by any caller.
advance_event() returns (key4, event_data8).
Callers (count_events, get_events) loop while data8[4:8] != b"\x00\x00\x00\x00".
SUB 0A — WAVEHDR response length distinguishes events from boundaries (NEW 2026-05-01)
When iterating events with the "Download All" pattern (1E → 0A → 1F → 0A → 1F → …), the
DATA_LENGTH at data_rsp.data[5] (= the byte BW echoes back as the offset for the data
fetch step) takes one of two values:
| WAVEHDR offset | Meaning |
|---|---|
0x46 (= 70) |
Real event start key — there is event data at this address |
0x2C (= 44) |
Boundary marker between events — this key is the END of the previous event AND the START key for the empty space after it (or is the next event's pre-header) |
Confirmed from the 5-1-26 "Download All" capture:
0A(key=01110000) → off=0x46 ← event 1 real start
1F → key=011121F2
0A(key=011121F2) → off=0x2C ← event 1 END / event 2 boundary
1F → key=01112238
0A(key=01112238) → off=0x46 ← event 2 real start (= boundary + 0x46)
1F → key=0111417E
0A(key=0111417E) → off=0x2C ← event 2 END / next-empty marker
1F → null sentinel
(⚠ 2026-10-26: the walk starts at the 0x46 key itself, as a plain 32-bit address.)
This is why event 2's first 5A chunk is at start_key + 0x46 — that's the address of the
"real start" 0x46-record, distinct from the 0x2C-record at the raw boundary. Use the
0x46 keys as the input to read_bulk_waveform_stream, not the 0x2C keys.
For event 1 only (start_key[2:4] = 0x0000) BW probes at counter=0x0000 directly, which is
the 0x46-keyed start record. Subsequent events use start_key + 0x46.
Practical iteration pattern (replaces the old 1E/1F walk for downloads):
Setup: SERIAL × 2 → CHCFG → 1E (token=0x00) → key0
For each event:
0A(cur_key) → DATA_LENGTH = 0x46 (real) or 0x2C (boundary)
1F (token=0x00) → next_key
if length was 0x46: → cur_key is a real event; queue it for download
cur_key = next_key
if next_key all-zero null sentinel: stop
Then for each queued real-event key:
download_event(key) → 5A bulk stream with STRT-bounded chunk walk
This is what BW does in the 5-1-26 "Download All" capture — it walks the full event chain
collecting (key, length) tuples first, then downloads each event using the 0x46 keys.
SUB 1A — compliance config — orphaned send bug (FIXED, do not re-introduce)
read_compliance_config() sends a 4-frame sequence (A, B, C, D) where:
- Frame A is a probe (no
recv_oneneeded — device ACKs but returns no data page) - Frames B, C, D each need a
recv_oneto collect the response
There must be NO extra self._send(...) call before the B/C/D recv loop without a
matching recv_one(). An orphaned send shifts all receives one step behind, leaving
frame D's channel block (trigger_level_geo, alarm_level_geo, max_range_geo) unread and
producing only ~1071 bytes instead of ~2126.
SUB 1A — anchor search range
_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].
IMPORTANT — the "10-byte anchor" \x01\x2c\x00\x00\xbe\x80\x00\x00\x00\x00 is NOT fully constant.
The first 2 bytes (\x01\x2c = 300) are the histogram_interval_sec field (uint16 BE, seconds) —
the value 300 is just the 5-minute default. When histogram interval is set to a different value
(e.g. 15min = 0x0384 = \x03\x84), those bytes change. Only the 6-byte suffix
\xbe\x80\x00\x00\x00\x00 is truly constant. The code already uses the 6-byte anchor.
Do not narrow the search range to cfg[40:100] — the old range was only accidentally correct because
the orphaned-send bug was prepending a 44-byte spurious header, pushing the anchor from
its real position (cfg[11]) into the 40–100 window.
Sample rate and DLE jitter in cfg data
Sample rate 4096 (0x1000) causes DLE jitter: the frame carries 10 10 00 on the wire,
which unstuffs to 10 00 — 2 bytes instead of 3. This makes frame C 1 byte shorter and
shifts all subsequent absolute offsets by −1. The anchor approach is immune to this.
Do NOT use fixed absolute offsets for sample_rate or record_time.
TCP / cellular transport
- Protocol bytes over TCP are bit-for-bit identical to RS-232. No wrapping.
- The modem (RV50/RV55) forwards bytes with up to ~1s buffering.
TcpTransportusesread_until_idle(idle_gap=1.5s)to drain the buffer completely before parsing. - Cold-boot: unit sends the 16-byte ASCII string
"Operating System"before entering DLE-framed mode. The parser discards it (scans for DLE+STX). - RV50/RV55 sends
\r\nRING\r\n\r\nCONNECT\r\nover TCP to the caller even with Quiet Mode enabled. Parser handles this — do not strip it manually before feeding toS3FrameParser.
Required ACEmanager settings (Sierra Wireless RV50/RV55)
| Setting | Value | Why |
|---|---|---|
| Configure Serial Port | 38400,8N1 |
Must match MiniMate baud |
| Flow Control | None |
Hardware FC blocks TX if pins unconnected |
| Quiet Mode | Enable | Critical. Disabled injects RING/CONNECT onto serial, corrupting S3 handshake |
| Data Forwarding Timeout | 1 (= 0.1 s) |
Lower latency |
| TCP Connect Response Delay | 0 |
Non-zero silently drops first POLL frame |
| TCP Idle Timeout | 2 (minutes) |
Prevents premature disconnect |
| DB9 Serial Echo | Disable |
Echo corrupts the data stream |
Key confirmed field locations
SUB FE — Full Config (166 destuffed bytes)
| Offset | Field | Type | Notes |
|---|---|---|---|
| 0x34 | firmware version string | ASCII | e.g. "S338.17" |
| 0x56–0x57 | calibration year | uint16 BE | 0x07E9 = 2025 |
| 0x0109 | aux trigger enabled | uint8 | 0x00 = off, 0x01 = on |
SUB 1A — Compliance Config (~2126 bytes total after 4-frame sequence)
| Field | How to find it |
|---|---|
| recording_mode | uint8 at anchor − 3 (write) / anchor − 4 (read) ✅ confirmed 2026-04-20 |
| sample_rate | uint16 BE at anchor − 2 |
| histogram_interval_sec | uint16 BE at anchor − 4 (seconds); same offset in read & write ✅ confirmed 2026-04-20 |
| record_time | float32 BE at anchor + 10 |
| trigger_level_geo | float32 BE, located in channel block |
| alarm_level_geo | float32 BE, adjacent to trigger_level_geo |
| geo_hardware_constant (adc_scale_factor) | float32 BE at channel_label+28 in both read (E5) and write (SUB 71) payloads — reads 6.206053 on BOTH tested units (BE11529 and BE18189); identical across all geo channels (Tran/Vert/Long) and all captures. Confirmed 2026-04-17 from Interface Handbook §4.5: this is the ADC-to-velocity scale factor = 1/sensitivity = (in/s per V). Firmware uses it as: PPV (in/s) = ADC_voltage × 6.206053. Cross-check: 1.61133 V (ADC full-scale) × 6.206053 = 10.000 in/s (Normal range ✅). Do NOT write this field — it is a hardware/firmware constant. |
| geo_range (sensitivity selector) | uint8 at channel_label+33 in both read (E5) and write (SUB 71) payloads (an event file's setup copy has it at label+29: reference D.6.4) — CONFIRMED 2026-04-20 from 4-20-26 geo sensitivity captures: 0x00 = Normal 10.000 in/s (standard gain), 0x01 = Sensitive 1.250 in/s (high gain). Present in all three geo channel blocks (Tran, Vert, Long). NOTE: channel_label+20 reads 0x01 on ALL captures regardless of range setting — it is NOT this field. Note: the "SUB 71 write offset = +29" that appears in earlier analysis was an artifact of incorrect BW-style destuffing applied to write frame data — write frame data is RAW, so the literal 0x10 bytes in the channel block header are preserved, and the offset is the same as in the E5 read payload. |
| 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].
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.
Field layout relative to the 6-byte anchor (write payload / E5 read — noted where different):
| Offset | Field | Format | Notes |
|---|---|---|---|
| anchor − 9 | mode_prefix | uint8 | 0x00 for Single Shot / Continuous; 0x10 for Histogram (DLE prefix in E5 encoding) and Histogram+Continuous (actual config byte). See "compliance_raw DLE encoding" note below. |
| anchor − 8 | recording_mode | uint8 | Same offset for both read and write — confirmed 2026-04-21. _encode_compliance_config writes buf[anc-8]. NOTE: for Histogram (0x03), E5 encodes the value as 0x10 0x03 so compliance_raw[anc-9]=0x10, compliance_raw[anc-8]=0x03. |
| anchor − 7 | constant | 0x10 |
Always 0x10 in both E5 read and BW write payloads (not a DLE marker — it is part of the sample_rate field area). Do NOT overwrite. |
| anchor − 6 | sample_rate | uint16 BE | same in read & write |
| anchor − 4 | histogram_interval_sec | uint16 BE | seconds; same in read & write ✅ 2026-04-20 |
| anchor − 2 | 0x00 0x00 |
padding | |
| anchor | \xbe\x80\x00\x00\x00\x00 |
anchor | |
| anchor + 6 | record_time | float32 BE | same in read & write |
recording_mode enum (confirmed 2026-04-20 from 4-20-26 captures):
| Value | Mode | anchor-9 in compliance_raw |
|---|---|---|
0x00 |
Single Shot | 0x00 |
0x01 |
Continuous | 0x00 |
0x02 |
❓ not observed | ❓ |
0x03 |
Histogram | 0x10 (DLE prefix from E5 wire encoding of 0x03) |
0x04 |
Histogram + Continuous | 0x10 (actual config byte for this mode) |
compliance_raw DLE encoding — IMPORTANT (confirmed 2026-04-21 from 4-20-26 captures):
compliance_raw (returned by read_compliance_config()) is NOT purely logical bytes — it is
the wire-encoded representation where 0x03 bytes in the config are preceded by a 0x10 DLE
prefix (because S3FrameParser preserves DLE+ETX inner-frame pairs as two literal bytes).
Consequences:
- When recording_mode =
0x03(Histogram),compliance_raw[anc-9] = 0x10(DLE prefix) andcompliance_raw[anc-8] = 0x03(the value). The anchor position is +1 compared to modes without0x03bytes before the anchor. - For Histogram+Continuous (
0x04),compliance_raw[anc-9] = 0x10for a different reason: it is an actual stored config byte, not a DLE prefix. - The anchor search (
buf.find(b'\xbe\x80\x00\x00\x00\x00', 0, 150)) correctly locates the anchor regardless of these mode-dependent shifts. - When SFM writes recording_mode and round-trips the rest verbatim, the byte at
anc-9is preserved from the previous read. This means transitioning Histogram→other modes via SFM leaves a0x10atanc-9. The device stores it as a literal byte; it does not affect recording mode operation (which is atanc-8), but differs from what BW writes. This is a known minor discrepancy that does not impact device behavior. - Histogram recording mode (0x03) write via SFM: untested. When starting from a mode with
anc-9 = 0x00, SFM writes bare0x03at anc-8. BW would write0x10 0x03. Device likely accepts both (write frames probably use offset/length for framing, not ETX scanning).
DLE escaping in write frames — confirmed 2026-04-20: Blastware escapes 0x03 bytes in
write frame data as 0x10 0x03 on the wire (defensive ETX escaping). Our build_bw_write_frame
does NOT do this escaping — it sends data bytes raw. Device acceptance of bare 0x03 bytes
in write frame data is confirmed for the tested modes (Single Shot, Continuous, Histogram+Continuous
where 0x10 0x03 already appears from round-tripping). Histogram mode (bare 0x03 write from
non-Histogram starting state) has not been directly tested.
SUB 0C — Waveform Record (210 bytes = data[11:11+0xD2])
sub_code=0x10 (Waveform single-shot) — 9-byte timestamp header:
| Offset | Field | Type |
|---|---|---|
| 0 | day | uint8 |
| 1 | sub_code | uint8 (0x10) |
| 2 | month | uint8 |
| 3–4 | year | uint16 BE |
| 5 | unknown | uint8 (always 0) |
| 6 | hour | uint8 |
| 7 | minute | uint8 |
| 8 | second | uint8 |
sub_code=0x03 (Waveform continuous) — 10-byte timestamp header (1-byte shift):
Confirmed 2026-04-03 against Blastware event report (15:20:17 Apr 3 2026).
Raw wire bytes: 10 03 10 04 07 ea 00 0f 14 11
| Offset | Field | Type | Notes |
|---|---|---|---|
| 0 | unknown_a | uint8 | 0x10 observed |
| 1 | day | uint8 | doubles as sub_code position in 0x10 layout |
| 2 | unknown_b | uint8 | 0x10 observed |
| 3 | month | uint8 | |
| 4–5 | year | uint16 BE | |
| 6 | unknown | uint8 | |
| 7 | hour | uint8 | |
| 8 | minute | uint8 | |
| 9 | second | uint8 |
Peak values (both record types):
| Location | Field | Type |
|---|---|---|
tran_pos - 12 |
peak_vector_sum | float32 BE — label-relative, NOT fixed offset |
label + 6 |
PPV per channel | float32 BE (search for "Tran", "Vert", "Long", "MicL") |
PPV labels are NOT 4-byte aligned. The label-relative approach is the only reliable method.
peak_vector_sum is exactly 12 bytes before the "Tran" label — confirmed for both
sub_code=0x10 and sub_code=0x03. Do NOT use fixed offset 87 (only incidentally correct
for 0x10 records).
SFM REST API (sfm/server.py)
Live device endpoints (connect to device per-request)
GET /device/info?port=COM5 ← serial
GET /device/info?host=1.2.3.4&tcp_port=9034 ← cellular
GET /device/events?host=1.2.3.4&tcp_port=9034&baud=38400
GET /device/events?serial=UM20147&host=...&tcp_port=... ← list with event_id, either series (no 5A on a MiniMate)
POST /device/events/download?serial=UM20147&event_id=...&host=... ← download, check, store; returns db_event_id
GET /device/event?host=1.2.3.4&tcp_port=9034&index=0
GET /device/monitor/status?host=1.2.3.4&tcp_port=9034 ← battery, memory, mode
POST /device/monitor/start?host=1.2.3.4&tcp_port=9034 ← start recording
POST /device/monitor/stop?host=1.2.3.4&tcp_port=9034 ← stop recording
POST /device/monitor/start?serial=UM20147&host=...&tcp_port=...&dry_run=&even_if_already= ← audited start, either series
POST /device/monitor/stop?serial=UM20147&host=...&tcp_port=...&dry_run=&even_if_already= ← audited stop, either series
GET /device/settings?serial=UM20147&host=1.2.3.4&tcp_port=9034 ← shared-model settings, either series
POST /device/hangup?host=1.2.3.4&tcp_port=9034 ← release a held Series-4 line
serial= (UM = Series 4, BE/BA = Series 3) on /device/info, /connect,
/monitor/status, /settings returns the shared model, uncached; on /events and
/events/download it lists and downloads by event_id; on /monitor/start and
/monitor/stop it runs the audited change (dry_run=true returns the frames and sends
nothing; even_if_already=true sends even when the unit is already in that state). A
UM serial on any other /device/* route is 501; any request taking the legacy
Series-3 path at a held Series-4 address is 409.
The legacy Series-3 writes and erase (POST /device/config, /config/project,
/events/erase, /rescue, POST /device/call_home) take an optional serial= and
refuse 409, nothing sent, when the unit at the address does not answer as Series 3
or is not the named unit. The stop tools (monitor/start|stop without a serial,
stop_monitoring_blind, _slow_drip, _spam) are exempt by design.
SFM must run a single uvicorn worker (locks and held lines are per process).
Server retries once on ProtocolError for TCP connections (handles cold-boot timing).
DB read endpoints (query seismo_relay.db written by ach_server.py)
GET /db/units ← all known serials + summary stats
GET /db/events?serial=BE11529&from_dt=&to_dt=&limit= ← triggered events, newest first
GET /db/monitor_log?serial=BE11529&from_dt=&to_dt= ← monitoring intervals, newest first
GET /db/sessions?serial=BE11529&limit=50 ← ACH call-home sessions, newest first
PATCH /db/events/{id}/false_trigger?value=true ← flag/unflag false triggers
GET /db/device_commands?serial=UM20147&limit=100 ← start/stop audit trail (sent, states), newest first
DB file: bridges/captures/seismo_relay.db (default; override with --db-path at startup).
All DB endpoints are read-only except PATCH /db/events/{id}/false_trigger.
Key wire captures (reference material)
| Capture | Location | Contents |
|---|---|---|
| 1-2-26 | bridges/captures/1-2-26/ |
SUB 5A BW TX frames — confirmed 5A frame format, 11-byte params, DLE-aware checksum (⚠ that model retracted 2026-10-26: a standard frame, length + 32-bit address) |
| 3-11-26 | bridges/captures/3-11-26/ |
Full compliance setup write, Aux Trigger capture |
| 3-31-26 | bridges/captures/3-31-26/ |
Complete event download cycle (148 BW / 147 S3 frames) — confirmed 1E/0A/0C/1F sequence; only 1 event stored so token=0xFE appeared to work |
| 4-3-26 | bridges/captures/4-3-26/ |
Browse-mode S3 capture with 2+ events — confirmed all-zero params for 1F, 1F response layout, null sentinel, 0A context requirement |
| 4-27-26 | bridges/captures/4-27-26/ |
BW "open 2sec waveform" + "copy event to disk" + paired SFM "seismo_dl" — first proof that SFM was over-reading 5× past event end. BW reads 14 chunks at 0x0200 increments + TERM at end_offset; SFM was reading 37 chunks at 0x0400 increments. STRT end_key field located. |
| 5-1-26 | bridges/captures/5-1-26/comcheck/ |
Three sub-captures: SFM 3-sec download (seismo_dl_…), BW comms-check + 3-sec download (bwcap3sec/), BW second-event download + "Download All" (raw_*_170945/_171216). Confirmed: TERM frame formula across 3 events; metadata pages 0x1002/0x1004 are global (read once per session) (⚠ retracted 2026-10-26: event 1's chunks at 0x0200/0x0400); event-1 vs event-N chunk-pattern split; WAVEHDR length 0x46 vs 0x2C disambiguates real events from boundaries. |
Write commands (SUBs 68–83) — confirmed 2026-04-07
⚠ RETRACTED 2026-10-27 (#46, measured): write frames are ordinary requests. Every 02/03/04/10 is escaped and the checksum is SUM8 of the payload, as in every request. The length field [4:6] is the data's length. A config block is its own length N + 2 bytes; the compliance image (2,092) goes in addressed chunks (params[2:4]; 512 B now, 1,024 B in March). This re-encodes all 3,869 Blastware requests from February to April, plus 26 write frames from 2026-10-26. The "raw except BW_CMD", "DLE-aware checksum", "offset = data[1] + 2" and "71×3 at 0x1004" below were the same frames read with their escape bytes in. The trigger block is READ (SUB 0x2E) -- its byte 5 differs by unit -- not a fixed blob. Code:
build_bw_write_frame,protocol.write_image,b5037b0. The text below is history.
All confirmed from 3-11-26 BW TX capture (raw_bw_20260311_170151.bin, frames 102–112).
Write frame format — CRITICAL: minimal DLE stuffing
Write frames do NOT use the same DLE stuffing as read frames. Only the BW_CMD byte (0x10 at payload position [0]) is doubled on the wire. All other bytes — flags, sub, offset, params, data, and checksum — are written RAW without stuffing.
Confirmed from all 11 write frames in the 3-11-26/170151 BW capture. ✅ 2026-04-07
Do NOT use dle_stuff() or build_bw_frame() for write commands. Use build_bw_write_frame().
Actual wire layout:
[41] ACK
[02] STX
[10 10] BW_CMD doubled (ONLY DLE stuffing applied)
[00] flags
[sub] write command byte (0x68–0x83)
[00] always zero
[hi][lo] offset uint16 BE — RAW (not stuffed even if hi=0x10)
[params] 10 bytes — RAW
[data] variable-length write payload — RAW (0x10 bytes not stuffed)
[chk] checksum — RAW (not stuffed even if 0x10)
[03] ETX
Total wire length = 2 (ACK+STX) + 2 (doubled BW_CMD) + 15 (raw header) + len(data) + 1 (chk) + 1 (ETX)
= 21 + len(data)
De-stuffed payload (logical; used for checksum computation only):
[0] BW_CMD 0x10
[1] flags 0x00
[2] SUB write command byte (0x68–0x83)
[3] 0x00 always zero
[4] offset_hi
[5] offset_lo
[6:16] params 10-byte field (see per-SUB notes below)
[16:] data write payload (variable length; absent for confirm frames)
[-1] chk large-frame DLE-aware checksum (see below)
Write SUBs = Read SUB + 0x60. Response SUB follows the standard 0xFF − Request SUB rule.
Write frame checksum
All write frames (data frames AND confirm frames) use the large-frame DLE-aware checksum:
chk = (sum(b for b in payload[2:] if b != 0x10) + 0x10) & 0xFF
This is identical to the SUB 5A DLE-aware checksum. Confirmed against all 11 write frames in the 3-11-26/170151 capture. ✅ 2026-04-07
Note: confirm frames contain no embedded 0x10 bytes, so both the standard SUM8 and the
DLE-aware formula produce the same result for them — but build_bw_write_frame always uses
the DLE-aware formula for consistency.
Write ack responses
All device acks for write commands are 17-byte zero-data S3 frames:
[DLE=0x10][STX=0x02][stuffed(header + chk)][bare ETX=0x03]
The data section carries zeros; RSP_SUB = 0xFF − write_request_SUB.
Write SUB constants and sequences
| Request SUB | Function | Offset | Response SUB |
|---|---|---|---|
| 0x68 | Event index write | data[1] + 2 |
0x97 |
| 0x73 | Confirm B (follows 68) | 0 | 0x8C |
| 0x71 | Compliance write (×3 chunks) | see below | 0x8E |
| 0x72 | Confirm A (follows 71×3, 69) | 0 | 0x8D |
| 0x82 | Trigger config write | data[1] + 2 |
0x7D |
| 0x83 | Trigger confirm (follows 82) | 0 | 0x7C |
| 0x69 | Waveform data write | data[1] + 2 |
0x96 |
| 0x74 | Confirm C (follows 69) | 0 | 0x8B |
Offset formula for single-chunk writes (0x68, 0x69, 0x82): offset = data[1] + 2
The write payload always begins with a 2-byte header [0x00][length], where data[1] is
an embedded length field. The offset encodes this inner length + 2 (accounting for the
header bytes). Confirmed from all three single-chunk write frames in the 3-11-26 capture:
| SUB | data[0:4] (hex) | data[1] | offset | total data len |
|---|---|---|---|---|
| 0x68 | 00 58 09 00 |
0x58=88 | 0x5A=90 | 91 |
| 0x82 | 00 1A D5 00 |
0x1A=26 | 0x1C=28 | 29 |
| 0x69 | 00 C8 08 00 |
0xC8=200 | 0xCA=202 | 204 |
Full sequence: 68→73 | 71×3→72 | 82→83 | 69→74→72
SUB 71 — compliance write chunk parameters
The full compliance config payload (~2128 bytes) is split into exactly 3 chunks. Confirmed from 3-11-26 BW TX capture frames 104–108:
| Chunk | Size | offset |
params (10 bytes hex) |
|---|---|---|---|
| 1 (first) | 1027 bytes | 0x1004 | 00 00 00 00 00 00 00 00 00 00 |
| 2 (middle) | 1055 bytes | 0x1004 | 00 00 00 10 04 00 00 00 00 00 |
| 3 (last) | remainder | 0x002C | 00 00 08 00 00 00 00 00 00 00 |
Total: 1027 + 1055 + N = 2082 + N bytes (N ≈ 46 for a standard 2128-byte config).
After all 3 chunks are acked (SUB 0x8E each), send SUB 72 confirm → device acks 0x8D.
build_bw_write_frame() — framing.py
build_bw_write_frame(sub, data, *, offset=0, params=bytes(10)) -> bytes
Use for all write commands (SUBs 68–83) including confirm frames (data=b"").
Do NOT use build_bw_frame for write commands — it uses standard SUM8, not the
large-frame DLE-aware checksum required for writes.
push_config_raw() — client.py
client.push_config_raw(event_index_data, compliance_data, trigger_data, waveform_data)
Orchestrates the full write sequence in the confirmed order. All payloads are raw bytes
(no encoding performed at this level). A higher-level encoder that builds payloads from
a ComplianceConfig object is a future task.
Monitoring commands (SUBs 0x1C, 0x96, 0x97) — confirmed 2026-04-08
All confirmed from 4-8-26/2ndtry BW TX/S3 capture (clean start → 30s monitor → stop cycle).
SUB 0x1C — Monitor status read
Standard two-step read (probe at offset 0x00, data at offset 0x2C). Response SUB = 0xFF − 0x1C = 0xE3 (standard formula — no exception).
Payload length is 46–47 bytes IDLE, 48–49 bytes MONITORING — not a reliable sole indicator due to 1-byte jitter overlap at the boundary.
Monitoring flag (CONFIRMED 2026-04-09 — byte diff of all 144 data frames, 2ndtry capture):
section[1] == 0x00→ unit is idlesection[1] == 0x10→ unit is monitoring
This is data[12] (= frame.data[12]). The flag is 0x00 in all 36 IDLE_BEFORE frames,
0x10 in all 98 MONITORING frames, and 0x00 in all 10 IDLE_AFTER frames — 100% accurate.
HISTORY OF THIS FIELD (do not re-derive): The original implementation used section[1].
A re-analysis in the prior session incorrectly concluded section[1] is always 0x00 and
"corrected" the flag to section[6], which has non-binary values (0xea idle, 0x07 monitoring)
and is device-specific. The 2026-04-09 re-analysis confirms section[1] was right.
IMPORTANT — frame.data has checksum already stripped by S3FrameParser._finalise()
(raw_payload = body[:-1]; data = raw_payload[5:]). There is NO trailing checksum byte in
section. All relative-from-end offsets must account for this.
Battery and memory fields are present in both states:
| Offset (relative to end) | Field | Type | Notes |
|---|---|---|---|
section[-10:-8] |
battery voltage × 100 | uint16 BE | 0x02A8 = 680 → 6.80 V |
section[-8:-4] |
memory total (bytes) | uint32 BE | e.g. 983026 ≈ 960 KB |
section[-4:] |
memory free (bytes) | uint32 BE | decreases as events are stored |
SESSION_RESET signal (41 03) — required for monitoring units
Confirmed from 4-8-26 BW TX captures: Blastware sends a 2-byte 41 03 (ACK + ETX,
no STX) immediately before the first POLL probe AND between the probe and data frames.
This signal is required to wake units that are actively monitoring — without it
the unit does not respond to POLL over TCP. Harmless for idle units.
SESSION_RESET = bytes([0x41, 0x03]) is defined in framing.py and sent by
protocol.startup() before and between POLL frames.
SUB 0x96 — Start monitoring
Single write frame, no data payload (empty body). Response SUB = 0xFF − 0x96 = 0x69.
Wire bytes (confirmed frame 92 of 2ndtry BW capture):
41 02 10 10 00 96 00 00 00 00 00 00 00 00 00 00 00 00 00 a6 03
SUB 0x97 — Stop monitoring
Single write frame, no data payload (empty body). Response SUB = 0xFF − 0x97 = 0x68.
Wire bytes (confirmed frame 305 of 2ndtry BW capture):
41 02 10 10 00 97 00 00 00 00 00 00 00 00 00 00 00 00 00 a7 03
Both start and stop acks are standard 17-byte zero-data S3 frames.
On-device sensor check behavior (confirmed 2026-04-08)
Confirmed from 4-8-26/sensor-check BW+S3 capture (Blastware "Unit Channel Test" comms check issued while unit was performing its on-device sensor check).
Unit IS reachable during on-device sensor check — POLL (SUB 5B) responded normally throughout. However, the unit partially handled channel-test commands (SUB 0x0E) for channels 0–4 and then went silent for ~40 seconds while the sensor check ran, before resuming responses for channels 5–7 and the trigger test (SUB 0x98).
Key findings:
- On-device sensor check duration: approximately 40 seconds (log gap
18:40:48→18:41:28) - Unit IS reachable for POLL during the check window — SESSION_RESET + POLL works
- Partial command responses during check are possible (device may buffer some, drop others)
- The Blastware "Unit Channel Test" (remote comms check, SUBs 0x0E + 0x98) is a SEPARATE operation from the on-device check — it is a passive remote read; the unit's screen does not change during a remote comms check
SFM behavior after POST /device/monitor/start: _pollMonitorConfirm() polls
/device/monitor/status every 5 s for up to 60 s, updating the badge on each poll.
Status will show MONITORING once section[1] flips to 0x10.
SUBs known from sensor-check capture (4-8-26) — NOT YET IMPLEMENTED
| BW SUB | RSP SUB | Function | Notes |
|---|---|---|---|
| 0x15 | 0xEA | Serial number / short ID | 2-step read; data offset = 0x0A (10 bytes); confirmed serial "BE11529" at data[11+5:] |
| 0x01 | 0xFE | Device info block | 2-step read; data offset = 0x98 (152 bytes); payload includes serial + firmware + float config fields |
| 0x0E | 0xF1 | Channel sensor data | 2-step read; channel selector in params[6:8] (0x0000–0x0007); data length 0x0A per channel; used by Blastware "Unit Channel Test" — see docs/ for details |
| 0x98 | 0x67 | Trigger test | Single probe frame (params[0]=0xFF); sent twice per test cycle; all-zero data response; used after 0x0E channel scan |
Blastware's "Unit Channel Test" sequence: POLL×N → 0x15 → 0x01 → 0x08 → 0x01 → 0x0E×8 → 0x98×2 → 0x0E×8 (repeat pass with live ADC readings).
Compliance config field inventory (from Blastware UI, 2026-04-08)
Fields visible in the Blastware Compliance Setup dialog — most are NOT YET decoded to byte
offsets in the raw 1A/E5 payload. Only fields with ✅ have confirmed offsets in the code.
Recording Setup tab:
- Recording Mode: Continuous / Single Shot / Histogram / Histogram+Continuous ✅ (uint8 at anchor−3 in write, anchor−4 in read; 0x00=Single Shot, 0x01=Continuous, 0x03=Histogram, 0x04=Histogram+Continuous) — confirmed 2026-04-20
- Record Stop Mode: Fixed Record Time / Auto / Manual Stop (enum) ❓ (byte near recording_mode; data[40] in E5 sf1 changed 0x01→0x00 alongside Continuous→Single Shot — may be this field)
- Sample Rate: Standard 1024 / Fast 2048 / Faster 4096 sps ✅ (anchor−2)
- Record Time: float, seconds ✅ (anchor+10)
- Histogram Interval: 2s / 5s / 15s / 1m / 5m / 15m ✅ (uint16 BE seconds at anchor−4, same in read & write; mode-gated to Histogram/Histogram+Continuous) — confirmed 2026-04-20
- Storage Mode: Save All Data / Save Triggered (enum)
- Geophone Type: Standard Triaxial / 4.5 Hz (bool/enum)
- Geophone Channels: Enable all geophones (bool), Trigger Source (bool)
- Chan 1-3 Trigger Level (float, in/s) ✅ (
trigger_level_geo) - Chan 1-3 Maximum Range: Normal 10.000 / 1.25 in/s (enum) ✅ (
geo_rangeuint8; CONFIRMED 2026-04-20 from 4-20-26 geo sensitivity captures: offset =channel_label+33in both E5 read and SUB 71 write payloads (same bytes, round-tripped verbatim);0x00= Normal 10.000 in/s,0x01= Sensitive 1.250 in/s; applied to Tran/Vert/Long channel blocks). IMPORTANT:channel_label+20reads0x01on ALL captures and is NOT this field — it is a constant flag. The float32 atchannel_label+28= 6.206053 is the ADC-to-velocity scale factor (hardware constant, do NOT write). - Microphone Channels: Enable all microphones (bool), Trigger Source (bool)
- Chan 4 Trigger Level (dB or psi depending on units)
Notes tab:
- Enable User Notes (bool)
- Project, Client, User Name, Seis Loc (ASCII strings) ✅ (sourced from 5A metadata pages at counter 0x1002 / 0x1004 — see "SUB 5A — fixed metadata pages" section)
- Enable Extended Notes (bool); Extended Notes text; Extended Notes Title
- Enable Job Number (bool); Job Number (int)
- Enable Scaled Distance (bool); Distance from Blast (float); Charge Weight (float) — Scaled Distance is derived
Special Setups tab:
- Unit Timer: Timer Mode (Off/On), Start Date/Time, Stop Date/Time
- Self Check: Mode (Off/On), Time (HH:MM)
- Sensor Check: Before monitoring / After each event / Disabled ❓ (byte offset unknown)
- Measurement Units: Imperial / Metric
- Show Mic units in dB (bool)
- Time Format: 24 Hour / 12 Hour (AM/PM)
- Backlight on Time (seconds) ✅ (event index block +75)
- Power Saving Timeout (minutes) ✅ (event index block +83)
- Monitoring LCD Cycle ✅ (event index block +84:86)
- Set unit time with setup (bool)
The "Sensor Check" dropdown (Before monitoring / After each event / Disabled) has NOT
been located in the raw config bytes. The user's unit always runs with Before monitoring.
Full compliance config encoder is a future task.
Erase-all protocol (SUBs 0xA3/0xA2/0x06) — confirmed 2026-04-11
Full sequence confirmed from 4-11-26 MITM capture of a live Blastware ACH session
(bridges/captures/mitm/ach_mitm_20260411_001912/).
Wire sequence
BW → device: SUB 0xA3 params=00 00 00 00 00 00 00 FE 00 00 (begin erase)
device → BW: SUB 0x5C (ack)
BW → device: SUB 0x1C probe (offset=0x00)
device → BW: SUB 0xE3 (probe ack)
BW → device: SUB 0x1C data (offset=0x2C)
device → BW: SUB 0xE3 (monitor status response)
BW → device: SUB 0x06 probe (offset=0x00, params same)
device → BW: SUB 0xF9 (probe ack)
BW → device: SUB 0x06 data (offset=0x24)
device → BW: SUB 0xF9 (36-byte storage range response)
BW → device: SUB 0xA2 params=00 00 00 00 00 00 00 FE 00 00 (confirm erase)
device → BW: SUB 0x5D (ack — device memory is now cleared)
All frames use standard build_bw_frame (not write-format). Response SUBs follow the
standard 0xFF - SUB formula; no exceptions.
SUB 0x06 — event storage range response (36 bytes)
The 36-byte response body ends with two 4-byte event keys:
| Offset (from end) | Field | Notes |
|---|---|---|
[-8:-4] |
first stored event key | 01110000 when empty |
[-4:] |
last stored event key | 01110000 when empty |
Before erase: ends with <first_key> <last_key> (e.g. 0111ea60 0111eaa6).
After erase: both bytes read 01110000 — device's empty/reset sentinel.
Post-erase key counter reset
After a successful erase, the device resets its event counter. New events start from
key 0x01110000 again — the same key as the very first event ever recorded. This means
key-based deduplication in the ACH server must account for key reuse:
- After our own erase:
ach_state.jsondownloaded_keysandmax_downloaded_keyare cleared so the next session starts fresh. - After an external erase: the ACH server detects it by comparing
max(device_keys)tomax_downloaded_keyfrom state. If the device max has rolled back below the historical max, all current device keys are treated as new regardless ofseen_keys.
ACH server state format (v0.9.0)
bridges/captures/ach_state.json:
{
"BE11529": {
"downloaded_keys": ["01110000", "0111245a"],
"max_downloaded_key": "0111245a",
"last_seen": "2026-04-11T01:04:36",
"serial": "BE11529",
"peer": "63.43.212.232:51920"
}
}
max_downloaded_key is the high-water mark — the largest key ever downloaded from the
unit. It is NOT reset when events are erased from the device (only when our server does
the erase). Used for post-erase detection.
Monitor log entries — SUB 0x0A partial records (confirmed 2026-04-11)
Confirmed from 4-11-26 MITM capture: 12 partial records (record type 0x2C) and 7 full
event records (record type 0x46) across 19 total 0x0A responses.
Record type detection
read_waveform_header() returns (raw_data, length) where raw_data = data_rsp.data
(the full payload including prefix bytes). The record type is at raw_data[0]:
| Value | Type | How to process |
|---|---|---|
0x46 |
Full triggered event | Normal download: 0C → 5A → 1F |
0x2C |
Monitor log entry (partial) | No 0C/5A; decode inline from 0A payload |
Length heuristic: length < 0x40 (64) reliably identifies partial records across all
observed captures. Both checks (raw_data[0] == 0x2C and length < 0x40) are used.
SUB 0x0A partial record (0x2C) payload layout
All offsets are from raw_data (the full data_rsp.data array including the 11-byte
prefix before the actual header bytes start).
raw_data[0] = 0x2C ← record type (partial / monitor log)
raw_data[1:11] = prefix bytes (vary; contain key4 copy, flags, length)
raw_data[11:] = timestamp and ASCII metadata payload
Timestamp auto-detection (confirmed from 4-11-26 capture):
raw_data[11] == 0x10 → 10-byte sub_code=0x03 format (continuous mode)
raw_data[11] != 0x10 → 9-byte sub_code=0x10 format (single-shot mode)
9-byte timestamp format (sub_code=0x10):
| Byte | Field |
|---|---|
| 0 | day |
| 1 | 0x10 (sub_code marker) |
| 2 | month |
| 3–4 | year (uint16 BE) |
| 5 | unknown (0x00) |
| 6 | hour |
| 7 | minute |
| 8 | second |
10-byte timestamp format (sub_code=0x03):
| Byte | Field |
|---|---|
| 0 | 0x10 (marker) |
| 1 | day |
| 2 | 0x10 (marker) |
| 3 | month |
| 4–5 | year (uint16 BE) |
| 6 | unknown (0x00) |
| 7 | hour |
| 8 | minute |
| 9 | second |
Two timestamps: Each partial record contains two timestamps — start_time and
stop_time — stored consecutively:
ts1(start) atraw_data[ts_offset : ts_offset + ts_size]wherets_offset = 11ts2(stop) atraw_data[ts1_end : ts1_end + ts_size]
Edge case — 1-byte gap between timestamps: Occurs when ts1 and ts2 share the same
minute:second. If try_ts(raw_data[ts1_end:]) fails, try try_ts(raw_data[ts1_end+1:]).
Confirmed in frames 121, 161, 165 of the 4-11-26 MITM capture. Frame 121 still shows 0s
duration (both decode to 16:02:00) — the extra byte appears in all same-second cases.
ASCII metadata after timestamps:
<separator bytes> BE<serial>\x00Geo: <float> in/s ...
- Serial: scan for
b"BE", read untilb"\x00"(e.g."BE11529") - Geo threshold: scan for
b"Geo: ", read float until next space (e.g.0.254in/s)
A separator of variable length (4–5 bytes of \x00 + flags) sits between the two
timestamps and the ASCII region. The b"BE" anchor scan is robust to separator length
variation.
_decode_0a_partial_header(raw_data, index, key4) — client.py
Returns a MonitorLogEntry or None. Called by get_monitor_log_entries() for each
event key whose 0x0A response has raw_data[0] == 0x2C or length < 0x40.
MiniMateClient.get_monitor_log_entries(skip_keys=None) — client.py
Browse-mode walk: 1E → 0A → check type → decode if partial → 1F. No 0x0C or 5A reads
performed. Full (0x46) records are skipped without decoding. Returns list[MonitorLogEntry].
skip_keys (optional set[str]): keys in this set are still advanced through the walk
(to avoid disrupting the iteration sequence), but no MonitorLogEntry is created for them.
MonitorLogEntry model — models.py
@dataclass
class MonitorLogEntry:
index: int # 0-based position
key: str # 8-hex event key
start_time: Optional[datetime.datetime] = None
stop_time: Optional[datetime.datetime] = None
serial: Optional[str] = None
geo_threshold_ips: Optional[float] = None
raw_header: Optional[bytes] = field(default=None, repr=False)
@property
def duration_seconds(self) -> Optional[float]: ...
ACH server integration (v0.10.0)
After get_events(), the ACH server calls get_monitor_log_entries(skip_keys=seen_keys).
New entries are saved to monitor_log.json in the session directory. Monitor log keys are
included in current_keys for state persistence so they are not re-processed on the next
call-home.
Auto Call Home config (SUBs 0x2C / 0x7E / 0x7F) — confirmed 2026-04-20
Full read/write pipeline confirmed from bridges/captures/4-20-26/call home settings/
(10 BW TX write frames diffed against the S3 read response).
Accessible in Blastware: Remote Access → Setup Unit.
Protocol
SUB 0x2C — Call Home Config READ (response 0xD3)
Standard two-step read: probe offset 0x0000, data offset 0x007C (124).
Returns 125 raw bytes (one more than DATA_LENGTH) because the device encodes
num_retries value 3 as \x10\x03 on the wire — S3FrameParser preserves both
bytes literally, shifting all subsequent field positions by +1.
SUB 0x7E — Call Home Config WRITE (response 0x81)
Write format (only BW_CMD 0x10 doubled on wire; DLE-aware checksum).
Payload = 125-byte read payload + \x00\x00 = 127 bytes.
Offset = data[1] + 2 = 0x7C + 2 = 0x7E.
SUB 0x7F — Call Home WRITE CONFIRM (response 0x80)
Confirm frame, no data payload. Required after SUB 0x7E.
Field map (raw 125-byte array from data_rsp.data[11:])
| Raw Offset | Field | Notes |
|---|---|---|
[5] |
auto_call_home_enabled |
0x00=off, 0x01=on |
[6:46] |
dial_string |
40-byte null-padded ASCII |
[87] |
after_event_recorded |
bool |
[91] |
at_specified_times |
bool |
[93] |
time1_enabled |
bool |
[101] |
time1_hour |
0–23 |
[102] |
time1_min |
0–59 |
[95] |
time2_enabled |
bool |
[105] |
time2_hour |
0–23 |
[106] |
time2_min |
0–59 |
[117] |
DLE prefix 0x10 |
Part of \x10\x03 (DLE-escaped ETX encoding value 3) |
[118] |
num_retries |
Value = 3; detect via raw[117] == 0x10 |
[120] |
time_between_retries_sec |
Shifted +1 from logical 119 |
[122] |
wait_for_connection_sec |
Shifted +1 from logical 121 |
[124] |
warm_up_time_sec |
Shifted +1 from logical 123 |
DLE-escaped 0x03 at raw[117:119]: The byte value 0x03 is indistinguishable from the
frame ETX terminator, so the device encodes it as \x10\x03 (DLE + ETX inner-terminator).
S3FrameParser in STATE_AFTER_DLE on ETX appends both bytes as literal payload. The write
frame sends them verbatim — device accepts \x10\x03 and interprets it as value 3.
Unconfirmed fields: time slots 3 and 4 (offsets unknown), modem_power_relay_enabled.
CallHomeConfig model — models.py
@dataclass
class CallHomeConfig:
raw: Optional[bytes] = None # 125-byte raw read payload
auto_call_home_enabled: Optional[bool] = None # raw[5]
dial_string: Optional[str] = None # raw[6:46]
after_event_recorded: Optional[bool] = None # raw[87]
at_specified_times: Optional[bool] = None # raw[91]
time1_enabled: Optional[bool] = None # raw[93]
time1_hour: Optional[int] = None # raw[101]
time1_min: Optional[int] = None # raw[102]
time2_enabled: Optional[bool] = None # raw[95]
time2_hour: Optional[int] = None # raw[105]
time2_min: Optional[int] = None # raw[106]
num_retries: Optional[int] = None # raw[118] (DLE-prefixed)
time_between_retries_sec: Optional[int] = None # raw[120] (shifted +1)
wait_for_connection_sec: Optional[int] = None # raw[122] (shifted +1)
warm_up_time_sec: Optional[int] = None # raw[124] (shifted +1)
SFM REST API — sfm/server.py
GET /device/call_home?host=1.2.3.4&tcp_port=9034 ← read call home config
POST /device/call_home?host=1.2.3.4&tcp_port=9034 ← write call home config
POST body fields (all optional): auto_call_home_enabled, after_event_recorded,
at_specified_times, time1_enabled, time1_hour, time1_min, time2_enabled,
time2_hour, time2_min.
Note: dial_string is read-only in the current implementation (omitted from POST
body) because writing a dial string may require DLE escaping for embedded control characters.
What's next
See README.md → Roadmap (Future) for the canonical deferred-work list. This section is kept as a status log of in-progress / recently-shipped technical details (encoding schemes, byte layouts, etc.) that are too low-level for the README's roadmap.
-
Database — SQLite store for events + monitor log entries; dedup by key; queryable
-
Histograms — decode histogram-mode A5 data (noise floor tracking)
-
Blastware-compatible file output —
write_blastware_file()andwrite_mlg()implemented.blastware_filename()generates correct Blastware filenames (AB0 for direct, AB0W/AB0H for ACH). SFM's own MiniMate downloads carry the W/H letter (2026-10-30):with_type_letter()reads it from the file's STRT[18] (#41) on all three naming paths (device-access download,WaveformStore.save, the legacy/device/event/{i}/blastware_file); Blastware's direct downloads leave it off. Confirmed BYTE-PERFECT against BW reference (v0.14.3, 2026-05-05): when fed the BW 5-1-26 3-sec capture's A5 frames, the SFM-built file matches BW's savedM529LKIQ.G10byte-for-byte (8708 bytes, 0 differences). Live SFM downloads of event 0 (3-sec) and event 1 (3-sec continuation) both open cleanly in Blastware with full Event Reports, frequency analysis, and waveform plots. Body assembly is just contiguous concatenation of frame contributions in stream order (probe → meta@0x1002 → meta@0x1004 → samples → TERM); no stripping, no overlay, no special handling. Histogram+Continuous mode deferred (5A stream for those events embeds histogram interval records that may need different handling — untested under v0.14.x). Extension mapping: extensions encode timestamp (AB0T for ACH, AB0 for direct), NOT recording mode. Filename format:<prefix_letter><serial3><4-char-base36-stem><ext>Serial encoding (CONFIRMED 2026-04-22):
prefix_letter = chr(ord('B') + floor(serial_numeric / 1000)),serial3 = f"{serial_numeric % 1000:03d}". Examples: BE6907→H907, BE11529→M529, BE14036→P036, BE17353→S353, BE18003→T003. The prefix letter encodes the production generation (batch of 1000 units).Stem encoding (FULLY CONFIRMED 2026-04-22): stem = 4-char base-36 of
floor(total_seconds / 1296)wheretotal_seconds = (event_local_time − 1985-01-01T00:00:00_local)in seconds. Epoch =1985-01-01 00:00:00device local time — confirmed against 3,248 files from 10-year production archive with zero errors. Decode:event_time = datetime(1985,1,1) + timedelta(seconds=stem_int*1296 + ab_int). Example: P036L318.C80H → BE14036, 2025-05-26 15:00:08, Full Histogram. -
Blastware filename extension — NEW FIRMWARE FULLY DECODED (confirmed 2026-04-21, further confirmed 2026-04-22 from 10-year production archive frequency analysis):
Extension format =
AB0T(4 chars):AB= 2-char base-36 encoding oftotal_seconds % 1296(seconds within the 21.6-min window, 0–1295);A = value // 36,B = value % 360= always literal digit zero (third character, invariant)T= event type:W= Full Waveform,H= Full Histogram
Combined with the 4-char stem, the full filename encodes a complete second-resolution timestamp. Verified against three S353L4H0.{3M0W,8S0H,9X0W} events (all match to the second) plus large-scale frequency analysis of a 10-year archive.
3-day cycle property (confirmed 2026-04-22): A unit recording at a fixed daily time cycles through exactly 3 extensions with a 3-day period. Each calendar day shifts
total_seconds % 1296by 864 (since86400 % 1296 = 864). The cycle repeats every 3 days becausegcd(1296, 864) = 432and1296 / 432 = 3. The three extension values are spaced 432 seconds apart. Confirmed from 10-year archive: the top 3 extensions overall wereCE0H(95 files),0E0H(93),OE0H(91) — all three are the 3-day cycle of a 06:00:14 daily call-in time (seconds-in-window = 14, 446, 878; all three haveEas second character because14 = Ein base-36 and adding 864 never changesvalue % 36since864 = 24 × 36).B character invariance: For a unit recording at a fixed time of day, the second character
Bof the extension (value % 36) never changes — only the first characterAcycles through 3 values. This means same-time-of-day files from different dates all share the sameBcharacter.Old firmware (S338, 3-char extensions ending in
0): encoding unknown. Extension is NOT recording mode.blastware_filename()returns.N00as a placeholder for old-firmware units.Micromate Series 4 uses a different extension format entirely (observed:
IDFH,IDFW). TheAB0Tformula applies only to MiniMate Plus / V10.72 firmware. -
Compliance config encoder — build raw write payloads from a
ComplianceConfigobject -
Test Histogram recording mode (0x03) write via SFM — confirmed working for Single Shot / Continuous / Histogram+Continuous; Histogram (0x03) needs a live test from a non-Histogram starting state (bare 0x03 in write vs BW's DLE-escaped
10 03) -
Compliance write anchor-9 cleanup — when changing recording_mode via SFM, the byte at anchor-9 is not explicitly managed. A spurious
0x10may persist after Histogram→other mode transitions. Does not affect device operation but differs from BW's byte-perfect output. -
Locate "Sensor Check" byte in compliance config (need capture with Disabled vs Before-monitoring)
-
Call Home — map time slots 3/4 offsets; add dial_string write support; confirm
modem_power_relay_enabled -
Modem manager — push RV50/RV55 configs via Sierra Wireless API
-
RV55 DCD/DTR issue — newer RV55 firmware doesn't assert DCD by default; units don't resume monitoring after call-home disconnect (
--restart-monitoringflag deferred)
BW capture reference
bridges/captures/ contains the following BW TX + S3 response captures for protocol analysis:
| Folder / File | Contents |
|---|---|
1-2-26/ |
First SUB 5A BW TX capture — established 5A frame format (raw offset_hi, DLE-aware checksum). 10 frames verified. (⚠ model retracted 2026-10-26) |
3-11-26/raw_bw_20260311_170151.bin |
Full compliance write + event download (SUBs 68→83 confirmed, frames 102–112) |
3-31-26/ |
Single-event download (148 BW / 147 S3 frames) — 1E/0A/0C/1F sequence confirmed (single event so token=0xFE appeared to work in either branch) |
4-2-26/ |
Download-mode BW TX capture — POLL×3 requirement confirmed (frames 68-73 between 1F and first 5A) |
4-3-26-multi_event/ |
Browse-mode S3 capture with 2+ events — all-zero params for 1F, null sentinel layout, 0A context requirement |
4-8-26/ |
Monitor status read, start/stop monitoring, SESSION_RESET signal, sensor check |
4-11-26 (mitm/ach_mitm_20260411_001912/) |
Full ACH call-home MITM — erase protocol (0xA3/0x06/0xA2), monitor log partial records confirmed |
4-20-26/raw_bw_*_recording_mode_*.bin |
Recording mode changes: Continuous→Single Shot, →Histogram, →Histogram+Continuous |
4-20-26/histogram interval/ |
Histogram interval changes: 1min, 5min, 15min, 15sec |
4-20-26/geo sensitivity/ |
Geo sensitivity changes: 1.25 in/s (Sensitive), 10 in/s (Normal) |
4-20-26/call home settings/ |
Call home config read/write captures |
4-27-26/ |
BW "open 2sec waveform" + "copy event to disk" + paired SFM "seismo_dl" — first proof of 5× SFM over-read. STRT end_key field located. |
5-1-26/comcheck/ |
Triplet of captures that nailed the v0.14.0 walk: SFM 3-sec download (seismo_dl_…), BW comms-check + 3-sec download (bwcap3sec/), BW second-event download + "Download All" (raw_*_170945 / _171216). Confirmed: TERM frame formula across 3 events, metadata pages 0x1002/0x1004 are global session metadata (⚠ retracted 2026-10-26: event 1's chunks at 0x0200/0x0400), event-1 vs event-N chunk pattern split, WAVEHDR off=0x46 vs 0x2C disambiguates real events from boundaries. |
5-1-26/comcheck/bwcap3sec/ |
The byte-perfect reference for v0.14.3. All 17 BW 5A request frames (probe, 2 metadata, 13 samples, TERM) reproduce byte-for-byte from SFM's framing helpers — including the 10 10 00 DLE-stuffed counter for sample @ 0x1000 that was the long-standing failure mode. |
5-4-26/ |
BW MITM captures of "copy 3sec / 2sec / Download All" + paired SFM session (seismo_dl_20260504_145701) showing the +0x46 event-N probe bug producing 110-chunk runaway walk. Cross-references against 5-1-26 confirmed device behavior is identical. |
To parse BW TX captures: use bridges/captures/ scripts or adapt the find_write_frames() pattern
in /tmp/analyze_write_payload.py — it correctly handles 0x10 0x03 DLE-escaped ETX bytes
inside write frame data (the naive parser terminates early at the escaped 0x03).