Adds a client-side pre-flight that warns the user before starting an
SD-output capture when the card is nearly full or the planned capture
will not fit. Per the firmware/client split (ADR 0001): firmware owns
the safe MINFree gate, the client owns the UX warning.
- SdCardCaptureEstimate: pure best-effort size estimator
(rate x channels x bytes/sample x duration).
- SdCardSpaceCheck / SdCardSpaceCheckResult: evaluates free space against
the estimate and a configurable "nearly full" floor (default 100 MB),
with a human-readable message and truncation ETA.
- DaqifiStreamingDevice.CheckSdCardSpaceAsync(...): queries SD space,
evaluates, and raises the new advisory LowSdSpaceWarning event. Never
blocks; callers decide whether to proceed before StartSdCardLoggingAsync.
- SetSdCardMinimumFreeSpace + SCPI SetSdMinFreeSpace: optional hand-off to
the firmware MINFree gate (v3.5.0+, at/below the supported floor).
Verified on real hardware (USB): SD space query, both warning paths
(won't-fit + nearly-full) with events, and the MINFree command.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Implements #230 — a client-side pre-flight that warns (never blocks) the user before starting an SD-output capture when the card is nearly full or the planned capture won't fit. Per the firmware/client split recorded in ADR 0001: the firmware owns the safe
SD:MINFreegate, the client owns the UX warning.The SD space query (
GetSdCardStorageAsync→SdCardStorageInfo) already landed in #214; this PR builds the warning layer on top.What's added
SdCardCaptureEstimate— a pure, best-effort size estimator (rate × channels × bytes/sample × duration) withBytesPerSecond/EstimatedBytes(overflow-clamped). DefaultsBytesPerSamplePerChannelto the raw 16-bit ADC width, documented as a floor (encoded logs are larger).SdCardSpaceCheck+SdCardSpaceCheckResult— pure evaluator applying the two rules from the issue: free < estimate → "won't fit" (+ truncation ETA), and free < 100 MB (configurable) → "nearly full". Produces a human-readable message.LowSdSpaceWarningEventArgs+LowSdSpaceWarningevent onISdCardOperations/DaqifiStreamingDevice.CheckSdCardSpaceAsync(plannedCapture?, minimumFreeBytes?, ct)— queries SD space, evaluates, raises the event when warranted, returns the structured result. Advisory only; the caller decides whether to proceed beforeStartSdCardLoggingAsync.SetSdCardMinimumFreeSpace(bytes)+ SCPISetSdMinFreeSpace— optional hand-off to the firmwareSD:MINFreegate (v3.5.0+, at/below the supported floor, so safe to send unconditionally).Design note
The pre-flight is a separate method, not auto-run inside
StartSdCardLoggingAsync. The issue requires "let the user proceed if they want" — the user must see the warning and decide before start commits, which is only possible as a distinct step (an internal check that raised mid-start couldn't let them abort, since the warning must not block).StartSdCardLoggingAsync's docs cross-referenceCheckSdCardSpaceAsyncfor discoverability.Testing
net9.0andnet10.0.SetSdCardMinimumFreeSpace(52428800)accepted by firmware, no error (reset to 0 afterward) ✓🤖 Generated with Claude Code