fix(sfm): store a MiniMate download through the Blastware-file import path, as production does (#8)
A live Series-3 download was stored from the live 5A decode (store.save): a histogram got no samples and nothing to plot (bench 2026-10-29). The download now carries the assembled Blastware file (DownloadedEvent.bw_bytes, built by the new blastware_file_bytes -- byte-identical to Blastware's own K441LTON.900 and K441LTOK.R10), and persist_download stores it through save_imported_bw, the path the watcher uses for Blastware's files, the way Series 4 already uses save_imported_idf. The event is decoded from the file: histogram samples, setup-block sample rate and record time (#44/#45). source.kind is 'sfm-live'. The file path does not yet read three things right (measured on BE9441): a histogram's vector sum (0.503 where Blastware and the unit say 0.385 -- the decode checker's open finding), the mic peak (0), and a sensitive range. So the unit's own 0C channel peaks, mic and vector sum are overlaid, as Series 4 does, except an impossible vector sum (below the largest channel; BE9441's 0C read -0.0, bench #4), and the unit's range is passed through for the stored samples. Store consequence: new live MiniMate downloads only; existing rows and files are untouched; no backfill, no migration. The record type still reads 'Waveform' for a live histogram until #41 (record type from STRT[18]) lands from the decode checker's branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
ce441a0911
commit
9492e49400
8 files changed
+180
-32
No files matched your search
@@ -702,8 +702,18 @@ def write_blastware_file(
|
||||
a5_frames: list[S3Frame],
|
||||
path: Union[str, Path],
|
||||
) -> None:
|
||||
"""Write `blastware_file_bytes(event, a5_frames)` to `path`."""
|
||||
Path(path).write_bytes(blastware_file_bytes(event, a5_frames))
|
||||
|
||||
|
||||
def blastware_file_bytes(
|
||||
event: Event,
|
||||
a5_frames: list[S3Frame],
|
||||
) -> bytes:
|
||||
"""
|
||||
Write a Blastware waveform file from a downloaded event.
|
||||
The Blastware waveform file for a downloaded event, as bytes -- what
|
||||
write_blastware_file writes, and what a live SFM download stores through the
|
||||
file-import path (sfm.event_ingest).
|
||||
|
||||
Args:
|
||||
event: Event object (populated by get_events() or download_waveform()).
|
||||
@@ -712,23 +722,18 @@ def write_blastware_file(
|
||||
(page_key=0x0000). Pass include_terminator=True to
|
||||
read_bulk_waveform_stream() when collecting frames.
|
||||
Must have at least 2 frames (probe + terminator).
|
||||
path: Destination file path. Parent directory must exist.
|
||||
Extension should be set via blastware_filename().
|
||||
|
||||
File layout:
|
||||
[22B header] [21B STRT] [body bytes] [26B footer]
|
||||
|
||||
Raises:
|
||||
ValueError: if a5_frames is empty or has no terminator (page_key=0).
|
||||
OSError: if the file cannot be written.
|
||||
|
||||
Confirmed correct waveform body reconstruction against M529LIY6 (example event) (2026-04-21).
|
||||
"""
|
||||
if not a5_frames:
|
||||
raise ValueError("a5_frames must not be empty")
|
||||
|
||||
path = Path(path)
|
||||
|
||||
# ── Extract STRT record from probe frame ────────────────────────────────
|
||||
# The STRT record (21 bytes) lives verbatim inside A5[0].data[7:].
|
||||
# It is stored as-is in the waveform file — do NOT reconstruct it from Event
|
||||
@@ -923,12 +928,7 @@ def write_blastware_file(
|
||||
+ b"\x00\x00"
|
||||
)
|
||||
|
||||
# ── Write file ───────────────────────────────────────────────────────────
|
||||
with open(path, "wb") as f:
|
||||
f.write(header)
|
||||
f.write(strt)
|
||||
f.write(body)
|
||||
f.write(footer)
|
||||
return header + strt + body + footer
|
||||
|
||||
|
||||
def read_blastware_file(path: Union[str, Path]) -> Event:
|
||||
|
||||
Reference in new issue
Block a user