Files
marte-debug/ARCHITECTURE.md
2026-02-21 20:20:08 +01:00

1.9 KiB

System Architecture

1. Overview

The suite consists of a C++ server library (libmarte_dev.so) that instrument MARTe2 applications at runtime, and a native Rust client for visualization.

2. Core Mechanism: Registry Patching

The "Zero-Code-Change" requirement is met by intercepting the MARTe2 ClassRegistryDatabase. When the DebugService initializes, it replaces the standard object builders for critical classes:

  1. Broker Injection: Standard Brokers (e.g., MemoryMapInputBroker) are replaced with DebugBrokerWrapper. This captures data every time a GAM reads or writes a signal.
  2. Scheduler Injection: The FastScheduler is replaced with DebugFastScheduler. This provides hooks at the start/end of each real-time cycle for execution control (pausing).

3. Communication Layer

The system uses three distinct channels:

3.1 Command & Control (TCP Port 8080)

  • Protocol: Text-based over TCP.
  • Role: Object tree discovery (TREE), signal metadata (DISCOVER), and trace activation (TRACE).
  • Response Format: JSON for complex data, OK/ERROR for status.

3.2 High-Speed Telemetry (UDP Port 8081)

  • Protocol: Binary over UDP.
  • Format: Packed C-structs.
  • Header: [Magic:4][Seq:4][TS:8][Count:4] (Packed, 20 bytes).
  • Payload: [ID:4][Size:4][Data:N] (Repeated for each traced signal).

3.3 Log Streaming (TCP Port 8082)

  • Protocol: Real-time event streaming.
  • Role: Forwards global REPORT_ERROR calls from the framework to the GUI client.

4. Component Diagram

[ MARTe2 App ] <--- [ DebugFastScheduler ] (Registry Patch)
      |                     |
      + <--- [ DebugBrokerWrapper ] (Registry Patch)
      |                     |
[ DebugService ] <----------+
      |
      +---- (TCP 8080) ----> [ Rust GUI Client ]
      +---- (UDP 8081) ----> [   (Oscilloscope)  ]
      +---- (TCP 8082) ----> [   (Log Terminal)  ]