Skip to content

feat: parse analog_in_data_ts for batched PB streaming messages #449

@cptkoolbeenz

Description

@cptkoolbeenz

Context

The firmware is adding batched PB streaming (daqifi/daqifi-nyquist-firmware#238) to improve throughput by packing multiple sample sets into a single protobuf message. This requires the desktop app to parse the analog_in_data_ts field to reconstruct per-sample-set timestamps.

Current Behavior

Each PB streaming message contains one sample set:

  • msg_time_stamp = timestamp for this sample set
  • analog_in_data = channel values (count = enabled channels)
  • analog_in_data_ts = empty (count=0, unused)

New Behavior (after firmware #238)

Each PB message may contain multiple sample sets batched together:

  • msg_time_stamp = first sample set's timestamp (base)
  • analog_in_data_ts = one timestamp per sample set (absolute or offset from base)
  • analog_in_data = all values concatenated (count = N sample sets × enabled channels)

Example (3 sample sets, 4 channels enabled):

msg_time_stamp: 1000000
analog_in_data_ts: [1000000, 1000100, 1000200]
analog_in_data: [v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11]

The app should chunk analog_in_data by the known channel count (analog_in_port_num) and assign each chunk the corresponding analog_in_data_ts entry.

Required Changes

In daqifi-core (ProtobufProtocolHandler or equivalent message parser):

  1. When AnalogInDataTs has entries (Count > 0):

    • Determine samples per set from AnalogInPortNum (channel count from initial info message)
    • Chunk AnalogInData into groups of channelCount values
    • Assign each group the timestamp from AnalogInDataTs[groupIndex]
  2. When AnalogInDataTs is empty (Count == 0):

    • Current behavior unchanged (one sample set per message, use MsgTimeStamp)

Backward Compatibility

  • Messages without analog_in_data_ts work exactly as before
  • The app should handle both batched and non-batched messages seamlessly
  • No proto file changes needed — analog_in_data_ts (field 4) already exists in the proto3 schema

Performance Impact

Firmware benchmarks show batching improves PB streaming ceilings:

  • USB PB 1ch: 18kHz → 20kHz
  • USB PB 16ch: 5kHz → 7kHz
  • 15-39% fewer bytes per sample (reduced framing overhead)

Related

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