Skip to content

CoreDeviceAdapter v0.4.0: LineBasedMessageParser incompatible with protobuf binary messages #35

@tylerkron

Description

@tylerkron

Summary

CoreDeviceAdapter v0.4.0 uses LineBasedMessageParser which is designed for text-based protocols (like SCPI responses) but cannot parse binary protobuf messages sent by DAQiFi devices after initial command exchange.

Current Behavior

  • CoreDeviceAdapter successfully connects to devices and sends SCPI commands
  • Device responses after initial SCPI commands are binary protobuf messages
  • LineBasedMessageParser cannot parse these binary messages, so MessageReceived events never fire
  • Device initialization fails to complete due to lack of response processing

Root Cause

The CoreDeviceAdapter uses LineBasedMessageParser (see LineBasedMessageParser.cs) which:

  • Expects text messages terminated by line endings (CRLF)
  • Uses UTF-8 encoding to convert bytes to strings
  • Cannot handle binary protobuf data that contains null bytes and non-text content

Expected Behavior

CoreDeviceAdapter should support both:

  1. Text-based SCPI command responses (current functionality)
  2. Binary protobuf message parsing for device status and data messages

Proposed Solution

Add support for protobuf message parsing in CoreDeviceAdapter by either:

  1. Creating a CompositeMessageParser that can handle both text and protobuf formats
  2. Adding a ProtobufMessageParser alongside LineBasedMessageParser
  3. Making the message parser configurable in CoreDeviceAdapter constructor

Impact

This limitation prevents Phase 2 integration of CoreDeviceAdapter in daqifi-desktop application. Current workaround is using Phase 1 approach (existing transport + Core 0.4.0 ScpiMessageProducer).

Device Communication Flow

  1. SCPI Commands (text-based): DEVICE:ON, DEVICE:FORMAT PROTOBUF → LineBasedMessageParser works
  2. Device Status Responses (binary protobuf): DaqifiOutMessage with device metadata → LineBasedMessageParser fails
  3. Data Streaming (binary protobuf): Continuous measurement data → LineBasedMessageParser fails

Test Case

// This should work but currently fails:
var adapter = new CoreDeviceAdapter(transport);
adapter.MessageReceived += (sender, args) => {
    // This event never fires for protobuf responses
    Console.WriteLine($"Received: {args.Data}");
};
adapter.SendAsync("DEVICE:INFO"); // Response is protobuf, not parsed

Priority

High - Required for Phase 2 CoreDeviceAdapter integration in daqifi-desktop v0.4.1

🤖 Generated with Claude Code

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