9 Commits

Author SHA1 Message Date
Martino Ferrari
56bb3536fc Implemented all basic features 2026-02-23 13:17:16 +01:00
Martino Ferrari
6b1fc59fc0 Implemetned better buffering and high frequency tracing 2026-02-23 12:00:14 +01:00
Martino Ferrari
253a4989f9 Testing HF data 2026-02-23 11:24:32 +01:00
Martino Ferrari
04fb98bc74 Fixed ui for high frequency data 2026-02-23 11:17:11 +01:00
Martino Ferrari
3ad581d13b Removede scheduler 2026-02-23 10:25:58 +01:00
Martino Ferrari
38bb971bc4 cleaned up 2026-02-23 10:17:22 +01:00
Martino Ferrari
87b9ccebfd Implemented separate TCP logger service 2026-02-21 22:30:16 +01:00
Martino Ferrari
817d7276b7 Added tutorial and fixed issues on debugservice 2026-02-21 20:33:29 +01:00
Martino Ferrari
955eb02924 Updated with scheduler 2026-02-21 20:20:08 +01:00
25 changed files with 1792 additions and 950 deletions

61
API.md Normal file
View File

@@ -0,0 +1,61 @@
# API Documentation
## 1. TCP Control Interface (Port 8080)
### 1.1 `TREE`
Retrieves the full object hierarchy.
- **Request:** `TREE
`
- **Response:** `JSON_OBJECT
OK TREE
`
### 1.2 `DISCOVER`
Lists all registrable signals and their metadata.
- **Request:** `DISCOVER
`
- **Response:** `{"Signals": [...]}
OK DISCOVER
`
### 1.3 `TRACE <path> <state>`
Enables/disables telemetry for a signal.
- **Example:** `TRACE App.Data.Timer.Counter 1
`
- **Response:** `OK TRACE <match_count>
`
### 1.4 `FORCE <path> <value>`
Overrides a signal value in memory.
- **Example:** `FORCE App.Data.DDB.Signal 123.4
`
- **Response:** `OK FORCE <match_count>
`
### 1.5 `PAUSE` / `RESUME`
Controls global execution state via the Scheduler.
- **Request:** `PAUSE
`
- **Response:** `OK
`
---
## 2. UDP Telemetry Format (Port 8081)
Telemetry packets are Little-Endian and use `#pragma pack(1)`.
### 2.1 TraceHeader (20 Bytes)
| Offset | Type | Name | Description |
| :--- | :--- | :--- | :--- |
| 0 | uint32 | magic | Always `0xDA7A57AD` |
| 4 | uint32 | seq | Incremental sequence number |
| 8 | uint64 | timestamp | High-resolution timestamp |
| 16 | uint32 | count | Number of samples in payload |
### 2.2 Sample Entry
| Offset | Type | Name | Description |
| :--- | :--- | :--- | :--- |
| 0 | uint32 | id | Internal Signal ID (from `DISCOVER`) |
| 4 | uint32 | size | Data size in bytes |
| 8 | Bytes | data | Raw signal memory |

44
ARCHITECTURE.md Normal file
View File

@@ -0,0 +1,44 @@
# 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.
- **Service:** `TcpLogger` (Standalone component).
- **Role:** Forwards global `REPORT_ERROR` calls and `stdout` messages to the GUI client.
## 4. Component Diagram
```text
[ MARTe2 App ] <--- [ DebugFastScheduler ] (Registry Patch)
| |
+ <--- [ DebugBrokerWrapper ] (Registry Patch)
| |
+---------------------+
| |
[ DebugService ] [ TcpLogger ]
| |
+--- (TCP 8080) ------+-----> [ Rust GUI Client ]
+--- (UDP 8081) ------+-----> [ (Oscilloscope) ]
+--- (TCP 8082) ------+-----> [ (Log Terminal) ]
```

View File

