Skip to content

Offline CSV export under-counts analog channels (infers from first sample, which has only 1 value) #34

Description

@tylerkron

Summary

When exporting an SD log to CSV offline (--sd-parse <file> --sd-export-csv <out>) and the log file has no embedded device-config/status message, ExportSdSessionToCsvAsync infers the analog channel count by peeking the first sample:

var first = enumerator.Current;
analogCount = first.AnalogValues.Count;   // Program.cs ~line 1155

But the device's first stream message routinely carries only a single analog value (subsequent messages carry the full set). So analogCount is inferred as 1, and SdCardSampleSource then truncates every later sample to one analog channel, printing:

Warning: sample has 2 analog values but configured channel count is 1; extra channels will not appear in the CSV.

The result is silent data loss — the exported CSV contains only AI0, dropping all other analog channels.

Reproduction

# capture a 2-channel stream to a bin with no status frame, then export offline
--serial <port> --sd-capture-parse capture.bin --rate 100 --duration 2 --channels 3
--sd-parse capture.bin --sd-export-csv capture.csv

capture.csv has a single AI0 column despite two analog channels being enabled.

Notes

  • Core's CsvExporter is not at fault — it faithfully writes exactly the channels the ISampleSource declares. The bug is the channel-count inference in the example app.
  • Files that do contain a device-config frame (e.g. real --sd-download results) export all channels correctly, because analogCount comes from DeviceConfig.AnalogPortCount.

Suggested fix

Infer the analog count from the maximum AnalogValues.Count seen across a small prefix of samples (or the whole file), not the first sample — or default to the device's AnalogPortCount when any config is available.

Found during daqifi-core v1.2.0 pre-release hardware testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions