4.6 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
MARTe2 component library providing real-time signal streaming (UDPStreamer DataSource → StreamHub → web/ImGui oscilloscopes) and zero-code-change debugging (DebugService Interface: trace/force/breakpoint via registry-patched broker wrappers). See ARCHITECTURE.md for full detail and Docs/ for per-component references.
Build & Test
Requires MARTe2 and MARTe2-components built externally; env.sh sets MARTe2_DIR, MARTe2_Components_DIR, TARGET=x86-linux, and LD_LIBRARY_PATH (needed both for building and for running anything).
source env.sh
make -f Makefile.gcc core # all C++ MARTe2 components
make -f Makefile.gcc apps # StreamHub standalone app
make -f Makefile.gcc test # build GTest + Integration tests
make -f Makefile.gcc clean
# Run tests (after source env.sh)
./Build/x86-linux/GTest/MainGTest.ex # unit tests (UDPStreamer)
./Build/x86-linux/GTest/MainGTest.ex --gtest_filter='Name*' # single test
./Build/x86-linux/Test/Integration/Integration/IntegrationTests.ex # DebugService integration tests
# Build a single component (each component dir has its own Makefile.gcc)
make -C Source/Components/DataSources/UDPStreamer -f Makefile.gcc
# Go clients
cd Common/Client/go && go build ./...
cd Client/debugger && go build ./...
# ImGui desktop client (not a MARTe2 component; needs SDL2)
cd Client/streamhub && cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build
End-to-end demo scripts (build + launch full stack, see headers for ports/options): ./run_combined_test.sh, ./run_streamhub.sh.
Build output goes to Build/x86-linux/ (shared libs per component, .ex executables).
Architecture
Two independent data paths:
- Streaming path:
UDPStreamerDataSource serialises signals each RT cycle to UDPS binary packets (UDP 44500, unicast/multicast) →StreamHub(Source/Applications/StreamHub/, headless C++ app: ring buffers, LTTB decimation, trigger FSM) → WebSocket 8090 → browser (Client/udpstreamer, Go) or native ImGui client (Client/streamhub). - Debug path:
DebugServicepatches theClassRegistryDatabaseatInitialise()so subsequentConfigureApplication()instantiatesDebugBrokerWrapper<T>around allMemoryMap*Brokertypes — no application changes. RT hot path goes throughDebugServiceI(abstract singleton inDebugServiceI.h) for forcing/tracing/breakpoints. Exposes TCP 8080 (text commands), UDP 8081 (trace telemetry), works withTcpLoggeron 8082. Web UI:Client/debugger(Go).
Shared wire format: Common/UDP/UDPSProtocol.h defines the UDPS binary protocol (17-byte packed header, 136-byte signal descriptors, little-endian). It is deliberately MARTe2-free so it's shared by C++ producers (UDPStreamer, DebugService), the C++ consumer (Source/Components/Interfaces/UDPStream/UDPSClient), and the Go decoder (Common/Client/go/udpsprotocol). Changes to the protocol must be mirrored across all of these, plus the JS client parsers.
StreamHub WebSocket protocol: JSON text frames for commands/events, binary frames for data pushes — spec in ARCHITECTURE.md §6. The Go hub (Client/udpstreamer) and C++ StreamHub implement the identical protocol; both clients (browser JS and ImGui) must stay compatible with both.
StreamHub History: HistoryWriter (Source/Applications/StreamHub/HistoryWriter.{h,cpp}) provides disk-backed circular storage of signal data. Each signal is stored in a separate .shist binary file with a 64-byte header and pre-allocated circular data region of (float64 time, float64 value) pairs. Configured via a +History block in the StreamHub config with keys: Directory (required), DurationHours (default 1), Decimation (default 1), FlushIntervalSec (default 5), MinDiskFreeMB (default 500). WS commands: historyInfo (returns metadata), historyZoom (reads time range from disk). Both the web SPA (Client/udpstreamer/static/app.js) and ImGui client support history zoom queries alongside in-memory ring zoom.
Conventions
- No STL in MARTe2 components (
Source/Components/): use MARTe2 types (StreamString,FastPollingMutexSem, fixed arrays). STL/C++17 is fine inClient/streamhub/andSource/Applications/StreamHub/follows MARTe2 style but links MARTe2 core. FastPollingMutexSemon RT hot paths (never OS mutexes).- Each component dir has
Makefile.gcc(wrapper),Makefile.inc(sources/includes), anddepends.x86-linux/dependsRaw.x86-linux(generated dependency files). - EUPL v1.1 license headers on C++ sources.