@@ -35,6 +35,7 @@ include_directories(
${MARTe2_DIR}/Source/Core/Scheduler/L4LoggerService
${MARTe2_DIR}/Source/Core/FileSystem/L1Portability
${MARTe2_DIR}/Source/Core/FileSystem/L3Streams
${MARTe2_DIR}/Source/Core/Scheduler/L5GAMs
${MARTe2_Components_DIR}/Source/Components/DataSources/EpicsDataSource
${MARTe2_Components_DIR}/Source/Components/DataSources/FileDataSource
${MARTe2_Components_DIR}/Source/Components/GAMs/IOGAM

32
DEMO.md Normal file
View File

@@ -0,0 +1,32 @@
# Demo Walkthrough: High-Speed Tracing
This demo demonstrates tracing a `Timer.Counter` signal at 100Hz and verifying its consistency.
### 1. Launch the Test Environment
Start the validation environment which simulates a real-time app:
```bash
./Build/Test/Integration/ValidationTest
```
*Note: The test will wait for a trace command before finishing.*
### 2. Connect the GUI
In another terminal:
```bash
cd Tools/gui_client
cargo run --release
```
### 3. Explore the Tree
1. On the left panel (**Application Tree**), expand `Root.App.Data.Timer`.
2. Click the ` Info` button on the `Timer` node to see its configuration (e.g., `SleepTime: 10000`).
### 4. Activate Trace
1. Locate the `Counter` signal under the `Timer` node.
2. Click the **📈 Trace** button.
3. The **Oscilloscope** in the center will immediately begin plotting the incremental counter.
4. Verify the **UDP Packets** counter in the top bar is increasing rapidly.
### 5. Test Execution Control
1. Click the **⏸ Pause** button in the top bar.
2. Observe that the plot stops updating and the counter value holds steady.
3. Click **▶ Resume** to continue execution.

View File

@@ -5,9 +5,7 @@
#include "BrokerI.h"
#include "MemoryMapBroker.h"
#include "ObjectRegistryDatabase.h"
#include "ReferenceT.h"
#include "ObjectBuilder.h"
#include "HighResolutionTimer.h"
// Original broker headers
#include "MemoryMapInputBroker.h"
@@ -72,7 +70,7 @@ public:
StreamString signalName;
if (!dataSourceIn.GetSignalName(dsIdx, signalName)) signalName = "Unknown";
// 1. Register canonical DataSource name (Absolute)
// 1. Register canonical DataSource name (Absolute, No Root prefix)
StreamString dsFullName;
dsFullName.Printf("%s.%s", dsPath.Buffer(), signalName.Buffer());
service->RegisterSignal(addr, type, dsFullName.Buffer());
@@ -87,7 +85,7 @@ public:
DebugService::GetFullObjectName(*(gamRef.operator->()), absGamPath);
gamFullName.Printf("%s.%s.%s", absGamPath.Buffer(), dirStr, signalName.Buffer());
} else {
gamFullName.Printf("Root.%s.%s.%s", functionName, dirStr, signalName.Buffer());
gamFullName.Printf("%s.%s.%s", functionName, dirStr, signalName.Buffer());
}
signalInfoPointers[i] = service->RegisterSignal(addr, type, gamFullName.Buffer());
} else {

View File

@@ -4,7 +4,7 @@
#include "CompilerTypes.h"
#include "TypeDescriptor.h"
#include "StreamString.h"
#include "MemoryOperationsHelper.h"
#include <cstring> // For memcpy
namespace MARTe {
@@ -59,7 +59,14 @@ public:
uint32 packetSize = 4 + 4 + size;
uint32 read = readIndex;
uint32 write = writeIndex;
uint32 available = (read <= write) ? (bufferSize - (write - read) - 1) : (read - write - 1);
// Calculate available space
uint32 available = 0;
if (read <= write) {
available = bufferSize - (write - read) - 1;
} else {
available = read - write - 1;
}
if (available < packetSize) return false;
@@ -69,6 +76,9 @@ public:
WriteToBuffer(&tempWrite, &size, 4);
WriteToBuffer(&tempWrite, data, size);
// Memory Barrier to ensure data is visible before index update
// __sync_synchronize();
// Final atomic update
writeIndex = tempWrite;
return true;
@@ -80,20 +90,27 @@ public:
if (read == write) return false;
uint32 tempRead = read;
uint32 tempId, tempSize;
uint32 tempId = 0;
uint32 tempSize = 0;
// Peek header
ReadFromBuffer(&tempRead, &tempId, 4);
ReadFromBuffer(&tempRead, &tempSize, 4);
if (tempSize > maxSize) {
// Error case: drop data up to writeIndex
// Error case: drop data up to writeIndex (resync)
readIndex = write;
return false;
}
ReadFromBuffer(&tempRead, dataBuffer, tempSize);
signalID = tempId;
size = tempSize;
// Memory Barrier
// __sync_synchronize();
readIndex = tempRead;
return true;
}
@@ -107,18 +124,32 @@ public:
private:
void WriteToBuffer(uint32 *idx, void* src, uint32 count) {
uint8* s = (uint8*)src;
for (uint32 i=0; i<count; i++) {
buffer[*idx] = s[i];
*idx = (*idx + 1) % bufferSize;
uint32 current = *idx;
uint32 spaceToEnd = bufferSize - current;
if (count <= spaceToEnd) {
std::memcpy(&buffer[current], src, count);
*idx = (current + count) % bufferSize;
} else {
std::memcpy(&buffer[current], src, spaceToEnd);
uint32 remaining = count - spaceToEnd;
std::memcpy(&buffer[0], (uint8*)src + spaceToEnd, remaining);
*idx = remaining;
}
}
void ReadFromBuffer(uint32 *idx, void* dst, uint32 count) {
uint8* d = (uint8*)dst;
for (uint32 i=0; i<count; i++) {
d[i] = buffer[*idx];
*idx = (*idx + 1) % bufferSize;
uint32 current = *idx;
uint32 spaceToEnd = bufferSize - current;
if (count <= spaceToEnd) {
std::memcpy(dst, &buffer[current], count);
*idx = (current + count) % bufferSize;
} else {
std::memcpy(dst, &buffer[current], spaceToEnd);
uint32 remaining = count - spaceToEnd;
std::memcpy((uint8*)dst + spaceToEnd, &buffer[0], remaining);
*idx = remaining;
}
}

View File

@@ -1,8 +1,6 @@
#ifndef DEBUGSERVICE_H
#define DEBUGSERVICE_H
#include "DataSourceI.h"
#include "GAM.h"
#include "MessageI.h"
#include "StreamString.h"
#include "BasicUDPSocket.h"
@@ -10,30 +8,17 @@
#include "ReferenceContainer.h"
#include "SingleThreadService.h"
#include "EmbeddedServiceMethodBinderI.h"
#include "FastMath.h"
#include "CompilerTypes.h"
#include "Object.h"
#include "DebugCore.h"
#include "ClassRegistryDatabase.h"
#include "ErrorManagement.h"
#include "AdvancedErrorManagement.h"
#include "LoggerConsumerI.h"
#include "Threads.h"
#include "EventSem.h"
namespace MARTe {
struct LogEntry {
ErrorManagement::ErrorInformation info;
char8 description[MAX_ERROR_MESSAGE_SIZE];
};
struct SignalAlias {
StreamString name;
uint32 signalIndex;
};
class DebugService : public ReferenceContainer, public MessageI, public EmbeddedServiceMethodBinderI, public LoggerConsumerI {
class DebugService : public ReferenceContainer, public MessageI, public EmbeddedServiceMethodBinderI {
public:
CLASS_REGISTER_DECLARATION()
@@ -46,33 +31,30 @@ public:
void ProcessSignal(DebugSignalInfo* signalInfo, uint32 size);
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
virtual void ConsumeLogMessage(LoggerPage *logPage);
static void LogCallback(const ErrorManagement::ErrorInformation &errorInfo, const char8 * const errorDescription);
void InsertLogIntoQueue(LoggerPage *logPage);
bool IsPaused() const { return isPaused; }
void SetPaused(bool paused) { isPaused = paused; }
static bool GetFullObjectName(const Object &obj, StreamString &fullPath);
private:
void HandleCommand(StreamString cmd, BasicTCPSocket *client);
uint32 ForceSignal(const char8* name, const char8* valueStr);
uint32 UnforceSignal(const char8* name);
uint32 TraceSignal(const char8* name, bool enable, uint32 decimation = 1);
void Discover(BasicTCPSocket *client);
void ListNodes(const char8* path, BasicTCPSocket *client);
void InfoNode(const char8* path, BasicTCPSocket *client);
private:
void HandleCommand(StreamString cmd, BasicTCPSocket *client);
uint32 ExportTree(ReferenceContainer *container, StreamString &json);
void PatchRegistry();
ErrorManagement::ErrorType Server(ExecutionInfo & info);
ErrorManagement::ErrorType Streamer(ExecutionInfo & info);
ErrorManagement::ErrorType LogStreamer(ExecutionInfo & info);
uint16 controlPort;
uint16 streamPort;
uint16 logPort;
StreamString streamIP;
bool isServer;
bool suppressTimeoutLogs;
@@ -80,15 +62,13 @@ private:
BasicTCPSocket tcpServer;
BasicUDPSocket udpSocket;
BasicTCPSocket logServer;
class ServiceBinder : public EmbeddedServiceMethodBinderI {
public:
enum ServiceType { ServerType, StreamerType, LogStreamerType };
enum ServiceType { ServerType, StreamerType };
ServiceBinder(DebugService *parent, ServiceType type) : parent(parent), type(type) {}
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info) {
if (type == StreamerType) return parent->Streamer(info);
if (type == LogStreamerType) return parent->LogStreamer(info);
return parent->Server(info);
}
private:
@@ -98,15 +78,12 @@ private:
ServiceBinder binderServer;
ServiceBinder binderStreamer;
ServiceBinder binderLogStreamer;
SingleThreadService threadService;
SingleThreadService streamerService;
SingleThreadService logStreamerService;
ThreadIdentifier serverThreadId;
ThreadIdentifier streamerThreadId;
ThreadIdentifier logStreamerThreadId;
static const uint32 MAX_SIGNALS = 4096;
DebugSignalInfo signals[MAX_SIGNALS];
@@ -123,17 +100,7 @@ private:
BasicTCPSocket* activeClients[MAX_CLIENTS];
FastPollingMutexSem clientsMutex;
BasicTCPSocket* activeLogClients[MAX_CLIENTS];
FastPollingMutexSem logClientsMutex;
static const uint32 LOG_QUEUE_SIZE = 1024;
LogEntry logQueue[LOG_QUEUE_SIZE];
volatile uint32 logQueueRead;
volatile uint32 logQueueWrite;
EventSem logEvent;
static DebugService* instance;
static ErrorManagement::ErrorProcessFunctionType originalLogCallback;
};
}

65
Headers/TcpLogger.h Normal file
View File

@@ -0,0 +1,65 @@
#ifndef TCPLOGGER_H
#define TCPLOGGER_H
#include "LoggerConsumerI.h"
#include "ReferenceContainer.h"
#include "EmbeddedServiceMethodBinderI.h"
#include "BasicTCPSocket.h"
#include "SingleThreadService.h"
#include "FastPollingMutexSem.h"
#include "EventSem.h"
namespace MARTe {
struct TcpLogEntry {
ErrorManagement::ErrorInformation info;
char8 description[MAX_ERROR_MESSAGE_SIZE];
};
/**
* @brief Logger consumer that publishes framework logs to TCP and stdout.
* @details Implements LoggerConsumerI to be used inside a LoggerService.
*/
class TcpLogger : public ReferenceContainer, public LoggerConsumerI, public EmbeddedServiceMethodBinderI {
public:
CLASS_REGISTER_DECLARATION()
TcpLogger();
virtual ~TcpLogger();
virtual bool Initialise(StructuredDataI & data);
/**
* @brief Implementation of LoggerConsumerI.
* Called by LoggerService.
*/
virtual void ConsumeLogMessage(LoggerPage *logPage);
/**
* @brief Worker thread method for TCP streaming.
*/
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
private:
void InsertLogIntoQueue(const ErrorManagement::ErrorInformation &info, const char8 * const description);
uint16 port;
BasicTCPSocket server;
static const uint32 MAX_CLIENTS = 8;
BasicTCPSocket* activeClients[MAX_CLIENTS];
FastPollingMutexSem clientsMutex;
SingleThreadService service;
ThreadIdentifier workerThreadId;
static const uint32 QUEUE_SIZE = 1024;
TcpLogEntry queue[QUEUE_SIZE];
volatile uint32 readIdx;
volatile uint32 writeIdx;
EventSem eventSem;
};
}
#endif

View File

@@ -1,48 +1,51 @@
# MARTe2 Universal Debugging & Observability Suite
# MARTe2 Debug Suite
A professional-grade, zero-code-change debugging suite for the MARTe2 real-time framework.
## Features
- **Runtime Registry Patching**: Instruments all MARTe2 Brokers automatically at startup.
- **Hierarchical Tree Explorer**: Recursive visualization of the `ObjectRegistryDatabase`, including GAMs, DataSources, and Signals.
- **Real-Time Execution Control**: Pause and Resume application logic globally to perform static inspection.
- **High-Speed Telemetry**: Visual oscilloscope with sub-millisecond precision via UDP.
- **Persistent Forcing**: Type-aware signal overrides (Last-Writer-Wins) with persistent re-application.
- **Isolated Log Streaming**: Dedicated TCP channel for real-time framework logs to ensure command responsiveness.
## Components
### 1. C++ Core (`libmarte_dev.so`)
The core service that handles registry patching, TCP/UDP communication, and real-time safe data capture.
### 2. Rust GUI Client (`marte_debug_gui`)
A native, multi-threaded dashboard built with `egui`.
- **Side Panel**: Collapsible application tree and signal navigator.
- **Bottom Panel**: Advanced log terminal with Regex filtering and priority levels.
- **Right Panel**: Active Trace and Force management.
- **Central Pane**: High-frequency oscilloscope.
An interactive observability and debugging suite for the MARTe2 real-time framework.
## Quick Start
### Build
### 1. Build the project
```bash
# Build C++ Core
cd Build && cmake .. && make -j$(nproc)
# Build GUI Client
cd Tools/gui_client
cargo build --release
. ./env.sh
cd Build
cmake ..
make -j$(nproc)
```
### Run
1. Start your MARTe2 application with the `DebugService` enabled.
2. Launch the GUI:
```bash
./Tools/gui_client/target/release/marte_debug_gui
```
### 2. Run Integration Tests
```bash
./Test/Integration/ValidationTest # Verifies 100Hz tracing
./Test/Integration/SchedulerTest # Verifies execution control
```
## Communication Ports
- **8080 (TCP)**: Commands (TREE, FORCE, TRACE, PAUSE).
- **8082 (TCP)**: Real-time framework logs.
- **8081 (UDP)**: Signal telemetry data.
### 3. Launch GUI
```bash
cd Tools/gui_client
cargo run --release
```
## Features
- **Live Tree:** Explore the MARTe2 object database in real-time.
- **Oscilloscope:** Trace any signal at high frequency (100Hz+) with automatic scaling.
- **Signal Forcing:** Inject values directly into the real-time memory map.
- **Log Forwarding:** Integrated framework log viewer with regex filtering.
- **Execution Control:** Global pause/resume via scheduler-level hooks.
## Usage
To enable debugging in your application, add the following to your `.cfg`:
```text
+DebugService = {
Class = DebugService
ControlPort = 8080
UdpPort = 8081
}
+LoggerService = {
Class = LoggerService
+DebugConsumer = {
Class = TcpLogger
Port = 8082
}
}
```
The suite automatically patches the registry to instrument your existing Brokers and Schedulers.

41
SPECS.md Normal file
View File

@@ -0,0 +1,41 @@
# MARTe2 Debug Suite Specifications
## 1. Goal
Implement a "Zero-Code-Change" observability layer for the MARTe2 real-time framework, providing live telemetry, signal forcing, and execution control without modifying existing application source code.
## 2. Requirements
### 2.1 Functional Requirements (FR)
- **FR-01 (Discovery):** Discover the full MARTe2 object hierarchy at runtime.
- **FR-02 (Telemetry):** Stream high-frequency signal data (verified up to 100Hz) to a remote client.
- **FR-03 (Forcing):** Allow manual override of signal values in memory during execution.
- **FR-04 (Logs):** Stream global framework logs to a dedicated terminal via a standalone `TcpLogger` service.
- **FR-05 (Log Filtering):** The client must support filtering logs by type (Debug, Information, Warning, FatalError) and by content using regular expressions.
- **FR-06 (Execution & UI):**
- Provide a native GUI for visualization.
- Support Pause/Resume of real-time execution threads via scheduler injection.
- **FR-07 (Session Management):**
- The top panel must provide a "Disconnect" button to close active network streams.
- Support runtime re-configuration and "Apply & Reconnect" logic.
- **FR-08 (Decoupled Tracing):**
Clicking `trace` activates telemetry; data is buffered and shown as a "Last Value" in the sidebar, but not plotted until manually assigned.
- **FR-08 (Advanced Plotting):**
- Support multiple plot panels with perfectly synchronized time (X) axes.
- Drag-and-drop signals from the traced list into specific plots.
- Automatic distinct color assignment for each signal added to a plot.
- Plot modes: Standard (Time Series) and Logic Analyzer (Stacked rows).
- Signal transformations: Gain, offset, units, and custom labels.
- Visual styling: Deep customization of colors, line styles (Solid, Dashed, etc.), and marker shapes (Circle, Square, etc.).
- **FR-09 (Navigation):**
- Context menus for resetting zoom (X, Y, or both).
- "Fit to View" functionality that automatically scales both axes to encompass all available buffered data points.
### 2.2 Technical Constraints (TC)
- **TC-01:** No modifications allowed to the MARTe2 core library or component source code.
- **TC-02:** Instrumentation must use Runtime Class Registry Patching.
- **TC-03:** Real-time threads must remain lock-free; use `FastPollingMutexSem` or atomic operations for synchronization.
- **TC-04:** Telemetry must be delivered via UDP to minimize impact on real-time jitter.
## 3. Performance Metrics
- **Latency:** Telemetry dispatch overhead < 5 microseconds per signal.
- **Throughput:** Support for 100Hz+ sampling rates with zero packet loss on local networks.
- **Scalability:** Handle up to 4096 unique signals and 16 simultaneous client connections.

View File

@@ -25,7 +25,6 @@
namespace MARTe {
DebugService* DebugService::instance = NULL_PTR(DebugService*);
ErrorManagement::ErrorProcessFunctionType DebugService::originalLogCallback = NULL_PTR(ErrorManagement::ErrorProcessFunctionType);
static void EscapeJson(const char8* src, StreamString &dst) {
if (src == NULL_PTR(const char8*)) return;
@@ -43,17 +42,14 @@ static void EscapeJson(const char8* src, StreamString &dst) {
CLASS_REGISTER(DebugService, "1.0")
DebugService::DebugService() :
ReferenceContainer(), EmbeddedServiceMethodBinderI(), LoggerConsumerI(),
ReferenceContainer(), EmbeddedServiceMethodBinderI(),
binderServer(this, ServiceBinder::ServerType),
binderStreamer(this, ServiceBinder::StreamerType),
binderLogStreamer(this, ServiceBinder::LogStreamerType),
threadService(binderServer),
streamerService(binderStreamer),
logStreamerService(binderLogStreamer)
streamerService(binderStreamer)
{
controlPort = 0;
streamPort = 8081;
logPort = 8082;
streamIP = "127.0.0.1";
numberOfSignals = 0;
numberOfAliases = 0;
@@ -62,40 +58,27 @@ DebugService::DebugService() :
isPaused = false;
for (uint32 i=0; i<MAX_CLIENTS; i++) {
activeClients[i] = NULL_PTR(BasicTCPSocket*);
activeLogClients[i] = NULL_PTR(BasicTCPSocket*);
}
logQueueRead = 0;
logQueueWrite = 0;
serverThreadId = InvalidThreadIdentifier;
streamerThreadId = InvalidThreadIdentifier;
logStreamerThreadId = InvalidThreadIdentifier;
}
DebugService::~DebugService() {
if (instance == this) {
if (ErrorManagement::errorMessageProcessFunction == &DebugService::LogCallback) {
ErrorManagement::SetErrorProcessFunction(originalLogCallback);
}
instance = NULL_PTR(DebugService*);
}
threadService.Stop();
streamerService.Stop();
logStreamerService.Stop();
tcpServer.Close();
udpSocket.Close();
logServer.Close();
for (uint32 i=0; i<MAX_CLIENTS; i++) {
if (activeClients[i] != NULL_PTR(BasicTCPSocket*)) {
activeClients[i]->Close();
delete activeClients[i];
}
if (activeLogClients[i] != NULL_PTR(BasicTCPSocket*)) {
activeLogClients[i]->Close();
delete activeLogClients[i];
}
}
}
@@ -115,26 +98,21 @@ bool DebugService::Initialise(StructuredDataI & data) {
(void)data.Read("UdpPort", streamPort);
}
if (!data.Read("LogPort", logPort)) {
(void)data.Read("TcpLogPort", logPort);
StreamString tempIP;
if (data.Read("StreamIP", tempIP)) {
streamIP = tempIP;
} else {
streamIP = "127.0.0.1";
}
(void)data.Read("StreamIP", streamIP);
uint32 suppress = 1;
if (data.Read("SuppressTimeoutLogs", suppress)) {
suppressTimeoutLogs = (suppress == 1);
}
if (isServer) {
if (ErrorManagement::errorMessageProcessFunction != &DebugService::LogCallback) {
originalLogCallback = ErrorManagement::errorMessageProcessFunction;
ErrorManagement::SetErrorProcessFunction(&DebugService::LogCallback);
}
if (!traceBuffer.Init(1024 * 1024)) return false;
(void)logEvent.Create();
// 8MB Buffer for lossless tracing at high frequency
if (!traceBuffer.Init(8 * 1024 * 1024)) return false;
PatchRegistry();
@@ -142,20 +120,22 @@ bool DebugService::Initialise(StructuredDataI & data) {
threadData.Write("Timeout", (uint32)1000);
threadService.Initialise(threadData);
streamerService.Initialise(threadData);
logStreamerService.Initialise(threadData);
if (!tcpServer.Open()) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to open TCP Server Socket");
return false;
}
if (!tcpServer.Listen(controlPort)) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to Listen on port %u", controlPort);
return false;
}
printf("[DebugService] TCP Server listening on port %u\n", controlPort);
if (!udpSocket.Open()) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to open UDP Socket");
return false;
}
if (!logServer.Open()) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to open Log Server Socket");
return false;
}
printf("[DebugService] UDP Streamer socket opened\n");
if (threadService.Start() != ErrorManagement::NoError) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to start Server thread");
@@ -165,10 +145,7 @@ bool DebugService::Initialise(StructuredDataI & data) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to start Streamer thread");
return false;
}
if (logStreamerService.Start() != ErrorManagement::NoError) {
REPORT_ERROR(ErrorManagement::FatalError, "DebugService: Failed to start LogStreamer thread");
return false;
}
printf("[DebugService] Worker threads started.\n");
}
return true;
@@ -295,9 +272,6 @@ static bool RecursiveGetFullObjectName(ReferenceContainer *container, const Obje
bool DebugService::GetFullObjectName(const Object &obj, StreamString &fullPath) {
fullPath = "";
if (RecursiveGetFullObjectName(ObjectRegistryDatabase::Instance(), obj, fullPath)) {
StreamString abs = "Root.";
abs += fullPath;
fullPath = abs;
return true;
}
return false;
@@ -311,16 +285,10 @@ ErrorManagement::ErrorType DebugService::Server(ExecutionInfo & info) {
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
if (info.GetStage() == ExecutionInfo::StartupStage) {
serverThreadId = Threads::Id();
if (!tcpServer.Listen(controlPort)) return ErrorManagement::FatalError;
return ErrorManagement::NoError;
}
while (info.GetStage() == ExecutionInfo::MainStage) {
if (ErrorManagement::errorMessageProcessFunction != &DebugService::LogCallback) {
originalLogCallback = ErrorManagement::errorMessageProcessFunction;
ErrorManagement::SetErrorProcessFunction(&DebugService::LogCallback);
}
BasicTCPSocket *newClient = tcpServer.WaitConnection(1);
if (newClient != NULL_PTR(BasicTCPSocket *)) {
clientsMutex.FastLock();
@@ -371,73 +339,6 @@ ErrorManagement::ErrorType DebugService::Server(ExecutionInfo & info) {
return ErrorManagement::NoError;
}
ErrorManagement::ErrorType DebugService::LogStreamer(ExecutionInfo & info) {
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
if (info.GetStage() == ExecutionInfo::StartupStage) {
logStreamerThreadId = Threads::Id();
if (!logServer.Listen(logPort)) return ErrorManagement::FatalError;
return ErrorManagement::NoError;
}
while (info.GetStage() == ExecutionInfo::MainStage) {
BasicTCPSocket *newClient = logServer.WaitConnection(1);
if (newClient != NULL_PTR(BasicTCPSocket *)) {
logClientsMutex.FastLock();
bool added = false;
for (uint32 i=0; i<MAX_CLIENTS; i++) {
if (activeLogClients[i] == NULL_PTR(BasicTCPSocket*)) {
activeLogClients[i] = newClient;
added = true;
break;
}
}
logClientsMutex.FastUnLock();
if (!added) {
newClient->Close();
delete newClient;
}
}
bool hadData = false;
for (uint32 b=0; b<50; b++) {
if (logQueueRead == logQueueWrite) break;
hadData = true;
uint32 idx = logQueueRead % LOG_QUEUE_SIZE;
LogEntry &entry = logQueue[idx];
StreamString level;
ErrorManagement::ErrorCodeToStream(entry.info.header.errorType, level);
StreamString packet;
packet.Printf("LOG %s %s\n", level.Buffer(), entry.description);
uint32 size = packet.Size();
logClientsMutex.FastLock();
for (uint32 j=0; j<MAX_CLIENTS; j++) {
if (activeLogClients[j] != NULL_PTR(BasicTCPSocket*)) {
uint32 s = size;
if (!activeLogClients[j]->Write(packet.Buffer(), s)) {
activeLogClients[j]->Close();
delete activeLogClients[j];
activeLogClients[j] = NULL_PTR(BasicTCPSocket*);
}
}
}
logClientsMutex.FastUnLock();
logQueueRead++;
}
if (!hadData) {
(void)logEvent.Wait(TimeoutType(100));
logEvent.Reset();
} else {
Sleep::MSec(1);
}
}
return ErrorManagement::NoError;
}
ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo & info) {
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
if (info.GetStage() == ExecutionInfo::StartupStage) {
@@ -446,7 +347,7 @@ ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo & info) {
}
InternetHost dest(streamPort, streamIP.Buffer());
udpSocket.SetDestination(dest);
(void)udpSocket.SetDestination(dest);
uint8 packetBuffer[4096];
uint32 packetOffset = 0;
@@ -458,6 +359,7 @@ ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo & info) {
uint8 sampleData[1024];
bool hasData = false;
// TIGHT LOOP: Drain the buffer as fast as possible without sleeping
while ((info.GetStage() == ExecutionInfo::MainStage) && traceBuffer.Pop(id, sampleData, size, 1024)) {
hasData = true;
if (packetOffset == 0) {
@@ -466,36 +368,44 @@ ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo & info) {
header.seq = sequenceNumber++;
header.timestamp = HighResolutionTimer::Counter();
header.count = 0;
MemoryOperationsHelper::Copy(packetBuffer, &header, sizeof(TraceHeader));
std::memcpy(packetBuffer, &header, sizeof(TraceHeader));
packetOffset = sizeof(TraceHeader);
}
// Packet Packing: Header + [ID:4][Size:4][Data:N]
// If this sample doesn't fit, flush the current packet first
if (packetOffset + 8 + size > 1400) {
uint32 toWrite = packetOffset;
udpSocket.Write((char8*)packetBuffer, toWrite);
packetOffset = 0;
(void)udpSocket.Write((char8*)packetBuffer, toWrite);
// Re-init header for the next packet
TraceHeader header;
header.magic = 0xDA7A57AD;
header.seq = sequenceNumber++;
header.timestamp = HighResolutionTimer::Counter();
header.count = 0;
MemoryOperationsHelper::Copy(packetBuffer, &header, sizeof(TraceHeader));
std::memcpy(packetBuffer, &header, sizeof(TraceHeader));
packetOffset = sizeof(TraceHeader);
}
MemoryOperationsHelper::Copy(&packetBuffer[packetOffset], &id, 4);
MemoryOperationsHelper::Copy(&packetBuffer[packetOffset + 4], &size, 4);
MemoryOperationsHelper::Copy(&packetBuffer[packetOffset + 8], sampleData, size);
std::memcpy(&packetBuffer[packetOffset], &id, 4);
std::memcpy(&packetBuffer[packetOffset + 4], &size, 4);
std::memcpy(&packetBuffer[packetOffset + 8], sampleData, size);
packetOffset += (8 + size);
// Update sample count in the current packet header
TraceHeader *h = (TraceHeader*)packetBuffer;
h->count++;
}
// Flush any remaining data
if (packetOffset > 0) {
uint32 toWrite = packetOffset;
udpSocket.Write((char8*)packetBuffer, toWrite);
(void)udpSocket.Write((char8*)packetBuffer, toWrite);
packetOffset = 0;
}
// Only sleep if the buffer was completely empty
if (!hasData) Sleep::MSec(1);
}
return ErrorManagement::NoError;
@@ -524,7 +434,7 @@ void DebugService::HandleCommand(StreamString cmd, BasicTCPSocket *client) {
uint32 count = ForceSignal(name.Buffer(), val.Buffer());
if (client) {
StreamString resp; resp.Printf("OK FORCE %u\n", count);
uint32 s = resp.Size(); client->Write(resp.Buffer(), s);
uint32 s = resp.Size(); (void)client->Write(resp.Buffer(), s);
}
}
}
@@ -534,7 +444,7 @@ void DebugService::HandleCommand(StreamString cmd, BasicTCPSocket *client) {
uint32 count = UnforceSignal(name.Buffer());
if (client) {
StreamString resp; resp.Printf("OK UNFORCE %u\n", count);
uint32 s = resp.Size(); client->Write(resp.Buffer(), s);
uint32 s = resp.Size(); (void)client->Write(resp.Buffer(), s);
}
}
}
@@ -546,31 +456,31 @@ void DebugService::HandleCommand(StreamString cmd, BasicTCPSocket *client) {
if (cmd.GetToken(decim, delims, term)) {
AnyType decimVal(UnsignedInteger32Bit, 0u, &d);
AnyType decimStr(CharString, 0u, decim.Buffer());
TypeConvert(decimVal, decimStr);
(void)TypeConvert(decimVal, decimStr);
}
uint32 count = TraceSignal(name.Buffer(), enable, d);
if (client) {
StreamString resp; resp.Printf("OK TRACE %u\n", count);
uint32 s = resp.Size(); client->Write(resp.Buffer(), s);
uint32 s = resp.Size(); (void)client->Write(resp.Buffer(), s);
}
}
}
else if (token == "DISCOVER") Discover(client);
else if (token == "PAUSE") {
SetPaused(true);
if (client) { uint32 s = 3; client->Write("OK\n", s); }
if (client) { uint32 s = 3; (void)client->Write("OK\n", s); }
}
else if (token == "RESUME") {
SetPaused(false);
if (client) { uint32 s = 3; client->Write("OK\n", s); }
if (client) { uint32 s = 3; (void)client->Write("OK\n", s); }
}
else if (token == "TREE") {
StreamString json;
json = "{\"Name\": \"Root\", \"Class\": \"ObjectRegistryDatabase\", \"Children\": [\n";
ExportTree(ObjectRegistryDatabase::Instance(), json);
(void)ExportTree(ObjectRegistryDatabase::Instance(), json);
json += "\n]}\nOK TREE\n";
uint32 s = json.Size();
client->Write(json.Buffer(), s);
(void)client->Write(json.Buffer(), s);
}
else if (token == "INFO") {
StreamString path;
@@ -584,7 +494,7 @@ void DebugService::HandleCommand(StreamString cmd, BasicTCPSocket *client) {
else if (client) {
const char* msg = "ERROR: Unknown command\n";
uint32 s = StringHelper::Length(msg);
client->Write(msg, s);
(void)client->Write(msg, s);
}
}
}
@@ -636,7 +546,7 @@ void DebugService::InfoNode(const char8* path, BasicTCPSocket *client) {
json += "}\nOK INFO\n";
uint32 s = json.Size();
client->Write(json.Buffer(), s);
(void)client->Write(json.Buffer(), s);
}
uint32 DebugService::ExportTree(ReferenceContainer *container, StreamString &json) {
@@ -770,7 +680,7 @@ void DebugService::Discover(BasicTCPSocket *client) {
if (client) {
StreamString header = "{\n \"Signals\": [\n";
uint32 s = header.Size();
client->Write(header.Buffer(), s);
(void)client->Write(header.Buffer(), s);
mutex.FastLock();
for (uint32 i = 0; i < numberOfAliases; i++) {
StreamString line;
@@ -781,12 +691,12 @@ void DebugService::Discover(BasicTCPSocket *client) {
if (i < numberOfAliases - 1) line += ",";
line += "\n";
s = line.Size();
client->Write(line.Buffer(), s);
(void)client->Write(line.Buffer(), s);
}
mutex.FastUnLock();
StreamString footer = " ]\n}\nOK DISCOVER\n";
s = footer.Size();
client->Write(footer.Buffer(), s);
(void)client->Write(footer.Buffer(), s);
}
}
@@ -803,7 +713,7 @@ void DebugService::ListNodes(const char8* path, BasicTCPSocket *client) {
StreamString header;
header.Printf("Nodes under %s:\n", path ? path : "/");
uint32 s = header.Size();
client->Write(header.Buffer(), s);
(void)client->Write(header.Buffer(), s);
ReferenceContainer *container = dynamic_cast<ReferenceContainer*>(ref.operator->());
if (container) {
@@ -814,7 +724,7 @@ void DebugService::ListNodes(const char8* path, BasicTCPSocket *client) {
StreamString line;
line.Printf(" %s [%s]\n", child->GetName(), child->GetClassProperties()->GetName());
s = line.Size();
client->Write(line.Buffer(), s);
(void)client->Write(line.Buffer(), s);
}
}
}
@@ -822,15 +732,15 @@ void DebugService::ListNodes(const char8* path, BasicTCPSocket *client) {
DataSourceI *ds = dynamic_cast<DataSourceI*>(ref.operator->());
if (ds) {
StreamString dsHeader = " Signals:\n";
s = dsHeader.Size(); client->Write(dsHeader.Buffer(), s);
s = dsHeader.Size(); (void)client->Write(dsHeader.Buffer(), s);
uint32 nSignals = ds->GetNumberOfSignals();
for (uint32 i=0; i<nSignals; i++) {
StreamString sname, line;
ds->GetSignalName(i, sname);
(void)ds->GetSignalName(i, sname);
TypeDescriptor stype = ds->GetSignalType(i);
const char8* stypeName = TypeDescriptor::GetTypeNameFromTypeDescriptor(stype);
line.Printf(" %s [%s]\n", sname.Buffer(), stypeName ? stypeName : "Unknown");
s = line.Size(); client->Write(line.Buffer(), s);
s = line.Size(); (void)client->Write(line.Buffer(), s);
}
}
@@ -840,70 +750,31 @@ void DebugService::ListNodes(const char8* path, BasicTCPSocket *client) {
uint32 nOut = gam->GetNumberOfOutputSignals();
StreamString gamHeader;
gamHeader.Printf(" Input Signals (%d):\n", nIn);
s = gamHeader.Size(); client->Write(gamHeader.Buffer(), s);
s = gamHeader.Size(); (void)client->Write(gamHeader.Buffer(), s);
for (uint32 i=0; i<nIn; i++) {
StreamString sname, line;
gam->GetSignalName(InputSignals, i, sname);
(void)gam->GetSignalName(InputSignals, i, sname);
line.Printf(" %s\n", sname.Buffer());
s = line.Size(); client->Write(line.Buffer(), s);
s = line.Size(); (void)client->Write(line.Buffer(), s);
}
gamHeader.SetSize(0);
gamHeader.Printf(" Output Signals (%d):\n", nOut);
s = gamHeader.Size(); client->Write(gamHeader.Buffer(), s);
s = gamHeader.Size(); (void)client->Write(gamHeader.Buffer(), s);
for (uint32 i=0; i<nOut; i++) {
StreamString sname, line;
gam->GetSignalName(OutputSignals, i, sname);
(void)gam->GetSignalName(OutputSignals, i, sname);
line.Printf(" %s\n", sname.Buffer());
s = line.Size(); client->Write(line.Buffer(), s);
s = line.Size(); (void)client->Write(line.Buffer(), s);
}
}
const char* okMsg = "OK LS\n";
s = StringHelper::Length(okMsg);
client->Write(okMsg, s);
(void)client->Write(okMsg, s);
} else {
const char* msg = "ERROR: Path not found\n";
uint32 s = StringHelper::Length(msg);
client->Write(msg, s);
}
}
void DebugService::ConsumeLogMessage(LoggerPage *logPage) {
}
void DebugService::LogCallback(const ErrorManagement::ErrorInformation &errorInfo, const char8 * const errorDescription) {
ThreadIdentifier current = Threads::Id();
if (instance != NULL_PTR(DebugService*)) {
StreamString levelStr;
ErrorManagement::ErrorCodeToStream(errorInfo.header.errorType, levelStr);
printf("[%s] %s\n", levelStr.Buffer(), errorDescription);
fflush(stdout);
bool isWorkerThread = false;
if (instance->serverThreadId != InvalidThreadIdentifier && current == instance->serverThreadId) isWorkerThread = true;
if (instance->streamerThreadId != InvalidThreadIdentifier && current == instance->streamerThreadId) isWorkerThread = true;
if (instance->logStreamerThreadId != InvalidThreadIdentifier && current == instance->logStreamerThreadId) isWorkerThread = true;
if (isWorkerThread) return;
if (instance->suppressTimeoutLogs && StringHelper::SearchString(errorDescription, "Timeout expired in recv()") != NULL_PTR(const char8*)) return;
LoggerPage tempPage;
tempPage.errorInfo = errorInfo;
StringHelper::Copy(tempPage.errorStrBuffer, errorDescription);
instance->InsertLogIntoQueue(&tempPage);
}
if (originalLogCallback) originalLogCallback(errorInfo, errorDescription);
}
void DebugService::InsertLogIntoQueue(LoggerPage *logPage) {
uint32 next = (logQueueWrite + 1) % LOG_QUEUE_SIZE;
if (next != logQueueRead) {
LogEntry &entry = logQueue[logQueueWrite % LOG_QUEUE_SIZE];
entry.info = logPage->errorInfo;
StringHelper::Copy(entry.description, logPage->errorStrBuffer);
logQueueWrite = next;
(void)logEvent.Post();
(void)client->Write(msg, s);
}
}

156
Source/TcpLogger.cpp Normal file
View File

@@ -0,0 +1,156 @@
#include "TcpLogger.h"
#include "Threads.h"
#include "StringHelper.h"
#include "ConfigurationDatabase.h"
namespace MARTe {
CLASS_REGISTER(TcpLogger, "1.0")
TcpLogger::TcpLogger() :
ReferenceContainer(), LoggerConsumerI(), EmbeddedServiceMethodBinderI(),
service(*this)
{
port = 8082;
readIdx = 0;
writeIdx = 0;
workerThreadId = InvalidThreadIdentifier;
for (uint32 i=0; i<MAX_CLIENTS; i++) {
activeClients[i] = NULL_PTR(BasicTCPSocket*);
}
}
TcpLogger::~TcpLogger() {
service.Stop();
server.Close();
clientsMutex.FastLock();
for (uint32 i=0; i<MAX_CLIENTS; i++) {
if (activeClients[i] != NULL_PTR(BasicTCPSocket*)) {
activeClients[i]->Close();
delete activeClients[i];
activeClients[i] = NULL_PTR(BasicTCPSocket*);
}
}
clientsMutex.FastUnLock();
}
bool TcpLogger::Initialise(StructuredDataI & data) {
if (!ReferenceContainer::Initialise(data)) return false;
if (!data.Read("Port", port)) {
(void)data.Read("TcpPort", port);
}
(void)eventSem.Create();
ConfigurationDatabase threadData;
threadData.Write("Timeout", (uint32)1000);
if (!service.Initialise(threadData)) return false;
if (!server.Open()) return false;
if (!server.Listen(port)) {
return false;
}
printf("[TcpLogger] Listening on port %u\n", port);
if (service.Start() != ErrorManagement::NoError) {
return false;
}
return true;
}
void TcpLogger::ConsumeLogMessage(LoggerPage *logPage) {
if (logPage == NULL_PTR(LoggerPage*)) return;
// 1. Mirror to stdout
StreamString levelStr;
ErrorManagement::ErrorCodeToStream(logPage->errorInfo.header.errorType, levelStr);
printf("[%s] %s\n", levelStr.Buffer(), logPage->errorStrBuffer);
fflush(stdout);
// 2. Queue for TCP
InsertLogIntoQueue(logPage->errorInfo, logPage->errorStrBuffer);
}
void TcpLogger::InsertLogIntoQueue(const ErrorManagement::ErrorInformation &info, const char8 * const description) {
uint32 next = (writeIdx + 1) % QUEUE_SIZE;
if (next != readIdx) {
TcpLogEntry &entry = queue[writeIdx % QUEUE_SIZE];
entry.info = info;
StringHelper::Copy(entry.description, description);
writeIdx = next;
(void)eventSem.Post();
}
}
ErrorManagement::ErrorType TcpLogger::Execute(ExecutionInfo & info) {
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
if (info.GetStage() == ExecutionInfo::StartupStage) {
workerThreadId = Threads::Id();
return ErrorManagement::NoError;
}
while (info.GetStage() == ExecutionInfo::MainStage) {
// 1. Check for new connections
BasicTCPSocket *newClient = server.WaitConnection(1);
if (newClient != NULL_PTR(BasicTCPSocket *)) {
clientsMutex.FastLock();
bool added = false;
for (uint32 i=0; i<MAX_CLIENTS; i++) {
if (activeClients[i] == NULL_PTR(BasicTCPSocket*)) {
activeClients[i] = newClient;
added = true;
break;
}
}
clientsMutex.FastUnLock();
if (!added) {
newClient->Close();
delete newClient;
} else {
(void)newClient->SetBlocking(false);
}
}
// 2. Stream data to clients
bool hadData = false;
while (readIdx != writeIdx) {
hadData = true;
uint32 idx = readIdx % QUEUE_SIZE;
TcpLogEntry &entry = queue[idx];
StreamString level;
ErrorManagement::ErrorCodeToStream(entry.info.header.errorType, level);
StreamString packet;
packet.Printf("LOG %s %s\n", level.Buffer(), entry.description);
uint32 size = packet.Size();
clientsMutex.FastLock();
for (uint32 j=0; j<MAX_CLIENTS; j++) {
if (activeClients[j] != NULL_PTR(BasicTCPSocket*)) {
uint32 s = size;
if (!activeClients[j]->Write(packet.Buffer(), s)) {
activeClients[j]->Close();
delete activeClients[j];
activeClients[j] = NULL_PTR(BasicTCPSocket*);
}
}
}
clientsMutex.FastUnLock();
readIdx = (readIdx + 1) % QUEUE_SIZE;
}
if (!hadData) {
(void)eventSem.Wait(TimeoutType(100));
eventSem.Reset();
} else {
Sleep::MSec(1);
}
}
return ErrorManagement::NoError;
}
}

56
TUTORIAL.md Normal file
View File

@@ -0,0 +1,56 @@
# Tutorial: High-Speed Observability with MARTe2 Debug GUI
This guide will walk you through the process of tracing and forcing signals in a real-time MARTe2 application using the native Rust GUI client.
## 1. Environment Setup
### Launch the MARTe2 Application
First, start your application using the provided debug runner. This script launches the standard `MARTeApp.ex` while injecting the debugging layer:
```bash
./run_debug_app.sh
```
*Note: You should see logs indicating the `DebugService` has started on port 8080 and `TcpLogger` on port 8082.*
### Start the GUI Client
In a new terminal window, navigate to the client directory and run the GUI:
```bash
cd Tools/gui_client
cargo run --release
```
## 2. Exploring the Object Tree
Once connected, the left panel (**Application Tree**) displays the live hierarchy of your application.
1. **Navigate to Data:** Expand `Root` -> `App` -> `Data`.
2. **Inspect Nodes:** Click the ** Info** button next to any node (like `Timer` or `DDB`).
3. **View Metadata:** The bottom-left pane will display the full JSON configuration of that object, including its class, parameters, and signals.
## 3. Real-Time Signal Tracing (Oscilloscope)
Tracing allows you to see signal values exactly as they exist in the real-time memory map.
1. **Find a Signal:** In the tree, locate `Root.App.Data.Timer.Counter`.
2. **Activate Trace:** Click the **📈 Trace** button.
3. **Monitor the Scope:** The central **Oscilloscope** panel will begin plotting the signal.
4. **Verify Data Flow:** Check the **UDP Packets** counter in the top bar; it should be increasing rapidly, confirming high-speed data reception (Port 8081).
5. **Multi-Signal Trace:** You can click **📈 Trace** on other signals (like `Time`) to overlay multiple plots.
## 4. Signal Forcing (Manual Override)
Forcing allows you to bypass the framework logic and manually set a signal's value in memory.
1. **Locate Target:** Find a signal that is being written by a GAM, such as `Root.App.Data.DDB.Counter`.
2. **Open Force Dialog:** Click the **⚡ Force** button next to the signal.
3. **Inject Value:** In the popup dialog, enter a new value (e.g., `9999`) and click **Apply Force**.
4. **Observe Effect:** If you are tracing the same signal, the oscilloscope plot will immediately jump to and hold at `9999`.
5. **Release Control:** To stop forcing, click the **❌** button in the **Active Controls** (Right Panel) under "Forced Signals". The framework will resume writing its own values to that memory location.
## 5. Advanced Controls
### Global Pause
If you need to "freeze" the entire application to inspect a specific state:
- Click **⏸ Pause** in the top bar. The real-time threads will halt at the start of their next cycle.
- Click **▶ Resume** to restart the execution.
### Log Terminal
The bottom panel displays every `REPORT_ERROR` event from the C++ framework, powered by the standalone `TcpLogger` service.
- **Regex Filter:** Type a keyword like `Timer` in the filter box to isolate relevant events.
- **Pause Logs:** Toggle **⏸ Pause Logs** to stop the scrolling view while data continues to be captured in the background.

View File

@@ -1,18 +1,3 @@
+DebugService = {
Class = DebugService
ControlPort = 8080
StreamPort = 8081
StreamIP = "127.0.0.1"
}
+LoggerService = {
Class = LoggerService
CPUs = 0x1
+DebugConsumer = {
Class = DebugService
}
}
+App = {
Class = RealTimeApplication
+Functions = {
@@ -23,7 +8,7 @@
Counter = {
DataSource = Timer
Type = uint32
Frequency = 10
Frequency = 1000
}
Time = {
DataSource = Timer
@@ -47,7 +32,6 @@
DefaultDataSource = DDB
+Timer = {
Class = LinuxTimer
SleepTime = 1000000 // 1 second
Signals = {
Counter = {
Type = uint32
@@ -99,3 +83,19 @@
TimingDataSource = DAMS
}
}
+DebugService = {
Class = DebugService
ControlPort = 8080
UdpPort = 8081
StreamIP = "127.0.0.1"
}
+LoggerService = {
Class = LoggerService
CPUs = 0x1
+DebugConsumer = {
Class = TcpLogger
Port = 8082
}
}

View File

@@ -6,3 +6,6 @@ target_link_libraries(TraceTest marte_dev ${MARTe2_LIB})
add_executable(ValidationTest ValidationTest.cpp)
target_link_libraries(ValidationTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${LinuxTimer_LIB})
add_executable(SchedulerTest SchedulerTest.cpp)
target_link_libraries(SchedulerTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${LinuxTimer_LIB})

View File

@@ -0,0 +1,202 @@
#include "DebugService.h"
#include "DebugCore.h"
#include "ObjectRegistryDatabase.h"
#include "StandardParser.h"
#include "StreamString.h"
#include "BasicUDPSocket.h"
#include "BasicTCPSocket.h"
#include "RealTimeApplication.h"
#include "GlobalObjectsDatabase.h"
#include "MessageI.h"
#include <assert.h>
#include <stdio.h>
using namespace MARTe;
const char8 * const config_text =
"+DebugService = {"
" Class = DebugService "
" ControlPort = 8080 "
" UdpPort = 8081 "
" StreamIP = \"127.0.0.1\" "
"}"
"+App = {"
" Class = RealTimeApplication "
" +Functions = {"
" Class = ReferenceContainer "
" +GAM1 = {"
" Class = IOGAM "
" InputSignals = {"
" Counter = {"
" DataSource = Timer "
" Type = uint32 "
" }"
" }"
" OutputSignals = {"
" Counter = {"
" DataSource = DDB "
" Type = uint32 "
" }"
" }"
" }"
" }"
" +Data = {"
" Class = ReferenceContainer "
" DefaultDataSource = DDB "
" +Timer = {"
" Class = LinuxTimer "
" SleepTime = 100000 " // 100ms
" Signals = {"
" Counter = { Type = uint32 }"
" }"
" }"
" +DDB = {"
" Class = GAMDataSource "
" Signals = { Counter = { Type = uint32 } }"
" }"
" +DAMS = { Class = TimingDataSource }"
" }"
" +States = {"
" Class = ReferenceContainer "
" +State1 = {"
" Class = RealTimeState "
" +Threads = {"
" Class = ReferenceContainer "
" +Thread1 = {"
" Class = RealTimeThread "
" Functions = {GAM1} "
" }"
" }"
" }"
" }"
" +Scheduler = {"
" Class = FastScheduler "
" TimingDataSource = DAMS "
" }"
"}";
void TestSchedulerControl() {
printf("--- MARTe2 Scheduler Control Test ---\n");
ConfigurationDatabase cdb;
StreamString ss = config_text;
ss.Seek(0);
StandardParser parser(ss, cdb);
assert(parser.Parse());
assert(ObjectRegistryDatabase::Instance()->Initialise(cdb));
ReferenceT<DebugService> service = ObjectRegistryDatabase::Instance()->Find("DebugService");
assert(service.IsValid());
ReferenceT<RealTimeApplication> app = ObjectRegistryDatabase::Instance()->Find("App");
assert(app.IsValid());
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
printf("ERROR: Failed to prepare State1\n");
return;
}
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
printf("ERROR: Failed to start execution\n");
return;
}
printf("Application started. Waiting for cycles...\n");
Sleep::MSec(1000);
// Enable Trace First
{
BasicTCPSocket tClient;
if (tClient.Connect("127.0.0.1", 8080)) {
const char* cmd = "TRACE Root.App.Data.Timer.Counter 1\n";
uint32 s = StringHelper::Length(cmd);
tClient.Write(cmd, s);
tClient.Close();
} else {
printf("WARNING: Could not connect to DebugService to enable trace.\n");
}
}
BasicUDPSocket listener;
listener.Open();
listener.Listen(8081);
// Read current value
uint32 valBeforePause = 0;
char buffer[2048];
uint32 size = 2048;
TimeoutType timeout(500);
if (listener.Read(buffer, size, timeout)) {
// [Header][ID][Size][Value]
valBeforePause = *(uint32*)(&buffer[28]);
printf("Value before/at pause: %u\n", valBeforePause);
} else {
printf("WARNING: No data received before pause.\n");
}
// Send PAUSE
printf("Sending PAUSE command...\n");
BasicTCPSocket client;
if (client.Connect("127.0.0.1", 8080)) {
const char* cmd = "PAUSE\n";
uint32 s = StringHelper::Length(cmd);
client.Write(cmd, s);
client.Close();
} else {
printf("ERROR: Could not connect to DebugService to send PAUSE.\n");
}
Sleep::MSec(2000); // Wait 2 seconds
// Read again - should be same or very close if paused
uint32 valAfterWait = 0;
size = 2048; // Reset size
while(listener.Read(buffer, size, TimeoutType(10))) {
valAfterWait = *(uint32*)(&buffer[28]);
size = 2048;
}
printf("Value after 2s wait (drained): %u\n", valAfterWait);
// Check if truly paused
if (valAfterWait > valBeforePause + 5) {
printf("FAILURE: Counter increased significantly while paused! (%u -> %u)\n", valBeforePause, valAfterWait);
} else {
printf("SUCCESS: Counter held steady (or close) during pause.\n");
}
// Resume
printf("Sending RESUME command...\n");
{
BasicTCPSocket rClient;
if (rClient.Connect("127.0.0.1", 8080)) {
const char* cmd = "RESUME\n";
uint32 s = StringHelper::Length(cmd);
rClient.Write(cmd, s);
rClient.Close();
}
}
Sleep::MSec(1000);
// Check if increasing
uint32 valAfterResume = 0;
size = 2048;
if (listener.Read(buffer, size, timeout)) {
valAfterResume = *(uint32*)(&buffer[28]);
printf("Value after resume: %u\n", valAfterResume);
}
if (valAfterResume > valAfterWait) {
printf("SUCCESS: Execution resumed.\n");
} else {
printf("FAILURE: Execution did not resume.\n");
}
app->StopCurrentStateExecution();
}
int main() {
TestSchedulerControl();
return 0;
}

View File

@@ -6,194 +6,168 @@
#include "BasicUDPSocket.h"
#include "BasicTCPSocket.h"
#include "RealTimeApplication.h"
#include "GlobalObjectsDatabase.h"
#include "RealTimeLoader.h"
#include <assert.h>
#include <stdio.h>
using namespace MARTe;
const char8 * const config_text =
"+DebugService = {"
// Removed '+' prefix from names for simpler lookup
const char8 * const simple_config =
"DebugService = {"
" Class = DebugService "
" ControlPort = 8080 "
" UdpPort = 8081 "
" StreamIP = \"127.0.0.1\" "
"}"
"+App = {"
"App = {"
" Class = RealTimeApplication "
" +Functions = {"
" Class = ReferenceContainer "
" +GAM1 = {"
" Class = IOGAM "
" InputSignals = {"
" Counter = {"
" DataSource = Timer "
" Type = uint32 "
" }"
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
" Time = { DataSource = Timer Type = uint32 }"
" }"
" OutputSignals = {"
" Counter = {"
" DataSource = DDB "
" Type = uint32 "
" }"
" Counter = { DataSource = DDB Type = uint32 }"
" Time = { DataSource = DDB Type = uint32 }"
" }"
" }"
" }"
" +Data = {"
" Class = ReferenceContainer "
" DefaultDataSource = DDB "
" +Timer = {"
" Class = LinuxTimer "
" SleepTime = 10000 "
" Signals = {"
" Counter = { Type = uint32 }"
" }"
" }"
" +DDB = {"
" Class = GAMDataSource "
" Signals = { Counter = { Type = uint32 } }"
" }"
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } Time = { Type = uint32 } } }"
" +DDB = { Class = GAMDataSource Signals = { Counter = { Type = uint32 } Time = { Type = uint32 } } }"
" +DAMS = { Class = TimingDataSource }"
" }"
" +States = {"
" Class = ReferenceContainer "
" +State1 = {"
" Class = RealTimeState "
" +Threads = {"
" Class = ReferenceContainer "
" +Thread1 = {"
" Class = RealTimeThread "
" Functions = {GAM1} "
" }"
" }"
" }"
" }"
" +Scheduler = {"
" Class = GAMScheduler "
" TimingDataSource = DAMS "
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1} } } }"
" }"
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
"}";
void RunValidationTest() {
printf("--- MARTe2 100Hz Trace Validation Test ---\n");
printf("--- MARTe2 1kHz Lossless Trace Validation Test ---\n");
ObjectRegistryDatabase::Instance()->Purge();
// 1. Load Configuration
ConfigurationDatabase cdb;
StreamString ss = config_text;
StreamString ss = simple_config;
ss.Seek(0);
StandardParser parser(ss, cdb);
if (!parser.Parse()) {
printf("ERROR: Failed to parse configuration\n");
assert(parser.Parse());
cdb.MoveToRoot();
uint32 n = cdb.GetNumberOfChildren();
for (uint32 i=0; i<n; i++) {
const char8* name = cdb.GetChildName(i);
ConfigurationDatabase child;
cdb.MoveRelative(name);
cdb.Copy(child);
cdb.MoveToAncestor(1u);
StreamString className;
child.Read("Class", className);
Reference ref(className.Buffer(), GlobalObjectsDatabase::Instance()->GetStandardHeap());
ref->SetName(name);
assert(ref->Initialise(child));
ObjectRegistryDatabase::Instance()->Insert(ref);
}
Reference serviceGeneric = ObjectRegistryDatabase::Instance()->Find("DebugService");
Reference appGeneric = ObjectRegistryDatabase::Instance()->Find("App");
if (!serviceGeneric.IsValid() || !appGeneric.IsValid()) {
printf("ERROR: Objects NOT FOUND even without prefix\n");
return;
}
if (!ObjectRegistryDatabase::Instance()->Initialise(cdb)) {
printf("ERROR: Failed to initialise ObjectRegistryDatabase.\n");
DebugService *service = dynamic_cast<DebugService*>(serviceGeneric.operator->());
RealTimeApplication *app = dynamic_cast<RealTimeApplication*>(appGeneric.operator->());
assert(service);
assert(app);
if (!app->ConfigureApplication()) {
printf("ERROR: ConfigureApplication failed.\n");
return;
}
// 2. Start Application
ReferenceT<RealTimeApplication> app = ObjectRegistryDatabase::Instance()->Find("App");
if (!app.IsValid()) {
printf("ERROR: App not found\n");
return;
}
assert(app->PrepareNextState("State1") == ErrorManagement::NoError);
assert(app->StartNextStateExecution() == ErrorManagement::NoError);
// We try to use State1 directly as many MARTe2 apps start in the first defined state if no transition is needed
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
printf("ERROR: Failed to prepare state State1\n");
// We will try to investigate why, but for now we continue
}
printf("Application started at 1kHz. Enabling Traces...\n");
Sleep::MSec(500);
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
printf("ERROR: Failed to start execution. Maybe it needs an explicit state?\n");
// return;
}
// The registered name in DebugBrokerWrapper depends on GetFullObjectName
// With App as root, it should be App.Data.Timer.Counter
service->TraceSignal("App.Data.Timer.Counter", true, 1);
printf("Application started at 100Hz.\n");
Sleep::MSec(1000);
// 3. Enable Trace via TCP (Simulating GUI)
BasicTCPSocket client;
if (client.Connect("127.0.0.1", 8080)) {
const char* cmd = "TRACE Root.App.Data.Timer.Counter 1\n";
uint32 s = StringHelper::Length(cmd);
client.Write(cmd, s);
char resp[1024]; s = 1024;
TimeoutType timeout(1000);
if (client.Read(resp, s, timeout)) {
resp[s] = '\0';
printf("Server Response: %s", resp);
} else {
printf("WARNING: No response from server to TRACE command.\n");
}
client.Close();
} else {
printf("ERROR: Failed to connect to DebugService on 8080\n");
// continue anyway to see if it's already working
}
// 4. Setup UDP Listener
BasicUDPSocket listener;
if (!listener.Open()) { printf("ERROR: Failed to open UDP socket\n"); return; }
if (!listener.Listen(8081)) { printf("ERROR: Failed to listen on UDP 8081\n"); return; }
listener.Open();
listener.Listen(8081);
// 5. Validate for 30 seconds
printf("Validating telemetry for 30 seconds...\n");
uint32 lastVal = 0;
printf("Validating for 10 seconds...\n");
uint32 lastCounter = 0;
bool first = true;
uint32 packetCount = 0;
uint32 discontinuityCount = 0;
uint32 totalSamples = 0;
uint32 discontinuities = 0;
uint32 totalPackets = 0;
float64 startTime = HighResolutionTimer::Counter() * HighResolutionTimer::Period();
float64 startTest = HighResolutionTimer::Counter() * HighResolutionTimer::Period();
while ((HighResolutionTimer::Counter() * HighResolutionTimer::Period() - startTime) < 30.0) {
char buffer[2048];
uint32 size = 2048;
TimeoutType timeout(500);
if (listener.Read(buffer, size, timeout)) {
while ((HighResolutionTimer::Counter() * HighResolutionTimer::Period() - startTest) < 10.0) {
char buffer[4096];
uint32 size = 4096;
if (listener.Read(buffer, size, TimeoutType(100))) {
totalPackets++;
TraceHeader *h = (TraceHeader*)buffer;
if (h->magic == 0xDA7A57AD && h->count > 0) {
uint32 offset = sizeof(TraceHeader);
// Packet format: [Header][ID:4][Size:4][Value:N]
if (h->magic != 0xDA7A57AD) continue;
uint32 offset = sizeof(TraceHeader);
for (uint32 i=0; i<h->count; i++) {
uint32 sigId = *(uint32*)(&buffer[offset]);
uint32 val = *(uint32*)(&buffer[offset + 8]);
if (!first) {
if (val != lastVal + 1) {
discontinuityCount++;
if (sigId == 0) {
if (!first) {
if (val != lastCounter + 1) {
discontinuities++;
}
}
lastCounter = val;
totalSamples++;
}
lastVal = val;
first = false;
packetCount++;
if (packetCount % 500 == 0) {
printf("Received %u packets... Current Value: %u\n", packetCount, val);
}
uint32 sigSize = *(uint32*)(&buffer[offset + 4]);
offset += (8 + sigSize);
}
first = false;
}
}
printf("Test Finished.\n");
printf("Total Packets Received: %u (Expected ~3000)\n", packetCount);
printf("Discontinuities: %u\n", discontinuityCount);
printf("\n--- Test Results ---\n");
printf("Total UDP Packets: %u\n", totalPackets);
printf("Total Counter Samples: %u\n", totalSamples);
printf("Counter Discontinuities: %u\n", discontinuities);
float64 actualFreq = (float64)packetCount / 30.0;
printf("Average Frequency: %.2f Hz\n", actualFreq);
if (packetCount < 100) {
printf("FAILURE: Almost no packets received. Telemetry is broken.\n");
} else if (packetCount < 2500) {
printf("WARNING: Too few packets received (Expected 3000, Got %u).\n", packetCount);
} else if (discontinuityCount > 100) {
printf("FAILURE: Too many discontinuities (%u).\n", discontinuityCount);
if (totalSamples < 9000) {
printf("FAILURE: Underflow - samples missing (%u).\n", totalSamples);
} else if (discontinuities > 10) {
printf("FAILURE: Excessive discontinuities detected! (%u)\n", discontinuities);
} else {
printf("VALIDATION SUCCESSFUL!\n");
printf("VALIDATION SUCCESSFUL: 1kHz Lossless Tracing Verified.\n");
}
app->StopCurrentStateExecution();
listener.Close();
ObjectRegistryDatabase::Instance()->Purge();
}
int main() {

View File

@@ -1,35 +1,108 @@
#include <stdio.h>
#include <assert.h>
#include "DebugCore.h"
#include "DebugService.h"
#include "TcpLogger.h"
#include "ConfigurationDatabase.h"
#include "ObjectRegistryDatabase.h"
#include "StandardParser.h"
using namespace MARTe;
void TestRingBuffer() {
printf("Testing TraceRingBuffer...\n");
TraceRingBuffer rb;
assert(rb.Init(1024));
// Each entry is 4(ID) + 4(Size) + 4(Val) = 12 bytes.
// 100 entries = 1200 bytes.
assert(rb.Init(2048));
uint32 id = 42;
uint32 val = 12345678;
// Fill buffer to test wrap-around
uint32 id = 1;
uint32 val = 0xAAAAAAAA;
uint32 size = 4;
assert(rb.Push(id, &val, size));
assert(rb.Count() > 0);
for (int i=0; i<100; i++) {
id = i;
val = 0xBBBB0000 | i;
if (!rb.Push(id, &val, size)) {
printf("Failed at iteration %d\n", i);
assert(false);
}
}
uint32 poppedId = 0;
uint32 poppedVal = 0;
uint32 poppedSize = 0;
assert(rb.Count() == 100 * (4 + 4 + 4));
assert(rb.Pop(poppedId, &poppedVal, poppedSize, 4));
assert(poppedId == 42);
assert(poppedVal == 12345678);
assert(poppedSize == 4);
uint32 pId, pVal, pSize;
for (int i=0; i<100; i++) {
assert(rb.Pop(pId, &pVal, pSize, 4));
assert(pId == (uint32)i);
assert(pVal == (0xBBBB0000 | (uint32)i));
}
assert(rb.Count() == 0);
printf("TraceRingBuffer test passed.\n");
}
void TestSuffixMatch() {
printf("Testing SuffixMatch...\n");
DebugService service;
uint32 mock = 0;
service.RegisterSignal(&mock, UnsignedInteger32Bit, "App.Data.Timer.Counter");
// Should match
assert(service.TraceSignal("App.Data.Timer.Counter", true) == 1);
assert(service.TraceSignal("Timer.Counter", true) == 1);
assert(service.TraceSignal("Counter", true) == 1);
// Should NOT match
assert(service.TraceSignal("App.Timer", true) == 0);
assert(service.TraceSignal("unt", true) == 0);
printf("SuffixMatch test passed.\n");
}
void TestTcpLogger() {
printf("Testing TcpLogger...\n");
TcpLogger logger;
ConfigurationDatabase config;
config.Write("Port", (uint16)9999);
assert(logger.Initialise(config));
REPORT_ERROR_STATIC(ErrorManagement::Information, "Unit Test Log Message");
printf("TcpLogger basic test passed.\n");
}
void TestDebugServiceRegistration() {
printf("Testing DebugService Signal Registration...\n");
DebugService service;
uint32 val1 = 10;
float32 val2 = 20.0;
DebugSignalInfo* s1 = service.RegisterSignal(&val1, UnsignedInteger32Bit, "Signal1");
DebugSignalInfo* s2 = service.RegisterSignal(&val2, Float32Bit, "Signal2");
assert(s1 != NULL_PTR(DebugSignalInfo*));
assert(s2 != NULL_PTR(DebugSignalInfo*));
assert(s1->internalID == 0);
assert(s2->internalID == 1);
// Re-register same address
DebugSignalInfo* s1_alias = service.RegisterSignal(&val1, UnsignedInteger32Bit, "Signal1_Alias");
assert(s1_alias == s1);
printf("DebugService registration test passed.\n");
}
int main(int argc, char **argv) {
printf("Running MARTe2 Component Tests...\n");
printf("Running MARTe2 Debug Suite Unit Tests...\n");
TestRingBuffer();
TestDebugServiceRegistration();
TestSuffixMatch();
TestTcpLogger();
printf("\nALL UNIT TESTS PASSED!\n");
return 0;
}

View File

@@ -525,12 +525,6 @@ dependencies = [
"syn",
]
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
@@ -1798,16 +1792,15 @@ dependencies = [
name = "marte_debug_gui"
version = "0.1.0"
dependencies = [
"byteorder",
"chrono",
"crossbeam-channel",
"eframe",
"egui",
"egui_plot",
"once_cell",
"regex",
"serde",
"serde_json",
"tokio",
"socket2",
]
[[package]]
@@ -1859,17 +1852,6 @@ dependencies = [
"simd-adler32",
]
[[package]]
name = "mio"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
dependencies = [
"libc",
"wasi",
"windows-sys 0.61.2",
]
[[package]]
name = "moxcms"
version = "0.7.11"
@@ -2891,12 +2873,12 @@ dependencies = [
[[package]]
name = "socket2"
version = "0.6.2"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -3081,34 +3063,6 @@ dependencies = [
"zerovec",
]
[[package]]
name = "tokio"
version = "1.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
dependencies = [
"bytes",
"libc",
"mio",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-macros"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "toml_datetime"
version = "0.7.5+spec-1.1.0"

View File

@@ -5,12 +5,11 @@ edition = "2021"
[dependencies]
eframe = "0.31.0"
egui = "0.31.0"
egui_plot = "0.31.0"
tokio = { version = "1.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
byteorder = "1.4"
chrono = "0.4"
crossbeam-channel = "0.5"
regex = "1.12.3"
regex = "1.10"
socket2 = { version = "0.5", features = ["all"] }
once_cell = "1.21.3"

View File

@@ -1,5 +1,5 @@
use eframe::egui;
use egui_plot::{Line, Plot, PlotPoints};
use egui_plot::{Line, Plot, PlotPoints, MarkerShape, LineStyle, PlotBounds};
use std::collections::{HashMap, VecDeque};
use std::net::{TcpStream, UdpSocket};
use std::io::{Write, BufReader, BufRead};
@@ -8,7 +8,11 @@ use std::thread;
use serde::{Deserialize, Serialize};
use chrono::Local;
use crossbeam_channel::{unbounded, Receiver, Sender};
use socket2::{Socket, Domain, Type, Protocol};
use regex::Regex;
use once_cell::sync::Lazy;
static APP_START_TIME: Lazy<std::time::Instant> = Lazy::new(std::time::Instant::now);
// --- Models ---
@@ -51,6 +55,7 @@ struct LogEntry {
struct TraceData {
values: VecDeque<[f64; 2]>,
last_value: f64,
}
struct SignalMetadata {
@@ -58,6 +63,57 @@ struct SignalMetadata {
sig_type: String,
}
#[derive(Clone)]
struct ConnectionConfig {
ip: String,
tcp_port: String,
udp_port: String,
log_port: String,
version: u64,
}
#[derive(Clone, Copy, PartialEq, Debug)]
enum PlotType {
Normal,
LogicAnalyzer,
}
#[derive(Clone, Copy, PartialEq, Debug)]
enum MarkerType {
None,
Circle,
Square,
}
impl MarkerType {
fn to_shape(&self) -> Option<MarkerShape> {
match self {
MarkerType::None => None,
MarkerType::Circle => Some(MarkerShape::Circle),
MarkerType::Square => Some(MarkerShape::Square),
}
}
}
#[derive(Clone)]
struct SignalPlotConfig {
source_name: String,
label: String,
unit: String,
color: egui::Color32,
line_style: LineStyle,
marker_type: MarkerType,
gain: f64,
offset: f64,
}
struct PlotInstance {
id: String,
plot_type: PlotType,
signals: Vec<SignalPlotConfig>,
auto_bounds: bool,
}
enum InternalEvent {
Log(LogEntry),
Discovery(Vec<Signal>),
@@ -65,64 +121,55 @@ enum InternalEvent {
CommandResponse(String),
NodeInfo(String),
Connected,
Disconnected,
InternalLog(String),
TraceRequested(String),
ClearTrace(String),
UdpStats(u64),
UdpDropped(u32),
}
// --- App State ---
struct ForcingDialog {
signal_path: String,
sig_type: String,
dims: u8,
elems: u32,
value: String,
}
struct LogFilters {
content_regex: String,
show_debug: bool,
show_info: bool,
show_warning: bool,
show_error: bool,
paused: bool,
content_regex: String,
}
struct MarteDebugApp {
#[allow(dead_code)]
connected: bool,
tcp_addr: String,
log_addr: String,
signals: Vec<Signal>,
is_breaking: bool,
config: ConnectionConfig,
shared_config: Arc<Mutex<ConnectionConfig>>,
app_tree: Option<TreeItem>,
traced_signals: Arc<Mutex<HashMap<String, TraceData>>>,
id_to_meta: Arc<Mutex<HashMap<u32, SignalMetadata>>>,
traced_signals: Arc<Mutex<HashMap<String, TraceData>>>,
plots: Vec<PlotInstance>,
forced_signals: HashMap<String, String>,
is_paused: bool,
logs: VecDeque<LogEntry>,
log_filters: LogFilters,
// UI Panels
show_left_panel: bool,
show_right_panel: bool,
show_bottom_panel: bool,
selected_node: String,
node_info: String,
udp_packets: u64,
udp_dropped: u64,
forcing_dialog: Option<ForcingDialog>,
style_editor: Option<(usize, usize)>,
tx_cmd: Sender<String>,
rx_events: Receiver<InternalEvent>,
internal_tx: Sender<InternalEvent>,
shared_x_range: Option<[f64; 2]>,
}
impl MarteDebugApp {
@@ -130,192 +177,124 @@ impl MarteDebugApp {
let (tx_cmd, rx_cmd_internal) = unbounded::<String>();
let (tx_events, rx_events) = unbounded::<InternalEvent>();
let internal_tx = tx_events.clone();
let tcp_addr = "127.0.0.1:8080".to_string();
let log_addr = "127.0.0.1:8082".to_string();
let config = ConnectionConfig { ip: "127.0.0.1".to_string(), tcp_port: "8080".to_string(), udp_port: "8081".to_string(), log_port: "8082".to_string(), version: 0 };
let shared_config = Arc::new(Mutex::new(config.clone()));
let id_to_meta = Arc::new(Mutex::new(HashMap::new()));
let traced_signals = Arc::new(Mutex::new(HashMap::new()));
let id_to_meta_clone = id_to_meta.clone();
let traced_signals_clone = traced_signals.clone();
let shared_config_cmd = shared_config.clone();
let shared_config_log = shared_config.clone();
let shared_config_udp = shared_config.clone();
let tx_events_c = tx_events.clone();
thread::spawn(move || {
tcp_command_worker(tcp_addr, rx_cmd_internal, tx_events_c);
});
thread::spawn(move || { tcp_command_worker(shared_config_cmd, rx_cmd_internal, tx_events_c); });
let tx_events_log = tx_events.clone();
thread::spawn(move || {
tcp_log_worker(log_addr, tx_events_log);
});
thread::spawn(move || { tcp_log_worker(shared_config_log, tx_events_log); });
let tx_events_udp = tx_events.clone();
thread::spawn(move || {
udp_worker(8081, id_to_meta_clone, traced_signals_clone, tx_events_udp);
});
thread::spawn(move || { udp_worker(shared_config_udp, id_to_meta_clone, traced_signals_clone, tx_events_udp); });
Self {
connected: false,
tcp_addr: "127.0.0.1:8080".to_string(),
log_addr: "127.0.0.1:8082".to_string(),
signals: Vec::new(),
app_tree: None,
id_to_meta,
traced_signals,
forced_signals: HashMap::new(),
is_paused: false,
logs: VecDeque::with_capacity(2000),
log_filters: LogFilters {
content_regex: "".to_string(),
show_debug: true,
show_info: true,
show_warning: true,
show_error: true,
paused: false,
},
show_left_panel: true,
show_right_panel: true,
show_bottom_panel: true,
selected_node: "".to_string(),
node_info: "".to_string(),
udp_packets: 0,
forcing_dialog: None,
tx_cmd,
rx_events,
internal_tx,
connected: false, is_breaking: false, config, shared_config, app_tree: None, id_to_meta, traced_signals,
plots: vec![PlotInstance { id: "Plot 1".to_string(), plot_type: PlotType::Normal, signals: Vec::new(), auto_bounds: true }],
forced_signals: HashMap::new(), logs: VecDeque::with_capacity(2000),
log_filters: LogFilters { show_debug: true, show_info: true, show_warning: true, show_error: true, paused: false, content_regex: "".to_string() },
show_left_panel: true, show_right_panel: true, show_bottom_panel: true,
selected_node: "".to_string(), node_info: "".to_string(),
udp_packets: 0, udp_dropped: 0,
forcing_dialog: None, style_editor: None,
tx_cmd, rx_events, internal_tx,
shared_x_range: None,
}
}
fn next_color(idx: usize) -> egui::Color32 {
let colors = [
egui::Color32::from_rgb(100, 200, 255), egui::Color32::from_rgb(255, 100, 100),
egui::Color32::from_rgb(100, 255, 100), egui::Color32::from_rgb(255, 200, 100),
egui::Color32::from_rgb(255, 100, 255), egui::Color32::from_rgb(100, 255, 255),
egui::Color32::from_rgb(200, 255, 100), egui::Color32::WHITE,
];
colors[idx % colors.len()]
}
fn render_tree(&mut self, ui: &mut egui::Ui, item: &TreeItem, path: String) {
let current_path = if path.is_empty() {
item.name.clone()
} else if path == "Root" {
item.name.clone()
} else {
format!("{}.{}", path, item.name)
};
let current_path = if path.is_empty() { if item.name == "Root" { "".to_string() } else { item.name.clone() } }
else { if path.is_empty() { item.name.clone() } else { format!("{}.{}", path, item.name) } };
let label = if item.class == "Signal" { format!("📈 {}", item.name) } else { item.name.clone() };
if let Some(children) = &item.children {
let header = egui::CollapsingHeader::new(format!("{} [{}]", item.name, item.class))
.id_salt(&current_path);
let header = egui::CollapsingHeader::new(format!("{} [{}]", label, item.class)).id_salt(&current_path);
header.show(ui, |ui| {
ui.horizontal(|ui| {
if ui.selectable_label(self.selected_node == current_path, " Info").clicked() {
self.selected_node = current_path.clone();
let _ = self.tx_cmd.send(format!("INFO {}", current_path));
}
});
for child in children {
self.render_tree(ui, child, current_path.clone());
}
ui.horizontal(|ui| { if !current_path.is_empty() { if ui.selectable_label(self.selected_node == current_path, " Info").clicked() { self.selected_node = current_path.clone(); let _ = self.tx_cmd.send(format!("INFO {}", current_path)); } } });
for child in children { self.render_tree(ui, child, current_path.clone()); }
});
} else {
ui.horizontal(|ui| {
if ui.selectable_label(self.selected_node == current_path, format!("{} [{}]", item.name, item.class)).clicked() {
self.selected_node = current_path.clone();
let _ = self.tx_cmd.send(format!("INFO {}", current_path));
}
if ui.selectable_label(self.selected_node == current_path, format!("{} [{}]", label, item.class)).clicked() { self.selected_node = current_path.clone(); let _ = self.tx_cmd.send(format!("INFO {}", current_path)); }
if item.class.contains("Signal") {
if ui.button("📈 Trace").clicked() {
let _ = self.tx_cmd.send(format!("TRACE {} 1", current_path));
let _ = self.internal_tx.send(InternalEvent::TraceRequested(current_path.clone()));
}
if ui.button("⚡ Force").clicked() {
self.forcing_dialog = Some(ForcingDialog {
signal_path: current_path.clone(),
sig_type: item.sig_type.clone().unwrap_or_else(|| "Unknown".to_string()),
dims: item.dimensions.unwrap_or(0),
elems: item.elements.unwrap_or(1),
value: "".to_string(),
});
}
if ui.button("Trace").clicked() { let _ = self.tx_cmd.send(format!("TRACE {} 1", current_path)); let _ = self.internal_tx.send(InternalEvent::TraceRequested(current_path.clone())); }
if ui.button("⚡ Force").clicked() { self.forcing_dialog = Some(ForcingDialog { signal_path: current_path.clone(), value: "".to_string() }); }
}
});
}
}
}
fn tcp_command_worker(addr: String, rx_cmd: Receiver<String>, tx_events: Sender<InternalEvent>) {
fn tcp_command_worker(shared_config: Arc<Mutex<ConnectionConfig>>, rx_cmd: Receiver<String>, tx_events: Sender<InternalEvent>) {
let mut current_version = 0;
let mut current_addr = String::new();
loop {
if let Ok(mut stream) = TcpStream::connect(&addr) {
{ let config = shared_config.lock().unwrap(); if config.version != current_version { current_version = config.version; current_addr = format!("{}:{}", config.ip, config.tcp_port); } }
if current_addr.is_empty() || current_addr.starts_with(":") { thread::sleep(std::time::Duration::from_secs(1)); continue; }
if let Ok(mut stream) = TcpStream::connect(&current_addr) {
let _ = stream.set_nodelay(true);
let mut reader = BufReader::new(stream.try_clone().unwrap());
let _ = tx_events.send(InternalEvent::Connected);
let stop_flag = Arc::new(Mutex::new(false));
let stop_flag_reader = stop_flag.clone();
let tx_events_inner = tx_events.clone();
thread::spawn(move || {
let mut line = String::new();
let mut json_acc = String::new();
let mut in_json = false;
while reader.read_line(&mut line).is_ok() {
if *stop_flag_reader.lock().unwrap() { break; }
let trimmed = line.trim();
if trimmed.is_empty() { line.clear(); continue; }
if !in_json && trimmed.starts_with("{") {
in_json = true;
json_acc.clear();
}
if !in_json && trimmed.starts_with("{") { in_json = true; json_acc.clear(); }
if in_json {
json_acc.push_str(trimmed);
if trimmed == "OK DISCOVER" {
in_json = false;
let json_clean = json_acc.trim_end_matches("OK DISCOVER").trim();
match serde_json::from_str::<DiscoverResponse>(json_clean) {
Ok(resp) => { let _ = tx_events_inner.send(InternalEvent::Discovery(resp.signals)); }
Err(e) => { let _ = tx_events_inner.send(InternalEvent::InternalLog(format!("JSON Parse Error (Discover): {}", e))); }
}
json_acc.clear();
} else if trimmed == "OK TREE" {
in_json = false;
let json_clean = json_acc.trim_end_matches("OK TREE").trim();
match serde_json::from_str::<TreeItem>(json_clean) {
Ok(resp) => { let _ = tx_events_inner.send(InternalEvent::Tree(resp)); }
Err(e) => { let _ = tx_events_inner.send(InternalEvent::InternalLog(format!("JSON Parse Error (Tree): {}", e))); }
}
json_acc.clear();
} else if trimmed == "OK INFO" {
in_json = false;
let json_clean = json_acc.trim_end_matches("OK INFO").trim();
let _ = tx_events_inner.send(InternalEvent::NodeInfo(json_clean.to_string()));
json_acc.clear();
}
} else {
let _ = tx_events_inner.send(InternalEvent::CommandResponse(trimmed.to_string()));
}
if trimmed == "OK DISCOVER" { in_json = false; let json_clean = json_acc.trim_end_matches("OK DISCOVER").trim(); if let Ok(resp) = serde_json::from_str::<DiscoverResponse>(json_clean) { let _ = tx_events_inner.send(InternalEvent::Discovery(resp.signals)); } json_acc.clear(); }
else if trimmed == "OK TREE" { in_json = false; let json_clean = json_acc.trim_end_matches("OK TREE").trim(); if let Ok(resp) = serde_json::from_str::<TreeItem>(json_clean) { let _ = tx_events_inner.send(InternalEvent::Tree(resp)); } json_acc.clear(); }
else if trimmed == "OK INFO" { in_json = false; let json_clean = json_acc.trim_end_matches("OK INFO").trim(); let _ = tx_events_inner.send(InternalEvent::NodeInfo(json_clean.to_string())); json_acc.clear(); }
} else { let _ = tx_events_inner.send(InternalEvent::CommandResponse(trimmed.to_string())); }
line.clear();
}
});
while let Ok(cmd) = rx_cmd.recv() {
if stream.write_all(format!("{}\n", cmd).as_bytes()).is_err() {
break;
}
{ let config = shared_config.lock().unwrap(); if config.version != current_version { *stop_flag.lock().unwrap() = true; break; } }
if stream.write_all(format!("{}\n", cmd).as_bytes()).is_err() { break; }
}
let _ = tx_events.send(InternalEvent::Disconnected);
}
thread::sleep(std::time::Duration::from_secs(2));
}
}
fn tcp_log_worker(addr: String, tx_events: Sender<InternalEvent>) {
fn tcp_log_worker(shared_config: Arc<Mutex<ConnectionConfig>>, tx_events: Sender<InternalEvent>) {
let mut current_version = 0;
let mut current_addr = String::new();
loop {
if let Ok(stream) = TcpStream::connect(&addr) {
{ let config = shared_config.lock().unwrap(); if config.version != current_version { current_version = config.version; current_addr = format!("{}:{}", config.ip, config.log_port); } }
if current_addr.is_empty() || current_addr.starts_with(":") { thread::sleep(std::time::Duration::from_secs(1)); continue; }
if let Ok(stream) = TcpStream::connect(&current_addr) {
let mut reader = BufReader::new(stream);
let mut line = String::new();
while reader.read_line(&mut line).is_ok() {
if shared_config.lock().unwrap().version != current_version { break; }
let trimmed = line.trim();
if trimmed.starts_with("LOG ") {
let parts: Vec<&str> = trimmed[4..].splitn(2, ' ').collect();
if parts.len() == 2 {
let _ = tx_events.send(InternalEvent::Log(LogEntry {
time: Local::now().format("%H:%M:%S%.3f").to_string(),
level: parts[0].to_string(),
message: parts[1].to_string(),
}));
}
if parts.len() == 2 { let _ = tx_events.send(InternalEvent::Log(LogEntry { time: Local::now().format("%H:%M:%S%.3f").to_string(), level: parts[0].to_string(), message: parts[1].to_string() })); }
}
line.clear();
}
@@ -324,76 +303,82 @@ fn tcp_log_worker(addr: String, tx_events: Sender<InternalEvent>) {
}
}
fn udp_worker(port: u16, id_to_meta: Arc<Mutex<HashMap<u32, SignalMetadata>>>, traced_data: Arc<Mutex<HashMap<String, TraceData>>>, tx_events: Sender<InternalEvent>) {
if let Ok(socket) = UdpSocket::bind(format!("0.0.0.0:{}", port)) {
fn udp_worker(shared_config: Arc<Mutex<ConnectionConfig>>, id_to_meta: Arc<Mutex<HashMap<u32, SignalMetadata>>>, traced_data: Arc<Mutex<HashMap<String, TraceData>>>, tx_events: Sender<InternalEvent>) {
let mut current_version = 0;
let mut socket: Option<UdpSocket> = None;
let mut last_seq: Option<u32> = None;
loop {
let (ver, port) = { let config = shared_config.lock().unwrap(); (config.version, config.udp_port.clone()) };
if ver != current_version || socket.is_none() {
current_version = ver;
if port.is_empty() { socket = None; continue; }
let port_num: u16 = port.parse().unwrap_or(8081);
let s = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP)).ok();
let mut bound = false;
if let Some(sock) = s {
let _ = sock.set_reuse_address(true);
#[cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))]
let _ = sock.set_reuse_port(true);
let _ = sock.set_recv_buffer_size(10 * 1024 * 1024);
let addr = format!("0.0.0.0:{}", port_num).parse::<std::net::SocketAddr>().unwrap();
if sock.bind(&addr.into()).is_ok() { socket = Some(sock.into()); bound = true; }
}
if !bound { thread::sleep(std::time::Duration::from_secs(5)); continue; }
let _ = socket.as_ref().unwrap().set_read_timeout(Some(std::time::Duration::from_millis(500)));
last_seq = None;
}
let s = if let Some(sock) = socket.as_ref() { sock } else { thread::sleep(std::time::Duration::from_secs(1)); continue; };
let mut buf = [0u8; 4096];
let start_time = std::time::Instant::now();
let mut total_packets = 0u64;
loop {
if let Ok(n) = socket.recv(&mut buf) {
if shared_config.lock().unwrap().version != current_version { break; }
if let Ok(n) = s.recv(&mut buf) {
total_packets += 1;
if (total_packets % 100) == 0 {
let _ = tx_events.send(InternalEvent::UdpStats(total_packets));
}
if (total_packets % 500) == 0 { let _ = tx_events.send(InternalEvent::UdpStats(total_packets)); }
if n < 20 { continue; }
let mut magic_buf = [0u8; 4]; magic_buf.copy_from_slice(&buf[0..4]);
if u32::from_le_bytes(magic_buf) != 0xDA7A57AD { continue; }
let mut count_buf = [0u8; 4]; count_buf.copy_from_slice(&buf[16..20]);
let count = u32::from_le_bytes(count_buf);
let mut seq_buf = [0u8; 4]; seq_buf.copy_from_slice(&buf[4..8]);
let seq = u32::from_le_bytes(seq_buf);
if let Some(last) = last_seq { if seq != last + 1 && seq > last { let _ = tx_events.send(InternalEvent::UdpDropped(seq - last - 1)); } }
last_seq = Some(seq);
let count = u32::from_le_bytes(buf[16..20].try_into().unwrap());
let now = APP_START_TIME.elapsed().as_secs_f64();
let mut offset = 20;
let now = start_time.elapsed().as_secs_f64();
let mut local_updates: HashMap<String, Vec<[f64; 2]>> = HashMap::new();
let mut last_values: HashMap<String, f64> = HashMap::new();
let metas = id_to_meta.lock().unwrap();
let mut data_map = traced_data.lock().unwrap();
for _ in 0..count {
if offset + 8 > n { break; }
let mut id_buf = [0u8; 4]; id_buf.copy_from_slice(&buf[offset..offset+4]);
let id = u32::from_le_bytes(id_buf);
let mut size_buf = [0u8; 4]; size_buf.copy_from_slice(&buf[offset+4..offset+8]);
let size = u32::from_le_bytes(size_buf);
let id = u32::from_le_bytes(buf[offset..offset+4].try_into().unwrap());
let size = u32::from_le_bytes(buf[offset+4..offset+8].try_into().unwrap());
offset += 8;
if offset + size as usize > n { break; }
let data_slice = &buf[offset..offset + size as usize];
if let Some(meta) = metas.get(&id) {
let t = meta.sig_type.as_str();
let val = match size {
1 => { if t.contains('u') { data_slice[0] as f64 } else { (data_slice[0] as i8) as f64 } },
2 => {
let mut b = [0u8; 2]; b.copy_from_slice(data_slice);
if t.contains('u') { u16::from_le_bytes(b) as f64 } else { i16::from_le_bytes(b) as f64 }
},
4 => {
let mut b = [0u8; 4]; b.copy_from_slice(data_slice);
if t.contains("float") { f32::from_le_bytes(b) as f64 }
else if t.contains('u') { u32::from_le_bytes(b) as f64 }
else { i32::from_le_bytes(b) as f64 }
},
8 => {
let mut b = [0u8; 8]; b.copy_from_slice(data_slice);
if t.contains("float") { f64::from_le_bytes(b) }
else if t.contains('u') { u64::from_le_bytes(b) as f64 }
else { i64::from_le_bytes(b) as f64 }
},
2 => { let b = data_slice[0..2].try_into().unwrap(); if t.contains('u') { u16::from_le_bytes(b) as f64 } else { i16::from_le_bytes(b) as f64 } },
4 => { let b = data_slice[0..4].try_into().unwrap(); if t.contains("float") { f32::from_le_bytes(b) as f64 } else if t.contains('u') { u32::from_le_bytes(b) as f64 } else { i32::from_le_bytes(b) as f64 } },
8 => { let b = data_slice[0..8].try_into().unwrap(); if t.contains("float") { f64::from_le_bytes(b) } else if t.contains('u') { u64::from_le_bytes(b) as f64 } else { i64::from_le_bytes(b) as f64 } },
_ => 0.0,
};
for name in &meta.names {
if let Some(entry) = data_map.get_mut(name) {
entry.values.push_back([now, val]);
if entry.values.len() > 2000 { entry.values.pop_front(); }
}
}
for name in &meta.names { local_updates.entry(name.clone()).or_default().push([now, val]); last_values.insert(name.clone(), val); }
}
offset += size as usize;
}
drop(metas);
if !local_updates.is_empty() {
let mut data_map = traced_data.lock().unwrap();
for (name, new_points) in local_updates {
if let Some(entry) = data_map.get_mut(&name) {
for point in new_points { entry.values.push_back(point); }
if let Some(lv) = last_values.get(&name) { entry.last_value = *lv; }
while entry.values.len() > 10000 { entry.values.pop_front(); }
}
}
}
}
}
}
@@ -403,257 +388,175 @@ impl eframe::App for MarteDebugApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
while let Ok(event) = self.rx_events.try_recv() {
match event {
InternalEvent::Log(log) => {
if !self.log_filters.paused {
self.logs.push_back(log);
if self.logs.len() > 2000 { self.logs.pop_front(); }
}
}
InternalEvent::InternalLog(msg) => {
self.logs.push_back(LogEntry {
time: Local::now().format("%H:%M:%S").to_string(),
level: "GUI_ERROR".to_string(),
message: msg,
});
}
InternalEvent::Discovery(signals) => {
let mut metas = self.id_to_meta.lock().unwrap();
metas.clear();
for s in &signals {
let meta = metas.entry(s.id).or_insert_with(|| SignalMetadata { names: Vec::new(), sig_type: s.sig_type.clone() });
if !meta.names.contains(&s.name) { meta.names.push(s.name.clone()); }
}
self.signals = signals;
}
InternalEvent::Tree(tree) => {
self.app_tree = Some(tree);
}
InternalEvent::NodeInfo(info) => {
self.node_info = info;
}
InternalEvent::TraceRequested(name) => {
let mut data_map = self.traced_signals.lock().unwrap();
data_map.entry(name).or_insert_with(|| TraceData { values: VecDeque::with_capacity(2000) });
}
InternalEvent::ClearTrace(name) => {
let mut data_map = self.traced_signals.lock().unwrap();
data_map.remove(&name);
}
InternalEvent::CommandResponse(resp) => {
self.logs.push_back(LogEntry {
time: Local::now().format("%H:%M:%S").to_string(),
level: "CMD_RESP".to_string(),
message: resp,
});
}
InternalEvent::UdpStats(count) => {
self.udp_packets = count;
}
InternalEvent::Connected => {
let _ = self.tx_cmd.send("TREE".to_string());
let _ = self.tx_cmd.send("DISCOVER".to_string());
}
InternalEvent::Log(log) => { if !self.log_filters.paused { self.logs.push_back(log); if self.logs.len() > 2000 { self.logs.pop_front(); } } }
InternalEvent::Discovery(signals) => { let mut metas = self.id_to_meta.lock().unwrap(); metas.clear(); for s in &signals { let meta = metas.entry(s.id).or_insert_with(|| SignalMetadata { names: Vec::new(), sig_type: s.sig_type.clone() }); if !meta.names.contains(&s.name) { meta.names.push(s.name.clone()); } } }
InternalEvent::Tree(tree) => { self.app_tree = Some(tree); }
InternalEvent::NodeInfo(info) => { self.node_info = info; }
InternalEvent::TraceRequested(name) => { let mut data_map = self.traced_signals.lock().unwrap(); data_map.entry(name).or_insert_with(|| TraceData { values: VecDeque::with_capacity(10000), last_value: 0.0 }); }
InternalEvent::ClearTrace(name) => { let mut data_map = self.traced_signals.lock().unwrap(); data_map.remove(&name); for plot in &mut self.plots { plot.signals.retain(|s| s.source_name != name); } }
InternalEvent::UdpStats(count) => { self.udp_packets = count; }
InternalEvent::UdpDropped(dropped) => { self.udp_dropped += dropped as u64; }
InternalEvent::Connected => { self.connected = true; let _ = self.tx_cmd.send("TREE".to_string()); let _ = self.tx_cmd.send("DISCOVER".to_string()); }
InternalEvent::Disconnected => { self.connected = false; }
InternalEvent::InternalLog(msg) => { self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI_ERROR".to_string(), message: msg }); }
InternalEvent::CommandResponse(resp) => { self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "CMD_RESP".to_string(), message: resp }); }
}
}
if let Some(dragged_name) = ctx.data_mut(|d| d.get_temp::<String>(egui::Id::new("drag_signal"))) {
egui::Area::new(egui::Id::new("drag_ghost")).fixed_pos(ctx.input(|i| i.pointer.hover_pos().unwrap_or(egui::Pos2::ZERO))).order(egui::Order::Tooltip).show(ctx, |ui| { ui.group(|ui| { ui.label(format!("📈 {}", dragged_name)); }); });
}
if let Some(dialog) = &mut self.forcing_dialog {
let mut close = false;
egui::Window::new("Force Signal").collapsible(false).resizable(false).show(ctx, |ui| {
ui.label(format!("Signal: {}", dialog.signal_path));
ui.label(format!("Type: {} (Dims: {}, Elems: {})", dialog.sig_type, dialog.dims, dialog.elems));
ui.horizontal(|ui| {
ui.label("Value:");
ui.text_edit_singleline(&mut dialog.value);
});
ui.horizontal(|ui| {
if ui.button("Apply Force").clicked() {
let _ = self.tx_cmd.send(format!("FORCE {} {}", dialog.signal_path, dialog.value));
self.forced_signals.insert(dialog.signal_path.clone(), dialog.value.clone());
close = true;
}
if ui.button("Cancel").clicked() { close = true; }
});
});
egui::Window::new("Force Signal").show(ctx, |ui| { ui.label(&dialog.signal_path); ui.text_edit_singleline(&mut dialog.value); ui.horizontal(|ui| { if ui.button("Apply").clicked() { let _ = self.tx_cmd.send(format!("FORCE {} {}", dialog.signal_path, dialog.value)); self.forced_signals.insert(dialog.signal_path.clone(), dialog.value.clone()); close = true; } if ui.button("Cancel").clicked() { close = true; } }); });
if close { self.forcing_dialog = None; }
}
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
if let Some((p_idx, s_idx)) = self.style_editor {
let mut close = false;
egui::Window::new("Signal Style").show(ctx, |ui| {
if let Some(plot) = self.plots.get_mut(p_idx) {
if let Some(sig) = plot.signals.get_mut(s_idx) {
ui.horizontal(|ui| { ui.label("Label:"); ui.text_edit_singleline(&mut sig.label); });
ui.horizontal(|ui| { ui.label("Unit:"); ui.text_edit_singleline(&mut sig.unit); });
ui.horizontal(|ui| { ui.label("Color:"); let mut color = sig.color.to_array(); if ui.color_edit_button_srgba_unmultiplied(&mut color).changed() { sig.color = egui::Color32::from_rgba_unmultiplied(color[0], color[1], color[2], color[3]); } });
ui.horizontal(|ui| { ui.label("Gain:"); ui.add(egui::DragValue::new(&mut sig.gain).speed(0.1)); });
ui.horizontal(|ui| { ui.label("Offset:"); ui.add(egui::DragValue::new(&mut sig.offset).speed(1.0)); });
if ui.button("Close").clicked() { close = true; }
}
}
});
if close { self.style_editor = None; }
}
egui::TopBottomPanel::top("top").show(ctx, |ui| {
ui.horizontal(|ui| {
ui.toggle_value(&mut self.show_left_panel, "🗂 Tree");
ui.toggle_value(&mut self.show_right_panel, "⚙ Debug");
ui.toggle_value(&mut self.show_right_panel, "📊 Signals");
ui.toggle_value(&mut self.show_bottom_panel, "📜 Logs");
ui.separator();
ui.heading("MARTe2 Debug Explorer");
if ui.button(" Plot").clicked() { self.plots.push(PlotInstance { id: format!("Plot {}", self.plots.len()+1), plot_type: PlotType::Normal, signals: Vec::new(), auto_bounds: true }); }
ui.separator();
if ui.button("🔄 Refresh").clicked() {
let _ = self.tx_cmd.send("TREE".to_string());
let _ = self.tx_cmd.send("DISCOVER".to_string());
}
let (btn_text, btn_color) = if self.is_breaking { (" Resume", egui::Color32::GREEN) } else { ("⏸ Pause", egui::Color32::YELLOW) };
if ui.button(egui::RichText::new(btn_text).color(btn_color)).clicked() { self.is_breaking = !self.is_breaking; let _ = self.tx_cmd.send(if self.is_breaking { "PAUSE".to_string() } else { "RESUME".to_string() }); }
ui.separator();
if self.is_paused {
if ui.button("▶ Resume").clicked() {
let _ = self.tx_cmd.send("RESUME".to_string());
self.is_paused = false;
}
} else {
if ui.button("⏸ Pause").clicked() {
let _ = self.tx_cmd.send("PAUSE".to_string());
self.is_paused = true;
}
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.label(format!("UDP Packets: {}", self.udp_packets));
ui.menu_button("🔌 Connection", |ui| {
egui::Grid::new("conn_grid").num_columns(2).show(ui, |ui| {
ui.label("IP:"); ui.text_edit_singleline(&mut self.config.ip); ui.end_row();
ui.label("Control:"); ui.text_edit_singleline(&mut self.config.tcp_port); ui.end_row();
ui.label("Telemetry:"); ui.text_edit_singleline(&mut self.config.udp_port); ui.end_row();
ui.label("Logs:"); ui.text_edit_singleline(&mut self.config.log_port); ui.end_row();
});
ui.separator();
if ui.button("🔄 Apply & Reconnect").clicked() { self.config.version += 1; *self.shared_config.lock().unwrap() = self.config.clone(); ui.close_menu(); }
if ui.button("❌ Disconnect").clicked() { self.config.version += 1; let mut cfg = self.config.clone(); cfg.ip = "".to_string(); *self.shared_config.lock().unwrap() = cfg; ui.close_menu(); }
});
let status_color = if self.connected { egui::Color32::GREEN } else { egui::Color32::RED };
ui.label(egui::RichText::new(if self.connected { "● Online" } else { "○ Offline" }).color(status_color));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.label(format!("UDP: OK[{}] DROP[{}]", self.udp_packets, self.udp_dropped)); });
});
});
if self.show_bottom_panel {
egui::TopBottomPanel::bottom("log_panel").resizable(true).default_height(200.0).show(ctx, |ui| {
ui.horizontal(|ui| {
ui.heading("System Logs");
ui.separator();
ui.label("Filter:");
ui.text_edit_singleline(&mut self.log_filters.content_regex);
ui.checkbox(&mut self.log_filters.show_debug, "Debug");
ui.checkbox(&mut self.log_filters.show_info, "Info");
ui.checkbox(&mut self.log_filters.show_warning, "Warn");
ui.checkbox(&mut self.log_filters.show_error, "Error");
ui.separator();
ui.toggle_value(&mut self.log_filters.paused, "⏸ Pause Logs");
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("🗑 Clear").clicked() { self.logs.clear(); }
});
});
ui.separator();
let regex = if !self.log_filters.content_regex.is_empty() { Regex::new(&self.log_filters.content_regex).ok() } else { None };
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.auto_shrink([false, false])
.show(ui, |ui| {
for log in &self.logs {
let show = match log.level.as_str() {
"Debug" => self.log_filters.show_debug,
"Information" => self.log_filters.show_info,
"Warning" => self.log_filters.show_warning,
"FatalError" | "OSError" | "ParametersError" => self.log_filters.show_error,
_ => true,
};
if !show { continue; }
if let Some(re) = &regex { if !re.is_match(&log.message) && !re.is_match(&log.level) { continue; } }
let color = match log.level.as_str() {
"FatalError" | "OSError" | "ParametersError" => egui::Color32::from_rgb(255, 100, 100),
"Warning" => egui::Color32::from_rgb(255, 255, 100),
"Information" => egui::Color32::from_rgb(100, 255, 100),
"Debug" => egui::Color32::from_rgb(100, 100, 255),
"GUI_ERROR" => egui::Color32::from_rgb(255, 50, 255),
"CMD_RESP" => egui::Color32::from_rgb(255, 255, 255),
_ => egui::Color32::WHITE,
};
ui.scope(|ui| {
ui.horizontal(|ui| {
ui.label(egui::RichText::new(&log.time).monospace().color(egui::Color32::GRAY));
ui.label(egui::RichText::new(format!("[{}]", log.level)).color(color).strong());
ui.add(egui::Label::new(&log.message).wrap());
ui.allocate_space(egui::vec2(ui.available_width(), 0.0));
});
});
}
});
});
}
if self.show_left_panel {
egui::SidePanel::left("signals_panel").resizable(true).width_range(300.0..=600.0).show(ctx, |ui| {
ui.heading("Application Tree");
ui.separator();
egui::ScrollArea::vertical().id_salt("tree_scroll").show(ui, |ui| {
if let Some(tree) = self.app_tree.clone() {
self.render_tree(ui, &tree, "".to_string());
} else {
ui.label("Connecting to server...");
}
});
ui.separator();
ui.heading("Node Information");
egui::ScrollArea::vertical().id_salt("info_scroll").show(ui, |ui| {
if self.node_info.is_empty() {
ui.label("Click 'Info' on a node to view details");
} else {
ui.add(egui::Label::new(egui::RichText::new(&self.node_info).monospace()).wrap());
}
});
});
}
if self.show_left_panel { egui::SidePanel::left("left").resizable(true).width_range(200.0..=500.0).show(ctx, |ui| { egui::ScrollArea::vertical().show(ui, |ui| { if let Some(tree) = self.app_tree.clone() { self.render_tree(ui, &tree, "".to_string()); } }); }); }
if self.show_right_panel {
egui::SidePanel::right("debug_panel").resizable(true).width_range(200.0..=400.0).show(ctx, |ui| {
ui.heading("Active Controls");
ui.separator();
ui.label(egui::RichText::new("Forced Signals").strong());
egui::ScrollArea::vertical().id_salt("forced_scroll").show(ui, |ui| {
let mut to_update = None;
let mut to_remove = None;
for (path, val) in &self.forced_signals {
egui::SidePanel::right("right").resizable(true).width_range(250.0..=400.0).show(ctx, |ui| {
ui.heading("Traced Signals");
let mut names: Vec<_> = { let data_map = self.traced_signals.lock().unwrap(); data_map.keys().cloned().collect() };
names.sort();
egui::ScrollArea::vertical().id_salt("traced_scroll").show(ui, |ui| {
for key in names {
let last_val = { self.traced_signals.lock().unwrap().get(&key).map(|d| d.last_value).unwrap_or(0.0) };
ui.horizontal(|ui| {
if ui.selectable_label(false, format!("{}: {}", path, val)).clicked() {
to_update = Some(path.clone());
}
if ui.button("").clicked() {
let _ = self.tx_cmd.send(format!("UNFORCE {}", path));
to_remove = Some(path.clone());
}
});
}
if let Some(p) = to_remove { self.forced_signals.remove(&p); }
if let Some(p) = to_update {
self.forcing_dialog = Some(ForcingDialog {
signal_path: p.clone(), sig_type: "Unknown".to_string(), dims: 0, elems: 1,
value: self.forced_signals.get(&p).unwrap().clone(),
let response = ui.add(egui::Label::new(format!("{}: {:.2}", key, last_val)).sense(egui::Sense::drag()));
if response.drag_started() { ctx.data_mut(|d| d.insert_temp(egui::Id::new("drag_signal"), key.clone())); }
if ui.button("").clicked() { let _ = self.tx_cmd.send(format!("TRACE {} 0", key)); let _ = self.internal_tx.send(InternalEvent::ClearTrace(key)); }
});
}
});
ui.separator();
ui.label(egui::RichText::new("Traced Signals").strong());
egui::ScrollArea::vertical().id_salt("traced_scroll").show(ui, |ui| {
let mut names: Vec<_> = {
let data_map = self.traced_signals.lock().unwrap();
data_map.keys().cloned().collect()
};
names.sort();
for key in names {
ui.horizontal(|ui| {
ui.label(&key);
if ui.button("").clicked() {
let _ = self.tx_cmd.send(format!("TRACE {} 0", key));
let _ = self.internal_tx.send(InternalEvent::ClearTrace(key));
}
});
ui.heading("Forced Signals");
for (path, val) in &self.forced_signals { ui.horizontal(|ui| { ui.label(format!("{}: {}", path, val)); if ui.button("").clicked() { let _ = self.tx_cmd.send(format!("UNFORCE {}", path)); } }); }
});
}
if self.show_bottom_panel {
egui::TopBottomPanel::bottom("log_panel").resizable(true).default_height(150.0).show(ctx, |ui| {
ui.horizontal(|ui| {
ui.heading("System Logs"); ui.separator();
ui.checkbox(&mut self.log_filters.show_debug, "Debug"); ui.checkbox(&mut self.log_filters.show_info, "Info"); ui.checkbox(&mut self.log_filters.show_warning, "Warn"); ui.checkbox(&mut self.log_filters.show_error, "Error");
ui.separator();
ui.label("Filter:"); ui.text_edit_singleline(&mut self.log_filters.content_regex);
ui.separator();
ui.toggle_value(&mut self.log_filters.paused, "⏸ Pause");
if ui.button("🗑 Clear").clicked() { self.logs.clear(); }
});
ui.separator();
let regex = if !self.log_filters.content_regex.is_empty() { Regex::new(&self.log_filters.content_regex).ok() } else { None };
egui::ScrollArea::vertical().stick_to_bottom(true).auto_shrink([false, false]).show(ui, |ui| {
for log in &self.logs {
let show = match log.level.as_str() { "Debug" => self.log_filters.show_debug, "Information" => self.log_filters.show_info, "Warning" => self.log_filters.show_warning, "FatalError" | "OSError" | "ParametersError" => self.log_filters.show_error, _ => true };
if !show { continue; }
if let Some(re) = &regex { if !re.is_match(&log.message) && !re.is_match(&log.level) { continue; } }
let color = match log.level.as_str() { "FatalError" | "OSError" | "ParametersError" => egui::Color32::from_rgb(255, 100, 100), "Warning" => egui::Color32::from_rgb(255, 255, 100), "Information" => egui::Color32::from_rgb(100, 255, 100), "Debug" => egui::Color32::from_rgb(100, 100, 255), "GUI_ERROR" => egui::Color32::from_rgb(255, 50, 255), "CMD_RESP" => egui::Color32::from_rgb(255, 255, 255), _ => egui::Color32::WHITE };
ui.horizontal_wrapped(|ui| { ui.label(egui::RichText::new(&log.time).color(egui::Color32::GRAY).monospace()); ui.label(egui::RichText::new(format!("[{}]", log.level)).color(color).strong()); ui.add(egui::Label::new(&log.message).wrap()); });
}
});
});
}
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Oscilloscope");
let plot = Plot::new("traces_plot")
.legend(egui_plot::Legend::default())
.auto_bounds_x()
.auto_bounds_y()
.y_axis_min_width(4.0);
plot.show(ui, |plot_ui| {
let data_map = self.traced_signals.lock().unwrap();
for (name, data) in data_map.iter() {
let points: PlotPoints = data.values.iter().cloned().collect();
plot_ui.line(Line::new(points).name(name));
let n_plots = self.plots.len();
if n_plots > 0 {
let plot_height = ui.available_height() / n_plots as f32;
let mut to_remove = None;
let mut current_range = None;
for (p_idx, plot_inst) in self.plots.iter_mut().enumerate() {
ui.group(|ui| {
ui.horizontal(|ui| { ui.label(egui::RichText::new(&plot_inst.id).strong()); ui.selectable_value(&mut plot_inst.plot_type, PlotType::Normal, "Series"); ui.selectable_value(&mut plot_inst.plot_type, PlotType::LogicAnalyzer, "Logic"); if ui.button("🗑").clicked() { to_remove = Some(p_idx); } });
let mut plot = Plot::new(&plot_inst.id).height(plot_height - 40.0).show_axes([true, true]);
if let Some(range) = self.shared_x_range { if !plot_inst.auto_bounds { plot = plot.include_x(range[0]).include_x(range[1]); } }
if plot_inst.auto_bounds { plot = plot.auto_bounds(egui::Vec2b::new(true, true)); }
let plot_resp = plot.show(ui, |plot_ui| {
if !plot_inst.auto_bounds { if let Some(range) = self.shared_x_range { let bounds = plot_ui.plot_bounds(); plot_ui.set_plot_bounds(PlotBounds::from_min_max([range[0], bounds.min()[1]], [range[1], bounds.max()[1]])); } }
let data_map = self.traced_signals.lock().unwrap();
for (s_idx, sig_cfg) in plot_inst.signals.iter().enumerate() {
if let Some(data) = data_map.get(&sig_cfg.source_name) {
let mut points = Vec::new();
for [t, v] in &data.values {
let mut final_v = *v * sig_cfg.gain + sig_cfg.offset;
if plot_inst.plot_type == PlotType::LogicAnalyzer { final_v = (s_idx as f64 * 1.5) + (if final_v > 0.5 { 1.0 } else { 0.0 }); }
points.push([*t, final_v]);
}
plot_ui.line(Line::new(PlotPoints::from(points)).name(&sig_cfg.label).color(sig_cfg.color));
}
}
if p_idx == 0 || current_range.is_none() { let b = plot_ui.plot_bounds(); current_range = Some([b.min()[0], b.max()[0]]); }
});
if plot_resp.response.hovered() && ctx.input(|i| i.pointer.any_released()) {
if let Some(dropped) = ctx.data_mut(|d| d.get_temp::<String>(egui::Id::new("drag_signal"))) {
let color = Self::next_color(plot_inst.signals.len());
plot_inst.signals.push(SignalPlotConfig { source_name: dropped.clone(), label: dropped.clone(), unit: "".to_string(), color, line_style: LineStyle::Solid, marker_type: MarkerType::None, gain: 1.0, offset: 0.0 });
self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI".to_string(), message: format!("Dropped {} into plot", dropped) });
ctx.data_mut(|d| d.remove_temp::<String>(egui::Id::new("drag_signal")));
}
}
if plot_resp.response.dragged() || ctx.input(|i| i.pointer.any_click() || i.smooth_scroll_delta.y != 0.0) { if plot_resp.response.hovered() { plot_inst.auto_bounds = false; let b = plot_resp.transform.bounds(); self.shared_x_range = Some([b.min()[0], b.max()[0]]); } }
plot_resp.response.context_menu(|ui| {
if ui.button("🔍 Fit View").clicked() { plot_inst.auto_bounds = true; self.shared_x_range = None; ui.close_menu(); }
ui.separator();
let mut sig_to_remove = None;
for (s_idx, sig) in plot_inst.signals.iter().enumerate() {
ui.horizontal(|ui| { ui.label(&sig.label); if ui.button("🎨").clicked() { self.style_editor = Some((p_idx, s_idx)); ui.close_menu(); } if ui.button("").clicked() { sig_to_remove = Some(s_idx); ui.close_menu(); } });
}
if let Some(idx) = sig_to_remove { plot_inst.signals.remove(idx); }
});
});
}
});
if let Some(idx) = to_remove { self.plots.remove(idx); }
if let Some(range) = current_range { if self.shared_x_range.is_none() { self.shared_x_range = Some(range); } }
} else { ui.centered_and_justified(|ui| { ui.label("Add a plot panel to begin analysis"); }); }
});
ctx.request_repaint_after(std::time::Duration::from_millis(16));
@@ -661,13 +564,6 @@ impl eframe::App for MarteDebugApp {
}
fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([1280.0, 800.0]),
..Default::default()
};
eframe::run_native(
"MARTe2 Debug Explorer",
options,
Box::new(|cc| Ok(Box::new(MarteDebugApp::new(cc)))),
)
let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_inner_size([1280.0, 800.0]), ..Default::default() };
eframe::run_native("MARTe2 Debug Explorer", options, Box::new(|cc| Ok(Box::new(MarteDebugApp::new(cc)))))
}

150
app_output.log Normal file
View File

@@ -0,0 +1,150 @@
MARTe2 Environment Set (MARTe2_DIR=/home/martino/Projects/marte_debug/dependency/MARTe2)
MARTe2 Components Environment Set (MARTe2_Components_DIR=/home/martino/Projects/marte_debug/dependency/MARTe2-components)
Cleaning up lingering processes...
Launching standard MARTeApp.ex with debug_test.cfg...
[Debug - Bootstrap.cpp:79]: Arguments:
-f = "Test/Configurations/debug_test.cfg"
-l = "RealTimeLoader"
-s = "State1"
[Information - Bootstrap.cpp:207]: Loader parameters:
-f = "Test/Configurations/debug_test.cfg"
-l = "RealTimeLoader"
-s = "State1"
Loader = "RealTimeLoader"
Filename = "Test/Configurations/debug_
[Information - Loader.cpp:67]: DefaultCPUs set to 1
[Information - Loader.cpp:74]: SchedulerGranularity is 10000
[Debug - Loader.cpp:189]: Purging ObjectRegistryDatabase with 0 objects
[Debug - Loader.cpp:192]: Purge ObjectRegistryDatabase. Number of objects left: 0
[Information - LinuxTimer.cpp:117]: SleepNature was not set. Using Default.
[Information - LinuxTimer.cpp:127]: Phase was not configured, using default 0
[Warning - LinuxTimer.cpp:164]: ExecutionMode not specified using: IndependentThread
[Warning - LinuxTimer.cpp:185]: CPUMask not specified using: 255
[Warning - LinuxTimer.cpp:191]: StackSize not specified using: 262144
[Information - LinuxTimer.cpp:236]: No timer provider specified. Falling back to HighResolutionTimeProvider
[Information - HighResolutionTimeProvider.cpp:163]: Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
[Information - HighResolutionTimeProvider.cpp:61]: Inner initialization succeeded
[Information - LinuxTimer.cpp:267]: Backward compatibility parameters injection unnecessary
[Information - RealTimeThread.cpp:190]: No CPUs defined for the RealTimeThread Thread1
[Information - RealTimeThread.cpp:193]: No StackSize defined for the RealTimeThread Thread1
[DebugService] TCP Server listening on port 8080
[DebugService] UDP Streamer socket opened
[ParametersError - StringHelper.cpp:60]: Error: invalid input arguments
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[ParametersError - StringHelper.cpp:60]: Error: invalid input arguments
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[DebugService] Worker threads started.
[TcpLogger] Listening on port 8082
[ParametersError - StringHelper.cpp:60]: Error: invalid input arguments
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Information] LoaderPostInit not set
[Information] Going to rtAppBuilder.ConfigureAfterInitialisation()
[Information] Going to InitialiseSignalsDatabase
[Information] Going to FlattenSignalsDatabases
[Information] Caching introspection signals
[Information] Flattening functions input signals
[Debug] Updating the signal database
[Debug] Finished updating the signal database
[Information] Flattening functions output signals
[Debug] Updating the signal database
[Debug] Finished updating the signal database
[Information] Flattening data sources signals
[Debug] Updating the signal database
[Debug] Finished updating the signal database
[Debug] Updating the signal database
[Debug] Finished updating the signal database
[Debug] Updating the signal database
[Debug] Finished updating the signal database
[Information] Going to VerifyDataSourcesSignals
[Debug] Updating the signal database
[Information] Verifying signals for Timer
[Debug] Finished updating the signal database
[Information] Going to ResolveStates
[Information] Resolving state State1
[Information] Resolving thread container Threads
[Information] Resolving thread State1.Thread1
[Information] Resolving GAM1
[Information] Going to ResolveDataSources
[Information] Verifying signals for Logger
[Information] Resolving for function GAM1 [idx: 0]
[Information] Resolving 2 signals
[Information] Resolving 2 signals
[Information] Verifying signals for DDB
[Information] Verifying signals for DAMS
[Information] Going to VerifyConsumersAndProducers
[Information] Started application in state State1
[Information] Application starting
[Information] Verifying consumers and producers for Timer
[Information] Verifying consumers and producers for Logger
[Information] Verifying consumers and producers for DDB
[Information] Verifying consumers and producers for DAMS
[Information] Going to CleanCaches
[Debug] Purging dataSourcesIndexesCache. Number of children:3
[Debug] Purging functionsIndexesCache. Number of children:1
[Debug] Purging dataSourcesSignalIndexCache. Number of children:3
[Debug] Purging dataSourcesFunctionIndexesCache. Number of children:1
[Debug] Purging functionsMemoryIndexesCache. Number of children:2
[Debug] Purged functionsMemoryIndexesCache. Number of children:0
[Debug] Purged cachedIntrospections. Number of children:0
[Information] Going to rtAppBuilder.PostConfigureDataSources()
[Information] Going to rtAppBuilder.PostConfigureFunctions()
[Information] Going to rtAppBuilder.Copy()
[Information] Going to AllocateGAMMemory
[Information] Going to AllocateDataSourceMemory()
[Information] Going to AddBrokersToFunctions
[Information] Creating broker MemoryMapSynchronisedInputBroker for GAM1 and signal Counter(0)
[Information] Creating broker MemoryMapInputBroker for GAM1 and signal Time(1)
[Information] Getting input brokers for Timer
[Information] Getting output brokers for Timer
[Information] Getting input brokers for Logger
[Information] Getting output brokers for Logger
[Information] Getting input brokers for DDB
[Information] Getting output brokers for DDB
[Information] Getting input brokers for DAMS
[Information] Getting output brokers for DAMS
[Information] Going to FindStatefulDataSources
[Information] Going to configure scheduler
[Information] Preparing state State1
[Information] Frequency found = 1.000000
[Information] Frequency found = 1.000000
[Information] The timer will be set using a frequency of 1.000000 Hz
[ParametersError] Error: invalid input arguments
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
[Information] LinuxTimer::Prepared = true
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
[Information] Time [0:0]:0
[Information] Time [0:0]:2000000
[Information] Time [0:0]:3000000
[Information] Time [0:0]:4000000
[Information] Time [0:0]:5000000
[Information] Time [0:0]:6000000
[Information] Time [0:0]:7000000
[Information] Time [0:0]:8000000
[Information] Time [0:0]:9000000
[Information] Time [0:0]:10000000
[Information] Time [0:0]:11000000
[Information] Time [0:0]:12000000
[Information] Time [0:0]:13000000
[Information] Time [0:0]:14000000
[Information] Time [0:0]:15000000
[Information] Time [0:0]:16000000
[Information] Time [0:0]:17000000
[Information] Time [0:0]:18000000
[Information] Time [0:0]:19000000
[Information] Time [0:0]:20000000
[Information] Time [0:0]:21000000
[Information] Time [0:0]:22000000
[Information] Time [0:0]:23000000
[Information] Time [0:0]:24000000
[Information] Time [0:0]:25000000
[Information] Time [0:0]:26000000
[Information] Time [0:0]:27000000
[Information] Time [0:0]:28000000

View File

@@ -21,12 +21,12 @@
"cc",
"-v",
"-o",
"CMakeFiles/cmTC_27c6b.dir/CMakeCCompilerABI.c.o",
"CMakeFiles/cmTC_a4cfb.dir/CMakeCCompilerABI.c.o",
"-c",
"/usr/share/cmake/Modules/CMakeCCompilerABI.c"
],
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-0cxTtB",
"output": "CMakeFiles/cmTC_27c6b.dir/CMakeCCompilerABI.c.o"
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-xo4CnB",
"output": "CMakeFiles/cmTC_a4cfb.dir/CMakeCCompilerABI.c.o"
},
{
"file": "/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp",
@@ -34,12 +34,59 @@
"c++",
"-v",
"-o",
"CMakeFiles/cmTC_2b812.dir/CMakeCXXCompilerABI.cpp.o",
"CMakeFiles/cmTC_f4fc4.dir/CMakeCXXCompilerABI.cpp.o",
"-c",
"/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-JvDZsz",
"output": "CMakeFiles/cmTC_2b812.dir/CMakeCXXCompilerABI.cpp.o"
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-tgsqrG",
"output": "CMakeFiles/cmTC_f4fc4.dir/CMakeCXXCompilerABI.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Source/DebugFastScheduler.cpp",
"arguments": [
"c++",
"-DARCHITECTURE=x86_gcc",
"-DENVIRONMENT=Linux",
"-DMARTe2_TEST_ENVIRONMENT=GTest",
"-DUSE_PTHREAD",
"-Dmarte_dev_EXPORTS",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L0Types",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L2Objects",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Events",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Logger",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Messages",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5FILES",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-fPIC",
"-MD",
"-MT",
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o",
"-MF",
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o.d",
"-o",
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o",
"-c",
"/home/martino/Projects/marte_debug/Source/DebugFastScheduler.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build",
"output": "CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Source/DebugService.cpp",
@@ -63,16 +110,17 @@
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-fPIC",
"-MD",
"-MT",
@@ -87,6 +135,53 @@
"directory": "/home/martino/Projects/marte_debug/Build",
"output": "CMakeFiles/marte_dev.dir/Source/DebugService.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Source/TcpLogger.cpp",
"arguments": [
"c++",
"-DARCHITECTURE=x86_gcc",
"-DENVIRONMENT=Linux",
"-DMARTe2_TEST_ENVIRONMENT=GTest",
"-DUSE_PTHREAD",
"-Dmarte_dev_EXPORTS",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L0Types",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L2Objects",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Events",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Logger",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Messages",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5FILES",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-fPIC",
"-MD",
"-MT",
"CMakeFiles/marte_dev.dir/Source/TcpLogger.cpp.o",
"-MF",
"CMakeFiles/marte_dev.dir/Source/TcpLogger.cpp.o.d",
"-o",
"CMakeFiles/marte_dev.dir/Source/TcpLogger.cpp.o",
"-c",
"/home/martino/Projects/marte_debug/Source/TcpLogger.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build",
"output": "CMakeFiles/marte_dev.dir/Source/TcpLogger.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Test/UnitTests/main.cpp",
"arguments": [
@@ -108,10 +203,10 @@
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
@@ -120,6 +215,7 @@
"-I/home/martino/Projects/marte_debug/Test/UnitTests/../../Source",
"-I/home/martino/Projects/marte_debug/Test/UnitTests/../../Headers",
"-pthread",
"-g",
"-MD",
"-MT",
"Test/UnitTests/CMakeFiles/UnitTests.dir/main.cpp.o",
@@ -154,16 +250,17 @@
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-MD",
"-MT",
"Test/Integration/CMakeFiles/IntegrationTest.dir/main.cpp.o",
@@ -176,5 +273,140 @@
],
"directory": "/home/martino/Projects/marte_debug/Build/Test/Integration",
"output": "CMakeFiles/IntegrationTest.dir/main.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Test/Integration/TraceTest.cpp",
"arguments": [
"c++",
"-DARCHITECTURE=x86_gcc",
"-DENVIRONMENT=Linux",
"-DMARTe2_TEST_ENVIRONMENT=GTest",
"-DUSE_PTHREAD",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L0Types",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L2Objects",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Events",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Logger",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Messages",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5FILES",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-MD",
"-MT",
"Test/Integration/CMakeFiles/TraceTest.dir/TraceTest.cpp.o",
"-MF",
"CMakeFiles/TraceTest.dir/TraceTest.cpp.o.d",
"-o",
"CMakeFiles/TraceTest.dir/TraceTest.cpp.o",
"-c",
"/home/martino/Projects/marte_debug/Test/Integration/TraceTest.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build/Test/Integration",
"output": "CMakeFiles/TraceTest.dir/TraceTest.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Test/Integration/ValidationTest.cpp",
"arguments": [
"c++",
"-DARCHITECTURE=x86_gcc",
"-DENVIRONMENT=Linux",
"-DMARTe2_TEST_ENVIRONMENT=GTest",
"-DUSE_PTHREAD",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L0Types",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L2Objects",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Events",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Logger",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Messages",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5FILES",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-MD",
"-MT",
"Test/Integration/CMakeFiles/ValidationTest.dir/ValidationTest.cpp.o",
"-MF",
"CMakeFiles/ValidationTest.dir/ValidationTest.cpp.o.d",
"-o",
"CMakeFiles/ValidationTest.dir/ValidationTest.cpp.o",
"-c",
"/home/martino/Projects/marte_debug/Test/Integration/ValidationTest.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build/Test/Integration",
"output": "CMakeFiles/ValidationTest.dir/ValidationTest.cpp.o"
},
{
"file": "/home/martino/Projects/marte_debug/Test/Integration/SchedulerTest.cpp",
"arguments": [
"c++",
"-DARCHITECTURE=x86_gcc",
"-DENVIRONMENT=Linux",
"-DMARTe2_TEST_ENVIRONMENT=GTest",
"-DUSE_PTHREAD",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L0Types",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L2Objects",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Configuration",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Events",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Logger",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L4Messages",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5FILES",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/BareMetal/L6App",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L3Services",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L4LoggerService",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L1Portability",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/FileSystem/L3Streams",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2/Source/Core/Scheduler/L5GAMs",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/EpicsDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/DataSources/FileDataSource",
"-I/home/martino/Projects/marte_debug/dependency/MARTe2-components/Source/Components/GAMs/IOGAM",
"-I/home/martino/Projects/marte_debug/Source",
"-I/home/martino/Projects/marte_debug/Headers",
"-pthread",
"-g",
"-MD",
"-MT",
"Test/Integration/CMakeFiles/SchedulerTest.dir/SchedulerTest.cpp.o",
"-MF",
"CMakeFiles/SchedulerTest.dir/SchedulerTest.cpp.o.d",
"-o",
"CMakeFiles/SchedulerTest.dir/SchedulerTest.cpp.o",
"-c",
"/home/martino/Projects/marte_debug/Test/Integration/SchedulerTest.cpp"
],
"directory": "/home/martino/Projects/marte_debug/Build/Test/Integration",
"output": "CMakeFiles/SchedulerTest.dir/SchedulerTest.cpp.o"
}
]

40
run_debug_app.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# run_debug_app.sh - Launch the MARTe2 Debugging Environment using standard MARTeApp.ex
# 1. Environment Setup
if [ -f "./env.sh" ]; then
source ./env.sh
else
echo "ERROR: env.sh not found. Ensure you are in the project root."
exit 1
fi
# 2. Paths
MARTE_EX="${MARTe2_DIR}/Build/${TARGET}/App/MARTeApp.ex"
DEBUG_LIB="$(pwd)/Build/libmarte_dev.so"
# Component library base search path
COMPONENTS_BUILD_DIR="${MARTe2_Components_DIR}/Build/${TARGET}/Components"
# DYNAMICALLY FIND ALL COMPONENT DIRS
# MARTe2 Loader needs the specific directories containing .so files in LD_LIBRARY_PATH
ALL_COMPONENT_DIRS=$(find "$COMPONENTS_BUILD_DIR" -type d)
for dir in $ALL_COMPONENT_DIRS; do
if ls "$dir"/*.so >/dev/null 2>&1; then
export LD_LIBRARY_PATH="$dir:$LD_LIBRARY_PATH"
fi
done
# Ensure our build dir and core dir are included
export LD_LIBRARY_PATH="$(pwd)/Build:${MARTe2_DIR}/Build/${TARGET}/Core:${LD_LIBRARY_PATH}"
# 3. Cleanup
echo "Cleaning up lingering processes..."
pkill -9 MARTeApp.ex
sleep 1
# 4. Launch Application
echo "Launching standard MARTeApp.ex with debug_test.cfg..."
# PRELOAD ensures our DebugService class is available to the registry early
export LD_PRELOAD="${DEBUG_LIB}"
"$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1

View File

@@ -1,21 +1,14 @@
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source $DIR/env.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
export MARTe2_DIR=/home/martino/Projects/marte_debug/dependency/MARTe2
export TARGET=x86-linux
MARTE_APP=$MARTe2_DIR/Build/$TARGET/App/MARTeApp.ex
echo "Cleaning up old instances..."
pkill -9 IntegrationTest
pkill -9 ValidationTest
pkill -9 SchedulerTest
pkill -9 main
sleep 2
# Build paths for all components
LIBS=$DIR/Build
LIBS=$LIBS:$MARTe2_DIR/Build/$TARGET/Core
LIBS=$LIBS:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LinuxTimer
LIBS=$LIBS:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LoggerDataSource
LIBS=$LIBS:$MARTe2_Components_DIR/Build/$TARGET/Components/GAMs/IOGAM
export LD_LIBRARY_PATH=$LIBS:$LD_LIBRARY_PATH
# ./Build/Test/Integration/IntegrationTest -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
$MARTE_APP -f $DIR/Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
echo "Starting MARTe2 Integration Tests..."
./Build/Test/Integration/ValidationTest