Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f8f04856ed |
+1
-1
@@ -1,4 +1,5 @@
|
|||||||
Build/
|
Build/
|
||||||
|
Build_Coverage/
|
||||||
bin/
|
bin/
|
||||||
*.o
|
*.o
|
||||||
*.so
|
*.so
|
||||||
@@ -7,4 +8,3 @@ bin/
|
|||||||
dependency/
|
dependency/
|
||||||
.cache/
|
.cache/
|
||||||
target/
|
target/
|
||||||
CLAUDE.md
|
|
||||||
|
|||||||
@@ -1,281 +1,61 @@
|
|||||||
# API Documentation
|
# API Documentation
|
||||||
|
|
||||||
This document covers both transport implementations. The command text protocol is identical
|
## 1. TCP Control Interface (Port 8080)
|
||||||
for both; only the carrier differs.
|
|
||||||
|
### 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
|
||||||
|
`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. DebugService — TCP Command Interface (default port 8080)
|
## 2. UDP Telemetry Format (Port 8081)
|
||||||
|
|
||||||
Commands are newline-terminated (`\n`) UTF-8 text strings sent over a persistent TCP
|
Telemetry packets are Little-Endian and use `#pragma pack(1)`.
|
||||||
connection. One client is served at a time; concurrent connections queue.
|
|
||||||
|
### 2.1 TraceHeader (20 Bytes)
|
||||||
A client sending more than **100 commands per second** is disconnected (rate limit).
|
| Offset | Type | Name | Description |
|
||||||
A client that sends no data for **30 seconds** is disconnected (idle timeout).
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| 0 | uint32 | magic | Always `0xDA7A57AD` |
|
||||||
### 1.1 `DISCOVER`
|
| 4 | uint32 | seq | Incremental sequence number |
|
||||||
List all registered signals with full metadata.
|
| 8 | uint64 | timestamp | High-resolution timestamp |
|
||||||
|
| 16 | uint32 | count | Number of samples in payload |
|
||||||
- **Request:** `DISCOVER\n`
|
|
||||||
- **Response:**
|
### 2.2 Sample Entry
|
||||||
```
|
| Offset | Type | Name | Description |
|
||||||
{"Signals":[{"id":<n>,"name":"…","alias":"…","type":"…","elements":<n>},...]}
|
| :--- | :--- | :--- | :--- |
|
||||||
OK DISCOVER
|
| 0 | uint32 | id | Internal Signal ID (from `DISCOVER`) |
|
||||||
```
|
| 4 | uint32 | size | Data size in bytes |
|
||||||
|
| 8 | Bytes | data | Raw signal memory |
|
||||||
### 1.2 `TREE`
|
|
||||||
Return the full live `ObjectRegistryDatabase` hierarchy as JSON.
|
|
||||||
|
|
||||||
- **Request:** `TREE\n`
|
|
||||||
- **Response:**
|
|
||||||
```json
|
|
||||||
{"name":"Root","children":[…]}
|
|
||||||
OK TREE
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.3 `INFO <path>`
|
|
||||||
Return metadata for a specific ORD node. Response is enriched with config fields
|
|
||||||
(Frequency, Units, PVNames, …) when a full config has been provided via `SetFullConfig`.
|
|
||||||
|
|
||||||
- **Request:** `INFO App.Functions.GAM1\n`
|
|
||||||
- **Response:**
|
|
||||||
```
|
|
||||||
{"path":"…","class":"…","signals":[…],"config":{…}}
|
|
||||||
OK INFO
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.4 `LS [path]`
|
|
||||||
List the immediate children of an ORD node.
|
|
||||||
|
|
||||||
- **Request:** `LS App.Data\n`
|
|
||||||
- **Response:**
|
|
||||||
```
|
|
||||||
{"nodes":["Timer","DDB"]}
|
|
||||||
OK LS
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.5 `TRACE <name> <0|1> [decimation]`
|
|
||||||
Enable or disable high-speed tracing for a signal. Optional `decimation` controls
|
|
||||||
how many RT cycles are skipped between samples (default 1 = every cycle).
|
|
||||||
|
|
||||||
- **Request:** `TRACE App.Data.DDB.Counter 1\n`
|
|
||||||
- **Request:** `TRACE App.Data.DDB.Counter 1 10\n` *(every 10th sample)*
|
|
||||||
- **Response:** `OK TRACE <match_count>\n`
|
|
||||||
|
|
||||||
### 1.6 `FORCE <name> <value>`
|
|
||||||
Inject a persistent value into a signal's memory location. The RT broker will copy
|
|
||||||
the forced value on every cycle until `UNFORCE` is called.
|
|
||||||
|
|
||||||
- **Request:** `FORCE App.Data.DDB.Counter 9999\n`
|
|
||||||
- **Response:** `OK FORCE <match_count>\n`
|
|
||||||
|
|
||||||
### 1.7 `UNFORCE <name>`
|
|
||||||
Remove a forced value; the signal resumes its normal data-flow value.
|
|
||||||
|
|
||||||
- **Request:** `UNFORCE App.Data.DDB.Counter\n`
|
|
||||||
- **Response:** `OK UNFORCE <match_count>\n`
|
|
||||||
|
|
||||||
### 1.8 `BREAK <name> <op> <threshold>`
|
|
||||||
Set a conditional breakpoint on a signal. When the condition fires, the application
|
|
||||||
pauses and execution stepping becomes available. Supported operators:
|
|
||||||
|
|
||||||
| `op` string | Condition |
|
|
||||||
|---|---|
|
|
||||||
| `>` | signal > threshold |
|
|
||||||
| `<` | signal < threshold |
|
|
||||||
| `==` | signal == threshold |
|
|
||||||
| `>=` | signal >= threshold |
|
|
||||||
| `<=` | signal <= threshold |
|
|
||||||
| `!=` | signal != threshold |
|
|
||||||
| `OFF` | disable break (same as `BREAK <name> OFF`) |
|
|
||||||
|
|
||||||
- **Request:** `BREAK App.Data.DDB.Counter > 1000\n`
|
|
||||||
- **Response:** `OK BREAK <match_count>\n`
|
|
||||||
|
|
||||||
### 1.9 `BREAK <name> OFF`
|
|
||||||
Clear the breakpoint on a signal (equivalent to `BREAK <name> OFF 0`).
|
|
||||||
|
|
||||||
- **Request:** `BREAK App.Data.DDB.Counter OFF\n`
|
|
||||||
- **Response:** `OK BREAK <match_count>\n`
|
|
||||||
|
|
||||||
### 1.10 `PAUSE`
|
|
||||||
Halt all patched RT threads at the start of their next Execute cycle.
|
|
||||||
|
|
||||||
- **Request:** `PAUSE\n`
|
|
||||||
- **Response:** `OK\n`
|
|
||||||
|
|
||||||
### 1.11 `RESUME`
|
|
||||||
Release paused RT threads.
|
|
||||||
|
|
||||||
- **Request:** `RESUME\n`
|
|
||||||
- **Response:** `OK\n`
|
|
||||||
|
|
||||||
### 1.12 `STEP <n> [thread]`
|
|
||||||
Resume execution for exactly `n` RT output-broker cycles then pause again.
|
|
||||||
Optional `thread` (OS thread name) restricts counting to one thread.
|
|
||||||
|
|
||||||
- **Request:** `STEP 5\n`
|
|
||||||
- **Request:** `STEP 1 RealTimeThread1\n`
|
|
||||||
- **Response:** `OK STEP\n`
|
|
||||||
|
|
||||||
### 1.13 `STEP_STATUS`
|
|
||||||
Query current pause and stepping state.
|
|
||||||
|
|
||||||
- **Request:** `STEP_STATUS\n`
|
|
||||||
- **Response:**
|
|
||||||
```json
|
|
||||||
{"paused":true,"gam":"App.Functions.GAM1","remaining":3}
|
|
||||||
OK STEP_STATUS
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.14 `VALUE <name>`
|
|
||||||
Read the current raw value of a signal from its memory address. Arrays are
|
|
||||||
capped at 256 elements; larger signals include `"truncated":true`.
|
|
||||||
|
|
||||||
- **Request:** `VALUE App.Data.DDB.Counter\n`
|
|
||||||
- **Response:**
|
|
||||||
```json
|
|
||||||
{"name":"App.Data.DDB.Counter","type":"uint32","elements":1,"values":[42]}
|
|
||||||
OK VALUE
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.15 `MONITOR SIGNAL <name> <periodMs>`
|
|
||||||
Register a signal for slow-rate polling. The service reads the signal directly
|
|
||||||
from its `DataSourceI` and sends the value at the specified period.
|
|
||||||
|
|
||||||
- **Request:** `MONITOR SIGNAL App.Data.DDB.Counter 500\n`
|
|
||||||
- **Response:** `OK MONITOR <id>\n`
|
|
||||||
|
|
||||||
On `DebugService`, monitored values are pushed over UDP with signal ID = internal monitor ID.
|
|
||||||
On `WebDebugService`, they are broadcast as `{"type":"monitor",…}` SSE events.
|
|
||||||
|
|
||||||
### 1.16 `UNMONITOR SIGNAL <name>`
|
|
||||||
Stop polling a monitored signal.
|
|
||||||
|
|
||||||
- **Request:** `UNMONITOR SIGNAL App.Data.DDB.Counter\n`
|
|
||||||
- **Response:** `OK UNMONITOR\n`
|
|
||||||
|
|
||||||
### 1.17 `CONFIG`
|
|
||||||
Return the full application configuration as JSON. Requires that `SetFullConfig()` was
|
|
||||||
called after `ConfigureApplication()`.
|
|
||||||
|
|
||||||
- **Request:** `CONFIG\n`
|
|
||||||
- **Response:**
|
|
||||||
```json
|
|
||||||
{"App":{"Class":"RealTimeApplication",…}}
|
|
||||||
OK CONFIG
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.18 `MSG <object> <function> [key=value …]`
|
|
||||||
Send a MARTe2 `Message` to any object in the ORD.
|
|
||||||
|
|
||||||
- **Request:** `MSG App.Functions.GAM1 Reset\n`
|
|
||||||
- **Request:** `MSG App.StateMachine GOTOSTATE NewState=Running\n`
|
|
||||||
- **Response:** `OK MSG\n` or `ERROR MSG <reason>\n`
|
|
||||||
|
|
||||||
### 1.19 `SERVICE_INFO`
|
|
||||||
Return metadata about the debug service itself.
|
|
||||||
|
|
||||||
- **Request:** `SERVICE_INFO\n`
|
|
||||||
- **Response:**
|
|
||||||
```json
|
|
||||||
{"transport":"TCP","controlPort":8080,"udpPort":8081,"logPort":8082}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. WebDebugService — HTTP Interface (default port 8090)
|
|
||||||
|
|
||||||
### 2.1 `GET /`
|
|
||||||
Returns the embedded single-page application. Open in any web browser.
|
|
||||||
|
|
||||||
### 2.2 `POST /api/command`
|
|
||||||
Execute any command from Section 1. The request body is the command text
|
|
||||||
(without a trailing newline). CORS headers are included.
|
|
||||||
|
|
||||||
- **Request headers:** `Content-Type: text/plain`
|
|
||||||
- **Request body:** e.g. `TRACE App.Data.DDB.Counter 1`
|
|
||||||
- **Response:** Plain text; same content as the TCP response.
|
|
||||||
|
|
||||||
### 2.3 `GET /api/events`
|
|
||||||
Long-lived Server-Sent Events stream. Up to 8 simultaneous clients.
|
|
||||||
|
|
||||||
Each event is formatted as:
|
|
||||||
```
|
|
||||||
event: message
|
|
||||||
data: <json>
|
|
||||||
|
|
||||||
```
|
|
||||||
(blank line terminates each event per SSE spec)
|
|
||||||
|
|
||||||
#### SSE event types
|
|
||||||
|
|
||||||
| `type` field | Additional fields | Description |
|
|
||||||
|---|---|---|
|
|
||||||
| `trace` | `name`, `ts` (ns), `value` (f64) | One traced signal sample |
|
|
||||||
| `monitor` | `name`, `ts` (ns), `value` (f64) | One slow-rate monitor sample |
|
|
||||||
| `log` | `level`, `msg` | Forwarded `REPORT_ERROR` log entry |
|
|
||||||
| `status` | `paused` (bool), `gam`, `remaining` | Pause/step state heartbeat (every 500 ms) |
|
|
||||||
| `discover` | `signals` (array) | Full signal list (sent on SSE connect) |
|
|
||||||
| `tree` | `tree` (object) | Full ORD tree (sent on SSE connect) |
|
|
||||||
|
|
||||||
Example trace event:
|
|
||||||
```
|
|
||||||
event: message
|
|
||||||
data: {"type":"trace","name":"App.Data.DDB.Counter","ts":1234567890,"value":42.0}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. UDP Telemetry Format (DebugService, default port 8081)
|
|
||||||
|
|
||||||
Packets are little-endian and packed (`#pragma pack(1)`).
|
|
||||||
|
|
||||||
### 3.1 `TraceHeader` (20 bytes)
|
|
||||||
|
|
||||||
| Offset | Type | Field | Description |
|
|
||||||
|---|---|---|---|
|
|
||||||
| 0 | uint32 | `magic` | Always `0xDA7A57AD` |
|
|
||||||
| 4 | uint32 | `seq` | Monotonically incrementing sequence number |
|
|
||||||
| 8 | uint64 | `timestamp` | High-resolution hardware timestamp |
|
|
||||||
| 16 | uint32 | `count` | Number of samples in this datagram |
|
|
||||||
|
|
||||||
### 3.2 Sample Entry (per signal)
|
|
||||||
|
|
||||||
| Offset | Type | Field | Description |
|
|
||||||
|---|---|---|---|
|
|
||||||
| 0 | uint32 | `id` | Signal ID from `DISCOVER` |
|
|
||||||
| 4 | uint64 | `timestamp` | Per-sample RT timestamp |
|
|
||||||
| 12 | uint32 | `size` | Payload size in bytes |
|
|
||||||
| 16 | bytes | `data` | Raw signal memory (`size` bytes) |
|
|
||||||
|
|
||||||
Multiple samples may be packed into one datagram up to `STREAMER_MTU = 1400` bytes.
|
|
||||||
A new datagram is started when the next sample would overflow the MTU.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Log Forwarding (DebugService, default port 8082)
|
|
||||||
|
|
||||||
The `TcpLogger` component (`Source/Components/Interfaces/TCPLogger/`) connects to the
|
|
||||||
MARTe2 global `LoggerI` and forwards every `REPORT_ERROR` call as a text line:
|
|
||||||
|
|
||||||
```
|
|
||||||
<level>|<object>|<function>|<message>\n
|
|
||||||
```
|
|
||||||
|
|
||||||
Up to 8 simultaneous log clients are supported. If no client is connected, log events
|
|
||||||
are silently discarded.
|
|
||||||
|
|
||||||
To enable:
|
|
||||||
|
|
||||||
```text
|
|
||||||
+Logger = {
|
|
||||||
Class = TcpLogger
|
|
||||||
Port = 8082
|
|
||||||
MaxClients = 8
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
On `WebDebugService`, logs are forwarded to SSE clients as `{"type":"log","level":"…","msg":"…"}`
|
|
||||||
events — no separate `TcpLogger` instance is required.
|
|
||||||
|
|||||||
+32
-257
@@ -1,269 +1,44 @@
|
|||||||
# System Architecture
|
# System Architecture
|
||||||
|
|
||||||
## 1. Overview
|
## 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.
|
||||||
The MARTe2 Debug Suite is a C++ server library that instruments running MARTe2 applications
|
|
||||||
without modifying their source code. It exposes an abstract `DebugServiceI` interface that
|
|
||||||
decouples the broker injection layer from the communication transport, allowing multiple
|
|
||||||
transport backends to coexist (currently TCP/UDP and HTTP/SSE).
|
|
||||||
|
|
||||||
```
|
|
||||||
┌────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ MARTe2 Application │
|
|
||||||
│ ┌──────────┐ ┌───────────────────────┐ ┌──────────────────┐ │
|
|
||||||
│ │ GAM(s) │ │ DebugBrokerWrapper │ │ FastScheduler │ │
|
|
||||||
│ │ │◄──│ (Registry-patched) │ │ (unmodified) │ │
|
|
||||||
│ └──────────┘ └──────────┬────────────┘ └──────────────────┘ │
|
|
||||||
│ │ RT-path API │
|
|
||||||
└────────────────────────────┼───────────────────────────────────────┘
|
|
||||||
│
|
|
||||||
┌────────▼────────┐
|
|
||||||
│ DebugServiceI │ ← Abstract interface (singleton)
|
|
||||||
└────────┬────────┘
|
|
||||||
┌─────────────┴──────────────┐
|
|
||||||
│ │
|
|
||||||
┌────────▼────────┐ ┌─────────▼────────┐
|
|
||||||
│ DebugService │ │ WebDebugService │
|
|
||||||
│ TCP/UDP │ │ HTTP/SSE │
|
|
||||||
└────────┬────────┘ └─────────┬─────────┘
|
|
||||||
│ │
|
|
||||||
┌──────────┼──────────┐ ┌──────────┼──────────┐
|
|
||||||
│TCP 8080 │UDP 8081 │ │HTTP 8090 │SSE stream │
|
|
||||||
│(commands)│(telemetry│ │(commands)│(telemetry)│
|
|
||||||
└────┬─────┴────┬─────┘ └─────┬────┴────┬──────┘
|
|
||||||
│ │ │ │
|
|
||||||
┌────▼──────────▼─────┐ ┌─────────▼─────────▼──────┐
|
|
||||||
│ Rust/egui GUI │ │ Web Browser (built-in UI)│
|
|
||||||
│ (Tools/gui_client) │ │ http://localhost:8090 │
|
|
||||||
└─────────────────────┘ └───────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Core Mechanism: Registry Patching
|
## 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:
|
||||||
|
|
||||||
The "Zero-Code-Change" requirement is met by intercepting the MARTe2 `ClassRegistryDatabase`.
|
1. **Broker Injection:** Standard Brokers (e.g., `MemoryMapInputBroker`) are replaced with `DebugBrokerWrapper`. This captures data every time a GAM reads or writes a signal.
|
||||||
When `DebugService` or `WebDebugService` initialises, `PatchRegistry()` replaces the
|
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).
|
||||||
`ObjectBuilder` for every standard `MemoryMap*Broker` class in the registry. When
|
|
||||||
`RealTimeApplication::ConfigureApplication()` runs afterward it instantiates wrapped broker
|
|
||||||
objects instead of the originals — the application sees no difference.
|
|
||||||
|
|
||||||
Patched broker types:
|
## 3. Communication Layer
|
||||||
|
The system uses three distinct channels:
|
||||||
|
|
||||||
| Class | Wrapper |
|
### 3.1 Command & Control (TCP Port 8080)
|
||||||
|---|---|
|
- **Protocol:** Text-based over TCP.
|
||||||
| `MemoryMapInputBroker` | `DebugBrokerWrapper<MemoryMapInputBroker>` |
|
- **Role:** Object tree discovery (`TREE`), signal metadata (`DISCOVER`), and trace activation (`TRACE`).
|
||||||
| `MemoryMapOutputBroker` | `DebugBrokerWrapper<MemoryMapOutputBroker>` |
|
- **Response Format:** JSON for complex data, `OK/ERROR` for status.
|
||||||
| `MemoryMapSynchronisedInputBroker` | `DebugBrokerWrapper<MemoryMapSynchronisedInputBroker>` |
|
|
||||||
| `MemoryMapSynchronisedOutputBroker` | `DebugBrokerWrapper<MemoryMapSynchronisedOutputBroker>` |
|
|
||||||
| `MemoryMapMultiBufferBroker` | `DebugBrokerWrapper<MemoryMapMultiBufferBroker>` |
|
|
||||||
| `MemoryMapMultiBufferOutputBroker` | `DebugBrokerWrapper<MemoryMapMultiBufferOutputBroker>` |
|
|
||||||
| `MemoryMapAsynchronousInputBroker` | `DebugBrokerWrapperAsync<MemoryMapAsynchronousInputBroker>` |
|
|
||||||
| `MemoryMapAsynchronousOutputBroker` | `DebugBrokerWrapperAsync<MemoryMapAsynchronousOutputBroker>` |
|
|
||||||
| `MemoryMapInterpolatedInputBroker` | `DebugBrokerWrapper<MemoryMapInterpolatedInputBroker>` |
|
|
||||||
| `MemoryMapStatefulOutputBroker` | `DebugBrokerWrapper<MemoryMapStatefulOutputBroker>` |
|
|
||||||
| `MemoryMapStatefulInputBroker` | `DebugBrokerWrapper<MemoryMapStatefulInputBroker>` |
|
|
||||||
|
|
||||||
---
|
### 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. DebugServiceI Abstraction Layer
|
### 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.
|
||||||
|
|
||||||
`Source/Components/Interfaces/DebugService/DebugServiceI.h` defines the abstract singleton
|
## 4. Component Diagram
|
||||||
interface. It has two logical groups:
|
```text
|
||||||
|
[ MARTe2 App ] <--- [ DebugFastScheduler ] (Registry Patch)
|
||||||
### 3.1 RT-path API
|
| |
|
||||||
Called from broker threads on every RT cycle. Must be as cheap as possible; the only
|
+ <--- [ DebugBrokerWrapper ] (Registry Patch)
|
||||||
permissible synchronisation primitive is `FastPollingMutexSem`.
|
| |
|
||||||
|
+---------------------+
|
||||||
| Method | Purpose |
|
| |
|
||||||
|---|---|
|
[ DebugService ] [ TcpLogger ]
|
||||||
| `RegisterSignal(addr, type, name, …)` | Called once per signal during broker `Init()` |
|
| |
|
||||||
| `ProcessSignal(info, size, timestamp)` | Apply forcing, check break, push trace sample |
|
+--- (TCP 8080) ------+-----> [ Rust GUI Client ]
|
||||||
| `RegisterBroker(…)` | Cache broker metadata for active/break index updates |
|
+--- (UDP 8081) ------+-----> [ (Oscilloscope) ]
|
||||||
| `IsPaused() / SetPaused(bool)` | Query / set global pause state |
|
+--- (TCP 8082) ------+-----> [ (Log Terminal) ]
|
||||||
| `ConsumeStepIfNeeded(gamName, thread)` | Decrement step counter on output-broker Execute |
|
|
||||||
|
|
||||||
### 3.2 Control-path API
|
|
||||||
Called from server/command-handler threads; latency acceptable.
|
|
||||||
|
|
||||||
| Method | Purpose |
|
|
||||||
|---|---|
|
|
||||||
| `ForceSignal / UnforceSignal` | Persistent value injection |
|
|
||||||
| `TraceSignal(name, enable, decimation)` | Enable/disable ring-buffer tracing |
|
|
||||||
| `SetBreak / ClearBreak` | Conditional breakpoints |
|
|
||||||
| `IsInstrumented(path, …)` | Query whether a signal is reachable |
|
|
||||||
| `RegisterMonitorSignal / UnmonitorSignal` | Slow-rate signal polling |
|
|
||||||
|
|
||||||
### 3.3 Static singleton pattern
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
// Concrete implementation registers itself:
|
|
||||||
DebugServiceI::SetInstance(this); // in Initialise()
|
|
||||||
DebugServiceI::SetInstance(NULL_PTR(…)); // in destructor
|
|
||||||
|
|
||||||
// Broker wrappers retrieve it (no ORD search on the hot path):
|
|
||||||
DebugServiceI *svc = DebugServiceI::GetInstance();
|
|
||||||
if (svc != NULL_PTR(DebugServiceI*)) { ... }
|
|
||||||
```
|
|
||||||
|
|
||||||
Shared data structures (`SignalAlias`, `BrokerInfo`) are also defined in `DebugServiceI.h`
|
|
||||||
so both transport implementations can use them without a circular dependency.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Transport Implementations
|
|
||||||
|
|
||||||
### 4.1 DebugService (TCP/UDP)
|
|
||||||
|
|
||||||
`Source/Components/Interfaces/DebugService/DebugService.h/.cpp`
|
|
||||||
|
|
||||||
Runs two `SingleThreadService` threads:
|
|
||||||
|
|
||||||
| Thread | Role |
|
|
||||||
|---|---|
|
|
||||||
| `Server()` | Accepts one TCP client at a time; reads text commands; writes JSON/text responses |
|
|
||||||
| `Streamer()` | Drains `TraceRingBuffer`; assembles and sends UDP datagrams; polls monitored signals |
|
|
||||||
|
|
||||||
Communication ports (all configurable):
|
|
||||||
|
|
||||||
| Port | Protocol | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `ControlPort` (default 8080) | TCP text | Commands and responses |
|
|
||||||
| `UdpPort` (default 8081) | UDP binary | High-speed telemetry (`TraceHeader` + samples) |
|
|
||||||
| `LogPort` (default 8082) | TCP stream | Log forwarding via `TcpLogger` sidecar |
|
|
||||||
|
|
||||||
### 4.2 WebDebugService (HTTP/SSE)
|
|
||||||
|
|
||||||
`Source/Components/Interfaces/WebDebugService/WebDebugService.h/.cpp`
|
|
||||||
|
|
||||||
Serves a single HTTP port (default 8090) with an embedded browser UI. Runs two
|
|
||||||
`SingleThreadService` threads:
|
|
||||||
|
|
||||||
| Thread | Role |
|
|
||||||
|---|---|
|
|
||||||
| `HttpServer()` | Accepts TCP connections; routes GET/POST/OPTIONS; upgrades SSE clients |
|
|
||||||
| `Streamer()` | Drains `TraceRingBuffer` → SSE events; polls monitored signals; heartbeat |
|
|
||||||
|
|
||||||
HTTP endpoints:
|
|
||||||
|
|
||||||
| Endpoint | Method | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `/` | GET | Serves embedded single-page application (HTML/CSS/JS) |
|
|
||||||
| `/api/command` | POST | Execute a debug command; returns text response |
|
|
||||||
| `/api/events` | GET | Server-Sent Events stream for real-time telemetry (up to 8 clients) |
|
|
||||||
|
|
||||||
The embedded web UI (`Source/Components/Interfaces/WebDebugService/WebUI.h`) is a
|
|
||||||
self-contained single-page application using Chart.js for real-time signal plots and a
|
|
||||||
Catppuccin Mocha dark theme. No install or server-side tooling required.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Signal Flow
|
|
||||||
|
|
||||||
### 5.1 Registration (startup, single-threaded)
|
|
||||||
|
|
||||||
```
|
|
||||||
ConfigureApplication()
|
|
||||||
└─► DebugBrokerWrapper::Init()
|
|
||||||
└─► DebugBrokerHelper::InitSignals()
|
|
||||||
├─► DebugServiceI::RegisterSignal() (canonical name + GAM alias)
|
|
||||||
└─► DebugServiceI::RegisterBroker()
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5.2 RT loop (hot path, multi-threaded)
|
|
||||||
|
|
||||||
```
|
|
||||||
RealTimeThread::Execute()
|
|
||||||
└─► DebugBrokerWrapper::Execute()
|
|
||||||
├─► Base::Execute() (data moved in/out of GAM memory)
|
|
||||||
└─► DebugBrokerHelper::Process()
|
|
||||||
├─► For each active signal:
|
|
||||||
│ └─► DebugServiceI::ProcessSignal()
|
|
||||||
│ ├─► if isForcing: memcpy forcedValue → signal memory
|
|
||||||
│ ├─► if isTracing & decimation fires:
|
|
||||||
│ │ └─► tracePushMutex → TraceRingBuffer::Push()
|
|
||||||
│ └─► if breakOp set: evaluate condition → SetPaused(true)
|
|
||||||
└─► (output brokers only) DebugServiceI::ConsumeStepIfNeeded()
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5.3 Telemetry delivery
|
|
||||||
|
|
||||||
**DebugService (UDP)**
|
|
||||||
```
|
|
||||||
Streamer thread
|
|
||||||
└─► TraceRingBuffer::Pop()
|
|
||||||
└─► assemble into streamerPacketBuffer (MTU=1400)
|
|
||||||
└─► BasicUDPSocket::Write() → client
|
|
||||||
```
|
|
||||||
|
|
||||||
**WebDebugService (SSE)**
|
|
||||||
```
|
|
||||||
Streamer thread
|
|
||||||
└─► TraceRingBuffer::Pop()
|
|
||||||
└─► BroadcastSse("message", {"type":"trace","name":…,"value":…})
|
|
||||||
└─► write "event: message\ndata: {…}\n\n" to each SSE socket
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. TraceRingBuffer
|
|
||||||
|
|
||||||
Single-producer / single-consumer circular byte buffer defined in `DebugCore.h`.
|
|
||||||
|
|
||||||
```
|
|
||||||
Buffer layout per entry: [ID:4][Timestamp:8][Size:4][Data:N]
|
|
||||||
```
|
|
||||||
|
|
||||||
- `Push()` is serialised by `tracePushMutex` (multiple RT threads write; one Streamer reads).
|
|
||||||
- `Pop()` is called exclusively by the Streamer thread.
|
|
||||||
- Ring is initialised to 4 MB in both transport implementations.
|
|
||||||
- On corrupt `size` field (`size >= bufferSize`): discards all entries to prevent cascading
|
|
||||||
bad reads (Fix #5).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 7. Performance Hardening
|
|
||||||
|
|
||||||
The following fixes were applied after initial implementation to improve correctness and
|
|
||||||
real-time safety.
|
|
||||||
|
|
||||||
| Fix | Area | Change |
|
|
||||||
|---|---|---|
|
|
||||||
| **#1** | UDP streamer | Named constants `STREAMER_MTU = 1400` and `STREAMER_BUFFER_SIZE = 4096`; removed magic numbers |
|
|
||||||
| **#2** | Multi-producer ring | `tracePushMutex` serialises `TraceRingBuffer::Push()` from concurrent RT threads |
|
|
||||||
| **#3** | Break evaluation | Break indices copied to stack-local array while holding `activeMutex`; condition evaluated outside the lock |
|
|
||||||
| **#4** | Decimation counter | `Atomic::Add` used for lock-free per-signal decimation in multi-producer `ProcessSignal` |
|
|
||||||
| **#5** | Ring corruption | `Pop()` skips only the current corrupt entry; falls back to full discard only when `size >= bufferSize` |
|
|
||||||
| **#6** | TCP rate limit | Server disconnects clients sending > 100 commands/second (`CMD_RATE_LIMIT = 100`) |
|
|
||||||
| **#7** | Broker index swap | `Vec::Swap` inside spinlock followed by free outside; avoids holding the lock during deallocation |
|
|
||||||
| **#8** | Idle timeout | Active TCP client disconnected after 30 s of silence (`CLIENT_IDLE_TIMEOUT_MS = 30000`) |
|
|
||||||
| **#9** | VALUE output size | `GetSignalValue` caps output at 256 elements (`GET_VALUE_MAX_ELEMENTS`); includes `"Truncated"` flag |
|
|
||||||
| **#10** | TCP framing | `inputBuffer` accumulates partial commands across `Read()` calls; bounded at 8 KiB (`INPUT_BUFFER_MAX`) |
|
|
||||||
| **#11** | CDB cursor | `Initialise()` never calls `MoveToRoot()` on the CDB passed by the framework; avoids corrupting `ReferenceContainer` traversal |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 8. Repository Layout
|
|
||||||
|
|
||||||
```
|
|
||||||
Source/
|
|
||||||
Core/Types/
|
|
||||||
Vec/ — RT-safe dynamic array (no STL)
|
|
||||||
Result/ — Error-carrying return type
|
|
||||||
Components/Interfaces/
|
|
||||||
DebugService/
|
|
||||||
DebugCore.h — DebugSignalInfo, TraceRingBuffer, BreakOp
|
|
||||||
DebugServiceI.h — Abstract interface + SignalAlias, BrokerInfo
|
|
||||||
DebugBrokerWrapper.h — DebugBrokerHelper, wrapper templates, registry builder
|
|
||||||
DebugService.h/.cpp — TCP/UDP transport implementation
|
|
||||||
WebDebugService/
|
|
||||||
WebUI.h — Embedded single-page HTML/CSS/JS application
|
|
||||||
WebDebugService.h/.cpp — HTTP/SSE transport implementation
|
|
||||||
TCPLogger/
|
|
||||||
TcpLogger.h/.cpp — LoggerConsumerI forwarding logs to TCP clients
|
|
||||||
Test/
|
|
||||||
Integration/ — Integration test suite (180 s SIGALRM guard)
|
|
||||||
UnitTests/ — Unit test suite
|
|
||||||
Tools/
|
|
||||||
gui_client/ — Rust/egui native GUI (DebugService TCP/UDP transport)
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(marte_dev)
|
||||||
|
|
||||||
|
if(NOT DEFINED ENV{MARTe2_DIR})
|
||||||
|
message(FATAL_ERROR "MARTe2_DIR not set. Please source env.sh")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(MARTe2_DIR $ENV{MARTe2_DIR})
|
||||||
|
set(MARTe2_Components_DIR $ENV{MARTe2_Components_DIR})
|
||||||
|
set(TARGET $ENV{TARGET})
|
||||||
|
|
||||||
|
# Define Architecture macros
|
||||||
|
add_definitions(-DARCHITECTURE=x86_gcc)
|
||||||
|
add_definitions(-DENVIRONMENT=Linux)
|
||||||
|
add_definitions(-DMARTe2_TEST_ENVIRONMENT=GTest) # Optional
|
||||||
|
add_definitions(-DUSE_PTHREAD)
|
||||||
|
|
||||||
|
# Add -pthread and coverage flags
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
|
||||||
|
if(ENABLE_COVERAGE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L0Types
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L1Portability
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L2Objects
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L3Streams
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Configuration
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Events
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Logger
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Messages
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L5FILES
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L5GAMs
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L6App
|
||||||
|
${MARTe2_DIR}/Source/Core/Scheduler/L1Portability
|
||||||
|
${MARTe2_DIR}/Source/Core/Scheduler/L3Services
|
||||||
|
${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
|
||||||
|
Source
|
||||||
|
Headers
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES "Source/*.cpp")
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||||
|
|
||||||
|
# Target MARTe2 library
|
||||||
|
set(MARTe2_LIB ${MARTe2_DIR}/Build/${TARGET}/Core/libMARTe2.so)
|
||||||
|
set(IOGAM_LIB ${MARTe2_Components_DIR}/Build/${TARGET}/Components/GAMs/IOGAM/libIOGAM.so)
|
||||||
|
set(LinuxTimer_LIB ${MARTe2_Components_DIR}/Build/${TARGET}/Components/DataSources/LinuxTimer/libLinuxTimer.so)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
${MARTe2_LIB}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(Test/UnitTests)
|
||||||
|
add_subdirectory(Test/Integration)
|
||||||
@@ -1,81 +1,32 @@
|
|||||||
# Demo Walkthrough: High-Speed Tracing
|
# Demo Walkthrough: High-Speed Tracing
|
||||||
|
|
||||||
This demo traces a `Timer.Counter` signal at 100 Hz, tests execution control, and verifies
|
This demo demonstrates tracing a `Timer.Counter` signal at 100Hz and verifying its consistency.
|
||||||
signal forcing. It works with either transport — choose the option that matches your setup.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. Build and Launch the Test Environment
|
|
||||||
|
|
||||||
|
### 1. Launch the Test Environment
|
||||||
|
Start the validation environment which simulates a real-time app:
|
||||||
```bash
|
```bash
|
||||||
source env.sh
|
./Build/Test/Integration/ValidationTest
|
||||||
make -f Makefile.gcc
|
|
||||||
./Build/x86-linux/Test/Integration/IntegrationTests
|
|
||||||
```
|
```
|
||||||
|
*Note: The test will wait for a trace command before finishing.*
|
||||||
|
|
||||||
The integration test starts a MARTe2 application with `DebugService` or `WebDebugService`
|
### 2. Connect the GUI
|
||||||
already configured and waits for client interaction.
|
In another terminal:
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Connect a Client
|
|
||||||
|
|
||||||
### Option A — Web Browser (`WebDebugService`)
|
|
||||||
|
|
||||||
Open `http://localhost:8090` in any browser. The UI appears instantly with the live
|
|
||||||
object tree already loaded.
|
|
||||||
|
|
||||||
### Option B — Rust GUI (`DebugService`)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd Tools/gui_client
|
cd Tools/gui_client
|
||||||
cargo run --release
|
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`).
|
||||||
|
|
||||||
## 3. Explore the Tree
|
### 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.
|
||||||
|
|
||||||
1. In the **Application Tree**, expand `Root → App → Data → Timer`.
|
### 5. Test Execution Control
|
||||||
2. Click **Info** (web UI) or **ℹ Info** (Rust GUI) on the `Timer` node.
|
1. Click the **⏸ Pause** button in the top bar.
|
||||||
3. Verify the config panel shows `SleepTime: 10000` (100 Hz cycle).
|
2. Observe that the plot stops updating and the counter value holds steady.
|
||||||
|
3. Click **▶ Resume** to continue execution.
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Activate Trace
|
|
||||||
|
|
||||||
1. Locate the `Counter` signal under `Timer`.
|
|
||||||
2. Click **Trace** (web UI) or **📈 Trace** (Rust GUI).
|
|
||||||
3. The real-time plot begins with a monotonically increasing counter.
|
|
||||||
4. Confirm telemetry is flowing:
|
|
||||||
- **Web UI:** `{"type":"trace",…}` events appear in the browser DevTools Network tab.
|
|
||||||
- **Rust GUI:** The **UDP Packets** counter in the top bar increments rapidly.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Test Execution Control
|
|
||||||
|
|
||||||
1. Click **Pause** (⏸).
|
|
||||||
2. Observe that the plot freezes and the counter holds steady.
|
|
||||||
3. Click **Step** with count = 5.
|
|
||||||
4. The counter advances exactly 5 units then stops.
|
|
||||||
5. Click **Resume** (▶) to continue normal execution.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. Test Signal Forcing
|
|
||||||
|
|
||||||
1. Locate `Root.App.Data.DDB.Counter`.
|
|
||||||
2. Click **Force** and enter `99999`.
|
|
||||||
3. Observe the oscilloscope plot jump to and hold at `99999`.
|
|
||||||
4. Click **Unforce** to release — the counter resumes its normal value.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 7. Test a Breakpoint
|
|
||||||
|
|
||||||
1. Click **Break** on `Root.App.Data.DDB.Counter`.
|
|
||||||
2. Set operator `>` and threshold `500`.
|
|
||||||
3. Wait for the counter to exceed 500 — the application pauses automatically.
|
|
||||||
4. The status shows **PAUSED** at the GAM that triggered the break.
|
|
||||||
5. Click **Break OFF** then **Resume** to continue.
|
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
#ifndef DEBUGBROKERWRAPPER_H
|
||||||
|
#define DEBUGBROKERWRAPPER_H
|
||||||
|
|
||||||
|
#include "DebugService.h"
|
||||||
|
#include "BrokerI.h"
|
||||||
|
#include "MemoryMapBroker.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "ObjectBuilder.h"
|
||||||
|
#include "Vector.h"
|
||||||
|
#include "FastPollingMutexSem.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
|
#include "Atomic.h"
|
||||||
|
|
||||||
|
// Original broker headers
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
#include "MemoryMapOutputBroker.h"
|
||||||
|
#include "MemoryMapSynchronisedInputBroker.h"
|
||||||
|
#include "MemoryMapSynchronisedOutputBroker.h"
|
||||||
|
#include "MemoryMapInterpolatedInputBroker.h"
|
||||||
|
#include "MemoryMapMultiBufferInputBroker.h"
|
||||||
|
#include "MemoryMapMultiBufferOutputBroker.h"
|
||||||
|
#include "MemoryMapSynchronisedMultiBufferInputBroker.h"
|
||||||
|
#include "MemoryMapSynchronisedMultiBufferOutputBroker.h"
|
||||||
|
#include "MemoryMapAsyncOutputBroker.h"
|
||||||
|
#include "MemoryMapAsyncTriggerOutputBroker.h"
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper for optimized signal processing within brokers.
|
||||||
|
*/
|
||||||
|
class DebugBrokerHelper {
|
||||||
|
public:
|
||||||
|
static void Process(DebugService* service, BrokerInfo& info) {
|
||||||
|
if (service == NULL_PTR(DebugService*)) return;
|
||||||
|
|
||||||
|
while (service->IsPaused()) {
|
||||||
|
Sleep::MSec(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*info.anyActiveFlag) {
|
||||||
|
uint32 idx = info.currentSetIdx;
|
||||||
|
BrokerActiveSet& set = info.sets[idx];
|
||||||
|
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < set.numForced; i++) {
|
||||||
|
SignalExecuteInfo& s = set.forcedSignals[i];
|
||||||
|
DebugService::CopySignal(s.memoryAddress, s.forcedValue, s.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < set.numTraced; i++) {
|
||||||
|
SignalExecuteInfo& s = set.tracedSignals[i];
|
||||||
|
(void)service->traceBuffer.Push(s.internalID, ts, s.memoryAddress, s.size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InitSignals(BrokerI* broker, DataSourceI &dataSourceIn, DebugService* &service, DebugSignalInfo** &signalInfoPointers, uint32 numCopies, MemoryMapBrokerCopyTableEntry* copyTable, const char8* functionName, SignalDirection direction, volatile bool* anyActiveFlag) {
|
||||||
|
if (numCopies > 0) {
|
||||||
|
signalInfoPointers = new DebugSignalInfo*[numCopies];
|
||||||
|
for (uint32 i=0; i<numCopies; i++) signalInfoPointers[i] = NULL_PTR(DebugSignalInfo*);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (service == NULL_PTR(DebugService*)) service = DebugService::Instance();
|
||||||
|
|
||||||
|
if (service && (copyTable != NULL_PTR(MemoryMapBrokerCopyTableEntry*))) {
|
||||||
|
StreamString dsPath;
|
||||||
|
DebugService::GetFullObjectName(dataSourceIn, dsPath);
|
||||||
|
MemoryMapBroker* mmb = dynamic_cast<MemoryMapBroker*>(broker);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < numCopies; i++) {
|
||||||
|
void *addr = copyTable[i].dataSourcePointer;
|
||||||
|
TypeDescriptor type = copyTable[i].type;
|
||||||
|
uint32 dsIdx = i;
|
||||||
|
if (mmb != NULL_PTR(MemoryMapBroker*)) dsIdx = mmb->GetDSCopySignalIndex(i);
|
||||||
|
|
||||||
|
StreamString signalName;
|
||||||
|
if (!dataSourceIn.GetSignalName(dsIdx, signalName)) {
|
||||||
|
signalName.Printf("Signal_%u", dsIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamString dsFullName = dsPath;
|
||||||
|
if (dsFullName.Size() > 0) dsFullName += ".";
|
||||||
|
dsFullName += signalName;
|
||||||
|
service->RegisterSignal(addr, type, dsFullName.Buffer());
|
||||||
|
|
||||||
|
if (functionName != NULL_PTR(const char8*)) {
|
||||||
|
StreamString gamFullName;
|
||||||
|
const char8* dirStr = (direction == InputSignals) ? "In" : "Out";
|
||||||
|
Reference gamRef = ObjectRegistryDatabase::Instance()->Find(functionName);
|
||||||
|
if (gamRef.IsValid()) {
|
||||||
|
StreamString absGamPath;
|
||||||
|
DebugService::GetFullObjectName(*(gamRef.operator->()), absGamPath);
|
||||||
|
gamFullName = absGamPath;
|
||||||
|
} else {
|
||||||
|
gamFullName = functionName;
|
||||||
|
}
|
||||||
|
gamFullName += ".";
|
||||||
|
gamFullName += dirStr;
|
||||||
|
gamFullName += ".";
|
||||||
|
gamFullName += signalName;
|
||||||
|
signalInfoPointers[i] = service->RegisterSignal(addr, type, gamFullName.Buffer());
|
||||||
|
} else {
|
||||||
|
signalInfoPointers[i] = service->RegisterSignal(addr, type, dsFullName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service->RegisterBroker(signalInfoPointers, numCopies, mmb, anyActiveFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class DebugMemoryMapInputBroker : public MemoryMapInputBroker, public DebugBrokerI {
|
||||||
|
public:
|
||||||
|
DebugMemoryMapInputBroker() : MemoryMapInputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||||
|
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||||
|
}
|
||||||
|
virtual void SetService(DebugService* s) { service = s; }
|
||||||
|
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||||
|
virtual bool Execute() {
|
||||||
|
bool ret = MemoryMapInputBroker::Execute();
|
||||||
|
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) {
|
||||||
|
bool ret = MemoryMapInputBroker::Init(direction, ds, name, gamMem);
|
||||||
|
if (ret) {
|
||||||
|
DebugSignalInfo** sigPtrs = NULL;
|
||||||
|
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, GetNumberOfCopies(), this->copyTable, name, direction, &anyActive);
|
||||||
|
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
DebugService* service;
|
||||||
|
BrokerInfo* infoPtr;
|
||||||
|
volatile bool anyActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class DebugGenericBroker : public T, public DebugBrokerI {
|
||||||
|
public:
|
||||||
|
DebugGenericBroker() : T(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||||
|
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||||
|
}
|
||||||
|
virtual void SetService(DebugService* s) { service = s; }
|
||||||
|
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||||
|
virtual bool Execute() {
|
||||||
|
bool ret = T::Execute();
|
||||||
|
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) {
|
||||||
|
bool ret = T::Init(direction, ds, name, gamMem);
|
||||||
|
if (ret) {
|
||||||
|
DebugSignalInfo** sigPtrs = NULL;
|
||||||
|
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, name, direction, &anyActive);
|
||||||
|
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
DebugService* service;
|
||||||
|
BrokerInfo* infoPtr;
|
||||||
|
volatile bool anyActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DebugMemoryMapAsyncOutputBroker : public MemoryMapAsyncOutputBroker, public DebugBrokerI {
|
||||||
|
public:
|
||||||
|
DebugMemoryMapAsyncOutputBroker() : MemoryMapAsyncOutputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||||
|
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||||
|
}
|
||||||
|
virtual void SetService(DebugService* s) { service = s; }
|
||||||
|
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||||
|
virtual bool Execute() {
|
||||||
|
bool ret = MemoryMapAsyncOutputBroker::Execute();
|
||||||
|
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool InitWithBufferParameters(const SignalDirection d, DataSourceI &ds, const char8* n, void* m, const uint32 nb, const ProcessorType& c, const uint32 s) {
|
||||||
|
bool ret = MemoryMapAsyncOutputBroker::InitWithBufferParameters(d, ds, n, m, nb, c, s);
|
||||||
|
if (ret) {
|
||||||
|
DebugSignalInfo** sigPtrs = NULL;
|
||||||
|
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, n, d, &anyActive);
|
||||||
|
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
DebugService* service;
|
||||||
|
BrokerInfo* infoPtr;
|
||||||
|
volatile bool anyActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DebugMemoryMapAsyncTriggerOutputBroker : public MemoryMapAsyncTriggerOutputBroker, public DebugBrokerI {
|
||||||
|
public:
|
||||||
|
DebugMemoryMapAsyncTriggerOutputBroker() : MemoryMapAsyncTriggerOutputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||||
|
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||||
|
}
|
||||||
|
virtual void SetService(DebugService* s) { service = s; }
|
||||||
|
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||||
|
virtual bool Execute() {
|
||||||
|
bool ret = MemoryMapAsyncTriggerOutputBroker::Execute();
|
||||||
|
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool InitWithTriggerParameters(const SignalDirection d, DataSourceI &ds, const char8* n, void* m, const uint32 nb, const uint32 pre, const uint32 post, const ProcessorType& c, const uint32 s) {
|
||||||
|
bool ret = MemoryMapAsyncTriggerOutputBroker::InitWithTriggerParameters(d, ds, n, m, nb, pre, post, c, s);
|
||||||
|
if (ret) {
|
||||||
|
DebugSignalInfo** sigPtrs = NULL;
|
||||||
|
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, n, d, &anyActive);
|
||||||
|
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
DebugService* service;
|
||||||
|
BrokerInfo* infoPtr;
|
||||||
|
volatile bool anyActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef DebugGenericBroker<MemoryMapOutputBroker> DebugMemoryMapOutputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapSynchronisedInputBroker> DebugMemoryMapSynchronisedInputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapSynchronisedOutputBroker> DebugMemoryMapSynchronisedOutputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapInterpolatedInputBroker> DebugMemoryMapInterpolatedInputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapMultiBufferInputBroker> DebugMemoryMapMultiBufferInputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapMultiBufferOutputBroker> DebugMemoryMapMultiBufferOutputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapSynchronisedMultiBufferInputBroker> DebugMemoryMapSynchronisedMultiBufferInputBroker;
|
||||||
|
typedef DebugGenericBroker<MemoryMapSynchronisedMultiBufferOutputBroker> DebugMemoryMapSynchronisedMultiBufferOutputBroker;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class DebugBrokerBuilder : public ObjectBuilder {
|
||||||
|
public:
|
||||||
|
virtual Object *Build(HeapI* const heap) const {
|
||||||
|
return new (heap) T();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapInputBroker> DebugMemoryMapInputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapOutputBroker> DebugMemoryMapOutputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedInputBroker> DebugMemoryMapSynchronisedInputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedOutputBroker> DebugMemoryMapSynchronisedOutputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapInterpolatedInputBroker> DebugMemoryMapInterpolatedInputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferInputBroker> DebugMemoryMapMultiBufferInputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferOutputBroker> DebugMemoryMapMultiBufferOutputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferInputBroker> DebugMemoryMapSynchronisedMultiBufferInputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferOutputBroker> DebugMemoryMapSynchronisedMultiBufferOutputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapAsyncOutputBroker> DebugMemoryMapAsyncOutputBrokerBuilder;
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapAsyncTriggerOutputBroker> DebugMemoryMapAsyncTriggerOutputBrokerBuilder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,36 +4,20 @@
|
|||||||
#include "CompilerTypes.h"
|
#include "CompilerTypes.h"
|
||||||
#include "TypeDescriptor.h"
|
#include "TypeDescriptor.h"
|
||||||
#include "StreamString.h"
|
#include "StreamString.h"
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
namespace MARTe {
|
namespace MARTe {
|
||||||
|
|
||||||
// Break condition operators stored in DebugSignalInfo::breakOp
|
|
||||||
enum BreakOp {
|
|
||||||
BREAK_OFF = 0,
|
|
||||||
BREAK_GT = 1, // >
|
|
||||||
BREAK_LT = 2, // <
|
|
||||||
BREAK_EQ = 3, // ==
|
|
||||||
BREAK_GEQ = 4, // >=
|
|
||||||
BREAK_LEQ = 5, // <=
|
|
||||||
BREAK_NEQ = 6 // !=
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DebugSignalInfo {
|
struct DebugSignalInfo {
|
||||||
void* memoryAddress;
|
void* memoryAddress;
|
||||||
TypeDescriptor type;
|
TypeDescriptor type;
|
||||||
StreamString name;
|
StreamString name;
|
||||||
uint8 numberOfDimensions;
|
|
||||||
uint32 numberOfElements;
|
|
||||||
volatile bool isTracing;
|
volatile bool isTracing;
|
||||||
volatile bool isForcing;
|
volatile bool isForcing;
|
||||||
uint8 forcedValue[1024];
|
uint8 forcedValue[1024];
|
||||||
uint32 internalID;
|
uint32 internalID;
|
||||||
volatile uint32 decimationFactor;
|
volatile uint32 decimationFactor;
|
||||||
volatile uint32 decimationCounter;
|
volatile uint32 decimationCounter;
|
||||||
// Conditional break fields (zero-cost when breakOp == BREAK_OFF)
|
|
||||||
volatile uint8 breakOp; // BreakOp enum value
|
|
||||||
float64 breakThreshold; // comparison threshold
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
@@ -114,19 +98,7 @@ public:
|
|||||||
ReadFromBuffer(&tempRead, &tempSize, 4);
|
ReadFromBuffer(&tempRead, &tempSize, 4);
|
||||||
|
|
||||||
if (tempSize > maxSize) {
|
if (tempSize > maxSize) {
|
||||||
// FIX #5: Skip only the current entry rather than discarding the
|
readIndex = write;
|
||||||
// entire ring buffer. tempRead is already past the 16-byte header;
|
|
||||||
// advancing by tempSize lands at the start of the next entry.
|
|
||||||
//
|
|
||||||
// Safety fallback: if tempSize >= bufferSize the stored size field
|
|
||||||
// is corrupt (it can never be that large). In that case we cannot
|
|
||||||
// locate the next entry safely, so fall back to discarding everything
|
|
||||||
// to avoid reading garbage as sample headers on future Pop() calls.
|
|
||||||
if (tempSize >= bufferSize) {
|
|
||||||
readIndex = write; // corrupt ring — discard all
|
|
||||||
} else {
|
|
||||||
readIndex = (tempRead + tempSize) % bufferSize;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,12 +124,12 @@ private:
|
|||||||
uint32 current = *idx;
|
uint32 current = *idx;
|
||||||
uint32 spaceToEnd = bufferSize - current;
|
uint32 spaceToEnd = bufferSize - current;
|
||||||
if (count <= spaceToEnd) {
|
if (count <= spaceToEnd) {
|
||||||
memcpy(&buffer[current], src, count);
|
std::memcpy(&buffer[current], src, count);
|
||||||
*idx = (current + count) % bufferSize;
|
*idx = (current + count) % bufferSize;
|
||||||
} else {
|
} else {
|
||||||
memcpy(&buffer[current], src, spaceToEnd);
|
std::memcpy(&buffer[current], src, spaceToEnd);
|
||||||
uint32 remaining = count - spaceToEnd;
|
uint32 remaining = count - spaceToEnd;
|
||||||
memcpy(&buffer[0], (uint8*)src + spaceToEnd, remaining);
|
std::memcpy(&buffer[0], (uint8*)src + spaceToEnd, remaining);
|
||||||
*idx = remaining;
|
*idx = remaining;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,12 +138,12 @@ private:
|
|||||||
uint32 current = *idx;
|
uint32 current = *idx;
|
||||||
uint32 spaceToEnd = bufferSize - current;
|
uint32 spaceToEnd = bufferSize - current;
|
||||||
if (count <= spaceToEnd) {
|
if (count <= spaceToEnd) {
|
||||||
memcpy(dst, &buffer[current], count);
|
std::memcpy(dst, &buffer[current], count);
|
||||||
*idx = (current + count) % bufferSize;
|
*idx = (current + count) % bufferSize;
|
||||||
} else {
|
} else {
|
||||||
memcpy(dst, &buffer[current], spaceToEnd);
|
std::memcpy(dst, &buffer[current], spaceToEnd);
|
||||||
uint32 remaining = count - spaceToEnd;
|
uint32 remaining = count - spaceToEnd;
|
||||||
memcpy((uint8*)dst + spaceToEnd, &buffer[0], remaining);
|
std::memcpy((uint8*)dst + spaceToEnd, &buffer[0], remaining);
|
||||||
*idx = remaining;
|
*idx = remaining;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
#ifndef DEBUGSERVICE_H
|
||||||
|
#define DEBUGSERVICE_H
|
||||||
|
|
||||||
|
#include "MessageI.h"
|
||||||
|
#include "StreamString.h"
|
||||||
|
#include "BasicUDPSocket.h"
|
||||||
|
#include "BasicTCPSocket.h"
|
||||||
|
#include "ReferenceContainer.h"
|
||||||
|
#include "SingleThreadService.h"
|
||||||
|
#include "EmbeddedServiceMethodBinderI.h"
|
||||||
|
#include "Object.h"
|
||||||
|
#include "DebugCore.h"
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
|
||||||
|
class MemoryMapBroker;
|
||||||
|
class DebugService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Interface for instrumented brokers to allow service adoption.
|
||||||
|
*/
|
||||||
|
class DebugBrokerI {
|
||||||
|
public:
|
||||||
|
virtual ~DebugBrokerI() {}
|
||||||
|
virtual void SetService(DebugService* service) = 0;
|
||||||
|
virtual bool IsLinked() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SignalExecuteInfo {
|
||||||
|
void* memoryAddress;
|
||||||
|
void* forcedValue;
|
||||||
|
uint32 internalID;
|
||||||
|
uint32 size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BrokerActiveSet {
|
||||||
|
SignalExecuteInfo* forcedSignals;
|
||||||
|
uint32 numForced;
|
||||||
|
SignalExecuteInfo* tracedSignals;
|
||||||
|
uint32 numTraced;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BrokerInfo {
|
||||||
|
DebugSignalInfo** signalPointers;
|
||||||
|
uint32 numSignals;
|
||||||
|
MemoryMapBroker* broker;
|
||||||
|
BrokerActiveSet sets[2];
|
||||||
|
volatile uint32 currentSetIdx;
|
||||||
|
volatile bool* anyActiveFlag;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SignalAlias {
|
||||||
|
StreamString name;
|
||||||
|
uint32 signalIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DebugService : public ReferenceContainer, public MessageI, public EmbeddedServiceMethodBinderI {
|
||||||
|
public:
|
||||||
|
friend class DebugServiceTest;
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
DebugService();
|
||||||
|
virtual ~DebugService();
|
||||||
|
|
||||||
|
virtual bool Initialise(StructuredDataI & data);
|
||||||
|
|
||||||
|
DebugSignalInfo* RegisterSignal(void* memoryAddress, TypeDescriptor type, const char8* name);
|
||||||
|
|
||||||
|
static inline void CopySignal(void* dst, const void* src, const uint32 size) {
|
||||||
|
if (size == 4u) *static_cast<uint32*>(dst) = *static_cast<const uint32*>(src);
|
||||||
|
else if (size == 8u) *static_cast<uint64*>(dst) = *static_cast<const uint64*>(src);
|
||||||
|
else if (size == 1u) *static_cast<uint8*>(dst) = *static_cast<const uint8*>(src);
|
||||||
|
else if (size == 2u) *static_cast<uint16*>(dst) = *static_cast<const uint16*>(src);
|
||||||
|
else MemoryOperationsHelper::Copy(dst, src, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessSignal(DebugSignalInfo* signalInfo, uint32 size, uint64 timestamp);
|
||||||
|
|
||||||
|
void RegisterBroker(DebugSignalInfo** signalPointers, uint32 numSignals, MemoryMapBroker* broker, volatile bool* anyActiveFlag);
|
||||||
|
|
||||||
|
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
|
||||||
|
|
||||||
|
static DebugService* Instance();
|
||||||
|
|
||||||
|
bool IsPaused() const { return isPaused; }
|
||||||
|
void SetPaused(bool paused) { isPaused = paused; }
|
||||||
|
|
||||||
|
static bool GetFullObjectName(const Object &obj, StreamString &fullPath);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
void UpdateBrokersActiveStatus();
|
||||||
|
|
||||||
|
BrokerInfo* GetBrokerInfo(uint32 index) {
|
||||||
|
if (index < numberOfBrokers) return &brokers[index];
|
||||||
|
return NULL_PTR(BrokerInfo*);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PERFORMANCE-CRITICAL MEMBERS
|
||||||
|
static const uint32 MAX_BROKERS = 256;
|
||||||
|
BrokerInfo brokers[MAX_BROKERS];
|
||||||
|
uint32 numberOfBrokers;
|
||||||
|
TraceRingBuffer traceBuffer;
|
||||||
|
|
||||||
|
static const uint32 MAX_SIGNALS = 512;
|
||||||
|
DebugSignalInfo signals[MAX_SIGNALS];
|
||||||
|
uint32 numberOfSignals;
|
||||||
|
|
||||||
|
static const uint32 MAX_ALIASES = 1024;
|
||||||
|
SignalAlias aliases[MAX_ALIASES];
|
||||||
|
uint32 numberOfAliases;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
uint16 controlPort;
|
||||||
|
uint16 streamPort;
|
||||||
|
StreamString streamIP;
|
||||||
|
bool isServer;
|
||||||
|
bool suppressTimeoutLogs;
|
||||||
|
volatile bool isPaused;
|
||||||
|
|
||||||
|
BasicTCPSocket tcpServer;
|
||||||
|
BasicUDPSocket udpSocket;
|
||||||
|
|
||||||
|
class ServiceBinder : public EmbeddedServiceMethodBinderI {
|
||||||
|
public:
|
||||||
|
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);
|
||||||
|
return parent->Server(info);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
DebugService *parent;
|
||||||
|
ServiceType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
ServiceBinder binderServer;
|
||||||
|
ServiceBinder binderStreamer;
|
||||||
|
|
||||||
|
SingleThreadService threadService;
|
||||||
|
SingleThreadService streamerService;
|
||||||
|
|
||||||
|
ThreadIdentifier serverThreadId;
|
||||||
|
ThreadIdentifier streamerThreadId;
|
||||||
|
|
||||||
|
FastPollingMutexSem mutex;
|
||||||
|
|
||||||
|
static const uint32 MAX_CLIENTS = 16;
|
||||||
|
BasicTCPSocket* activeClients[MAX_CLIENTS];
|
||||||
|
FastPollingMutexSem clientsMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern DebugService* GlobalDebugServiceInstance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -29,8 +29,6 @@ public:
|
|||||||
|
|
||||||
virtual bool Initialise(StructuredDataI & data);
|
virtual bool Initialise(StructuredDataI & data);
|
||||||
|
|
||||||
virtual bool ExportData(StructuredDataI & data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implementation of LoggerConsumerI.
|
* @brief Implementation of LoggerConsumerI.
|
||||||
* Called by LoggerService.
|
* Called by LoggerService.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
all: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
mkdir -p Build && cd Build && . ../env.sh && cmake -DCMAKE_BUILD_TYPE=Debug .. && make
|
||||||
|
ln -sf libmarte_dev.so Build/DebugService.so
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf Build
|
||||||
|
|
||||||
|
.PHONY: all build clean
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
export TARGET=x86-linux
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
#Subprojects w.r.t. the main directory only (important to allow setting SPBM as an export variable).
|
|
||||||
#If SPB is directly exported as an environment variable it will also be evaluated as part of the subprojects SPB, thus
|
|
||||||
#potentially overriding its value
|
|
||||||
#Main target subprojects. May be overridden by shell definition.
|
|
||||||
SPBM?=Source/Components/Interfaces.x
|
|
||||||
SPBMT?=Test.x
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#This really has to be defined locally.
|
|
||||||
SUBPROJMAIN=$(SPBM:%.x=%.spb)
|
|
||||||
SUBPROJMAINTEST=$(SPBMT:%.x=%.spb)
|
|
||||||
SUBPROJMAINCLEAN=$(SPBM:%.x=%.spc)
|
|
||||||
SUBPROJMAINTESTCLEAN=$(SPBMT:%.x=%.spc)
|
|
||||||
|
|
||||||
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
|
|
||||||
ROOT_DIR=.
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
all: $(OBJS) core test
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
compile_commands.json:
|
|
||||||
bear -- make -f Makefile.gcc
|
|
||||||
|
|
||||||
core: $(SUBPROJMAIN) check-env
|
|
||||||
echo $(SUBPROJMAIN)
|
|
||||||
|
|
||||||
test: $(SUBPROJMAINTEST)
|
|
||||||
echo $(SUBPROJMAINTEST)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:: $(SUBPROJMAINCLEAN) $(SUBPROJMAINTESTCLEAN) clean_wipe_old
|
|
||||||
#clean:: $(SUBPROJMAINCLEAN) $(SUBPROJMAINTESTCLEAN) clean_wipe_old
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
|
|
||||||
check-marte:
|
|
||||||
ifndef MARTe2_DIR
|
|
||||||
$(error MARTe2_DIR is undefined)
|
|
||||||
endif
|
|
||||||
|
|
||||||
check-env:
|
|
||||||
ifndef MARTe2_DIR
|
|
||||||
$(error MARTe2_DIR is undefined)
|
|
||||||
endif
|
|
||||||
|
|
||||||
@@ -1,110 +1,51 @@
|
|||||||
# MARTe2 Debug Suite
|
# MARTe2 Debug Suite
|
||||||
|
|
||||||
An interactive observability and debugging suite for the MARTe2 real-time framework. Instruments any running application **without modifying its source code**, providing real-time signal tracing, forced-value injection, breakpoints, execution stepping, and log forwarding.
|
An interactive observability and debugging suite for the MARTe2 real-time framework.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### 1. Build
|
### 1. Build the project
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source env.sh
|
. ./env.sh
|
||||||
make -f Makefile.gcc
|
cd Build
|
||||||
|
cmake ..
|
||||||
|
make -j$(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Run Integration Tests
|
### 2. Run Integration Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source env.sh
|
./Test/Integration/ValidationTest # Verifies 100Hz tracing
|
||||||
./Build/x86-linux/Test/Integration/Integration/IntegrationTests.ex
|
./Test/Integration/SchedulerTest # Verifies execution control
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Choose Your Client
|
### 3. Launch GUI
|
||||||
|
|
||||||
**Option A — Web UI (no install required)**
|
|
||||||
|
|
||||||
Add `WebDebugService` to your application config and open `http://localhost:8090` in any browser:
|
|
||||||
|
|
||||||
```text
|
|
||||||
+WebDebugService = {
|
|
||||||
Class = WebDebugService
|
|
||||||
HttpPort = 8090
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Option B — Rust Native GUI**
|
|
||||||
|
|
||||||
Add `DebugService` to your application config, then launch the GUI:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd Tools/gui_client
|
cd Tools/gui_client
|
||||||
cargo run --release
|
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
|
```text
|
||||||
+DebugService = {
|
+DebugService = {
|
||||||
Class = DebugService
|
Class = DebugService
|
||||||
ControlPort = 8080
|
ControlPort = 8080
|
||||||
UdpPort = 8081
|
UdpPort = 8081
|
||||||
LogPort = 8082
|
}
|
||||||
|
|
||||||
|
+LoggerService = {
|
||||||
|
Class = LoggerService
|
||||||
|
+DebugConsumer = {
|
||||||
|
Class = TcpLogger
|
||||||
|
Port = 8082
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
The suite automatically patches the registry to instrument your existing Brokers and Schedulers.
|
||||||
---
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
| Feature | Description |
|
|
||||||
|---|---|
|
|
||||||
| **Zero-code-change** | Registry patching replaces standard brokers at runtime — no application changes needed |
|
|
||||||
| **Signal tracing** | Stream any signal at full RT rate over UDP (DebugService) or SSE (WebDebugService) |
|
|
||||||
| **Signal forcing** | Persistent value injection directly into the RT memory map |
|
|
||||||
| **Breakpoints** | Halt execution when a signal crosses a threshold (`> < == >= <= !=`) |
|
|
||||||
| **Execution stepping** | Step N RT cycles then pause; optionally filter by thread |
|
|
||||||
| **Live object tree** | Browse the full `ObjectRegistryDatabase` hierarchy with signal metadata |
|
|
||||||
| **Config serving** | Retrieve the complete application CDB as JSON |
|
|
||||||
| **Log forwarding** | All `REPORT_ERROR` events forwarded to the client in real time |
|
|
||||||
| **Signal monitoring** | Poll any `DataSourceI` signal at a configurable period |
|
|
||||||
| **MARTe2 messaging** | Send `Message` objects to any ORD object from the debug client |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Transports at a Glance
|
|
||||||
|
|
||||||
| | `DebugService` | `WebDebugService` |
|
|
||||||
|---|---|---|
|
|
||||||
| **Client** | Rust native GUI or any TCP tool | Any web browser |
|
|
||||||
| **Commands** | Text over TCP (port 8080) | HTTP POST `/api/command` |
|
|
||||||
| **Telemetry** | Binary UDP (port 8081) | Server-Sent Events `/api/events` |
|
|
||||||
| **Logs** | TcpLogger TCP (port 8082) | SSE event stream |
|
|
||||||
| **Install** | Rust + Cargo | None |
|
|
||||||
|
|
||||||
Both transports implement the same `DebugServiceI` interface and register themselves as the global singleton — they are mutually exclusive (one per application).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Repository Layout
|
|
||||||
|
|
||||||
```
|
|
||||||
Source/
|
|
||||||
Core/Types/
|
|
||||||
Vec/ — RT-safe dynamic array (no STL)
|
|
||||||
Result/ — Error-carrying return type
|
|
||||||
Components/Interfaces/
|
|
||||||
DebugService/
|
|
||||||
DebugCore.h — DebugSignalInfo, TraceRingBuffer, break op codes
|
|
||||||
DebugServiceI.h — Abstract interface + SignalAlias, BrokerInfo structs
|
|
||||||
DebugBrokerWrapper.h — Broker wrapper templates + registry builder helpers
|
|
||||||
DebugService.h/.cpp — TCP/UDP implementation
|
|
||||||
WebDebugService/
|
|
||||||
WebUI.h — Embedded single-page HTML/CSS/JS application
|
|
||||||
WebDebugService.h/.cpp — HTTP/SSE implementation
|
|
||||||
TCPLogger/
|
|
||||||
TcpLogger.h/.cpp — LoggerConsumerI forwarding logs to TCP clients
|
|
||||||
Test/
|
|
||||||
Integration/ — Integration test suite (180 s SIGALRM guard)
|
|
||||||
UnitTests/ — Unit test suite (COVERAGE V34)
|
|
||||||
Tools/
|
|
||||||
gui_client/ — Rust/egui native GUI (DebugService transport only)
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -1,145 +1,50 @@
|
|||||||
# MARTe2 Debug Suite Specifications
|
# MARTe2 Debug Suite Specifications
|
||||||
|
|
||||||
**Version:** 2.0
|
## 1. Goal
|
||||||
**Status:** Active / Implemented
|
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)
|
||||||
## 1. Executive Summary
|
- **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.
|
||||||
This project implements a "Zero-Code-Change" observability and debugging layer for the
|
|
||||||
MARTe2 real-time framework. Developers can trace, force, and monitor any signal in a
|
|
||||||
running MARTe2 application without modifying existing source code.
|
|
||||||
|
|
||||||
The suite ships two interchangeable transport backends sharing a common abstract interface:
|
|
||||||
|
|
||||||
- **`DebugService`** — TCP command channel + binary UDP telemetry + `TcpLogger` sidecar.
|
|
||||||
Paired with a native Rust/egui GUI.
|
|
||||||
- **`WebDebugService`** — HTTP command endpoint + Server-Sent Events telemetry, with an
|
|
||||||
embedded single-page browser UI. No additional client software required.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. System Architecture
|
|
||||||
|
|
||||||
- **`DebugServiceI` (Abstract Interface):** Singleton that decouples the broker injection
|
|
||||||
layer from the transport. Defined in `DebugServiceI.h`.
|
|
||||||
- **`DebugService` (TCP/UDP Transport):** TCP text command channel (port 8080), binary UDP
|
|
||||||
telemetry (port 8081), `TcpLogger` log sidecar (port 8082).
|
|
||||||
- **`WebDebugService` (HTTP/SSE Transport):** Single HTTP port (default 8090) serving the
|
|
||||||
embedded web UI, command API, and SSE telemetry stream.
|
|
||||||
- **`DebugBrokerWrapper` (Injection Layer):** C++ template wrappers injected via registry
|
|
||||||
patching. Depend only on `DebugServiceI`; transport-agnostic.
|
|
||||||
- **`TcpLogger` (Log Sidecar):** Optional standalone component forwarding `REPORT_ERROR`
|
|
||||||
events to TCP clients on a dedicated port (used with `DebugService` only).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Requirements
|
|
||||||
|
|
||||||
### 3.1 Functional Requirements (FR)
|
|
||||||
|
|
||||||
- **FR-01 (Discovery):** Discover the full MARTe2 object hierarchy at runtime. The client
|
|
||||||
SHALL request the full application tree and display it hierarchically.
|
|
||||||
- **FR-02 (Telemetry):** Stream high-frequency signal data (verified > 100 Hz) to a remote
|
|
||||||
client. `DebugService` uses binary UDP; `WebDebugService` uses SSE.
|
|
||||||
- **FR-03 (Forcing):** Allow manual override of signal values in memory during execution.
|
- **FR-03 (Forcing):** Allow manual override of signal values in memory during execution.
|
||||||
The override SHALL persist across RT cycles until explicitly released.
|
- **FR-04 (Logs):** Stream global framework logs to a dedicated terminal via a standalone `TcpLogger` service.
|
||||||
- **FR-04 (Logs):** Forward all `REPORT_ERROR` events to a connected client in real time.
|
- **FR-05 (Log Filtering):** The client must support filtering logs by type (Debug, Information, Warning, FatalError) and by content using regular expressions.
|
||||||
`DebugService` uses `TcpLogger` on a dedicated TCP port. `WebDebugService` embeds logs
|
- **FR-06 (Execution & UI):**
|
||||||
in the SSE stream.
|
- Provide a native GUI for visualization.
|
||||||
- **FR-05 (Log Filtering):** The client SHOULD support filtering log output by level and
|
- Support Pause/Resume of real-time execution threads via scheduler injection.
|
||||||
by content.
|
- **FR-07 (Session Management):**
|
||||||
- **FR-06 (Execution Control):** Provide pause and resume for all patched RT threads,
|
- The top panel must provide a "Disconnect" button to close active network streams.
|
||||||
allowing static inspection of the system state.
|
- Support runtime re-configuration and "Apply & Reconnect" logic.
|
||||||
- **FR-07 (Breakpoints):** Halt execution when a signal crosses a threshold. Supported
|
- **FR-08 (Decoupled Tracing):**
|
||||||
operators: `>`, `<`, `==`, `>=`, `<=`, `!=`.
|
Clicking `trace` activates telemetry; data is buffered and shown as a "Last Value" in the sidebar, but not plotted until manually assigned.
|
||||||
- **FR-08 (Execution Stepping):** After a pause or breakpoint, allow resuming for exactly
|
- **FR-08 (Advanced Plotting):**
|
||||||
N output-broker cycles then pausing again. Optional per-thread filter.
|
- Support multiple plot panels with perfectly synchronized time (X) axes.
|
||||||
- **FR-09 (Decoupled Tracing):** Activating a trace SHALL only stream data; displaying
|
- Drag-and-drop signals from the traced list into specific plots.
|
||||||
the data (plot, sidebar) is the client's responsibility.
|
- Automatic distinct color assignment for each signal added to a plot.
|
||||||
- **FR-10 (Signal Monitoring):** Poll any `DataSourceI` signal at a configurable period
|
- Plot modes: Standard (Time Series) and Logic Analyzer (Stacked rows).
|
||||||
without requiring that signal to be traced at full RT rate.
|
- Signal transformations: Gain, offset, units, and custom labels.
|
||||||
- **FR-11 (Config Awareness):** The service SHALL accept and store a full copy of the
|
- Visual styling: Deep customization of colors, line styles (Solid, Dashed, etc.), and marker shapes (Circle, Square, etc.).
|
||||||
application's CDB (`SetFullConfig`). `INFO` and `DISCOVER` responses SHALL be enriched
|
- **FR-09 (Navigation):**
|
||||||
with additional metadata fields from this CDB.
|
- Context menus for resetting zoom (X, Y, or both).
|
||||||
- **FR-12 (Config Serving):** Provide a `CONFIG` command returning the full stored
|
- "Fit to View" functionality that automatically scales both axes to encompass all available buffered data points.
|
||||||
configuration as JSON.
|
- **FR-10 (Scope Mode):**
|
||||||
- **FR-13 (MARTe2 Messaging):** Allow sending `Message` objects to any ORD object via an
|
- High-performance oscilloscope mode with configurable time windows (10ms to 10s).
|
||||||
`MSG` command.
|
- Global synchronization of time axes across all plot panels.
|
||||||
- **FR-14 (Dual Transport):** Both `DebugService` and `WebDebugService` SHALL implement
|
- Support for Free-run and Triggered acquisition (Single/Continuous, rising/falling edges).
|
||||||
the identical `DebugServiceI` interface and be mutually exclusive singletons. Switching
|
- **FR-11 (Data Recording):**
|
||||||
transport SHALL require only a config change (different class name, different port).
|
- Record any traced signal to disk in Parquet format.
|
||||||
- **FR-15 (Embedded Web UI):** `WebDebugService` SHALL serve a self-contained single-page
|
- Native file dialog for destination selection.
|
||||||
application with real-time plotting (Chart.js), signal tree, force/break/monitor dialogs,
|
- Visual recording indicator in the GUI.
|
||||||
and an integrated log viewer — without any external server or build tooling.
|
|
||||||
|
|
||||||
### 3.2 Technical Constraints (TC)
|
|
||||||
|
|
||||||
|
### 2.2 Technical Constraints (TC)
|
||||||
- **TC-01:** No modifications allowed to the MARTe2 core library or component source code.
|
- **TC-01:** No modifications allowed to the MARTe2 core library or component source code.
|
||||||
- **TC-02:** Instrumentation MUST use runtime class registry patching (`ClassRegistryDatabase`).
|
- **TC-02:** Instrumentation must use Runtime Class Registry Patching.
|
||||||
- **TC-03:** RT-path methods (`ProcessSignal`, `IsPaused`) MUST be lock-free or use only
|
- **TC-03:** Real-time threads must remain lock-free; use `FastPollingMutexSem` or atomic operations for synchronization.
|
||||||
`FastPollingMutexSem`; no heap allocation on the RT path.
|
- **TC-04:** Telemetry must be delivered via UDP to minimize impact on real-time jitter.
|
||||||
- **TC-04:** `DebugService` telemetry MUST use UDP to minimise jitter impact.
|
|
||||||
- **TC-05:** No STL — use `Vec<T>` and `StreamString` throughout.
|
|
||||||
- **TC-06:** C++98 compatibility for all source files (no `auto`, no range-for, no raw
|
|
||||||
string literals).
|
|
||||||
- **TC-07:** The `DebugServiceI` abstract interface MUST be the only dependency of
|
|
||||||
`DebugBrokerWrapper`. Concrete transport headers MUST NOT be included by broker code.
|
|
||||||
|
|
||||||
---
|
## 3. Performance Metrics
|
||||||
|
- **Latency:** Telemetry dispatch overhead < 5 microseconds per signal.
|
||||||
## 4. Performance Requirements
|
- **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.
|
||||||
- **Latency:** `ProcessSignal` overhead < 5 µs per signal when tracing is inactive.
|
- **Code Quality:** Maintain a minimum of **85% code coverage** across all core service and broker logic.
|
||||||
- **Throughput:** Support > 100 Hz signal tracing with zero sample loss on local networks
|
|
||||||
(UDP transport).
|
|
||||||
- **Scalability:** Handle up to 4096 unique signals.
|
|
||||||
- **Ring buffer size:** `TraceRingBuffer` initialised to 4 MB in both transports.
|
|
||||||
- **SSE clients:** `WebDebugService` supports up to 8 simultaneous SSE clients.
|
|
||||||
- **TCP rate limit:** Server disconnects clients sending > 100 commands/s.
|
|
||||||
- **VALUE output cap:** `GetSignalValue` returns at most 256 elements per call.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Performance Hardening Log
|
|
||||||
|
|
||||||
| Fix | Category | Description |
|
|
||||||
|---|---|---|
|
|
||||||
| **#1** | Naming | `STREAMER_MTU = 1400`, `STREAMER_BUFFER_SIZE = 4096` replace magic numbers |
|
|
||||||
| **#2** | Concurrency | `tracePushMutex` serialises multi-producer `TraceRingBuffer::Push()` |
|
|
||||||
| **#3** | Concurrency | Break indices copied under `activeMutex`; condition evaluated outside lock |
|
|
||||||
| **#4** | Concurrency | `Atomic::Add` for lock-free per-signal decimation counter |
|
|
||||||
| **#5** | Robustness | `TraceRingBuffer::Pop` skips corrupt entry; full discard only when unrecoverable |
|
|
||||||
| **#6** | Security | TCP command rate-limit: > 100 cmd/s → client disconnect |
|
|
||||||
| **#7** | Latency | `Vec::Swap` inside spinlock; deallocation outside — shorter lock hold time |
|
|
||||||
| **#8** | Robustness | 30-second idle timeout on active TCP client |
|
|
||||||
| **#9** | Safety | `VALUE` output capped at 256 elements; `"truncated":true` flag included |
|
|
||||||
| **#10** | Correctness | `inputBuffer` reassembles split TCP commands; bounded at 8 KiB |
|
|
||||||
| **#11** | Correctness | `Initialise()` never calls `MoveToRoot()` on the framework-supplied CDB |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. Command Protocol Summary
|
|
||||||
|
|
||||||
| Command | Transport | Description |
|
|
||||||
|---|---|---|
|
|
||||||
| `DISCOVER` | Both | Full signal list with metadata |
|
|
||||||
| `TREE` | Both | Live ORD hierarchy as JSON |
|
|
||||||
| `INFO <path>` | Both | Node metadata enriched from CDB |
|
|
||||||
| `LS [path]` | Both | Immediate children of ORD node |
|
|
||||||
| `TRACE <name> <0\|1> [dec]` | Both | Enable/disable signal tracing |
|
|
||||||
| `FORCE <name> <value>` | Both | Persistent signal value injection |
|
|
||||||
| `UNFORCE <name>` | Both | Remove forced value |
|
|
||||||
| `BREAK <name> <op> <thr>` | Both | Set conditional breakpoint |
|
|
||||||
| `BREAK <name> OFF` | Both | Clear breakpoint |
|
|
||||||
| `PAUSE` | Both | Halt all RT threads |
|
|
||||||
| `RESUME` | Both | Release paused RT threads |
|
|
||||||
| `STEP <n> [thread]` | Both | Run N cycles then pause |
|
|
||||||
| `STEP_STATUS` | Both | Query pause/step state |
|
|
||||||
| `VALUE <name>` | Both | Read current signal value |
|
|
||||||
| `MONITOR SIGNAL <name> <ms>` | Both | Register slow-rate polling |
|
|
||||||
| `UNMONITOR SIGNAL <name>` | Both | Stop slow-rate polling |
|
|
||||||
| `CONFIG` | Both | Full CDB as JSON |
|
|
||||||
| `MSG <obj> <fn> [k=v …]` | Both | Send MARTe2 Message |
|
|
||||||
| `SERVICE_INFO` | Both | Transport metadata |
|
|
||||||
|
|||||||
@@ -1,590 +0,0 @@
|
|||||||
#ifndef DEBUGBROKERWRAPPER_H
|
|
||||||
#define DEBUGBROKERWRAPPER_H
|
|
||||||
|
|
||||||
#include "BrokerI.h"
|
|
||||||
#include "DataSourceI.h"
|
|
||||||
#include "DebugServiceI.h"
|
|
||||||
#include "FastPollingMutexSem.h"
|
|
||||||
#include "HighResolutionTimer.h"
|
|
||||||
#include "MemoryMapBroker.h"
|
|
||||||
#include "ObjectBuilder.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "Threads.h"
|
|
||||||
|
|
||||||
// Original broker headers
|
|
||||||
#include "MemoryMapAsyncOutputBroker.h"
|
|
||||||
#include "MemoryMapAsyncTriggerOutputBroker.h"
|
|
||||||
#include "MemoryMapInputBroker.h"
|
|
||||||
#include "MemoryMapInterpolatedInputBroker.h"
|
|
||||||
#include "MemoryMapMultiBufferInputBroker.h"
|
|
||||||
#include "MemoryMapMultiBufferOutputBroker.h"
|
|
||||||
#include "MemoryMapOutputBroker.h"
|
|
||||||
#include "MemoryMapSynchronisedInputBroker.h"
|
|
||||||
#include "MemoryMapSynchronisedMultiBufferInputBroker.h"
|
|
||||||
#include "MemoryMapSynchronisedMultiBufferOutputBroker.h"
|
|
||||||
#include "MemoryMapSynchronisedOutputBroker.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
// Recursive search for any object with a given name anywhere in the registry.
|
|
||||||
// Used to find GAMs regardless of nesting level.
|
|
||||||
static Reference FindByNameRecursive(ReferenceContainer *container,
|
|
||||||
const char8 *name) {
|
|
||||||
if (container == NULL_PTR(ReferenceContainer *))
|
|
||||||
return Reference();
|
|
||||||
uint32 n = container->Size();
|
|
||||||
for (uint32 i = 0; i < n; i++) {
|
|
||||||
Reference child = container->Get(i);
|
|
||||||
if (!child.IsValid())
|
|
||||||
continue;
|
|
||||||
if (StringHelper::Compare(child->GetName(), name) == 0)
|
|
||||||
return child;
|
|
||||||
ReferenceContainer *sub =
|
|
||||||
dynamic_cast<ReferenceContainer *>(child.operator->());
|
|
||||||
if (sub != NULL_PTR(ReferenceContainer *)) {
|
|
||||||
Reference found = FindByNameRecursive(sub, name);
|
|
||||||
if (found.IsValid())
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Reference();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Helper for optimized signal processing within brokers.
|
|
||||||
*/
|
|
||||||
class DebugBrokerHelper {
|
|
||||||
public:
|
|
||||||
// Evaluate a break condition against the current live value of a signal.
|
|
||||||
// Returns true if the condition is met and execution should be paused.
|
|
||||||
// Only called when signal->breakOp != BREAK_OFF; reads memoryAddress directly.
|
|
||||||
static bool EvaluateBreak(const DebugSignalInfo *s) {
|
|
||||||
if (s->memoryAddress == NULL_PTR(void *)) return false;
|
|
||||||
float64 val = 0.0;
|
|
||||||
const TypeDescriptor &t = s->type;
|
|
||||||
if (t == Float64Bit) val = *static_cast<const float64 *>(s->memoryAddress);
|
|
||||||
else if (t == Float32Bit) val = *static_cast<const float32 *>(s->memoryAddress);
|
|
||||||
else if (t == UnsignedInteger32Bit) val = *static_cast<const uint32 *>(s->memoryAddress);
|
|
||||||
else if (t == SignedInteger32Bit) val = *static_cast<const int32 *>(s->memoryAddress);
|
|
||||||
else if (t == UnsignedInteger64Bit) val = static_cast<float64>(*static_cast<const uint64 *>(s->memoryAddress));
|
|
||||||
else if (t == SignedInteger64Bit) val = static_cast<float64>(*static_cast<const int64 *>(s->memoryAddress));
|
|
||||||
else if (t == UnsignedInteger16Bit) val = *static_cast<const uint16 *>(s->memoryAddress);
|
|
||||||
else if (t == SignedInteger16Bit) val = *static_cast<const int16 *>(s->memoryAddress);
|
|
||||||
else if (t == UnsignedInteger8Bit) val = *static_cast<const uint8 *>(s->memoryAddress);
|
|
||||||
else if (t == SignedInteger8Bit) val = *static_cast<const int8 *>(s->memoryAddress);
|
|
||||||
else return false; // unsupported type — skip
|
|
||||||
const float64 thr = s->breakThreshold;
|
|
||||||
switch (s->breakOp) {
|
|
||||||
case BREAK_GT: return val > thr;
|
|
||||||
case BREAK_LT: return val < thr;
|
|
||||||
case BREAK_EQ: return val == thr;
|
|
||||||
case BREAK_GEQ: return val >= thr;
|
|
||||||
case BREAK_LEQ: return val <= thr;
|
|
||||||
case BREAK_NEQ: return val != thr;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spin-wait point for output brokers — called from Execute() AFTER Process().
|
|
||||||
// Spins while paused, then consumes one step counter tick (if stepping).
|
|
||||||
// Input brokers must NOT call this — they complete normally to avoid blocking
|
|
||||||
// cross-thread EventSem posts (RealTimeThreadSynchBroker would time out).
|
|
||||||
static void OutputPauseAndStep(DebugServiceI *service, const char8 *gamName) {
|
|
||||||
if (service == NULL_PTR(DebugServiceI *)) return;
|
|
||||||
// Fast path: nothing to do when neither paused nor stepping.
|
|
||||||
// Avoids Threads::Name() lookup (and its mutex) on every 1000 Hz cycle.
|
|
||||||
if (!service->IsPaused() && !service->IsStepPending()) return;
|
|
||||||
// Wait if already paused (manual PAUSE or breakpoint from a previous cycle)
|
|
||||||
while (service->IsPaused()) Sleep::MSec(10);
|
|
||||||
// Pass the OS thread name so per-thread step filtering works.
|
|
||||||
const char8 *tName = Threads::Name(Threads::Id());
|
|
||||||
service->ConsumeStepIfNeeded(gamName, tName);
|
|
||||||
while (service->IsPaused()) Sleep::MSec(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Process(DebugServiceI *service,
|
|
||||||
DebugSignalInfo **signalInfoPointers,
|
|
||||||
Vector<uint32> &activeIndices, Vector<uint32> &activeSizes,
|
|
||||||
FastPollingMutexSem &activeMutex,
|
|
||||||
volatile bool *anyBreakFlag,
|
|
||||||
Vector<uint32> *breakIndices) {
|
|
||||||
if (service == NULL_PTR(DebugServiceI *))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// NOTE: No spin here. Spinning for paused state is handled in Execute() of
|
|
||||||
// OUTPUT brokers only (see OutputPauseAndStep). Input brokers must not block
|
|
||||||
// because that prevents cross-thread EventSem posts from completing.
|
|
||||||
|
|
||||||
activeMutex.FastLock();
|
|
||||||
uint32 n = activeIndices.GetNumberOfElements();
|
|
||||||
if (n > 0 && signalInfoPointers != NULL_PTR(DebugSignalInfo **)) {
|
|
||||||
// Capture timestamp ONCE per broker cycle for lowest impact
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1.0e9);
|
|
||||||
|
|
||||||
for (uint32 i = 0; i < n; i++) {
|
|
||||||
uint32 idx = activeIndices[i];
|
|
||||||
uint32 size = activeSizes[i];
|
|
||||||
DebugSignalInfo *s = signalInfoPointers[idx];
|
|
||||||
if (s != NULL_PTR(DebugSignalInfo *)) {
|
|
||||||
service->ProcessSignal(s, size, ts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIX #3: copy break indices under lock into a local stack array, then
|
|
||||||
// release activeMutex BEFORE evaluating. EvaluateBreak reads signal
|
|
||||||
// memory which can stall (cache miss); holding activeMutex during that
|
|
||||||
// stall would block UpdateBrokersBreakStatus() in the Server thread and
|
|
||||||
// cause unnecessary priority inversion on the RT path.
|
|
||||||
bool shouldCheckBreak = (*anyBreakFlag && !service->IsPaused() &&
|
|
||||||
breakIndices != NULL_PTR(Vector<uint32> *) &&
|
|
||||||
signalInfoPointers != NULL_PTR(DebugSignalInfo **));
|
|
||||||
static const uint32 MAX_BREAK_INDICES = 64u;
|
|
||||||
uint32 localBreakIdx[MAX_BREAK_INDICES];
|
|
||||||
uint32 nb = 0u;
|
|
||||||
if (shouldCheckBreak) {
|
|
||||||
nb = breakIndices->GetNumberOfElements();
|
|
||||||
if (nb > MAX_BREAK_INDICES) nb = MAX_BREAK_INDICES;
|
|
||||||
for (uint32 i = 0; i < nb; i++) {
|
|
||||||
localBreakIdx[i] = (*breakIndices)[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activeMutex.FastUnLock();
|
|
||||||
|
|
||||||
// Evaluate break conditions outside the lock — safe because
|
|
||||||
// EvaluateBreak only reads signalInfoPointers[idx]->memoryAddress,
|
|
||||||
// which is RT data-bus memory and is never freed during the RT cycle.
|
|
||||||
if (shouldCheckBreak && nb > 0u) {
|
|
||||||
for (uint32 i = 0; i < nb; i++) {
|
|
||||||
uint32 idx = localBreakIdx[i];
|
|
||||||
DebugSignalInfo *s = signalInfoPointers[idx];
|
|
||||||
if (s != NULL_PTR(DebugSignalInfo *) && s->breakOp != BREAK_OFF &&
|
|
||||||
EvaluateBreak(s)) {
|
|
||||||
service->SetPaused(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pass numCopies explicitly so we can mock it
|
|
||||||
static void
|
|
||||||
InitSignals(BrokerI *broker, DataSourceI &dataSourceIn,
|
|
||||||
DebugServiceI *&service, DebugSignalInfo **&signalInfoPointers,
|
|
||||||
uint32 numCopies, MemoryMapBrokerCopyTableEntry *copyTable,
|
|
||||||
const char8 *functionName, SignalDirection direction,
|
|
||||||
volatile bool *anyActiveFlag, Vector<uint32> *activeIndices,
|
|
||||||
Vector<uint32> *activeSizes, FastPollingMutexSem *activeMutex,
|
|
||||||
volatile bool *anyBreakFlag, Vector<uint32> *breakIndices) {
|
|
||||||
if (numCopies > 0) {
|
|
||||||
signalInfoPointers = new DebugSignalInfo *[numCopies];
|
|
||||||
for (uint32 i = 0; i < numCopies; i++)
|
|
||||||
signalInfoPointers[i] = NULL_PTR(DebugSignalInfo *);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the singleton registered by DebugService::Initialise() — no ORD
|
|
||||||
// search on the Init path, and no dependency on a concrete type.
|
|
||||||
service = DebugServiceI::GetInstance();
|
|
||||||
|
|
||||||
if (service && (copyTable != NULL_PTR(MemoryMapBrokerCopyTableEntry *))) {
|
|
||||||
|
|
||||||
StreamString dsPath;
|
|
||||||
DebugServiceI::GetFullObjectName(dataSourceIn, dsPath);
|
|
||||||
fprintf(stderr, ">> %s broker for %s [%d]\n",
|
|
||||||
direction == InputSignals ? "Input" : "Output", dsPath.Buffer(),
|
|
||||||
numCopies);
|
|
||||||
MemoryMapBroker *mmb = dynamic_cast<MemoryMapBroker *>(broker);
|
|
||||||
if (mmb == NULL_PTR(MemoryMapBroker *)) {
|
|
||||||
fprintf(stderr, ">> Impossible to get broker pointer!!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32 i = 0; i < numCopies; i++) {
|
|
||||||
void *addr = copyTable[i].dataSourcePointer;
|
|
||||||
TypeDescriptor type = copyTable[i].type;
|
|
||||||
|
|
||||||
uint32 dsIdx = i;
|
|
||||||
if (mmb != NULL_PTR(MemoryMapBroker *)) {
|
|
||||||
dsIdx = mmb->GetDSCopySignalIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamString signalName;
|
|
||||||
if (!dataSourceIn.GetSignalName(dsIdx, signalName))
|
|
||||||
signalName = "Unknown";
|
|
||||||
fprintf(stderr, ">> registering %s.%s [%p]\n", dsPath.Buffer(),
|
|
||||||
signalName.Buffer(), mmb);
|
|
||||||
|
|
||||||
uint8 dims = 0;
|
|
||||||
uint32 elems = 1;
|
|
||||||
(void)dataSourceIn.GetSignalNumberOfDimensions(dsIdx, dims);
|
|
||||||
(void)dataSourceIn.GetSignalNumberOfElements(dsIdx, elems);
|
|
||||||
|
|
||||||
// Register canonical name
|
|
||||||
StreamString dsFullName;
|
|
||||||
dsFullName.Printf("%s.%s", dsPath.Buffer(), signalName.Buffer());
|
|
||||||
service->RegisterSignal(addr, type, dsFullName.Buffer(), dims, elems);
|
|
||||||
|
|
||||||
// Register alias
|
|
||||||
if (functionName != NULL_PTR(const char8 *)) {
|
|
||||||
StreamString gamFullName;
|
|
||||||
const char8 *dirStr =
|
|
||||||
(direction == InputSignals) ? "InputSignals" : "OutputSignals";
|
|
||||||
const char8 *dirStrShort = (direction == InputSignals) ? "In" : "Out";
|
|
||||||
|
|
||||||
// Search recursively through the entire registry for the GAM by name.
|
|
||||||
// Direct Find("GAM1") only checks top-level; the GAM may be nested
|
|
||||||
// several levels deep inside a RealTimeApplication container.
|
|
||||||
Reference gamRef =
|
|
||||||
FindByNameRecursive(ObjectRegistryDatabase::Instance(),
|
|
||||||
functionName);
|
|
||||||
fprintf(stderr, ">> GAM lookup '%s': %s\n", functionName,
|
|
||||||
gamRef.IsValid() ? "FOUND" : "NOT FOUND");
|
|
||||||
|
|
||||||
if (gamRef.IsValid()) {
|
|
||||||
StreamString absGamPath;
|
|
||||||
DebugServiceI::GetFullObjectName(*(gamRef.operator->()), absGamPath);
|
|
||||||
// Register short path (In/Out) for GUI compatibility
|
|
||||||
gamFullName.Printf("%s.%s.%s", absGamPath.Buffer(), dirStrShort,
|
|
||||||
signalName.Buffer());
|
|
||||||
signalInfoPointers[i] =
|
|
||||||
service->RegisterSignal(addr, type, gamFullName.Buffer(), dims, elems);
|
|
||||||
} else {
|
|
||||||
// Fallback to short form
|
|
||||||
gamFullName.Printf("%s.%s.%s", functionName, dirStrShort,
|
|
||||||
signalName.Buffer());
|
|
||||||
signalInfoPointers[i] =
|
|
||||||
service->RegisterSignal(addr, type, gamFullName.Buffer(), dims, elems);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
signalInfoPointers[i] =
|
|
||||||
service->RegisterSignal(addr, type, dsFullName.Buffer(), dims, elems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register broker in DebugService for optimized control
|
|
||||||
bool isOutputBroker = (direction == OutputSignals);
|
|
||||||
service->RegisterBroker(signalInfoPointers, numCopies, mmb, anyActiveFlag,
|
|
||||||
activeIndices, activeSizes, activeMutex,
|
|
||||||
anyBreakFlag, breakIndices,
|
|
||||||
(functionName != NULL_PTR(const char8 *)) ? functionName : dsPath.Buffer(),
|
|
||||||
isOutputBroker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Template class to instrument any MARTe2 Broker.
|
|
||||||
*/
|
|
||||||
template <typename BaseClass> class DebugBrokerWrapper : public BaseClass {
|
|
||||||
public:
|
|
||||||
DebugBrokerWrapper() : BaseClass() {
|
|
||||||
service = NULL_PTR(DebugServiceI *);
|
|
||||||
signalInfoPointers = NULL_PTR(DebugSignalInfo **);
|
|
||||||
numSignals = 0;
|
|
||||||
anyActive = false;
|
|
||||||
anyBreakActive = false;
|
|
||||||
isOutput = false;
|
|
||||||
gamName[0] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DebugBrokerWrapper() {
|
|
||||||
if (signalInfoPointers)
|
|
||||||
delete[] signalInfoPointers;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Execute() {
|
|
||||||
bool ret = BaseClass::Execute();
|
|
||||||
if (ret && (anyActive || anyBreakActive)) {
|
|
||||||
DebugBrokerHelper::Process(service, signalInfoPointers, activeIndices,
|
|
||||||
activeSizes, activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
// Output brokers are the safe pause point: base Execute has already
|
|
||||||
// committed data / posted any cross-thread EventSems.
|
|
||||||
if (ret && isOutput) {
|
|
||||||
DebugBrokerHelper::OutputPauseAndStep(service, gamName);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Init(SignalDirection direction, DataSourceI &ds,
|
|
||||||
const char8 *const name, void *gamMem) {
|
|
||||||
bool ret = BaseClass::Init(direction, ds, name, gamMem);
|
|
||||||
fprintf(stderr, ">> INIT BROKER %s %s\n", name,
|
|
||||||
direction == InputSignals ? "In" : "Out");
|
|
||||||
if (ret) {
|
|
||||||
numSignals = this->GetNumberOfCopies();
|
|
||||||
isOutput = (direction == OutputSignals);
|
|
||||||
StringHelper::CopyN(gamName, name, 255u);
|
|
||||||
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
|
|
||||||
numSignals, this->copyTable, name,
|
|
||||||
direction, &anyActive, &activeIndices,
|
|
||||||
&activeSizes, &activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Init(SignalDirection direction, DataSourceI &ds,
|
|
||||||
const char8 *const name, void *gamMem, const bool optim) {
|
|
||||||
bool ret = BaseClass::Init(direction, ds, name, gamMem, false);
|
|
||||||
fprintf(stderr, ">> INIT optimized BROKER %s %s\n", name,
|
|
||||||
direction == InputSignals ? "In" : "Out");
|
|
||||||
if (ret) {
|
|
||||||
numSignals = this->GetNumberOfCopies();
|
|
||||||
isOutput = (direction == OutputSignals);
|
|
||||||
StringHelper::CopyN(gamName, name, 255u);
|
|
||||||
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
|
|
||||||
numSignals, this->copyTable, name,
|
|
||||||
direction, &anyActive, &activeIndices,
|
|
||||||
&activeSizes, &activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugServiceI *service;
|
|
||||||
DebugSignalInfo **signalInfoPointers;
|
|
||||||
uint32 numSignals;
|
|
||||||
volatile bool anyActive;
|
|
||||||
volatile bool anyBreakActive;
|
|
||||||
bool isOutput;
|
|
||||||
char8 gamName[256];
|
|
||||||
Vector<uint32> activeIndices;
|
|
||||||
Vector<uint32> activeSizes;
|
|
||||||
Vector<uint32> breakIndices;
|
|
||||||
FastPollingMutexSem activeMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename BaseClass>
|
|
||||||
class DebugBrokerWrapperNoOptim : public BaseClass {
|
|
||||||
public:
|
|
||||||
DebugBrokerWrapperNoOptim() : BaseClass() {
|
|
||||||
service = NULL_PTR(DebugServiceI *);
|
|
||||||
signalInfoPointers = NULL_PTR(DebugSignalInfo **);
|
|
||||||
numSignals = 0;
|
|
||||||
anyActive = false;
|
|
||||||
anyBreakActive = false;
|
|
||||||
isOutput = false;
|
|
||||||
gamName[0] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DebugBrokerWrapperNoOptim() {
|
|
||||||
if (signalInfoPointers)
|
|
||||||
delete[] signalInfoPointers;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Execute() {
|
|
||||||
bool ret = BaseClass::Execute();
|
|
||||||
if (ret && (anyActive || anyBreakActive)) {
|
|
||||||
DebugBrokerHelper::Process(service, signalInfoPointers, activeIndices,
|
|
||||||
activeSizes, activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
if (ret && isOutput) {
|
|
||||||
DebugBrokerHelper::OutputPauseAndStep(service, gamName);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Init(SignalDirection direction, DataSourceI &ds,
|
|
||||||
const char8 *const name, void *gamMem) {
|
|
||||||
bool ret = BaseClass::Init(direction, ds, name, gamMem);
|
|
||||||
if (ret) {
|
|
||||||
numSignals = this->GetNumberOfCopies();
|
|
||||||
isOutput = (direction == OutputSignals);
|
|
||||||
StringHelper::CopyN(gamName, name, 255u);
|
|
||||||
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
|
|
||||||
numSignals, this->copyTable, name,
|
|
||||||
direction, &anyActive, &activeIndices,
|
|
||||||
&activeSizes, &activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugServiceI *service;
|
|
||||||
DebugSignalInfo **signalInfoPointers;
|
|
||||||
uint32 numSignals;
|
|
||||||
volatile bool anyActive;
|
|
||||||
volatile bool anyBreakActive;
|
|
||||||
bool isOutput;
|
|
||||||
char8 gamName[256];
|
|
||||||
Vector<uint32> activeIndices;
|
|
||||||
Vector<uint32> activeSizes;
|
|
||||||
Vector<uint32> breakIndices;
|
|
||||||
FastPollingMutexSem activeMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DebugMemoryMapAsyncOutputBroker : public MemoryMapAsyncOutputBroker {
|
|
||||||
public:
|
|
||||||
DebugMemoryMapAsyncOutputBroker() : MemoryMapAsyncOutputBroker() {
|
|
||||||
service = NULL_PTR(DebugServiceI *);
|
|
||||||
signalInfoPointers = NULL_PTR(DebugSignalInfo **);
|
|
||||||
numSignals = 0;
|
|
||||||
anyActive = false;
|
|
||||||
anyBreakActive = false;
|
|
||||||
gamName[0] = '\0';
|
|
||||||
}
|
|
||||||
virtual ~DebugMemoryMapAsyncOutputBroker() {
|
|
||||||
if (signalInfoPointers)
|
|
||||||
delete[] signalInfoPointers;
|
|
||||||
}
|
|
||||||
virtual bool Execute() {
|
|
||||||
bool ret = MemoryMapAsyncOutputBroker::Execute();
|
|
||||||
if (ret && (anyActive || anyBreakActive)) {
|
|
||||||
DebugBrokerHelper::Process(service, signalInfoPointers, activeIndices,
|
|
||||||
activeSizes, activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
// Async output brokers are always output direction
|
|
||||||
if (ret) {
|
|
||||||
DebugBrokerHelper::OutputPauseAndStep(service, gamName);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
virtual bool InitWithBufferParameters(const SignalDirection direction,
|
|
||||||
DataSourceI &dataSourceIn,
|
|
||||||
const char8 *const functionName,
|
|
||||||
void *const gamMemoryAddress,
|
|
||||||
const uint32 numberOfBuffersIn,
|
|
||||||
const ProcessorType &cpuMaskIn,
|
|
||||||
const uint32 stackSizeIn) {
|
|
||||||
bool ret = MemoryMapAsyncOutputBroker::InitWithBufferParameters(
|
|
||||||
direction, dataSourceIn, functionName, gamMemoryAddress,
|
|
||||||
numberOfBuffersIn, cpuMaskIn, stackSizeIn);
|
|
||||||
if (ret) {
|
|
||||||
numSignals = this->GetNumberOfCopies();
|
|
||||||
StringHelper::CopyN(gamName, (functionName != NULL_PTR(const char8 *)) ? functionName : "", 255u);
|
|
||||||
DebugBrokerHelper::InitSignals(
|
|
||||||
this, dataSourceIn, service, signalInfoPointers, numSignals,
|
|
||||||
this->copyTable, functionName, direction, &anyActive, &activeIndices,
|
|
||||||
&activeSizes, &activeMutex, &anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
DebugServiceI *service;
|
|
||||||
DebugSignalInfo **signalInfoPointers;
|
|
||||||
uint32 numSignals;
|
|
||||||
volatile bool anyActive;
|
|
||||||
volatile bool anyBreakActive;
|
|
||||||
char8 gamName[256];
|
|
||||||
Vector<uint32> activeIndices;
|
|
||||||
Vector<uint32> activeSizes;
|
|
||||||
Vector<uint32> breakIndices;
|
|
||||||
FastPollingMutexSem activeMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DebugMemoryMapAsyncTriggerOutputBroker
|
|
||||||
: public MemoryMapAsyncTriggerOutputBroker {
|
|
||||||
public:
|
|
||||||
DebugMemoryMapAsyncTriggerOutputBroker()
|
|
||||||
: MemoryMapAsyncTriggerOutputBroker() {
|
|
||||||
service = NULL_PTR(DebugServiceI *);
|
|
||||||
signalInfoPointers = NULL_PTR(DebugSignalInfo **);
|
|
||||||
numSignals = 0;
|
|
||||||
anyActive = false;
|
|
||||||
anyBreakActive = false;
|
|
||||||
gamName[0] = '\0';
|
|
||||||
}
|
|
||||||
virtual ~DebugMemoryMapAsyncTriggerOutputBroker() {
|
|
||||||
if (signalInfoPointers)
|
|
||||||
delete[] signalInfoPointers;
|
|
||||||
}
|
|
||||||
virtual bool Execute() {
|
|
||||||
bool ret = MemoryMapAsyncTriggerOutputBroker::Execute();
|
|
||||||
if (ret && (anyActive || anyBreakActive)) {
|
|
||||||
DebugBrokerHelper::Process(service, signalInfoPointers, activeIndices,
|
|
||||||
activeSizes, activeMutex,
|
|
||||||
&anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
if (ret) {
|
|
||||||
DebugBrokerHelper::OutputPauseAndStep(service, gamName);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
virtual bool InitWithTriggerParameters(
|
|
||||||
const SignalDirection direction, DataSourceI &dataSourceIn,
|
|
||||||
const char8 *const functionName, void *const gamMemoryAddress,
|
|
||||||
const uint32 numberOfBuffersIn, const uint32 preTriggerBuffersIn,
|
|
||||||
const uint32 postTriggerBuffersIn, const ProcessorType &cpuMaskIn,
|
|
||||||
const uint32 stackSizeIn) {
|
|
||||||
bool ret = MemoryMapAsyncTriggerOutputBroker::InitWithTriggerParameters(
|
|
||||||
direction, dataSourceIn, functionName, gamMemoryAddress,
|
|
||||||
numberOfBuffersIn, preTriggerBuffersIn, postTriggerBuffersIn, cpuMaskIn,
|
|
||||||
stackSizeIn);
|
|
||||||
if (ret) {
|
|
||||||
numSignals = this->GetNumberOfCopies();
|
|
||||||
StringHelper::CopyN(gamName, (functionName != NULL_PTR(const char8 *)) ? functionName : "", 255u);
|
|
||||||
DebugBrokerHelper::InitSignals(
|
|
||||||
this, dataSourceIn, service, signalInfoPointers, numSignals,
|
|
||||||
this->copyTable, functionName, direction, &anyActive, &activeIndices,
|
|
||||||
&activeSizes, &activeMutex, &anyBreakActive, &breakIndices);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
DebugServiceI *service;
|
|
||||||
DebugSignalInfo **signalInfoPointers;
|
|
||||||
uint32 numSignals;
|
|
||||||
volatile bool anyActive;
|
|
||||||
volatile bool anyBreakActive;
|
|
||||||
char8 gamName[256];
|
|
||||||
Vector<uint32> activeIndices;
|
|
||||||
Vector<uint32> activeSizes;
|
|
||||||
Vector<uint32> breakIndices;
|
|
||||||
FastPollingMutexSem activeMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> class DebugBrokerBuilder : public ObjectBuilder {
|
|
||||||
public:
|
|
||||||
virtual Object *Build(HeapI *const heap) const { return new (heap) T(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapInputBroker> DebugMemoryMapInputBroker;
|
|
||||||
// LCOV_EXCL_START
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapOutputBroker> DebugMemoryMapOutputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapSynchronisedInputBroker>
|
|
||||||
DebugMemoryMapSynchronisedInputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapSynchronisedOutputBroker>
|
|
||||||
DebugMemoryMapSynchronisedOutputBroker;
|
|
||||||
typedef DebugBrokerWrapperNoOptim<MemoryMapInterpolatedInputBroker>
|
|
||||||
DebugMemoryMapInterpolatedInputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapMultiBufferInputBroker>
|
|
||||||
DebugMemoryMapMultiBufferInputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapMultiBufferOutputBroker>
|
|
||||||
DebugMemoryMapMultiBufferOutputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapSynchronisedMultiBufferInputBroker>
|
|
||||||
DebugMemoryMapSynchronisedMultiBufferInputBroker;
|
|
||||||
typedef DebugBrokerWrapper<MemoryMapSynchronisedMultiBufferOutputBroker>
|
|
||||||
DebugMemoryMapSynchronisedMultiBufferOutputBroker;
|
|
||||||
// LCOV_EXCL_STOP
|
|
||||||
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapInputBroker>
|
|
||||||
DebugMemoryMapInputBrokerBuilder;
|
|
||||||
// LCOV_EXCL_START
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapOutputBroker>
|
|
||||||
DebugMemoryMapOutputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedInputBroker>
|
|
||||||
DebugMemoryMapSynchronisedInputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedOutputBroker>
|
|
||||||
DebugMemoryMapSynchronisedOutputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapInterpolatedInputBroker>
|
|
||||||
DebugMemoryMapInterpolatedInputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferInputBroker>
|
|
||||||
DebugMemoryMapMultiBufferInputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferOutputBroker>
|
|
||||||
DebugMemoryMapMultiBufferOutputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferInputBroker>
|
|
||||||
DebugMemoryMapSynchronisedMultiBufferInputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferOutputBroker>
|
|
||||||
DebugMemoryMapSynchronisedMultiBufferOutputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapAsyncOutputBroker>
|
|
||||||
DebugMemoryMapAsyncOutputBrokerBuilder;
|
|
||||||
typedef DebugBrokerBuilder<DebugMemoryMapAsyncTriggerOutputBroker>
|
|
||||||
DebugMemoryMapAsyncTriggerOutputBrokerBuilder;
|
|
||||||
// LCOV_EXCL_STOP
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,477 +0,0 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "GlobalObjectsDatabase.h"
|
|
||||||
#include "HighResolutionTimer.h"
|
|
||||||
#include "LoggerService.h"
|
|
||||||
#include "Message.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "ReferenceT.h"
|
|
||||||
#include "Sleep.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
#include "TcpLogger.h"
|
|
||||||
#include "Threads.h"
|
|
||||||
#include "TimeoutType.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
CLASS_REGISTER(DebugService, "1.0")
|
|
||||||
|
|
||||||
// C++98 ODR definitions for static constants
|
|
||||||
const uint32 DebugService::STREAMER_MTU;
|
|
||||||
const uint32 DebugService::STREAMER_BUFFER_SIZE;
|
|
||||||
const uint32 DebugService::CMD_RATE_LIMIT;
|
|
||||||
const uint32 DebugService::CLIENT_IDLE_TIMEOUT_MS;
|
|
||||||
const uint32 DebugService::INPUT_BUFFER_MAX;
|
|
||||||
|
|
||||||
// Maximum data bytes that fit in one sample entry inside a datagram:
|
|
||||||
// STREAMER_BUFFER_SIZE(65535) - TraceHeader(20) - entry_header(16) = 65499
|
|
||||||
static const uint32 MAX_SAMPLE_DATA_SIZE = 65499u;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Constructor / Destructor
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
DebugService::DebugService()
|
|
||||||
: DebugServiceBase(),
|
|
||||||
EmbeddedServiceMethodBinderI(),
|
|
||||||
binderServer(this, ServiceBinder::ServerType),
|
|
||||||
binderStreamer(this, ServiceBinder::StreamerType),
|
|
||||||
threadService(binderServer),
|
|
||||||
streamerService(binderStreamer) {
|
|
||||||
controlPort = 0u;
|
|
||||||
streamPort = 8081u;
|
|
||||||
logPort = 8082u;
|
|
||||||
streamIP = "127.0.0.1";
|
|
||||||
isServer = false;
|
|
||||||
suppressTimeoutLogs = true;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
streamerPacketOffset = 0u;
|
|
||||||
streamerSequenceNumber = 0u;
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
cmdWindowStartMs = 0u;
|
|
||||||
lastDataTimeMs = 0u;
|
|
||||||
inputBuffer = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugService::~DebugService() {
|
|
||||||
if (DebugServiceI::GetInstance() == this) {
|
|
||||||
DebugServiceI::SetInstance(NULL_PTR(DebugServiceI *));
|
|
||||||
}
|
|
||||||
threadService.Stop();
|
|
||||||
streamerService.Stop();
|
|
||||||
tcpServer.Close();
|
|
||||||
udpSocket.Close();
|
|
||||||
if (activeClient != NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
}
|
|
||||||
// signals owned by DebugServiceBase destructor
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Initialise
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool DebugService::Initialise(StructuredDataI &data) {
|
|
||||||
if (!ReferenceContainer::Initialise(data)) return false;
|
|
||||||
|
|
||||||
uint32 port = 0u;
|
|
||||||
if (data.Read("ControlPort", port)) {
|
|
||||||
controlPort = (uint16)port;
|
|
||||||
} else {
|
|
||||||
(void)data.Read("TcpPort", port);
|
|
||||||
controlPort = (uint16)port;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (controlPort > 0u) {
|
|
||||||
isServer = true;
|
|
||||||
DebugServiceI::SetInstance(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
port = 8081u;
|
|
||||||
if (data.Read("StreamPort", port)) {
|
|
||||||
streamPort = (uint16)port;
|
|
||||||
} else {
|
|
||||||
(void)data.Read("UdpPort", port);
|
|
||||||
streamPort = (uint16)port;
|
|
||||||
}
|
|
||||||
|
|
||||||
port = 8082u;
|
|
||||||
if (data.Read("LogPort", port)) {
|
|
||||||
logPort = (uint16)port;
|
|
||||||
} else {
|
|
||||||
(void)data.Read("TcpLogPort", port);
|
|
||||||
logPort = (uint16)port;
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamString tempIP;
|
|
||||||
if (data.Read("StreamIP", tempIP)) {
|
|
||||||
streamIP = tempIP;
|
|
||||||
} else {
|
|
||||||
streamIP = "127.0.0.1";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 suppress = 1u;
|
|
||||||
if (data.Read("SuppressTimeoutLogs", suppress)) {
|
|
||||||
suppressTimeoutLogs = (suppress == 1u);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Capture only the local subtree — do NOT call MoveToRoot() on the shared CDB.
|
|
||||||
(void)data.Copy(fullConfig);
|
|
||||||
|
|
||||||
if (isServer) {
|
|
||||||
if (!traceBuffer.Init(8 * 1024 * 1024)) return false;
|
|
||||||
PatchRegistry();
|
|
||||||
|
|
||||||
ConfigurationDatabase threadData;
|
|
||||||
threadData.Write("Timeout", (uint32)1000);
|
|
||||||
threadService.Initialise(threadData);
|
|
||||||
streamerService.Initialise(threadData);
|
|
||||||
|
|
||||||
if (!tcpServer.Open()) return false;
|
|
||||||
if (!tcpServer.Listen(controlPort)) return false;
|
|
||||||
if (!udpSocket.Open()) return false;
|
|
||||||
|
|
||||||
if (threadService.Start() != ErrorManagement::NoError) return false;
|
|
||||||
if (streamerService.Start() != ErrorManagement::NoError) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Transport config hook (called by RebuildConfigFromRegistry in base)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DebugService::RebuildTransportConfig() {
|
|
||||||
const char8 *myName = GetName();
|
|
||||||
if (myName != NULL_PTR(const char8 *)) {
|
|
||||||
if (fullConfig.MoveRelative(myName)) {
|
|
||||||
(void)fullConfig.Write("ControlPort", static_cast<uint32>(controlPort));
|
|
||||||
(void)fullConfig.Write("UdpPort", static_cast<uint32>(streamPort));
|
|
||||||
(void)fullConfig.Write("LogPort", static_cast<uint32>(logPort));
|
|
||||||
if (streamIP.Size() > 0u)
|
|
||||||
(void)fullConfig.Write("StreamIP", streamIP.Buffer());
|
|
||||||
(void)fullConfig.MoveToAncestor(1u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// SERVICE_INFO hook
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DebugService::GetServiceInfo(StreamString &out) {
|
|
||||||
out.Printf("OK SERVICE_INFO TCP_CTRL:%u UDP_STREAM:%u TCP_LOG:%u STATE:%s\n",
|
|
||||||
controlPort, streamPort, logPort,
|
|
||||||
isPaused ? "PAUSED" : "RUNNING");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Execute / HandleMessage (framework boilerplate)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType DebugService::Execute(ExecutionInfo &info) {
|
|
||||||
(void)info;
|
|
||||||
return ErrorManagement::FatalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType DebugService::HandleMessage(ReferenceT<Message> &data) {
|
|
||||||
(void)data;
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// InjectTcpLoggerIfNeeded
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DebugService::InjectTcpLoggerIfNeeded() {
|
|
||||||
if (logPort == 0u) return;
|
|
||||||
|
|
||||||
Reference existing = ObjectRegistryDatabase::Instance()->Find("LoggerService");
|
|
||||||
if (existing.IsValid()) {
|
|
||||||
ReferenceContainer *rc =
|
|
||||||
dynamic_cast<ReferenceContainer *>(existing.operator->());
|
|
||||||
if (rc != NULL_PTR(ReferenceContainer *)) {
|
|
||||||
for (uint32 i = 0u; i < rc->Size(); i++) {
|
|
||||||
ReferenceT<TcpLogger> child = rc->Get(i);
|
|
||||||
if (child.IsValid()) return; // already has a TcpLogger
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigurationDatabase lsCdb;
|
|
||||||
(void)lsCdb.Write("Class", "LoggerService");
|
|
||||||
uint32 cpus = 1u;
|
|
||||||
(void)lsCdb.Write("CPUs", cpus);
|
|
||||||
if (lsCdb.CreateRelative("+DebugConsumer")) {
|
|
||||||
(void)lsCdb.Write("Class", "TcpLogger");
|
|
||||||
uint32 p = static_cast<uint32>(logPort);
|
|
||||||
(void)lsCdb.Write("Port", p);
|
|
||||||
(void)lsCdb.MoveToAncestor(1u);
|
|
||||||
}
|
|
||||||
(void)lsCdb.MoveToRoot();
|
|
||||||
|
|
||||||
ReferenceT<LoggerService> ls(
|
|
||||||
"LoggerService", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
|
||||||
if (!ls.IsValid()) return;
|
|
||||||
ls->SetName("LoggerService");
|
|
||||||
if (!ls->Initialise(lsCdb)) return;
|
|
||||||
(void)ObjectRegistryDatabase::Instance()->Insert(ls);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Server thread
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType DebugService::Server(ExecutionInfo &info) {
|
|
||||||
if (info.GetStage() == ExecutionInfo::TerminationStage)
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
if (info.GetStage() == ExecutionInfo::StartupStage) {
|
|
||||||
serverThreadId = Threads::Id();
|
|
||||||
Sleep::MSec(500u);
|
|
||||||
InjectTcpLoggerIfNeeded();
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64 nowMs = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000.0);
|
|
||||||
|
|
||||||
if (activeClient == NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
BasicTCPSocket *newClient = tcpServer.WaitConnection(TimeoutType(100));
|
|
||||||
if (newClient != NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient = newClient;
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
cmdWindowStartMs = nowMs;
|
|
||||||
lastDataTimeMs = nowMs;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (nowMs - lastDataTimeMs > CLIENT_IDLE_TIMEOUT_MS) {
|
|
||||||
REPORT_ERROR_STATIC(ErrorManagement::Warning,
|
|
||||||
"Server: TCP client idle for >%u ms — closing connection.",
|
|
||||||
CLIENT_IDLE_TIMEOUT_MS);
|
|
||||||
inputBuffer = "";
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
} else if (!activeClient->IsConnected()) {
|
|
||||||
inputBuffer = "";
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
} else {
|
|
||||||
char buffer[1024];
|
|
||||||
uint32 size = 1024u;
|
|
||||||
if (activeClient->Read(buffer, size)) {
|
|
||||||
if (size > 0u) {
|
|
||||||
lastDataTimeMs = nowMs;
|
|
||||||
|
|
||||||
if (nowMs - cmdWindowStartMs >= 1000u) {
|
|
||||||
cmdWindowStartMs = nowMs;
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputBuffer.Size() + (uint32)size > INPUT_BUFFER_MAX) {
|
|
||||||
REPORT_ERROR_STATIC(ErrorManagement::Warning,
|
|
||||||
"Server: input buffer overflow (>%u bytes without newline) "
|
|
||||||
"— disconnecting.", INPUT_BUFFER_MAX);
|
|
||||||
inputBuffer = "";
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
} else {
|
|
||||||
(void)inputBuffer.Seek(inputBuffer.Size());
|
|
||||||
uint32 writeSize = (uint32)size;
|
|
||||||
inputBuffer.Write(buffer, writeSize);
|
|
||||||
|
|
||||||
const char8 *raw = inputBuffer.Buffer();
|
|
||||||
uint32 total = (uint32)inputBuffer.Size();
|
|
||||||
uint32 lineStart = 0u;
|
|
||||||
bool rateLimitExceeded = false;
|
|
||||||
|
|
||||||
for (uint32 pos = 0u; pos < total && !rateLimitExceeded; pos++) {
|
|
||||||
if (raw[pos] != '\n') continue;
|
|
||||||
uint32 len = pos - lineStart;
|
|
||||||
if (len > 0u && raw[lineStart + len - 1u] == '\r') len--;
|
|
||||||
if (len > 0u) {
|
|
||||||
cmdCountInWindow++;
|
|
||||||
if (cmdCountInWindow > CMD_RATE_LIMIT) {
|
|
||||||
REPORT_ERROR_STATIC(ErrorManagement::Warning,
|
|
||||||
"Server: client exceeded rate limit (%u cmd/s) "
|
|
||||||
"— disconnecting.", CMD_RATE_LIMIT);
|
|
||||||
rateLimitExceeded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
StreamString command;
|
|
||||||
uint32 cmdLen = len;
|
|
||||||
command.Write(raw + lineStart, cmdLen);
|
|
||||||
|
|
||||||
// Dispatch via base HandleCommand, write response to socket.
|
|
||||||
// Loop to handle partial writes for large responses.
|
|
||||||
StreamString out;
|
|
||||||
HandleCommand(command, out);
|
|
||||||
if (out.Size() > 0u) {
|
|
||||||
const char8 *wPtr = out.Buffer();
|
|
||||||
uint32 remaining = (uint32)out.Size();
|
|
||||||
lastDataTimeMs = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000.0);
|
|
||||||
while (remaining > 0u) {
|
|
||||||
uint32 wrote = remaining;
|
|
||||||
if (!activeClient->Write(wPtr, wrote) || wrote == 0u) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wPtr += wrote;
|
|
||||||
remaining -= wrote;
|
|
||||||
lastDataTimeMs = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lineStart = pos + 1u;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rateLimitExceeded) {
|
|
||||||
inputBuffer = "";
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
cmdCountInWindow = 0u;
|
|
||||||
} else {
|
|
||||||
StreamString newInputBuffer;
|
|
||||||
if (lineStart < total) {
|
|
||||||
uint32 remLen = total - lineStart;
|
|
||||||
newInputBuffer.Write(raw + lineStart, remLen);
|
|
||||||
}
|
|
||||||
inputBuffer = newInputBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
inputBuffer = "";
|
|
||||||
clientMutex.FastLock();
|
|
||||||
activeClient->Close();
|
|
||||||
delete activeClient;
|
|
||||||
activeClient = NULL_PTR(BasicTCPSocket *);
|
|
||||||
clientMutex.FastUnLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Streamer thread (UDP binary telemetry)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo &info) {
|
|
||||||
if (info.GetStage() == ExecutionInfo::TerminationStage)
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
if (info.GetStage() == ExecutionInfo::StartupStage) {
|
|
||||||
streamerThreadId = Threads::Id();
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
InternetHost dest(streamPort, streamIP.Buffer());
|
|
||||||
(void)udpSocket.SetDestination(dest);
|
|
||||||
|
|
||||||
// Poll monitored signals and push to trace ring buffer
|
|
||||||
uint64 currentTimeMs = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000.0);
|
|
||||||
mutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < monitoredSignals.GetNumberOfElements(); i++) {
|
|
||||||
if (currentTimeMs >= (monitoredSignals[i].lastPollTime +
|
|
||||||
monitoredSignals[i].periodMs)) {
|
|
||||||
monitoredSignals[i].lastPollTime = currentTimeMs;
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000000.0);
|
|
||||||
void *address = NULL_PTR(void *);
|
|
||||||
if (monitoredSignals[i].dataSource->GetSignalMemoryBuffer(
|
|
||||||
monitoredSignals[i].signalIdx, 0u, address)) {
|
|
||||||
tracePushMutex.FastLock();
|
|
||||||
traceBuffer.Push(monitoredSignals[i].internalID, ts,
|
|
||||||
(uint8 *)address, monitoredSignals[i].size);
|
|
||||||
tracePushMutex.FastUnLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutex.FastUnLock();
|
|
||||||
|
|
||||||
// Drain ring buffer into UDP packet(s).
|
|
||||||
//
|
|
||||||
// Batching strategy:
|
|
||||||
// - Normal samples (entry ≤ STREAMER_MTU): accumulate into a packet and
|
|
||||||
// flush when the next sample would push it past STREAMER_MTU.
|
|
||||||
// - Oversized samples (entry > STREAMER_MTU): flush any pending packet
|
|
||||||
// first, then send the oversized sample as its own datagram (up to
|
|
||||||
// STREAMER_BUFFER_SIZE bytes; handled transparently by IP fragmentation
|
|
||||||
// on loopback / internal networks).
|
|
||||||
// - MAX_SAMPLE_DATA_SIZE (65499 bytes) is the hard cap; larger entries
|
|
||||||
// in the ring buffer are skipped by Pop() and discarded.
|
|
||||||
bool hasData = false;
|
|
||||||
uint32 id, size;
|
|
||||||
uint64 ts;
|
|
||||||
|
|
||||||
while (traceBuffer.Pop(id, ts, streamerSampleBuffer, size, MAX_SAMPLE_DATA_SIZE)) {
|
|
||||||
hasData = true;
|
|
||||||
const uint32 entryBytes = 16u + size; // [id:4][ts:8][size:4][data:size]
|
|
||||||
|
|
||||||
// If this entry would push the current packet past the MTU target,
|
|
||||||
// flush what we have before appending (unless the buffer is empty).
|
|
||||||
if (streamerPacketOffset > 0u &&
|
|
||||||
streamerPacketOffset + entryBytes > STREAMER_MTU) {
|
|
||||||
uint32 toWrite = streamerPacketOffset;
|
|
||||||
(void)udpSocket.Write((char8 *)streamerPacketBuffer, toWrite);
|
|
||||||
streamerPacketOffset = 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open a new packet header if the buffer is empty.
|
|
||||||
if (streamerPacketOffset == 0u) {
|
|
||||||
TraceHeader hdr;
|
|
||||||
hdr.magic = 0xDA7A57ADu;
|
|
||||||
hdr.seq = streamerSequenceNumber++;
|
|
||||||
hdr.timestamp = HighResolutionTimer::Counter();
|
|
||||||
hdr.count = 0u;
|
|
||||||
memcpy(streamerPacketBuffer, &hdr, sizeof(TraceHeader));
|
|
||||||
streamerPacketOffset = (uint32)sizeof(TraceHeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the sample entry.
|
|
||||||
memcpy(&streamerPacketBuffer[streamerPacketOffset], &id, 4u);
|
|
||||||
memcpy(&streamerPacketBuffer[streamerPacketOffset + 4u], &ts, 8u);
|
|
||||||
memcpy(&streamerPacketBuffer[streamerPacketOffset + 12u], &size, 4u);
|
|
||||||
memcpy(&streamerPacketBuffer[streamerPacketOffset + 16u], streamerSampleBuffer, size);
|
|
||||||
streamerPacketOffset += entryBytes;
|
|
||||||
((TraceHeader *)streamerPacketBuffer)->count++;
|
|
||||||
|
|
||||||
// Oversized single sample: send immediately rather than accumulating.
|
|
||||||
if (streamerPacketOffset > STREAMER_MTU) {
|
|
||||||
uint32 toWrite = streamerPacketOffset;
|
|
||||||
(void)udpSocket.Write((char8 *)streamerPacketBuffer, toWrite);
|
|
||||||
streamerPacketOffset = 0u;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush any remaining partial packet.
|
|
||||||
if (streamerPacketOffset > 0u) {
|
|
||||||
uint32 toWrite = streamerPacketOffset;
|
|
||||||
(void)udpSocket.Write((char8 *)streamerPacketBuffer, toWrite);
|
|
||||||
streamerPacketOffset = 0u;
|
|
||||||
}
|
|
||||||
if (!hasData) Sleep::MSec(1u);
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
#ifndef DEBUGSERVICE_H
|
|
||||||
#define DEBUGSERVICE_H
|
|
||||||
|
|
||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "BasicUDPSocket.h"
|
|
||||||
#include "DebugServiceBase.h"
|
|
||||||
#include "EmbeddedServiceMethodBinderI.h"
|
|
||||||
#include "MessageI.h"
|
|
||||||
#include "ReferenceT.h"
|
|
||||||
#include "SingleThreadService.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief TCP/UDP implementation of DebugServiceI (via DebugServiceBase).
|
|
||||||
*
|
|
||||||
* Provides signal tracing (UDP), forced-value injection, break conditions,
|
|
||||||
* and a text command channel (TCP) with a log-forwarding sidecar (TcpLogger).
|
|
||||||
* All signal management and command dispatch logic lives in DebugServiceBase.
|
|
||||||
*/
|
|
||||||
class DebugService : public DebugServiceBase,
|
|
||||||
public MessageI,
|
|
||||||
public EmbeddedServiceMethodBinderI {
|
|
||||||
public:
|
|
||||||
friend class DebugServiceTest;
|
|
||||||
CLASS_REGISTER_DECLARATION()
|
|
||||||
|
|
||||||
DebugService();
|
|
||||||
virtual ~DebugService();
|
|
||||||
|
|
||||||
virtual bool Initialise(StructuredDataI &data);
|
|
||||||
|
|
||||||
virtual ErrorManagement::ErrorType Execute(ExecutionInfo &info);
|
|
||||||
virtual ErrorManagement::ErrorType HandleMessage(ReferenceT<Message> &data);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Transport-specific overrides of DebugServiceBase hooks
|
|
||||||
virtual void GetServiceInfo(StreamString &out);
|
|
||||||
virtual void RebuildTransportConfig();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void InjectTcpLoggerIfNeeded();
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType Server (ExecutionInfo &info);
|
|
||||||
ErrorManagement::ErrorType Streamer(ExecutionInfo &info);
|
|
||||||
|
|
||||||
// TCP/UDP-specific configuration
|
|
||||||
uint16 controlPort;
|
|
||||||
uint16 streamPort;
|
|
||||||
uint16 logPort;
|
|
||||||
StreamString streamIP;
|
|
||||||
bool isServer;
|
|
||||||
bool suppressTimeoutLogs;
|
|
||||||
|
|
||||||
BasicTCPSocket tcpServer;
|
|
||||||
BasicUDPSocket udpSocket;
|
|
||||||
|
|
||||||
class ServiceBinder : public EmbeddedServiceMethodBinderI {
|
|
||||||
public:
|
|
||||||
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);
|
|
||||||
return parent->Server(info);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
DebugService *parent;
|
|
||||||
ServiceType type;
|
|
||||||
};
|
|
||||||
|
|
||||||
ServiceBinder binderServer;
|
|
||||||
ServiceBinder binderStreamer;
|
|
||||||
SingleThreadService threadService;
|
|
||||||
SingleThreadService streamerService;
|
|
||||||
|
|
||||||
ThreadIdentifier serverThreadId;
|
|
||||||
ThreadIdentifier streamerThreadId;
|
|
||||||
|
|
||||||
// activeClient — exclusively owned by Server thread
|
|
||||||
FastPollingMutexSem clientMutex;
|
|
||||||
BasicTCPSocket *activeClient;
|
|
||||||
|
|
||||||
// Streamer assembly buffer
|
|
||||||
// STREAMER_MTU: target packet size for batching small signals (network-friendly).
|
|
||||||
// STREAMER_BUFFER_SIZE: maximum UDP datagram payload; large single-signal samples
|
|
||||||
// can exceed STREAMER_MTU and are sent as their own datagram up to this limit.
|
|
||||||
static const uint32 STREAMER_MTU = 1400u;
|
|
||||||
static const uint32 STREAMER_BUFFER_SIZE = 65535u;
|
|
||||||
uint8 streamerPacketBuffer[STREAMER_BUFFER_SIZE]; // assembled outgoing packet
|
|
||||||
uint8 streamerSampleBuffer[STREAMER_BUFFER_SIZE]; // staging for one popped sample
|
|
||||||
uint32 streamerPacketOffset;
|
|
||||||
uint32 streamerSequenceNumber;
|
|
||||||
|
|
||||||
// Rate-limiting and idle-timeout constants / state
|
|
||||||
static const uint32 CMD_RATE_LIMIT = 100u;
|
|
||||||
// Idle timeout: time with no incoming bytes before the connection is closed.
|
|
||||||
// Large applications (1000+ signals) can take >30 s to process a DISCOVER/TREE
|
|
||||||
// response, during which no commands are sent — use a generous default.
|
|
||||||
static const uint32 CLIENT_IDLE_TIMEOUT_MS = 120000u;
|
|
||||||
static const uint32 INPUT_BUFFER_MAX = 8192u;
|
|
||||||
|
|
||||||
uint32 cmdCountInWindow;
|
|
||||||
uint64 cmdWindowStartMs;
|
|
||||||
uint64 lastDataTimeMs;
|
|
||||||
|
|
||||||
// Carry-over buffer for multi-segment TCP commands
|
|
||||||
StreamString inputBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif // DEBUGSERVICE_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,213 +0,0 @@
|
|||||||
#ifndef DEBUGSERVICEBASE_H
|
|
||||||
#define DEBUGSERVICEBASE_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file DebugServiceBase.h
|
|
||||||
* @brief Shared base class for DebugService and WebDebugService.
|
|
||||||
*
|
|
||||||
* Extracts all signal-management, command-handling and config logic that is
|
|
||||||
* common to both the TCP/UDP transport (DebugService) and the HTTP/SSE
|
|
||||||
* transport (WebDebugService), eliminating the previous code duplication.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "DataSourceI.h"
|
|
||||||
#include "DebugServiceI.h"
|
|
||||||
#include "FastPollingMutexSem.h"
|
|
||||||
#include "ReferenceContainer.h"
|
|
||||||
#include "ReferenceT.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Intermediate base class that holds all shared debugging logic.
|
|
||||||
*
|
|
||||||
* Inherits from ReferenceContainer (to be a MARTe2 Object) and DebugServiceI
|
|
||||||
* (to expose the RT-path / control-path interface). Transport subclasses
|
|
||||||
* (DebugService, WebDebugService) inherit from this class and add only their
|
|
||||||
* transport-specific threading and socket logic.
|
|
||||||
*/
|
|
||||||
class DebugServiceBase : public ReferenceContainer, public DebugServiceI {
|
|
||||||
public:
|
|
||||||
friend class DebugServiceTest;
|
|
||||||
|
|
||||||
DebugServiceBase();
|
|
||||||
virtual ~DebugServiceBase();
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// DebugServiceI RT-path overrides (shared implementation)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
virtual DebugSignalInfo *RegisterSignal(void *memoryAddress,
|
|
||||||
TypeDescriptor type,
|
|
||||||
const char8 *name,
|
|
||||||
uint8 numberOfDimensions = 0,
|
|
||||||
uint32 numberOfElements = 1);
|
|
||||||
|
|
||||||
virtual void ProcessSignal(DebugSignalInfo *signalInfo, uint32 size,
|
|
||||||
uint64 timestamp);
|
|
||||||
|
|
||||||
virtual void RegisterBroker(DebugSignalInfo **signalPointers,
|
|
||||||
uint32 numSignals,
|
|
||||||
MemoryMapBroker *broker,
|
|
||||||
volatile bool *anyActiveFlag,
|
|
||||||
Vector<uint32> *activeIndices,
|
|
||||||
Vector<uint32> *activeSizes,
|
|
||||||
FastPollingMutexSem *activeMutex,
|
|
||||||
volatile bool *anyBreakFlag,
|
|
||||||
Vector<uint32> *breakIndices,
|
|
||||||
const char8 *gamName = NULL_PTR(const char8 *),
|
|
||||||
bool isOutput = false);
|
|
||||||
|
|
||||||
virtual bool IsPaused() const { return isPaused; }
|
|
||||||
virtual void SetPaused(bool paused) { isPaused = paused; }
|
|
||||||
virtual bool IsStepPending() const { return stepRemaining > 0u; }
|
|
||||||
virtual void ConsumeStepIfNeeded(const char8 *gamName,
|
|
||||||
const char8 *threadName = NULL_PTR(const char8 *));
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// DebugServiceI control-path overrides (shared implementation)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
virtual uint32 ForceSignal (const char8 *name, const char8 *valueStr);
|
|
||||||
virtual uint32 UnforceSignal(const char8 *name);
|
|
||||||
virtual uint32 TraceSignal (const char8 *name, bool enable, uint32 decimation = 1);
|
|
||||||
virtual uint32 SetBreak (const char8 *name, uint8 op, float64 threshold);
|
|
||||||
virtual uint32 ClearBreak (const char8 *name);
|
|
||||||
virtual bool IsInstrumented(const char8 *fullPath, bool &traceable, bool &forcable);
|
|
||||||
virtual uint32 RegisterMonitorSignal(const char8 *path, uint32 periodMs);
|
|
||||||
virtual uint32 UnmonitorSignal (const char8 *path);
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Shared control-path methods (used by transport subclasses)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parse and dispatch a debug command; write text response to @p out.
|
|
||||||
*
|
|
||||||
* Handles: TRACE, FORCE, UNFORCE, BREAK, PAUSE, RESUME, STEP, STEP_STATUS,
|
|
||||||
* VALUE, DISCOVER, TREE, INFO, LS, CONFIG, MONITOR, UNMONITOR,
|
|
||||||
* SERVICE_INFO, MSG.
|
|
||||||
*
|
|
||||||
* SERVICE_INFO delegates to GetServiceInfo() so each transport can fill in
|
|
||||||
* its own port/state information.
|
|
||||||
*/
|
|
||||||
void HandleCommand(const StreamString &cmdIn, StreamString &out);
|
|
||||||
|
|
||||||
void GetStepStatus(StreamString &out);
|
|
||||||
void GetSignalValue(const char8 *name, StreamString &out);
|
|
||||||
void Discover (StreamString &out);
|
|
||||||
void InfoNode (const char8 *path, StreamString &out);
|
|
||||||
void ListNodes (const char8 *path, StreamString &out);
|
|
||||||
void ServeConfig (StreamString &out);
|
|
||||||
|
|
||||||
void SetFullConfig(ConfigurationDatabase &config);
|
|
||||||
void RebuildConfigFromRegistry();
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Struct shared by both transports
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
struct MonitoredSignal {
|
|
||||||
ReferenceT<DataSourceI> dataSource;
|
|
||||||
uint32 signalIdx;
|
|
||||||
uint32 internalID;
|
|
||||||
uint32 periodMs;
|
|
||||||
uint64 lastPollTime;
|
|
||||||
uint32 size;
|
|
||||||
StreamString path;
|
|
||||||
};
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Constants
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
static const uint32 GET_VALUE_MAX_ELEMENTS = 256u;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Pre-build DISCOVER and TREE response caches.
|
|
||||||
*
|
|
||||||
* Called automatically by SetFullConfig() once the application is fully
|
|
||||||
* initialised. After this point, DISCOVER and TREE are served from the
|
|
||||||
* pre-built string with no mutex contention and no JSON generation cost.
|
|
||||||
* Both caches are invalidated whenever a new signal is registered (which
|
|
||||||
* normally only happens during broker init, before SetFullConfig).
|
|
||||||
*/
|
|
||||||
void BuildDiscoverCache();
|
|
||||||
void BuildTreeCache();
|
|
||||||
|
|
||||||
// Number of signals per DISCOVER_PART TCP chunk. Responses larger than
|
|
||||||
// this are split so the Go client can start parsing immediately.
|
|
||||||
static const uint32 DISCOVER_CHUNK_SIGNALS = 256u;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// =========================================================================
|
|
||||||
// Virtual hooks for transport subclasses
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fill the SERVICE_INFO response text (transport-specific).
|
|
||||||
*
|
|
||||||
* Called by HandleCommand when the SERVICE_INFO command is received.
|
|
||||||
* The base implementation writes nothing; subclasses override to append
|
|
||||||
* e.g. "OK SERVICE_INFO TCP_CTRL:8080 UDP_STREAM:8081 STATE:RUNNING\n".
|
|
||||||
*/
|
|
||||||
virtual void GetServiceInfo(StreamString &out) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write back transport-specific config keys after RebuildConfigFromRegistry().
|
|
||||||
*
|
|
||||||
* Called at the end of RebuildConfigFromRegistry() so that port numbers
|
|
||||||
* and other transport parameters that were read in Initialise() are
|
|
||||||
* reflected back into fullConfig (ExportData on ReferenceContainers
|
|
||||||
* doesn't re-emit config-file parameters).
|
|
||||||
*/
|
|
||||||
virtual void RebuildTransportConfig() {}
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Shared protected helpers
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
void Step(uint32 n, const char8 *threadName = NULL_PTR(const char8 *));
|
|
||||||
void UpdateBrokersActiveStatus();
|
|
||||||
void UpdateBrokersBreakStatus();
|
|
||||||
void PatchRegistry();
|
|
||||||
|
|
||||||
uint32 ExportTree(ReferenceContainer *container, StreamString &json,
|
|
||||||
const char8 *pathPrefix);
|
|
||||||
void EnrichWithConfig(const char8 *path, StreamString &json);
|
|
||||||
static void JsonifyDatabase(ConfigurationDatabase &db, StreamString &json);
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Shared data members
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
Vector<DebugSignalInfo *> signals;
|
|
||||||
Vector<SignalAlias> aliases;
|
|
||||||
Vector<BrokerInfo> brokers;
|
|
||||||
Vector<MonitoredSignal> monitoredSignals;
|
|
||||||
|
|
||||||
FastPollingMutexSem mutex;
|
|
||||||
FastPollingMutexSem tracePushMutex;
|
|
||||||
TraceRingBuffer traceBuffer;
|
|
||||||
|
|
||||||
volatile bool isPaused;
|
|
||||||
volatile uint32 stepRemaining;
|
|
||||||
StreamString pausedAtGam;
|
|
||||||
StreamString stepThreadFilter;
|
|
||||||
|
|
||||||
ConfigurationDatabase fullConfig;
|
|
||||||
bool manualConfigSet;
|
|
||||||
|
|
||||||
// Pre-built response caches. Guarded by mutex (brief lock for swap,
|
|
||||||
// none needed for reads once cacheValid is true and construction is done).
|
|
||||||
StreamString discoverCache; // full chunked DISCOVER_PART+DISCOVER payload
|
|
||||||
StreamString treeCache; // full TREE payload including sentinel
|
|
||||||
volatile bool discoverCacheValid;
|
|
||||||
volatile bool treeCacheValid;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif // DEBUGSERVICEBASE_H
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
#ifndef DEBUGSERVICEI_H
|
|
||||||
#define DEBUGSERVICEI_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file DebugServiceI.h
|
|
||||||
* @brief Abstract interface for the MARTe2 debug/instrumentation service.
|
|
||||||
*
|
|
||||||
* All broker wrappers (DebugBrokerWrapper) depend solely on this interface,
|
|
||||||
* decoupling them from the concrete TCP/UDP implementation. Alternative
|
|
||||||
* transports — TTY, WebSocket, shared-memory ring, etc. — can be plugged in
|
|
||||||
* by providing a new concrete implementation without touching any broker or
|
|
||||||
* application code.
|
|
||||||
*
|
|
||||||
* The interface is split into two logical groups:
|
|
||||||
*
|
|
||||||
* RT-path API
|
|
||||||
* Called from broker threads on every RT cycle. Implementations must
|
|
||||||
* keep these methods as cheap as possible; the only permissible
|
|
||||||
* synchronisation primitive is a fast spinlock (FastPollingMutexSem).
|
|
||||||
*
|
|
||||||
* Control-path API
|
|
||||||
* Called from server / command-handler threads (TCP, TTY, Web …).
|
|
||||||
* Latency here is acceptable; correctness and thread-safety matter.
|
|
||||||
*
|
|
||||||
* Concrete implementations register themselves during Initialise() via
|
|
||||||
* SetInstance(). Broker wrappers retrieve the active instance via
|
|
||||||
* GetInstance(); there is no ORD search on the hot path.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "DebugCore.h"
|
|
||||||
#include "FastPollingMutexSem.h"
|
|
||||||
#include "Object.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
#include "TypeDescriptor.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
// Forward declarations — concrete types are only needed in the implementation.
|
|
||||||
class MemoryMapBroker;
|
|
||||||
|
|
||||||
struct SignalAlias {
|
|
||||||
StreamString name;
|
|
||||||
uint32 signalIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BrokerInfo {
|
|
||||||
DebugSignalInfo **signalPointers;
|
|
||||||
uint32 numSignals;
|
|
||||||
MemoryMapBroker *broker;
|
|
||||||
volatile bool *anyActiveFlag;
|
|
||||||
Vector<uint32> *activeIndices;
|
|
||||||
Vector<uint32> *activeSizes;
|
|
||||||
FastPollingMutexSem *activeMutex;
|
|
||||||
volatile bool *anyBreakFlag;
|
|
||||||
Vector<uint32> *breakIndices;
|
|
||||||
StreamString gamName;
|
|
||||||
bool isOutput;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Abstract debug-service interface.
|
|
||||||
*/
|
|
||||||
class DebugServiceI {
|
|
||||||
public:
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Static instance registry
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the currently registered debug-service instance, or NULL.
|
|
||||||
*
|
|
||||||
* Called on every broker Init() path and from OutpautPauseAndStep().
|
|
||||||
* Returns NULL when no debug service has been initialised, in which case
|
|
||||||
* all instrumentation is a no-op.
|
|
||||||
*/
|
|
||||||
static DebugServiceI *GetInstance() { return instance; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register @p inst as the global debug-service.
|
|
||||||
*
|
|
||||||
* Concrete implementations call this from their Initialise() method.
|
|
||||||
* Passing NULL deregisters the current instance (called from the
|
|
||||||
* destructor so dangling pointers are never visible to broker threads).
|
|
||||||
*/
|
|
||||||
static void SetInstance(DebugServiceI *inst) { instance = inst; }
|
|
||||||
|
|
||||||
virtual ~DebugServiceI() {}
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// RT-path API (called from broker execute threads every cycle)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register a signal memory region with the debug service.
|
|
||||||
*
|
|
||||||
* Called once per signal during broker Init(). Returns a pointer to the
|
|
||||||
* internal DebugSignalInfo that the broker caches for use on the hot path.
|
|
||||||
* Thread-safe; must not be called after the RT loop has started.
|
|
||||||
*/
|
|
||||||
virtual DebugSignalInfo *RegisterSignal(void *memoryAddress,
|
|
||||||
TypeDescriptor type,
|
|
||||||
const char8 *name,
|
|
||||||
uint8 numberOfDimensions = 0,
|
|
||||||
uint32 numberOfElements = 1) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Process one signal on the RT path.
|
|
||||||
*
|
|
||||||
* Applies forced values (memcpy into signal memory) and, when tracing is
|
|
||||||
* enabled and the decimation counter fires, pushes a sample to the trace
|
|
||||||
* ring buffer. Called under the broker's activeMutex; implementations
|
|
||||||
* must not acquire any lock that is also held by the Server thread.
|
|
||||||
*/
|
|
||||||
virtual void ProcessSignal(DebugSignalInfo *signalInfo,
|
|
||||||
uint32 size,
|
|
||||||
uint64 timestamp) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register a broker so the service can push active/break index
|
|
||||||
* updates to it without iterating every signal.
|
|
||||||
*/
|
|
||||||
virtual void RegisterBroker(DebugSignalInfo **signalPointers,
|
|
||||||
uint32 numSignals,
|
|
||||||
MemoryMapBroker *broker,
|
|
||||||
volatile bool *anyActiveFlag,
|
|
||||||
Vector<uint32> *activeIndices,
|
|
||||||
Vector<uint32> *activeSizes,
|
|
||||||
FastPollingMutexSem *activeMutex,
|
|
||||||
volatile bool *anyBreakFlag,
|
|
||||||
Vector<uint32> *breakIndices,
|
|
||||||
const char8 *gamName = NULL_PTR(const char8 *),
|
|
||||||
bool isOutput = false) = 0;
|
|
||||||
|
|
||||||
/** @brief Return true if the RT loop is currently held at a pause/breakpoint. */
|
|
||||||
virtual bool IsPaused() const = 0;
|
|
||||||
|
|
||||||
/** @brief Set or clear the paused state (called by break-condition logic). */
|
|
||||||
virtual void SetPaused(bool paused) = 0;
|
|
||||||
|
|
||||||
/** @brief Return true if a step count is pending (stepRemaining > 0). */
|
|
||||||
virtual bool IsStepPending() const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Consume one step credit for the current output-broker cycle.
|
|
||||||
*
|
|
||||||
* Called by every output broker after Execute(). No-op when stepRemaining
|
|
||||||
* is zero (the common case); only acquires a mutex when stepping is active.
|
|
||||||
*/
|
|
||||||
virtual void ConsumeStepIfNeeded(
|
|
||||||
const char8 *gamName,
|
|
||||||
const char8 *threadName = NULL_PTR(const char8 *)) = 0;
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Control-path API (called from server / command-handler threads)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
virtual uint32 ForceSignal (const char8 *name, const char8 *valueStr) = 0;
|
|
||||||
virtual uint32 UnforceSignal(const char8 *name) = 0;
|
|
||||||
virtual uint32 TraceSignal (const char8 *name, bool enable, uint32 decimation = 1) = 0;
|
|
||||||
virtual uint32 SetBreak (const char8 *name, uint8 op, float64 threshold) = 0;
|
|
||||||
virtual uint32 ClearBreak (const char8 *name) = 0;
|
|
||||||
virtual bool IsInstrumented(const char8 *fullPath,
|
|
||||||
bool &traceable, bool &forcable) = 0;
|
|
||||||
virtual uint32 RegisterMonitorSignal(const char8 *path, uint32 periodMs) = 0;
|
|
||||||
virtual uint32 UnmonitorSignal (const char8 *path) = 0;
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Utility (implementation-agnostic, defined in DebugService.cpp)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Resolve the fully-qualified ORD path of @p obj into @p fullPath.
|
|
||||||
*
|
|
||||||
* Static so it can be called without a service instance. All concrete
|
|
||||||
* implementations (and InitSignals in DebugBrokerWrapper.h) use this
|
|
||||||
* to build canonical signal names. The definition lives in
|
|
||||||
* DebugService.cpp alongside FindPathInContainer().
|
|
||||||
*/
|
|
||||||
static bool GetFullObjectName(const Object &obj, StreamString &fullPath);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** Pointer to the single active debug-service instance. */
|
|
||||||
static DebugServiceI *instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif // DEBUGSERVICEI_H
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
# $Id: Makefile.gcc 3 2015-01-15 16:26:07Z aneto $
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
OBJSX=DebugService.x DebugServiceBase.x
|
|
||||||
|
|
||||||
PACKAGE=Components/Interfaces
|
|
||||||
|
|
||||||
ROOT_DIR=../../../../
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Result
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Vec
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/TCPLogger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
|
||||||
|
|
||||||
all: $(OBJS) $(SUBPROJ) \
|
|
||||||
$(BUILD_DIR)/DebugService$(LIBEXT) \
|
|
||||||
$(BUILD_DIR)/DebugService$(DLLEXT)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
#
|
|
||||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
|
||||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
|
||||||
#
|
|
||||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
|
||||||
# will be approved by the European Commission - subsequent
|
|
||||||
# versions of the EUPL (the "Licence");
|
|
||||||
# You may not use this work except in compliance with the
|
|
||||||
# Licence.
|
|
||||||
# You may obtain a copy of the Licence at:
|
|
||||||
#
|
|
||||||
# http://ec.europa.eu/idabc/eupl
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in
|
|
||||||
# writing, software distributed under the Licence is
|
|
||||||
# distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
# express or implied.
|
|
||||||
# See the Licence for the specific language governing
|
|
||||||
# permissions and limitations under the Licence.
|
|
||||||
#
|
|
||||||
#############################################################
|
|
||||||
|
|
||||||
OBJSX=
|
|
||||||
|
|
||||||
SPB = TCPLogger.x DebugService.x WebDebugService.x
|
|
||||||
|
|
||||||
ROOT_DIR=../../..
|
|
||||||
|
|
||||||
|
|
||||||
PACKAGE=Components
|
|
||||||
ROOT_DIR=../../..
|
|
||||||
ABS_ROOT_DIR=$(abspath $(ROOT_DIR))
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
all: $(OBJS) $(SUBPROJ)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
include Makefile.inc
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
OBJSX=TcpLogger.x
|
|
||||||
|
|
||||||
PACKAGE=Components/Interfaces
|
|
||||||
|
|
||||||
ROOT_DIR=../../../../
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
INCLUDES += -I.
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
|
||||||
|
|
||||||
all: $(OBJS) $(SUBPROJ) \
|
|
||||||
$(BUILD_DIR)/TcpLogger$(LIBEXT) \
|
|
||||||
$(BUILD_DIR)/TcpLogger$(DLLEXT)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export TARGET=x86-linux
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
OBJSX=WebDebugService.x DebugServiceBase.x
|
|
||||||
|
|
||||||
PACKAGE=Components/Interfaces
|
|
||||||
|
|
||||||
ROOT_DIR=../../../../
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/TCPLogger
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/DebugService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
|
||||||
|
|
||||||
DEBUGSERVICE_SRC=$(ROOT_DIR)/Source/Components/Interfaces/DebugService
|
|
||||||
|
|
||||||
all: $(OBJS) $(SUBPROJ) \
|
|
||||||
$(BUILD_DIR)/WebDebugService$(LIBEXT) \
|
|
||||||
$(BUILD_DIR)/WebDebugService$(DLLEXT)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
|
|
||||||
# Explicit rule to compile DebugServiceBase.cpp from the DebugService directory
|
|
||||||
$(BUILD_DIR)/DebugServiceBase.o: $(DEBUGSERVICE_SRC)/DebugServiceBase.cpp
|
|
||||||
$(COMPILER) -c $(OPTIM) $(INCLUDES) $(CPPFLAGS) $(CFLAGSPEC) $(DEBUG) \
|
|
||||||
$(DEBUGSERVICE_SRC)/DebugServiceBase.cpp -o $(BUILD_DIR)/DebugServiceBase.o
|
|
||||||
@@ -1,564 +0,0 @@
|
|||||||
#include "Atomic.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "DebugBrokerWrapper.h"
|
|
||||||
#include "GAM.h"
|
|
||||||
#include "HighResolutionTimer.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "ReferenceT.h"
|
|
||||||
#include "Sleep.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
#include "Threads.h"
|
|
||||||
#include "TimeoutType.h"
|
|
||||||
#include "TypeConversion.h"
|
|
||||||
#include "WebDebugService.h"
|
|
||||||
#include "WebUI.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// CLASS_REGISTER
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CLASS_REGISTER(WebDebugService, "1.0")
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Helper: convert raw bytes to float64 for SSE JSON
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static float64 WDS_ToFloat64(const uint8 *data, TypeDescriptor td) {
|
|
||||||
float64 v = 0.0;
|
|
||||||
if (td == Float32Bit) { float32 f; memcpy(&f, data, 4u); v = (float64)f; }
|
|
||||||
else if (td == Float64Bit) { memcpy(&v, data, 8u); }
|
|
||||||
else if (td == SignedInteger8Bit) { int8 x; memcpy(&x, data, 1u); v = (float64)x; }
|
|
||||||
else if (td == UnsignedInteger8Bit) { uint8 x; memcpy(&x, data, 1u); v = (float64)x; }
|
|
||||||
else if (td == SignedInteger16Bit) { int16 x; memcpy(&x, data, 2u); v = (float64)x; }
|
|
||||||
else if (td == UnsignedInteger16Bit){ uint16 x; memcpy(&x, data, 2u); v = (float64)x; }
|
|
||||||
else if (td == SignedInteger32Bit) { int32 x; memcpy(&x, data, 4u); v = (float64)x; }
|
|
||||||
else if (td == UnsignedInteger32Bit){ uint32 x; memcpy(&x, data, 4u); v = (float64)x; }
|
|
||||||
else if (td == SignedInteger64Bit) { int64 x; memcpy(&x, data, 8u); v = (float64)x; }
|
|
||||||
else if (td == UnsignedInteger64Bit){ uint64 x; memcpy(&x, data, 8u); v = (float64)(int64)x; }
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void WDS_EscapeJson(const char8 *src, StreamString &dst) {
|
|
||||||
if (src == NULL_PTR(const char8 *)) return;
|
|
||||||
while (*src != '\0') {
|
|
||||||
if (*src == '"') dst += "\\\"";
|
|
||||||
else if (*src == '\\') dst += "\\\\";
|
|
||||||
else if (*src == '\n') dst += "\\n";
|
|
||||||
else if (*src == '\r') dst += "\\r";
|
|
||||||
else if (*src == '\t') dst += "\\t";
|
|
||||||
else dst += *src;
|
|
||||||
src++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Constructor / Destructor
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
WebDebugService::WebDebugService()
|
|
||||||
: DebugServiceBase(),
|
|
||||||
EmbeddedServiceMethodBinderI(),
|
|
||||||
binderHttp(this, WdsBinder::Http),
|
|
||||||
binderStream(this, WdsBinder::Stream),
|
|
||||||
httpService(binderHttp),
|
|
||||||
streamerService(binderStream) {
|
|
||||||
httpPort = 8090u;
|
|
||||||
streamerSeq = 0u;
|
|
||||||
streamerT0Ns = 0u;
|
|
||||||
logHistoryWriteIdx = 0u;
|
|
||||||
logHistoryFill = 0u;
|
|
||||||
memset(logHistory, 0, sizeof(logHistory));
|
|
||||||
for (uint32 i = 0u; i < MAX_SSE_CLIENTS; i++) {
|
|
||||||
sseClients[i] = NULL_PTR(BasicTCPSocket *);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WebDebugService::~WebDebugService() {
|
|
||||||
if (DebugServiceI::GetInstance() == this) {
|
|
||||||
DebugServiceI::SetInstance(NULL_PTR(DebugServiceI *));
|
|
||||||
}
|
|
||||||
httpService.Stop();
|
|
||||||
streamerService.Stop();
|
|
||||||
tcpServer.Close();
|
|
||||||
sseMutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < MAX_SSE_CLIENTS; i++) {
|
|
||||||
if (sseClients[i] != NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
sseClients[i]->Close();
|
|
||||||
delete sseClients[i];
|
|
||||||
sseClients[i] = NULL_PTR(BasicTCPSocket *);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sseMutex.FastUnLock();
|
|
||||||
// signals owned by DebugServiceBase destructor
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Initialise
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool WebDebugService::Initialise(StructuredDataI &data) {
|
|
||||||
if (!ReferenceContainer::Initialise(data)) return false;
|
|
||||||
|
|
||||||
uint32 port = 8090u;
|
|
||||||
(void)data.Read("HttpPort", port);
|
|
||||||
httpPort = (uint16)port;
|
|
||||||
|
|
||||||
if (!traceBuffer.Init(4 * 1024 * 1024)) return false;
|
|
||||||
|
|
||||||
DebugServiceI::SetInstance(this);
|
|
||||||
PatchRegistry();
|
|
||||||
|
|
||||||
// Initialise Logger early so REPORT_ERROR calls are captured.
|
|
||||||
(void)Logger::Instance();
|
|
||||||
REPORT_ERROR(ErrorManagement::Information,
|
|
||||||
"WebDebugService initialised on port %d", (int)httpPort);
|
|
||||||
|
|
||||||
// Record time origin for relative SSE timestamps.
|
|
||||||
streamerT0Ns = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1.0e9);
|
|
||||||
|
|
||||||
ConfigurationDatabase threadData;
|
|
||||||
threadData.Write("Timeout", (uint32)1000);
|
|
||||||
httpService.Initialise(threadData);
|
|
||||||
streamerService.Initialise(threadData);
|
|
||||||
|
|
||||||
if (!tcpServer.Open()) return false;
|
|
||||||
if (!tcpServer.Listen(httpPort)) return false;
|
|
||||||
|
|
||||||
if (httpService.Start() != ErrorManagement::NoError) return false;
|
|
||||||
if (streamerService.Start() != ErrorManagement::NoError) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// EmbeddedServiceMethodBinderI — never actually called (sub-binders used)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType WebDebugService::Execute(ExecutionInfo &info) {
|
|
||||||
(void)info;
|
|
||||||
return ErrorManagement::FatalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// SERVICE_INFO hook
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void WebDebugService::GetServiceInfo(StreamString &out) {
|
|
||||||
out.Printf("OK SERVICE_INFO HTTP:%u STATE:%s\n",
|
|
||||||
(uint32)httpPort, isPaused ? "PAUSED" : "RUNNING");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// SSE broadcast
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void WebDebugService::BroadcastSse(const char8 *eventType,
|
|
||||||
const StreamString &data) {
|
|
||||||
StreamString pkt;
|
|
||||||
pkt.Printf("event: %s\ndata: ", eventType);
|
|
||||||
pkt += data;
|
|
||||||
pkt += "\n\n";
|
|
||||||
sseMutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < MAX_SSE_CLIENTS; i++) {
|
|
||||||
if (sseClients[i] != NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
uint32 sz = pkt.Size();
|
|
||||||
if (!sseClients[i]->Write(pkt.Buffer(), sz)) {
|
|
||||||
sseClients[i]->Close();
|
|
||||||
delete sseClients[i];
|
|
||||||
sseClients[i] = NULL_PTR(BasicTCPSocket *);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sseMutex.FastUnLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebDebugService::RemoveDeadSseClients() {
|
|
||||||
sseMutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < MAX_SSE_CLIENTS; i++) {
|
|
||||||
if (sseClients[i] != NULL_PTR(BasicTCPSocket *) &&
|
|
||||||
!sseClients[i]->IsConnected()) {
|
|
||||||
sseClients[i]->Close();
|
|
||||||
delete sseClients[i];
|
|
||||||
sseClients[i] = NULL_PTR(BasicTCPSocket *);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sseMutex.FastUnLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebDebugService::UpgradeToSse(BasicTCPSocket *client) {
|
|
||||||
const char8 *hdr =
|
|
||||||
"HTTP/1.1 200 OK\r\n"
|
|
||||||
"Content-Type: text/event-stream\r\n"
|
|
||||||
"Cache-Control: no-cache\r\n"
|
|
||||||
"Connection: keep-alive\r\n"
|
|
||||||
"Access-Control-Allow-Origin: *\r\n"
|
|
||||||
"\r\n";
|
|
||||||
uint32 sz = StringHelper::Length(hdr);
|
|
||||||
(void)client->Write(hdr, sz);
|
|
||||||
|
|
||||||
// Send an initial status event
|
|
||||||
mutex.FastLock();
|
|
||||||
bool paused = isPaused;
|
|
||||||
StreamString gam = pausedAtGam;
|
|
||||||
uint32 rem = stepRemaining;
|
|
||||||
mutex.FastUnLock();
|
|
||||||
StreamString initEv;
|
|
||||||
initEv.Printf(
|
|
||||||
"{\"type\":\"status\",\"paused\":%s,\"gam\":\"%s\",\"remaining\":%u}",
|
|
||||||
paused ? "true" : "false", gam.Buffer(), rem);
|
|
||||||
StreamString initPkt;
|
|
||||||
initPkt += "event: message\ndata: ";
|
|
||||||
initPkt += initEv;
|
|
||||||
initPkt += "\n\n";
|
|
||||||
uint32 isz = initPkt.Size();
|
|
||||||
(void)client->Write(initPkt.Buffer(), isz);
|
|
||||||
|
|
||||||
// Replay log history so the browser sees messages emitted before it connected
|
|
||||||
logHistoryMutex.FastLock();
|
|
||||||
{
|
|
||||||
uint32 startIdx = (logHistoryFill >= LOG_HISTORY_SIZE)
|
|
||||||
? logHistoryWriteIdx : 0u;
|
|
||||||
uint32 count = logHistoryFill;
|
|
||||||
for (uint32 i = 0u; i < count; i++) {
|
|
||||||
uint32 idx = (startIdx + i) % LOG_HISTORY_SIZE;
|
|
||||||
if (logHistory[idx][0] != '\0') {
|
|
||||||
StreamString histPkt;
|
|
||||||
histPkt += "event: message\ndata: ";
|
|
||||||
histPkt += logHistory[idx];
|
|
||||||
histPkt += "\n\n";
|
|
||||||
uint32 hsz = histPkt.Size();
|
|
||||||
(void)client->Write(histPkt.Buffer(), hsz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logHistoryMutex.FastUnLock();
|
|
||||||
|
|
||||||
// Register in the SSE client slot array
|
|
||||||
sseMutex.FastLock();
|
|
||||||
bool registered = false;
|
|
||||||
for (uint32 i = 0u; i < MAX_SSE_CLIENTS; i++) {
|
|
||||||
if (sseClients[i] == NULL_PTR(BasicTCPSocket *)) {
|
|
||||||
sseClients[i] = client;
|
|
||||||
registered = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sseMutex.FastUnLock();
|
|
||||||
if (!registered) {
|
|
||||||
client->Close();
|
|
||||||
delete client;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// HTTP request parsing
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool WebDebugService::ParseRequest(BasicTCPSocket *client,
|
|
||||||
StreamString &method, StreamString &path,
|
|
||||||
StreamString &body) {
|
|
||||||
static const uint32 MAX_HEADER = 8192u;
|
|
||||||
char8 buf[MAX_HEADER + 1];
|
|
||||||
uint32 total = 0u;
|
|
||||||
uint32 headerEnd = 0u;
|
|
||||||
bool foundEnd = false;
|
|
||||||
|
|
||||||
while (total < MAX_HEADER && !foundEnd) {
|
|
||||||
uint32 sz = MAX_HEADER - total;
|
|
||||||
if (!client->Read(buf + total, sz) || sz == 0u) break;
|
|
||||||
total += sz;
|
|
||||||
buf[total] = '\0';
|
|
||||||
for (uint32 i = 0u; i + 3u < total; i++) {
|
|
||||||
if (buf[i] == '\r' && buf[i+1] == '\n' &&
|
|
||||||
buf[i+2] == '\r' && buf[i+3] == '\n') {
|
|
||||||
headerEnd = i + 4u;
|
|
||||||
foundEnd = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!foundEnd) return false;
|
|
||||||
|
|
||||||
const char8 *line = buf;
|
|
||||||
const char8 *sp1 = StringHelper::SearchChar(line, ' ');
|
|
||||||
if (sp1 == NULL_PTR(const char8 *)) return false;
|
|
||||||
method = "";
|
|
||||||
{ uint32 mLen = (uint32)(sp1 - line); (void)method.Write(line, mLen); }
|
|
||||||
const char8 *sp2 = StringHelper::SearchChar(sp1 + 1, ' ');
|
|
||||||
if (sp2 == NULL_PTR(const char8 *)) return false;
|
|
||||||
path = "";
|
|
||||||
{ uint32 pLen = (uint32)(sp2 - sp1 - 1); (void)path.Write(sp1 + 1, pLen); }
|
|
||||||
|
|
||||||
uint32 contentLength = 0u;
|
|
||||||
const char8 *cl = StringHelper::SearchString(buf, "Content-Length:");
|
|
||||||
if (cl != NULL_PTR(const char8 *)) {
|
|
||||||
cl += 15u;
|
|
||||||
while (*cl == ' ') cl++;
|
|
||||||
AnyType cv(UnsignedInteger32Bit, 0u, &contentLength);
|
|
||||||
AnyType cs(CharString, 0u, cl);
|
|
||||||
(void)TypeConvert(cv, cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
body = "";
|
|
||||||
if (contentLength > 0u) {
|
|
||||||
uint32 alreadyRead = (total > headerEnd) ? (total - headerEnd) : 0u;
|
|
||||||
if (alreadyRead > 0u) (void)body.Write(buf + headerEnd, alreadyRead);
|
|
||||||
static const uint32 MAX_BODY = 16384u;
|
|
||||||
if (contentLength > alreadyRead && contentLength <= MAX_BODY) {
|
|
||||||
char8 bodyBuf[MAX_BODY];
|
|
||||||
uint32 toRead = contentLength - alreadyRead;
|
|
||||||
uint32 sz = toRead;
|
|
||||||
if (client->Read(bodyBuf, sz) && sz > 0u) {
|
|
||||||
(void)body.Write(bodyBuf, sz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebDebugService::SendHttp(BasicTCPSocket *client, uint32 code,
|
|
||||||
const char8 *ct, StreamString &body) {
|
|
||||||
StreamString resp;
|
|
||||||
resp.Printf("HTTP/1.1 %u %s\r\n"
|
|
||||||
"Content-Type: %s\r\n"
|
|
||||||
"Content-Length: %u\r\n"
|
|
||||||
"Cache-Control: no-cache\r\n"
|
|
||||||
"Access-Control-Allow-Origin: *\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"\r\n",
|
|
||||||
code, (code == 200u) ? "OK" : "Error",
|
|
||||||
ct, (uint32)body.Size());
|
|
||||||
resp += body;
|
|
||||||
uint32 sz = resp.Size();
|
|
||||||
(void)client->Write(resp.Buffer(), sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebDebugService::HandleRequest(BasicTCPSocket *client,
|
|
||||||
const StreamString &method,
|
|
||||||
const StreamString &path,
|
|
||||||
const StreamString &body) {
|
|
||||||
if (method == "GET" && (path == "/" || path == "/index.html")) {
|
|
||||||
StreamString html = WEB_UI_HTML;
|
|
||||||
SendHttp(client, 200u, "text/html; charset=utf-8", html);
|
|
||||||
} else if (method == "GET" && path == "/api/events") {
|
|
||||||
UpgradeToSse(client);
|
|
||||||
return; // socket ownership transferred
|
|
||||||
} else if (method == "POST" && path == "/api/command") {
|
|
||||||
StreamString out;
|
|
||||||
HandleCommand(body, out);
|
|
||||||
SendHttp(client, 200u, "text/plain; charset=utf-8", out);
|
|
||||||
} else if (method == "OPTIONS") {
|
|
||||||
const char8 *hdr =
|
|
||||||
"HTTP/1.1 204 No Content\r\n"
|
|
||||||
"Access-Control-Allow-Origin: *\r\n"
|
|
||||||
"Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n"
|
|
||||||
"Access-Control-Allow-Headers: Content-Type\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"\r\n";
|
|
||||||
uint32 sz = StringHelper::Length(hdr);
|
|
||||||
(void)client->Write(hdr, sz);
|
|
||||||
} else {
|
|
||||||
StreamString body404 = "Not Found";
|
|
||||||
SendHttp(client, 404u, "text/plain", body404);
|
|
||||||
}
|
|
||||||
client->Close();
|
|
||||||
delete client;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// HTTP server thread
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType WebDebugService::HttpServer(ExecutionInfo &info) {
|
|
||||||
if (info.GetStage() == ExecutionInfo::TerminationStage)
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
if (info.GetStage() == ExecutionInfo::StartupStage) {
|
|
||||||
Sleep::MSec(500u); // wait for ORD to finish
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
BasicTCPSocket *client = tcpServer.WaitConnection(TimeoutType(100u));
|
|
||||||
if (client == NULL_PTR(BasicTCPSocket *))
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
|
|
||||||
StreamString method, path, body;
|
|
||||||
if (ParseRequest(client, method, path, body)) {
|
|
||||||
HandleRequest(client, method, path, body);
|
|
||||||
// For SSE, HandleRequest transferred ownership — don't touch client here
|
|
||||||
} else {
|
|
||||||
client->Close();
|
|
||||||
delete client;
|
|
||||||
}
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Streamer thread — drains log, polls monitors, drains trace buffer, heartbeat
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ErrorManagement::ErrorType WebDebugService::Streamer(ExecutionInfo &info) {
|
|
||||||
if (info.GetStage() == ExecutionInfo::TerminationStage)
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
if (info.GetStage() == ExecutionInfo::StartupStage)
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
|
|
||||||
uint64 nowNs = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1.0e9);
|
|
||||||
uint64 nowMs = (nowNs >= streamerT0Ns) ? (nowNs - streamerT0Ns) / 1000000u : 0u;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Drain MARTe2 log pages → SSE log events
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
{
|
|
||||||
static const uint32 MAX_LOGS_PER_CYCLE = 32u;
|
|
||||||
uint32 logCount = 0u;
|
|
||||||
LoggerPage *logPage = Logger::Instance()->GetLogEntry();
|
|
||||||
while (logPage != NULL_PTR(LoggerPage *) && logCount < MAX_LOGS_PER_CYCLE) {
|
|
||||||
StreamString levelStr;
|
|
||||||
ErrorManagement::ErrorCodeToStream(
|
|
||||||
logPage->errorInfo.header.errorType, levelStr);
|
|
||||||
StreamString msgEsc;
|
|
||||||
WDS_EscapeJson(logPage->errorStrBuffer, msgEsc);
|
|
||||||
StreamString ev;
|
|
||||||
ev.Printf("{\"type\":\"log\",\"level\":\"%s\",\"msg\":\"%s\"}",
|
|
||||||
levelStr.Buffer(), msgEsc.Buffer());
|
|
||||||
Logger::Instance()->ReturnPage(logPage);
|
|
||||||
|
|
||||||
logHistoryMutex.FastLock();
|
|
||||||
{
|
|
||||||
uint32 evSz = ev.Size();
|
|
||||||
if (evSz >= LOG_ENTRY_MAX_SIZE) evSz = LOG_ENTRY_MAX_SIZE - 1u;
|
|
||||||
(void)StringHelper::CopyN(logHistory[logHistoryWriteIdx],
|
|
||||||
ev.Buffer(), evSz);
|
|
||||||
logHistory[logHistoryWriteIdx][evSz] = '\0';
|
|
||||||
logHistoryWriteIdx = (logHistoryWriteIdx + 1u) % LOG_HISTORY_SIZE;
|
|
||||||
if (logHistoryFill < LOG_HISTORY_SIZE) logHistoryFill++;
|
|
||||||
}
|
|
||||||
logHistoryMutex.FastUnLock();
|
|
||||||
|
|
||||||
BroadcastSse("message", ev);
|
|
||||||
logPage = Logger::Instance()->GetLogEntry();
|
|
||||||
logCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Poll monitored signals → SSE monitor events
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
mutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < monitoredSignals.GetNumberOfElements(); i++) {
|
|
||||||
if (nowMs >= (monitoredSignals[i].lastPollTime +
|
|
||||||
monitoredSignals[i].periodMs)) {
|
|
||||||
monitoredSignals[i].lastPollTime = nowMs;
|
|
||||||
uint32 tsMs = (uint32)nowMs;
|
|
||||||
void *addr = NULL_PTR(void *);
|
|
||||||
if (monitoredSignals[i].dataSource->GetSignalMemoryBuffer(
|
|
||||||
monitoredSignals[i].signalIdx, 0u, addr) &&
|
|
||||||
addr != NULL_PTR(void *)) {
|
|
||||||
uint32 sz = monitoredSignals[i].size;
|
|
||||||
if (sz > 1024u) sz = 1024u;
|
|
||||||
uint8 lb[1024]; memcpy(lb, addr, sz);
|
|
||||||
TypeDescriptor td = monitoredSignals[i].dataSource->GetSignalType(
|
|
||||||
monitoredSignals[i].signalIdx);
|
|
||||||
float64 val = WDS_ToFloat64(lb, td);
|
|
||||||
|
|
||||||
StreamString sigName;
|
|
||||||
for (uint32 j = 0u; j < aliases.GetNumberOfElements(); j++) {
|
|
||||||
if (signals[aliases[j].signalIndex]->internalID ==
|
|
||||||
monitoredSignals[i].internalID) {
|
|
||||||
sigName = aliases[j].name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sigName.Size() == 0u) sigName = monitoredSignals[i].path;
|
|
||||||
|
|
||||||
char8 valBuf[64] = { '\0' };
|
|
||||||
{
|
|
||||||
AnyType vdst(CharString, 0u, valBuf);
|
|
||||||
vdst.SetNumberOfElements(0u, 63u);
|
|
||||||
AnyType vsrc(Float64Bit, 0u, &val);
|
|
||||||
(void)TypeConvert(vdst, vsrc);
|
|
||||||
}
|
|
||||||
StreamString ev;
|
|
||||||
ev.Printf(
|
|
||||||
"{\"type\":\"monitor\",\"name\":\"%s\",\"ts\":%u,\"value\":%s}",
|
|
||||||
sigName.Buffer(), tsMs, valBuf);
|
|
||||||
mutex.FastUnLock();
|
|
||||||
BroadcastSse("message", ev);
|
|
||||||
mutex.FastLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutex.FastUnLock();
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Drain ring buffer → SSE trace events
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
static const uint32 MAX_TRACE_CYCLE = 50u;
|
|
||||||
uint32 id, size;
|
|
||||||
uint64 sampleTs;
|
|
||||||
bool hasData = false;
|
|
||||||
uint32 traceCount = 0u;
|
|
||||||
|
|
||||||
while (traceCount < MAX_TRACE_CYCLE &&
|
|
||||||
traceBuffer.Pop(id, sampleTs, traceSampleBuffer, size, TRACE_SAMPLE_MAX)) {
|
|
||||||
hasData = true;
|
|
||||||
traceCount++;
|
|
||||||
|
|
||||||
StreamString sigName;
|
|
||||||
TypeDescriptor sigType = UnsignedInteger32Bit;
|
|
||||||
mutex.FastLock();
|
|
||||||
for (uint32 i = 0u; i < signals.GetNumberOfElements(); i++) {
|
|
||||||
if (signals[i]->internalID == id) {
|
|
||||||
sigName = signals[i]->name;
|
|
||||||
sigType = signals[i]->type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutex.FastUnLock();
|
|
||||||
|
|
||||||
uint32 tsMs = (sampleTs >= streamerT0Ns)
|
|
||||||
? (uint32)((sampleTs - streamerT0Ns) / 1000000u) : 0u;
|
|
||||||
float64 val = WDS_ToFloat64(traceSampleBuffer, sigType);
|
|
||||||
char8 valBuf[64] = { '\0' };
|
|
||||||
{
|
|
||||||
AnyType vdst(CharString, 0u, valBuf); vdst.SetNumberOfElements(0u, 63u);
|
|
||||||
AnyType vsrc(Float64Bit, 0u, &val);
|
|
||||||
(void)TypeConvert(vdst, vsrc);
|
|
||||||
}
|
|
||||||
StreamString ev;
|
|
||||||
ev.Printf("{\"type\":\"trace\",\"name\":\"%s\",\"ts\":%u,\"value\":%s}",
|
|
||||||
sigName.Buffer(), tsMs, valBuf);
|
|
||||||
BroadcastSse("message", ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Periodic status heartbeat (every 500 ms)
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
static uint64 lastStatusMs = 0u;
|
|
||||||
if (nowMs - lastStatusMs >= 500u) {
|
|
||||||
lastStatusMs = nowMs;
|
|
||||||
mutex.FastLock();
|
|
||||||
bool paused = isPaused;
|
|
||||||
StreamString gam = pausedAtGam;
|
|
||||||
uint32 rem = stepRemaining;
|
|
||||||
mutex.FastUnLock();
|
|
||||||
StreamString ev;
|
|
||||||
ev.Printf(
|
|
||||||
"{\"type\":\"status\",\"paused\":%s,\"gam\":\"%s\",\"remaining\":%u}",
|
|
||||||
paused ? "true" : "false", gam.Buffer(), rem);
|
|
||||||
BroadcastSse("message", ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveDeadSseClients();
|
|
||||||
(void)hasData;
|
|
||||||
Sleep::MSec(10u);
|
|
||||||
return ErrorManagement::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
#ifndef WEBDEBUGSERVICE_H
|
|
||||||
#define WEBDEBUGSERVICE_H
|
|
||||||
|
|
||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "DebugServiceBase.h"
|
|
||||||
#include "EmbeddedServiceMethodBinderI.h"
|
|
||||||
#include "ReferenceT.h"
|
|
||||||
#include "SingleThreadService.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HTTP/SSE implementation of DebugServiceI (via DebugServiceBase).
|
|
||||||
*
|
|
||||||
* Serves a single-page web UI on httpPort (default 8090).
|
|
||||||
* Endpoints:
|
|
||||||
* GET / — embedded HTML application
|
|
||||||
* POST /api/command — execute a debug command; returns text response
|
|
||||||
* GET /api/events — Server-Sent Events stream for real-time telemetry
|
|
||||||
*
|
|
||||||
* All signal management and command dispatch logic lives in DebugServiceBase.
|
|
||||||
* This class adds only the HTTP/SSE transport.
|
|
||||||
*/
|
|
||||||
class WebDebugService : public DebugServiceBase,
|
|
||||||
public EmbeddedServiceMethodBinderI {
|
|
||||||
public:
|
|
||||||
friend class WebDebugServiceTest;
|
|
||||||
CLASS_REGISTER_DECLARATION()
|
|
||||||
|
|
||||||
WebDebugService();
|
|
||||||
virtual ~WebDebugService();
|
|
||||||
|
|
||||||
virtual bool Initialise(StructuredDataI &data);
|
|
||||||
|
|
||||||
// EmbeddedServiceMethodBinderI (framework dispatches to sub-binders)
|
|
||||||
virtual ErrorManagement::ErrorType Execute(ExecutionInfo &info);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Transport-specific overrides of DebugServiceBase hooks
|
|
||||||
virtual void GetServiceInfo(StreamString &out);
|
|
||||||
virtual void RebuildTransportConfig() {} // no transport-specific keys
|
|
||||||
|
|
||||||
private:
|
|
||||||
// HTTP server helpers
|
|
||||||
bool ParseRequest(BasicTCPSocket *client, StreamString &method,
|
|
||||||
StreamString &path, StreamString &body);
|
|
||||||
void SendHttp(BasicTCPSocket *client, uint32 code, const char8 *ct,
|
|
||||||
StreamString &body);
|
|
||||||
void HandleRequest(BasicTCPSocket *client, const StreamString &method,
|
|
||||||
const StreamString &path, const StreamString &body);
|
|
||||||
void UpgradeToSse(BasicTCPSocket *client);
|
|
||||||
|
|
||||||
// SSE broadcast
|
|
||||||
void BroadcastSse(const char8 *eventType, const StreamString &data);
|
|
||||||
void RemoveDeadSseClients();
|
|
||||||
|
|
||||||
// Service thread entry points
|
|
||||||
ErrorManagement::ErrorType HttpServer(ExecutionInfo &info);
|
|
||||||
ErrorManagement::ErrorType Streamer (ExecutionInfo &info);
|
|
||||||
|
|
||||||
// Sub-binder so the framework can dispatch to two separate threads
|
|
||||||
class WdsBinder : public EmbeddedServiceMethodBinderI {
|
|
||||||
public:
|
|
||||||
enum ServiceType { Http, Stream };
|
|
||||||
WdsBinder(WebDebugService *p, ServiceType t) : parent(p), stype(t) {}
|
|
||||||
virtual ErrorManagement::ErrorType Execute(ExecutionInfo &info) {
|
|
||||||
return (stype == Stream) ? parent->Streamer(info)
|
|
||||||
: parent->HttpServer(info);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
WebDebugService *parent;
|
|
||||||
ServiceType stype;
|
|
||||||
};
|
|
||||||
|
|
||||||
uint16 httpPort;
|
|
||||||
|
|
||||||
BasicTCPSocket tcpServer;
|
|
||||||
|
|
||||||
WdsBinder binderHttp;
|
|
||||||
WdsBinder binderStream;
|
|
||||||
SingleThreadService httpService;
|
|
||||||
SingleThreadService streamerService;
|
|
||||||
|
|
||||||
// SSE client list
|
|
||||||
static const uint32 MAX_SSE_CLIENTS = 8u;
|
|
||||||
BasicTCPSocket *sseClients[MAX_SSE_CLIENTS];
|
|
||||||
FastPollingMutexSem sseMutex;
|
|
||||||
|
|
||||||
// Streamer packet state
|
|
||||||
uint32 streamerSeq;
|
|
||||||
uint64 streamerT0Ns; // nanosecond origin for relative timestamps sent over SSE
|
|
||||||
|
|
||||||
// Log history buffer — replayed to newly connecting SSE clients
|
|
||||||
static const uint32 LOG_HISTORY_SIZE = 64u;
|
|
||||||
static const uint32 LOG_ENTRY_MAX_SIZE = 512u;
|
|
||||||
char8 logHistory[64][512];
|
|
||||||
uint32 logHistoryWriteIdx;
|
|
||||||
uint32 logHistoryFill;
|
|
||||||
FastPollingMutexSem logHistoryMutex;
|
|
||||||
|
|
||||||
// Staging buffer for trace ring-buffer pops (max UDP datagram payload).
|
|
||||||
static const uint32 TRACE_SAMPLE_MAX = 65499u;
|
|
||||||
uint8 traceSampleBuffer[TRACE_SAMPLE_MAX];
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif // WEBDEBUGSERVICE_H
|
|
||||||
@@ -1,611 +0,0 @@
|
|||||||
#ifndef WEBUI_H
|
|
||||||
#define WEBUI_H
|
|
||||||
|
|
||||||
#include "CompilerTypes.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
static const char8 *const WEB_UI_HTML =
|
|
||||||
"<!DOCTYPE html>\n"
|
|
||||||
"<html lang='en'>\n"
|
|
||||||
"<head>\n"
|
|
||||||
"<meta charset='UTF-8'>\n"
|
|
||||||
"<meta name='viewport' content='width=device-width,initial-scale=1'>\n"
|
|
||||||
"<title>MARTe2 Debug</title>\n"
|
|
||||||
"<script src='https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js'></script>\n"
|
|
||||||
"<style>\n"
|
|
||||||
":root{--base:#1e1e2e;--mantle:#181825;--crust:#11111b;--text:#cdd6f4;--sub:#a6adc8;\n"
|
|
||||||
" --ov:#6c7086;--s0:#313244;--s1:#45475a;--s2:#585b70;--blue:#89b4fa;\n"
|
|
||||||
" --green:#a6e3a1;--yellow:#f9e2af;--red:#f38ba8;--mauve:#cba6f7;--peach:#fab387;\n"
|
|
||||||
" --teal:#94e2d5;--sky:#89dceb;}\n"
|
|
||||||
"*{box-sizing:border-box;margin:0;padding:0;}\n"
|
|
||||||
"body{background:var(--base);color:var(--text);font-family:'JetBrains Mono','Fira Code',monospace;\n"
|
|
||||||
" font-size:12px;height:100vh;display:flex;flex-direction:column;overflow:hidden;}\n"
|
|
||||||
"#toolbar{background:var(--mantle);border-bottom:1px solid var(--s0);padding:5px 8px;\n"
|
|
||||||
" display:flex;align-items:center;gap:6px;flex-shrink:0;flex-wrap:wrap;}\n"
|
|
||||||
".dot{width:9px;height:9px;border-radius:50%;background:var(--red);flex-shrink:0;}\n"
|
|
||||||
".dot.ok{background:var(--green);}\n"
|
|
||||||
".dot.pause{background:var(--yellow);animation:blink 1s infinite;}\n"
|
|
||||||
"@keyframes blink{0%,100%{opacity:1}50%{opacity:.3}}\n"
|
|
||||||
"button{background:var(--s0);color:var(--text);border:1px solid var(--s1);border-radius:3px;\n"
|
|
||||||
" padding:2px 7px;cursor:pointer;font-size:11px;font-family:inherit;}\n"
|
|
||||||
"button:hover{background:var(--s1);}\n"
|
|
||||||
"button.act{background:var(--blue);color:var(--base);border-color:var(--blue);}\n"
|
|
||||||
"button.danger{background:var(--red);color:var(--base);border-color:var(--red);}\n"
|
|
||||||
"input[type=text],input[type=number]{background:var(--s0);color:var(--text);\n"
|
|
||||||
" border:1px solid var(--s1);border-radius:3px;padding:2px 5px;font-size:11px;font-family:inherit;}\n"
|
|
||||||
"input:focus{outline:none;border-color:var(--blue);}\n"
|
|
||||||
"label{color:var(--sub);font-size:11px;}\n"
|
|
||||||
"select{background:var(--s0);color:var(--text);border:1px solid var(--s1);border-radius:3px;\n"
|
|
||||||
" padding:2px 5px;font-size:11px;font-family:inherit;}\n"
|
|
||||||
".sep{width:1px;height:18px;background:var(--s1);flex-shrink:0;}\n"
|
|
||||||
"#main{display:flex;flex:1;overflow:hidden;}\n"
|
|
||||||
"#left{width:255px;background:var(--mantle);border-right:1px solid var(--s0);\n"
|
|
||||||
" display:flex;flex-direction:column;overflow:hidden;flex-shrink:0;}\n"
|
|
||||||
"#center{flex:1;display:flex;flex-direction:column;overflow:hidden;}\n"
|
|
||||||
"#right{width:215px;background:var(--mantle);border-left:1px solid var(--s0);\n"
|
|
||||||
" display:flex;flex-direction:column;overflow:hidden;flex-shrink:0;}\n"
|
|
||||||
"#bottom{height:135px;background:var(--mantle);border-top:1px solid var(--s0);\n"
|
|
||||||
" display:flex;flex-direction:column;flex-shrink:0;}\n"
|
|
||||||
".ph{background:var(--crust);padding:4px 7px;font-size:11px;color:var(--sub);\n"
|
|
||||||
" display:flex;align-items:center;justify-content:space-between;flex-shrink:0;\n"
|
|
||||||
" border-bottom:1px solid var(--s0);}\n"
|
|
||||||
".ph span{font-weight:bold;color:var(--blue);}\n"
|
|
||||||
"#tree{flex:1;overflow-y:auto;padding:3px;}\n"
|
|
||||||
".tr{display:flex;align-items:center;padding:2px 3px;border-radius:3px;gap:2px;cursor:default;}\n"
|
|
||||||
".tr:hover{background:var(--s0);}\n"
|
|
||||||
".tog{width:13px;text-align:center;cursor:pointer;color:var(--ov);font-size:10px;flex-shrink:0;}\n"
|
|
||||||
".ico{flex-shrink:0;font-size:10px;}\n"
|
|
||||||
".tn{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;}\n"
|
|
||||||
".sig{color:var(--green);}\n"
|
|
||||||
".tbtns{display:none;gap:2px;}\n"
|
|
||||||
".tr:hover .tbtns{display:flex;}\n"
|
|
||||||
".tb{background:none;border:none;padding:1px 3px;font-size:10px;cursor:pointer;\n"
|
|
||||||
" border-radius:2px;color:var(--sub);}\n"
|
|
||||||
".tb:hover{background:var(--s1);color:var(--text);}\n"
|
|
||||||
".tch{padding-left:13px;}\n"
|
|
||||||
"#ctrls{padding:4px 7px;display:flex;align-items:center;gap:5px;background:var(--crust);\n"
|
|
||||||
" border-bottom:1px solid var(--s0);flex-shrink:0;flex-wrap:wrap;}\n"
|
|
||||||
"#ca{flex:1;padding:6px;overflow:hidden;position:relative;}\n"
|
|
||||||
"#mc{display:block;width:100%;height:100%;}\n"
|
|
||||||
"#traced{flex:1;overflow-y:auto;padding:3px;}\n"
|
|
||||||
".ti{display:flex;align-items:center;gap:3px;padding:2px 4px;border-radius:3px;margin-bottom:1px;}\n"
|
|
||||||
".ti:hover{background:var(--s0);}\n"
|
|
||||||
".tc{width:7px;height:7px;border-radius:2px;flex-shrink:0;}\n"
|
|
||||||
".tnm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;}\n"
|
|
||||||
".tv{font-size:10px;color:var(--yellow);min-width:55px;text-align:right;flex-shrink:0;}\n"
|
|
||||||
".titbs{display:none;gap:2px;}\n"
|
|
||||||
".ti:hover .titbs{display:flex;}\n"
|
|
||||||
"#ltb{padding:3px 5px;display:flex;gap:6px;align-items:center;background:var(--crust);\n"
|
|
||||||
" border-bottom:1px solid var(--s0);flex-shrink:0;}\n"
|
|
||||||
"#lc{flex:1;overflow-y:auto;padding:2px 5px;}\n"
|
|
||||||
".le{font-size:10px;line-height:1.4;font-family:monospace;white-space:pre-wrap;word-break:break-all;}\n"
|
|
||||||
".lDEBUG{color:var(--ov);}\n"
|
|
||||||
".lINFO{color:var(--text);}\n"
|
|
||||||
".lWARNING{color:var(--yellow);}\n"
|
|
||||||
".lERROR{color:var(--red);}\n"
|
|
||||||
".mo{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.7);\n"
|
|
||||||
" z-index:100;align-items:center;justify-content:center;}\n"
|
|
||||||
".mo.show{display:flex;}\n"
|
|
||||||
".mb{background:var(--mantle);border:1px solid var(--s1);border-radius:7px;padding:15px;min-width:290px;}\n"
|
|
||||||
".mb h3{color:var(--blue);margin-bottom:11px;font-size:13px;}\n"
|
|
||||||
".fr{display:flex;align-items:center;gap:7px;margin-bottom:7px;}\n"
|
|
||||||
".fr label{min-width:75px;color:var(--sub);}\n"
|
|
||||||
".fr input,.fr select,.fr textarea{flex:1;}\n"
|
|
||||||
"textarea{background:var(--s0);color:var(--text);border:1px solid var(--s1);border-radius:3px;\n"
|
|
||||||
" padding:2px 5px;font-size:11px;font-family:inherit;resize:vertical;}\n"
|
|
||||||
"textarea:focus{outline:none;border-color:var(--blue);}\n"
|
|
||||||
".mbtns{display:flex;gap:7px;justify-content:flex-end;margin-top:11px;}\n"
|
|
||||||
"::-webkit-scrollbar{width:5px;height:5px;}\n"
|
|
||||||
"::-webkit-scrollbar-track{background:var(--mantle);}\n"
|
|
||||||
"::-webkit-scrollbar-thumb{background:var(--s1);border-radius:3px;}\n"
|
|
||||||
"</style>\n"
|
|
||||||
"</head>\n"
|
|
||||||
"<body>\n"
|
|
||||||
"<div id='toolbar'>\n"
|
|
||||||
" <div id='sdot' class='dot'></div>\n"
|
|
||||||
" <span id='stxt' style='color:var(--sub);font-size:11px'>Connecting\xe2\x80\xa6</span>\n"
|
|
||||||
" <div class='sep'></div>\n"
|
|
||||||
" <button onclick='cmd(\"DISCOVER\")'>Discover</button>\n"
|
|
||||||
" <button onclick='cmd(\"TREE\")'>Tree</button>\n"
|
|
||||||
" <div class='sep'></div>\n"
|
|
||||||
" <button id='pbtn' onclick='togglePause()'>Pause</button>\n"
|
|
||||||
" <div class='sep'></div>\n"
|
|
||||||
" <label>Step:</label>\n"
|
|
||||||
" <input type='number' id='sn' value='1' min='1' style='width:45px'>\n"
|
|
||||||
" <input type='text' id='sthr' list='thrnodes' placeholder='thread' style='width:90px'>\n"
|
|
||||||
" <datalist id='thrnodes'></datalist>\n"
|
|
||||||
" <button onclick='doStep()'>Step</button>\n"
|
|
||||||
" <button onclick='openMsg()'>Msg</button>\n"
|
|
||||||
" <div class='sep'></div>\n"
|
|
||||||
" <label>Win:</label>\n"
|
|
||||||
" <input type='number' id='winms' value='5000' min='100' style='width:60px' onchange='winMs=+this.value'>\n"
|
|
||||||
" <button onclick='clearChart()'>Clear</button>\n"
|
|
||||||
" <span id='ss' style='color:var(--yellow);font-size:11px'></span>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<div id='main'>\n"
|
|
||||||
" <div id='left'>\n"
|
|
||||||
" <div class='ph'><span>App Tree</span><button onclick='cmd(\"TREE\")' style='font-size:10px'>↻</button></div>\n"
|
|
||||||
" <div id='tree'><div style='color:var(--ov);padding:7px;font-size:11px'>Click Tree or Discover\xe2\x80\xa6</div></div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" <div id='center'>\n"
|
|
||||||
" <div id='ctrls'>\n"
|
|
||||||
" <label>Signal:</label>\n"
|
|
||||||
" <select id='sigsel' style='width:150px'><option value=''>-- pick --</option></select>\n"
|
|
||||||
" <button onclick='addToChart()'>+ Plot</button>\n"
|
|
||||||
" <button onclick='toggleFollow()' id='fbtn' class='act'>Follow</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" <div id='ca' ondragover='event.preventDefault()' ondrop='dropOnChart(event)'><canvas id='mc'></canvas></div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" <div id='right'>\n"
|
|
||||||
" <div class='ph'><span>Traced</span></div>\n"
|
|
||||||
" <div id='traced'></div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<div id='bottom'>\n"
|
|
||||||
" <div class='ph'>\n"
|
|
||||||
" <span>Log</span>\n"
|
|
||||||
" <div style='display:flex;gap:5px;align-items:center'>\n"
|
|
||||||
" <label><input type='checkbox' id='fdbg' checked> D</label>\n"
|
|
||||||
" <label><input type='checkbox' id='finf' checked> I</label>\n"
|
|
||||||
" <label><input type='checkbox' id='fwrn' checked> W</label>\n"
|
|
||||||
" <label><input type='checkbox' id='ferr' checked> E</label>\n"
|
|
||||||
" <button onclick='document.getElementById(\"lc\").innerHTML=\"\"'>Clr</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" <div id='lc'></div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<!-- Modals -->\n"
|
|
||||||
"<div class='mo' id='frcm'>\n"
|
|
||||||
" <div class='mb'>\n"
|
|
||||||
" <h3>Force Signal</h3>\n"
|
|
||||||
" <div class='fr'><label>Signal:</label><span id='frcn' style='color:var(--green);font-size:11px;flex:1;overflow:hidden;text-overflow:ellipsis'></span></div>\n"
|
|
||||||
" <div class='fr'><label>Value:</label><input type='text' id='frcv'></div>\n"
|
|
||||||
" <div class='mbtns'>\n"
|
|
||||||
" <button onclick='closeM(\"frcm\")'>Cancel</button>\n"
|
|
||||||
" <button onclick='doUnforce()'>Unforce</button>\n"
|
|
||||||
" <button class='act' onclick='doForce()'>Force</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<div class='mo' id='brkm'>\n"
|
|
||||||
" <div class='mb'>\n"
|
|
||||||
" <h3>Break Condition</h3>\n"
|
|
||||||
" <div class='fr'><label>Signal:</label><span id='brkn' style='color:var(--green);font-size:11px;flex:1;overflow:hidden;text-overflow:ellipsis'></span></div>\n"
|
|
||||||
" <div class='fr'><label>Op:</label><select id='brkop'><option>></option><option><</option><option>==</option><option>>=</option><option><=</option><option>!=</option></select></div>\n"
|
|
||||||
" <div class='fr'><label>Threshold:</label><input type='number' id='brkthr' step='any' value='0'></div>\n"
|
|
||||||
" <div class='mbtns'>\n"
|
|
||||||
" <button onclick='closeM(\"brkm\")'>Cancel</button>\n"
|
|
||||||
" <button onclick='doClrBreak()'>Clear</button>\n"
|
|
||||||
" <button class='act' onclick='doBreak()'>Set</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<div class='mo' id='monm'>\n"
|
|
||||||
" <div class='mb'>\n"
|
|
||||||
" <h3>Monitor Signal</h3>\n"
|
|
||||||
" <div class='fr'><label>Signal:</label><span id='monn' style='color:var(--green);font-size:11px;flex:1;overflow:hidden;text-overflow:ellipsis'></span></div>\n"
|
|
||||||
" <div class='fr'><label>Period ms:</label><input type='number' id='monp' value='100' min='10'></div>\n"
|
|
||||||
" <div class='mbtns'>\n"
|
|
||||||
" <button onclick='closeM(\"monm\")'>Cancel</button>\n"
|
|
||||||
" <button onclick='doUnmonitor()'>Unmonitor</button>\n"
|
|
||||||
" <button class='act' onclick='doMonitor()'>Monitor</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<div class='mo' id='msgm'>\n"
|
|
||||||
" <div class='mb'>\n"
|
|
||||||
" <h3>Send Message</h3>\n"
|
|
||||||
" <div class='fr'><label>Dest:</label><input type='text' id='msgd' list='msgnodes' autocomplete='off'></div>\n"
|
|
||||||
" <datalist id='msgnodes'></datalist>\n"
|
|
||||||
" <div class='fr'><label>Function:</label><input type='text' id='msgf'></div>\n"
|
|
||||||
" <div class='fr'><label>Payload:</label><textarea id='msgp' rows='3' placeholder='key=val key2=val2'></textarea></div>\n"
|
|
||||||
" <div class='mbtns'>\n"
|
|
||||||
" <button onclick='closeM(\"msgm\")'>Cancel</button>\n"
|
|
||||||
" <button class='act' onclick='doMsg()'>Send</button>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
"</div>\n"
|
|
||||||
"<script>\n"
|
|
||||||
"var sigs=[],td={},isPaused=false,chart=null,cds={},winMs=5000,follow=true,curSig='',tnodes=[],threads=[];\n"
|
|
||||||
"var lc=document.getElementById('lc');\n"
|
|
||||||
"var COLS=['#89b4fa','#a6e3a1','#fab387','#cba6f7','#f38ba8','#94e2d5','#f9e2af','#89dceb'];\n"
|
|
||||||
"var ci=0;\n"
|
|
||||||
"function nc(){return COLS[ci++%COLS.length];}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- SSE ---\n"
|
|
||||||
"function connect(){\n"
|
|
||||||
" var es=new EventSource('/api/events');\n"
|
|
||||||
" es.onopen=function(){\n"
|
|
||||||
" document.getElementById('sdot').className='dot ok';\n"
|
|
||||||
" document.getElementById('stxt').textContent='Connected';\n"
|
|
||||||
" cmd('TREE');cmd('DISCOVER');\n"
|
|
||||||
" };\n"
|
|
||||||
" es.onerror=function(){\n"
|
|
||||||
" document.getElementById('sdot').className='dot';\n"
|
|
||||||
" document.getElementById('stxt').textContent='Reconnecting\xe2\x80\xa6';\n"
|
|
||||||
" es.close();setTimeout(connect,3000);\n"
|
|
||||||
" };\n"
|
|
||||||
" es.onmessage=function(e){\n"
|
|
||||||
" try{handle(JSON.parse(e.data));}catch(x){}\n"
|
|
||||||
" };\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function handle(ev){\n"
|
|
||||||
" if(ev.type==='trace'||ev.type==='monitor'){\n"
|
|
||||||
" var n=ev.name,ts=ev.ts,v=ev.value;\n"
|
|
||||||
" var isNew=!td[n];\n"
|
|
||||||
" if(isNew){td[n]={pts:[],last:0,col:nc(),inC:false,tracing:false,forced:false};addOpt(n);updTraced();}\n"
|
|
||||||
" td[n].pts.push({x:ts,y:v});\n"
|
|
||||||
" if(td[n].pts.length>10000)td[n].pts.shift();\n"
|
|
||||||
" td[n].last=v;\n"
|
|
||||||
" } else if(ev.type==='log'){\n"
|
|
||||||
" appLog(ev.level,ev.msg);\n"
|
|
||||||
" } else if(ev.type==='status'){\n"
|
|
||||||
" isPaused=ev.paused;\n"
|
|
||||||
" updPause();\n"
|
|
||||||
" var ss=document.getElementById('ss');\n"
|
|
||||||
" if(ev.paused){\n"
|
|
||||||
" ss.textContent='PAUSED'+(ev.gam?' at '+ev.gam:'')+(ev.remaining?' ('+ev.remaining+'step)':'');\n"
|
|
||||||
" document.getElementById('sdot').className='dot pause';\n"
|
|
||||||
" } else {\n"
|
|
||||||
" ss.textContent='';\n"
|
|
||||||
" document.getElementById('sdot').className='dot ok';\n"
|
|
||||||
" }\n"
|
|
||||||
" } else if(ev.type==='discover'){\n"
|
|
||||||
" sigs=ev.signals||[];\n"
|
|
||||||
" buildSel();\n"
|
|
||||||
" } else if(ev.type==='tree'){\n"
|
|
||||||
" renderTree(ev.tree);\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Chart ---\n"
|
|
||||||
"function initChart(){\n"
|
|
||||||
" var ctx=document.getElementById('mc').getContext('2d');\n"
|
|
||||||
" chart=new Chart(ctx,{\n"
|
|
||||||
" type:'line',\n"
|
|
||||||
" data:{datasets:[]},\n"
|
|
||||||
" options:{\n"
|
|
||||||
" animation:false,responsive:true,maintainAspectRatio:false,parsing:false,\n"
|
|
||||||
" plugins:{legend:{display:true,position:'bottom',\n"
|
|
||||||
" labels:{color:'#a6adc8',boxWidth:12,font:{size:10},\n"
|
|
||||||
" generateLabels:function(ch){return ch.data.datasets.map(function(ds,i){\n"
|
|
||||||
" return {text:ds.label.split('.').pop(),fillStyle:ds.borderColor,\n"
|
|
||||||
" strokeStyle:ds.borderColor,lineWidth:0,datasetIndex:i};});}},\n"
|
|
||||||
" onClick:function(e,li){remFromChart(chart.data.datasets[li.datasetIndex].label);}\n"
|
|
||||||
" }},\n"
|
|
||||||
" scales:{\n"
|
|
||||||
" x:{type:'linear',ticks:{color:'#6c7086',maxTicksLimit:8,\n"
|
|
||||||
" callback:function(v){return (v/1000).toFixed(1)+'s';}},\n"
|
|
||||||
" grid:{color:'#313244'}},\n"
|
|
||||||
" y:{ticks:{color:'#6c7086'},grid:{color:'#313244'}}\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" });\n"
|
|
||||||
" resizeChart();\n"
|
|
||||||
" window.addEventListener('resize',resizeChart);\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function resizeChart(){\n"
|
|
||||||
" var a=document.getElementById('ca');\n"
|
|
||||||
" var c=document.getElementById('mc');\n"
|
|
||||||
" c.width=a.clientWidth;c.height=a.clientHeight;\n"
|
|
||||||
" if(chart)chart.resize();\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function updChart(){\n"
|
|
||||||
" if(!chart)return;\n"
|
|
||||||
" var keys=Object.keys(cds);\n"
|
|
||||||
" if(keys.length===0)return;\n"
|
|
||||||
" // Find the latest timestamp across all charted signals for follow mode\n"
|
|
||||||
" var latestTs=0;\n"
|
|
||||||
" for(var i=0;i<keys.length;i++){\n"
|
|
||||||
" var t=td[keys[i]];\n"
|
|
||||||
" if(t&&t.pts.length>0){var lt=t.pts[t.pts.length-1].x;if(lt>latestTs)latestTs=lt;}\n"
|
|
||||||
" }\n"
|
|
||||||
" for(var i=0;i<keys.length;i++){\n"
|
|
||||||
" var n=keys[i],d=cds[n],t=td[n];\n"
|
|
||||||
" if(!t)continue;\n"
|
|
||||||
" if(follow){\n"
|
|
||||||
" var pts=[],minT=latestTs-winMs;\n"
|
|
||||||
" for(var j=0;j<t.pts.length;j++){if(t.pts[j].x>=minT)pts.push(t.pts[j]);}\n"
|
|
||||||
" chart.data.datasets[d].data=pts;\n"
|
|
||||||
" } else {\n"
|
|
||||||
" chart.data.datasets[d].data=t.pts.slice();\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" chart.update('none');\n"
|
|
||||||
"}\n"
|
|
||||||
"setInterval(function(){if(Object.keys(cds).length>0)updChart();tickValues();},100);\n"
|
|
||||||
"\n"
|
|
||||||
"function addToChart(){\n"
|
|
||||||
" var n=document.getElementById('sigsel').value;\n"
|
|
||||||
" if(!n||cds.hasOwnProperty(n))return;\n"
|
|
||||||
" if(!td[n])td[n]={pts:[],last:0,col:nc(),inC:false,tracing:false,forced:false};\n"
|
|
||||||
" var col=td[n].col,idx=chart.data.datasets.length;\n"
|
|
||||||
" cds[n]=idx;td[n].inC=true;td[n].tracing=true;\n"
|
|
||||||
" chart.data.datasets.push({label:n,data:[],borderColor:col,\n"
|
|
||||||
" backgroundColor:col+'20',borderWidth:1.5,pointRadius:0,tension:0});\n"
|
|
||||||
" chart.update('none');updTraced();\n"
|
|
||||||
" cmd('TRACE '+n+' 1');\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function addByName(n){\n"
|
|
||||||
" if(!n||cds.hasOwnProperty(n))return;\n"
|
|
||||||
" if(!td[n])td[n]={pts:[],last:0,col:nc(),inC:false,tracing:false,forced:false};\n"
|
|
||||||
" var col=td[n].col,idx=chart.data.datasets.length;\n"
|
|
||||||
" cds[n]=idx;td[n].inC=true;td[n].tracing=true;\n"
|
|
||||||
" chart.data.datasets.push({label:n,data:[],borderColor:col,\n"
|
|
||||||
" backgroundColor:col+'20',borderWidth:1.5,pointRadius:0,tension:0});\n"
|
|
||||||
" chart.update('none');updTraced();\n"
|
|
||||||
" cmd('TRACE '+n+' 1');\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function dragStart(ev,n){ev.dataTransfer.setData('text',n);}\n"
|
|
||||||
"function dropOnChart(ev){ev.preventDefault();var n=ev.dataTransfer.getData('text');if(n)addByName(n);}\n"
|
|
||||||
"\n"
|
|
||||||
"function remFromChart(n){\n"
|
|
||||||
" if(!cds.hasOwnProperty(n))return;\n"
|
|
||||||
" var idx=cds[n];\n"
|
|
||||||
" chart.data.datasets.splice(idx,1);\n"
|
|
||||||
" delete cds[n];\n"
|
|
||||||
" var ks=Object.keys(cds);\n"
|
|
||||||
" for(var i=0;i<ks.length;i++){if(cds[ks[i]]>idx)cds[ks[i]]--;}\n"
|
|
||||||
" if(td[n])td[n].inC=false;\n"
|
|
||||||
" chart.update('none');updTraced();\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function clearChart(){\n"
|
|
||||||
" var ks=Object.keys(cds);\n"
|
|
||||||
" for(var i=0;i<ks.length;i++){if(td[ks[i]])td[ks[i]].inC=false;}\n"
|
|
||||||
" chart.data.datasets=[];cds={};\n"
|
|
||||||
" chart.update('none');updTraced();\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function toggleFollow(){\n"
|
|
||||||
" follow=!follow;\n"
|
|
||||||
" document.getElementById('fbtn').className=follow?'act':'';\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Traced list ---\n"
|
|
||||||
"function escId(s){return String(s).replace(/[^a-zA-Z0-9]/g,'_');}\n"
|
|
||||||
"function updTraced(){\n"
|
|
||||||
" var h='',ks=Object.keys(td);\n"
|
|
||||||
" for(var i=0;i<ks.length;i++){\n"
|
|
||||||
" var n=ks[i],t=td[n];\n"
|
|
||||||
" var v=typeof t.last==='number'?t.last.toPrecision(5):String(t.last);\n"
|
|
||||||
" var sn=n.split('.').pop();\n"
|
|
||||||
" h+='<div class=\"ti\" draggable=\"true\" ondragstart=\"dragStart(event,\\''+escJ(n)+'\\')\">'\n"
|
|
||||||
" h+='<div class=\"tc\" style=\"background:'+t.col+'\"></div>';\n"
|
|
||||||
" h+='<div class=\"tnm\" title=\"'+escH(n)+'\">'+escH(sn)+'</div>';\n"
|
|
||||||
" h+='<div class=\"tv\" id=\"tv_'+escId(n)+'\">'+escH(v)+'</div>';\n"
|
|
||||||
" h+='<div class=\"titbs\">';\n"
|
|
||||||
" if(t.inC)h+='<button class=\"tb\" onclick=\"remFromChart(\\''+escJ(n)+'\\')\">✕</button>';\n"
|
|
||||||
" else h+='<button class=\"tb\" onclick=\"addByName(\\''+escJ(n)+'\\')\">▶</button>';\n"
|
|
||||||
" if(t.tracing)h+='<button class=\"tb\" title=\"Untrace\" onclick=\"untraceN(\\''+escJ(n)+'\\')\">T×</button>';\n"
|
|
||||||
" if(t.forced) h+='<button class=\"tb\" title=\"Unforce\" onclick=\"doUnforceN(\\''+escJ(n)+'\\')\">F×</button>';\n"
|
|
||||||
" else h+='<button class=\"tb\" onclick=\"openFrc(\\''+escJ(n)+'\\')\">F</button>';\n"
|
|
||||||
" h+='</div></div>';\n"
|
|
||||||
" }\n"
|
|
||||||
" document.getElementById('traced').innerHTML=h;\n"
|
|
||||||
"}\n"
|
|
||||||
"function untraceN(n){cmd('TRACE '+n+' 0');if(td[n])td[n].tracing=false;updTraced();}\n"
|
|
||||||
"function doUnforceN(n){cmd('UNFORCE '+n);if(td[n])td[n].forced=false;updTraced();}\n"
|
|
||||||
"function tickValues(){\n"
|
|
||||||
" var ks=Object.keys(td);\n"
|
|
||||||
" for(var i=0;i<ks.length;i++){\n"
|
|
||||||
" var n=ks[i],t=td[n];\n"
|
|
||||||
" var el=document.getElementById('tv_'+escId(n));\n"
|
|
||||||
" if(el){var v=typeof t.last==='number'?t.last.toPrecision(5):String(t.last);el.textContent=v;}\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Signal select ---\n"
|
|
||||||
"function buildSel(){\n"
|
|
||||||
" var s=document.getElementById('sigsel');\n"
|
|
||||||
" s.innerHTML='<option value=\"\">-- pick --</option>';\n"
|
|
||||||
" for(var i=0;i<sigs.length;i++){\n"
|
|
||||||
" s.innerHTML+='<option value=\"'+escH(sigs[i].name)+'\">'+escH(sigs[i].name)+'</option>';\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
"function addOpt(n){\n"
|
|
||||||
" var s=document.getElementById('sigsel');\n"
|
|
||||||
" for(var i=0;i<s.options.length;i++){if(s.options[i].value===n)return;}\n"
|
|
||||||
" s.innerHTML+='<option value=\"'+escH(n)+'\">'+escH(n)+'</option>';\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Log ---\n"
|
|
||||||
"function appLog(lv,msg){\n"
|
|
||||||
" var f={DEBUG:document.getElementById('fdbg').checked,\n"
|
|
||||||
" INFO:document.getElementById('finf').checked,\n"
|
|
||||||
" WARNING:document.getElementById('fwrn').checked,\n"
|
|
||||||
" ERROR:document.getElementById('ferr').checked};\n"
|
|
||||||
" if(lv==='Information')lv='INFO';\n"
|
|
||||||
" else if(lv==='Warning')lv='WARNING';\n"
|
|
||||||
" else if(lv==='Debug')lv='DEBUG';\n"
|
|
||||||
" else if(lv==='FatalError'||lv==='Error'||lv==='WARN')lv='ERROR';\n"
|
|
||||||
" if(!f[lv])return;\n"
|
|
||||||
" var d=document.createElement('div');\n"
|
|
||||||
" d.className='le l'+lv;\n"
|
|
||||||
" var now=new Date();\n"
|
|
||||||
" var ts=now.toTimeString().split(' ')[0]+'.'+String(now.getMilliseconds()).padStart(3,'0');\n"
|
|
||||||
" d.textContent='['+ts+']['+lv.substring(0,4)+'] '+msg;\n"
|
|
||||||
" lc.appendChild(d);\n"
|
|
||||||
" if(lc.children.length>500)lc.removeChild(lc.firstChild);\n"
|
|
||||||
" lc.scrollTop=lc.scrollHeight;\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Tree ---\n"
|
|
||||||
"function renderTree(node){\n"
|
|
||||||
" tnodes=[];threads=[];\n"
|
|
||||||
" var c=document.getElementById('tree');\n"
|
|
||||||
" c.innerHTML='';\n"
|
|
||||||
" if(!node)return;\n"
|
|
||||||
" renderNode(node,c,0,'');\n"
|
|
||||||
" var dl=document.getElementById('thrnodes');\n"
|
|
||||||
" dl.innerHTML='';\n"
|
|
||||||
" for(var i=0;i<threads.length;i++){\n"
|
|
||||||
" var op=document.createElement('option');op.value=threads[i];dl.appendChild(op);\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
"function renderNode(node,parent,depth,pathPfx){\n"
|
|
||||||
" var fullPath=pathPfx?(pathPfx+'.'+node.Name):node.Name;\n"
|
|
||||||
" var isRoot=(node.Class==='ObjectRegistryDatabase');\n"
|
|
||||||
" if(isRoot)fullPath='';\n"
|
|
||||||
" var isSig=node.IsTraceable||node.IsForcable;\n"
|
|
||||||
" if(!isRoot&&fullPath&&!isSig)tnodes.push(fullPath);\n"
|
|
||||||
" if(node.Class==='RealTimeThread'&&node.Name)threads.push(node.Name);\n"
|
|
||||||
" var div=document.createElement('div');\n"
|
|
||||||
" div.className='tn-node';\n"
|
|
||||||
" var row=document.createElement('div');\n"
|
|
||||||
" row.className='tr';\n"
|
|
||||||
" row.style.paddingLeft=(3+depth*13)+'px';\n"
|
|
||||||
" var hasCh=node.Children&&node.Children.length>0;\n"
|
|
||||||
" var tog=document.createElement('span');\n"
|
|
||||||
" tog.className='tog';\n"
|
|
||||||
" if(hasCh){\n"
|
|
||||||
" tog.textContent='\\u25b8';\n"
|
|
||||||
" tog.onclick=function(){\n"
|
|
||||||
" var ch=div.querySelector('.tch');\n"
|
|
||||||
" if(ch){ch.style.display=ch.style.display==='none'?'':'none';\n"
|
|
||||||
" tog.textContent=ch.style.display==='none'?'\\u25b8':'\\u25be';}\n"
|
|
||||||
" };\n"
|
|
||||||
" }\n"
|
|
||||||
" var ico=document.createElement('span');\n"
|
|
||||||
" ico.className='ico';\n"
|
|
||||||
" ico.textContent=isSig?'\\u25c6':(hasCh?'\\u25c9':'\\u25cb');\n"
|
|
||||||
" ico.style.color=isSig?'var(--green)':(hasCh?'var(--blue)':'var(--ov)');\n"
|
|
||||||
" var nm=document.createElement('span');\n"
|
|
||||||
" nm.className='tn'+(isSig?' sig':'');\n"
|
|
||||||
" nm.textContent=node.Name;\n"
|
|
||||||
" nm.title=(node.Class||'')+(node.Type?' ['+node.Type+']':'');\n"
|
|
||||||
" row.appendChild(tog);row.appendChild(ico);row.appendChild(nm);\n"
|
|
||||||
" if(isSig){\n"
|
|
||||||
" var btns=document.createElement('span');\n"
|
|
||||||
" btns.className='tbtns';\n"
|
|
||||||
" var fp=fullPath;\n"
|
|
||||||
" if(node.IsTraceable){\n"
|
|
||||||
" addBtn(btns,'T','Trace',function(){if(!td[fp])td[fp]={pts:[],last:0,col:nc(),inC:false,tracing:false,forced:false};td[fp].tracing=true;cmd('TRACE '+fp+' 1');updTraced();});\n"
|
|
||||||
" addBtn(btns,'\\u25b6','Plot',function(){addByName(fp);});\n"
|
|
||||||
" }\n"
|
|
||||||
" if(node.IsForcable){\n"
|
|
||||||
" addBtn(btns,'F','Force',function(){openFrc(fp);});\n"
|
|
||||||
" addBtn(btns,'B','Break',function(){openBrk(fp);});\n"
|
|
||||||
" }\n"
|
|
||||||
" addBtn(btns,'M','Monitor',function(){openMon(fp);});\n"
|
|
||||||
" row.appendChild(btns);\n"
|
|
||||||
" }\n"
|
|
||||||
" div.appendChild(row);\n"
|
|
||||||
" if(hasCh){\n"
|
|
||||||
" var chDiv=document.createElement('div');\n"
|
|
||||||
" chDiv.className='tch';\n"
|
|
||||||
" for(var i=0;i<node.Children.length;i++){\n"
|
|
||||||
" renderNode(node.Children[i],chDiv,depth+1,isRoot?'':fullPath);\n"
|
|
||||||
" }\n"
|
|
||||||
" div.appendChild(chDiv);\n"
|
|
||||||
" }\n"
|
|
||||||
" parent.appendChild(div);\n"
|
|
||||||
"}\n"
|
|
||||||
"function addBtn(parent,lbl,title,fn){\n"
|
|
||||||
" var b=document.createElement('button');\n"
|
|
||||||
" b.className='tb';b.textContent=lbl;b.title=title;\n"
|
|
||||||
" b.onclick=fn;parent.appendChild(b);\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Commands ---\n"
|
|
||||||
"function cmd(c){\n"
|
|
||||||
" fetch('/api/command',{method:'POST',headers:{'Content-Type':'text/plain'},body:c})\n"
|
|
||||||
" .then(function(r){return r.text();})\n"
|
|
||||||
" .then(function(txt){\n"
|
|
||||||
" if(c.indexOf('DISCOVER')===0){\n"
|
|
||||||
" try{\n"
|
|
||||||
" var clean=txt.replace(/\\nOK DISCOVER\\n?$/,'');\n"
|
|
||||||
" var r=JSON.parse(clean);\n"
|
|
||||||
" if(r.Signals){sigs=r.Signals;buildSel();}\n"
|
|
||||||
" }catch(e){}\n"
|
|
||||||
" } else if(c.indexOf('TREE')===0){\n"
|
|
||||||
" try{renderTree(JSON.parse(txt.replace(/\\nOK TREE\\n?$/,'')));}\n"
|
|
||||||
" catch(e){appLog('ERROR','Tree parse: '+e);}\n"
|
|
||||||
" } else if(c.indexOf('STEP_STATUS')===0){\n"
|
|
||||||
" try{\n"
|
|
||||||
" var clean=txt.replace(/\\nOK STEP_STATUS\\n?$/,'');\n"
|
|
||||||
" var st=JSON.parse(clean);\n"
|
|
||||||
" var ev={type:'status',paused:st.Paused,gam:st.PausedAtGam,remaining:st.StepRemaining};\n"
|
|
||||||
" handle(ev);\n"
|
|
||||||
" }catch(e){}\n"
|
|
||||||
" }\n"
|
|
||||||
" })\n"
|
|
||||||
" .catch(function(e){appLog('ERROR','cmd failed: '+e);});\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"function togglePause(){\n"
|
|
||||||
" cmd(isPaused?'RESUME':'PAUSE');\n"
|
|
||||||
"}\n"
|
|
||||||
"function updPause(){\n"
|
|
||||||
" var b=document.getElementById('pbtn');\n"
|
|
||||||
" b.textContent=isPaused?'Resume':'Pause';\n"
|
|
||||||
" b.className=isPaused?'danger':'';\n"
|
|
||||||
"}\n"
|
|
||||||
"function doStep(){\n"
|
|
||||||
" var n=document.getElementById('sn').value||'1';\n"
|
|
||||||
" var t=document.getElementById('sthr').value;\n"
|
|
||||||
" var c='STEP '+n;if(t)c+=' '+t;\n"
|
|
||||||
" cmd(c);\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Modals ---\n"
|
|
||||||
"function openFrc(n){curSig=n;document.getElementById('frcn').textContent=n;\n"
|
|
||||||
" document.getElementById('frcv').value='';showM('frcm');}\n"
|
|
||||||
"function doForce(){var v=document.getElementById('frcv').value;\n"
|
|
||||||
" if(v!==''){cmd('FORCE '+curSig+' '+v);if(td[curSig])td[curSig].forced=true;}\n"
|
|
||||||
" closeM('frcm');updTraced();}\n"
|
|
||||||
"function doUnforce(){cmd('UNFORCE '+curSig);if(td[curSig])td[curSig].forced=false;closeM('frcm');updTraced();}\n"
|
|
||||||
"\n"
|
|
||||||
"function openBrk(n){curSig=n;document.getElementById('brkn').textContent=n;showM('brkm');}\n"
|
|
||||||
"function doBreak(){var op=document.getElementById('brkop').value;\n"
|
|
||||||
" var t=document.getElementById('brkthr').value;\n"
|
|
||||||
" cmd('BREAK '+curSig+' '+op+' '+t);closeM('brkm');}\n"
|
|
||||||
"function doClrBreak(){cmd('BREAK '+curSig+' OFF');closeM('brkm');}\n"
|
|
||||||
"\n"
|
|
||||||
"function openMon(n){curSig=n;document.getElementById('monn').textContent=n;showM('monm');}\n"
|
|
||||||
"function doMonitor(){var p=document.getElementById('monp').value||'100';\n"
|
|
||||||
" cmd('MONITOR SIGNAL '+curSig+' '+p);closeM('monm');}\n"
|
|
||||||
"function doUnmonitor(){cmd('UNMONITOR SIGNAL '+curSig);closeM('monm');}\n"
|
|
||||||
"\n"
|
|
||||||
"function openMsg(){\n"
|
|
||||||
" var dl=document.getElementById('msgnodes');\n"
|
|
||||||
" dl.innerHTML='';\n"
|
|
||||||
" for(var i=0;i<tnodes.length;i++){\n"
|
|
||||||
" var op=document.createElement('option');op.value=tnodes[i];dl.appendChild(op);\n"
|
|
||||||
" }\n"
|
|
||||||
" showM('msgm');\n"
|
|
||||||
"}\n"
|
|
||||||
"function doMsg(){var d=document.getElementById('msgd').value;\n"
|
|
||||||
" var f=document.getElementById('msgf').value;\n"
|
|
||||||
" var p=document.getElementById('msgp').value;\n"
|
|
||||||
" var c='MSG '+d+' '+f+' 0';if(p)c+=' '+p.replace(/\\n/g,' ');\n"
|
|
||||||
" cmd(c);closeM('msgm');}\n"
|
|
||||||
"\n"
|
|
||||||
"function showM(id){document.getElementById(id).className='mo show';}\n"
|
|
||||||
"function closeM(id){document.getElementById(id).className='mo';}\n"
|
|
||||||
"document.querySelectorAll('.mo').forEach(function(el){\n"
|
|
||||||
" el.addEventListener('click',function(e){if(e.target===el)closeM(el.id);});\n"
|
|
||||||
"});\n"
|
|
||||||
"\n"
|
|
||||||
"// --- Utils ---\n"
|
|
||||||
"function escH(s){return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/\"/g,'"');}\n"
|
|
||||||
"function escJ(s){return String(s).replace(/\\\\/g,'\\\\\\\\').replace(/'/g,\"\\\\'\");}\n"
|
|
||||||
"\n"
|
|
||||||
"// Init\n"
|
|
||||||
"initChart();\n"
|
|
||||||
"connect();\n"
|
|
||||||
"</script>\n"
|
|
||||||
"</body>\n"
|
|
||||||
"</html>\n";
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
|
|
||||||
#endif // WEBUI_H
|
|
||||||
@@ -0,0 +1,518 @@
|
|||||||
|
#include "DebugService.h"
|
||||||
|
#include "StandardParser.h"
|
||||||
|
#include "StreamString.h"
|
||||||
|
#include "BasicSocket.h"
|
||||||
|
#include "DebugBrokerWrapper.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "ClassRegistryItem.h"
|
||||||
|
#include "ObjectBuilder.h"
|
||||||
|
#include "TypeConversion.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
|
#include "ConfigurationDatabase.h"
|
||||||
|
#include "GAM.h"
|
||||||
|
#include "Atomic.h"
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
|
||||||
|
DebugService* GlobalDebugServiceInstance = NULL_PTR(DebugService*);
|
||||||
|
|
||||||
|
static void EscapeJson(const char8* src, StreamString &dst) {
|
||||||
|
if (src == NULL_PTR(const char8*)) return;
|
||||||
|
while (*src != '\0') {
|
||||||
|
if (*src == '"') dst += "\\\"";
|
||||||
|
else if (*src == '\\') dst += "\\\\";
|
||||||
|
else if (*src == '\n') dst += "\\n";
|
||||||
|
else if (*src == '\r') dst += "\\r";
|
||||||
|
else if (*src == '\t') dst += "\\t";
|
||||||
|
else dst += *src;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool SuffixMatch(const char8* target, const char8* pattern) {
|
||||||
|
uint32 tLen = StringHelper::Length(target); uint32 pLen = StringHelper::Length(pattern);
|
||||||
|
if (pLen > tLen) return false;
|
||||||
|
const char8* suffix = target + (tLen - pLen);
|
||||||
|
if (StringHelper::Compare(suffix, pattern) == 0) { if (tLen == pLen || *(suffix - 1) == '.') return true; }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool RecursiveGetFullObjectName(ReferenceContainer *container, const Object &obj, StreamString &path) {
|
||||||
|
uint32 size = container->Size();
|
||||||
|
for (uint32 i=0; i<size; i++) {
|
||||||
|
Reference child = container->Get(i);
|
||||||
|
if (child.IsValid()) {
|
||||||
|
if (child.operator->() == &obj) { path = child->GetName(); return true; }
|
||||||
|
ReferenceContainer *inner = dynamic_cast<ReferenceContainer*>(child.operator->());
|
||||||
|
if (inner) {
|
||||||
|
if (RecursiveGetFullObjectName(inner, obj, path)) {
|
||||||
|
StreamString prefix = child->GetName(); prefix += "."; prefix += path;
|
||||||
|
path = prefix; return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DebugService::GetFullObjectName(const Object &obj, StreamString &fullPath) {
|
||||||
|
fullPath = "";
|
||||||
|
if (RecursiveGetFullObjectName(ObjectRegistryDatabase::Instance(), obj, fullPath)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(DebugService, "1.0")
|
||||||
|
|
||||||
|
DebugService* DebugService::Instance() {
|
||||||
|
return GlobalDebugServiceInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PatchItemInternal(const char8* className, ObjectBuilder* builder) {
|
||||||
|
ClassRegistryDatabase *db = ClassRegistryDatabase::Instance();
|
||||||
|
ClassRegistryItem *item = (ClassRegistryItem*)db->Find(className);
|
||||||
|
if (item != NULL_PTR(ClassRegistryItem*)) {
|
||||||
|
item->SetObjectBuilder(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 DebugService::ForceSignal(const char8* name, const char8* valueStr) {
|
||||||
|
mutex.FastLock(); uint32 count = 0;
|
||||||
|
for (uint32 i = 0; i < numberOfAliases; i++) {
|
||||||
|
if (aliases[i].name == name || SuffixMatch(aliases[i].name.Buffer(), name)) {
|
||||||
|
DebugSignalInfo &s = signals[aliases[i].signalIndex]; s.isForcing = true;
|
||||||
|
AnyType dest(s.type, 0u, s.forcedValue); AnyType source(CharString, 0u, valueStr); (void)TypeConvert(dest, source);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mutex.FastUnLock(); return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 DebugService::UnforceSignal(const char8* name) {
|
||||||
|
mutex.FastLock(); uint32 count = 0;
|
||||||
|
for (uint32 i = 0; i < numberOfAliases; i++) {
|
||||||
|
if (aliases[i].name == name || SuffixMatch(aliases[i].name.Buffer(), name)) { signals[aliases[i].signalIndex].isForcing = false; count++; }
|
||||||
|
}
|
||||||
|
mutex.FastUnLock(); return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 DebugService::TraceSignal(const char8* name, bool enable, uint32 decimation) {
|
||||||
|
mutex.FastLock(); uint32 count = 0;
|
||||||
|
for (uint32 i = 0; i < numberOfAliases; i++) {
|
||||||
|
if (aliases[i].name == name || SuffixMatch(aliases[i].name.Buffer(), name)) {
|
||||||
|
uint32 sigIdx = aliases[i].signalIndex;
|
||||||
|
DebugSignalInfo &s = signals[sigIdx];
|
||||||
|
s.isTracing = enable;
|
||||||
|
s.decimationFactor = decimation;
|
||||||
|
s.decimationCounter = 0;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mutex.FastUnLock(); return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorManagement::ErrorType DebugService::Execute(ExecutionInfo & info) {
|
||||||
|
return ErrorManagement::FatalError;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorManagement::ErrorType DebugService::Server(ExecutionInfo & info) {
|
||||||
|
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
|
||||||
|
if (info.GetStage() == ExecutionInfo::StartupStage) { serverThreadId = Threads::Id(); return ErrorManagement::NoError; }
|
||||||
|
while (info.GetStage() == ExecutionInfo::MainStage) {
|
||||||
|
BasicTCPSocket *newClient = tcpServer.WaitConnection(10);
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
for (uint32 i=0; i<MAX_CLIENTS; i++) {
|
||||||
|
BasicTCPSocket *client = NULL_PTR(BasicTCPSocket*);
|
||||||
|
clientsMutex.FastLock(); client = activeClients[i]; clientsMutex.FastUnLock();
|
||||||
|
if (client != NULL_PTR(BasicTCPSocket*)) {
|
||||||
|
char buffer[1024]; uint32 size = 1024; TimeoutType timeout(0);
|
||||||
|
if (client->Read(buffer, size, timeout) && size > 0) {
|
||||||
|
StreamString command; command.Write(buffer, size); HandleCommand(command, client);
|
||||||
|
} else if (!client->IsValid()) {
|
||||||
|
clientsMutex.FastLock(); client->Close(); delete client; activeClients[i] = NULL_PTR(BasicTCPSocket*); clientsMutex.FastUnLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep::MSec(10);
|
||||||
|
}
|
||||||
|
return ErrorManagement::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorManagement::ErrorType DebugService::Streamer(ExecutionInfo & info) {
|
||||||
|
if (info.GetStage() == ExecutionInfo::TerminationStage) return ErrorManagement::NoError;
|
||||||
|
if (info.GetStage() == ExecutionInfo::StartupStage) { streamerThreadId = Threads::Id(); return ErrorManagement::NoError; }
|
||||||
|
InternetHost dest(streamPort, streamIP.Buffer());
|
||||||
|
(void)udpSocket.SetDestination(dest);
|
||||||
|
uint8 packetBuffer[4096]; uint32 packetOffset = 0; uint32 sequenceNumber = 0;
|
||||||
|
while (info.GetStage() == ExecutionInfo::MainStage) {
|
||||||
|
uint32 id, size; uint64 ts; uint8 sampleData[1024]; bool hasData = false;
|
||||||
|
while ((info.GetStage() == ExecutionInfo::MainStage) && traceBuffer.Pop(id, ts, sampleData, size, 1024)) {
|
||||||
|
hasData = true;
|
||||||
|
if (packetOffset == 0) {
|
||||||
|
TraceHeader header; header.magic = 0xDA7A57AD; header.seq = sequenceNumber++; header.timestamp = HighResolutionTimer::Counter(); header.count = 0;
|
||||||
|
std::memcpy(packetBuffer, &header, sizeof(TraceHeader)); packetOffset = sizeof(TraceHeader);
|
||||||
|
}
|
||||||
|
if (packetOffset + 16 + size > 1400) {
|
||||||
|
uint32 toWrite = packetOffset; (void)udpSocket.Write((char8*)packetBuffer, toWrite);
|
||||||
|
TraceHeader header; header.magic = 0xDA7A57AD; header.seq = sequenceNumber++; header.timestamp = HighResolutionTimer::Counter(); header.count = 0;
|
||||||
|
std::memcpy(packetBuffer, &header, sizeof(TraceHeader)); packetOffset = sizeof(TraceHeader);
|
||||||
|
}
|
||||||
|
std::memcpy(&packetBuffer[packetOffset], &id, 4);
|
||||||
|
std::memcpy(&packetBuffer[packetOffset + 4], &ts, 8);
|
||||||
|
std::memcpy(&packetBuffer[packetOffset + 12], &size, 4);
|
||||||
|
std::memcpy(&packetBuffer[packetOffset + 16], sampleData, size);
|
||||||
|
packetOffset += (16 + size);
|
||||||
|
((TraceHeader*)packetBuffer)->count++;
|
||||||
|
}
|
||||||
|
if (packetOffset > 0) { uint32 toWrite = packetOffset; (void)udpSocket.Write((char8*)packetBuffer, toWrite); packetOffset = 0; }
|
||||||
|
if (!hasData) Sleep::MSec(1);
|
||||||
|
}
|
||||||
|
return ErrorManagement::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugService::DebugService() :
|
||||||
|
ReferenceContainer(), EmbeddedServiceMethodBinderI(),
|
||||||
|
binderServer(this, ServiceBinder::ServerType),
|
||||||
|
binderStreamer(this, ServiceBinder::StreamerType),
|
||||||
|
threadService(binderServer),
|
||||||
|
streamerService(binderStreamer)
|
||||||
|
{
|
||||||
|
GlobalDebugServiceInstance = this;
|
||||||
|
controlPort = 0;
|
||||||
|
streamPort = 8081;
|
||||||
|
streamIP = "127.0.0.1";
|
||||||
|
numberOfSignals = 0;
|
||||||
|
numberOfAliases = 0;
|
||||||
|
numberOfBrokers = 0;
|
||||||
|
isServer = false;
|
||||||
|
suppressTimeoutLogs = true;
|
||||||
|
isPaused = false;
|
||||||
|
for (uint32 i=0; i<MAX_CLIENTS; i++) {
|
||||||
|
activeClients[i] = NULL_PTR(BasicTCPSocket*);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forced patching on library load
|
||||||
|
__attribute__((constructor))
|
||||||
|
static void GlobalDebugSuiteInit() {
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapInputBroker> B1; PatchItemInternal("MemoryMapInputBroker", new B1());
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapOutputBroker> B2; PatchItemInternal("MemoryMapOutputBroker", new B2());
|
||||||
|
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedInputBroker> B3; PatchItemInternal("MemoryMapSynchronisedInputBroker", new B3());
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedOutputBroker> B4; PatchItemInternal("MemoryMapSynchronisedOutputBroker", new B4());
|
||||||
|
|
||||||
|
typedef DebugBrokerBuilder<DebugMemoryMapInterpolatedInputBroker> B5; PatchItemInternal("MemoryMapInterpolatedInputBroker", new B5());
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugService::~DebugService() {
|
||||||
|
if (GlobalDebugServiceInstance == this) GlobalDebugServiceInstance = NULL_PTR(DebugService*);
|
||||||
|
threadService.Stop(); streamerService.Stop();
|
||||||
|
tcpServer.Close(); udpSocket.Close();
|
||||||
|
for (uint32 i=0; i<MAX_CLIENTS; i++) {
|
||||||
|
if (activeClients[i] != NULL_PTR(BasicTCPSocket*)) { activeClients[i]->Close(); delete activeClients[i]; }
|
||||||
|
}
|
||||||
|
for (uint32 i=0; i<numberOfBrokers; i++) {
|
||||||
|
for (uint32 j=0; j<2; j++) {
|
||||||
|
if (brokers[i].sets[j].forcedSignals) delete[] brokers[i].sets[j].forcedSignals;
|
||||||
|
if (brokers[i].sets[j].tracedSignals) delete[] brokers[i].sets[j].tracedSignals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DebugService::Initialise(StructuredDataI & data) {
|
||||||
|
if (!ReferenceContainer::Initialise(data)) return false;
|
||||||
|
if (!data.Read("ControlPort", controlPort)) (void)data.Read("TcpPort", controlPort);
|
||||||
|
if (controlPort > 0) { isServer = true; GlobalDebugServiceInstance = this; }
|
||||||
|
if (!data.Read("StreamPort", streamPort)) (void)data.Read("UdpPort", streamPort);
|
||||||
|
StreamString tempIP; if (data.Read("StreamIP", tempIP)) streamIP = tempIP; else streamIP = "127.0.0.1";
|
||||||
|
uint32 suppress = 1; if (data.Read("SuppressTimeoutLogs", suppress)) suppressTimeoutLogs = (suppress == 1);
|
||||||
|
|
||||||
|
if (isServer) {
|
||||||
|
if (!traceBuffer.Init(8 * 1024 * 1024)) return false;
|
||||||
|
ConfigurationDatabase threadData; threadData.Write("Timeout", (uint32)1000);
|
||||||
|
threadService.Initialise(threadData); streamerService.Initialise(threadData);
|
||||||
|
if (!tcpServer.Open()) return false;
|
||||||
|
if (!tcpServer.Listen(controlPort)) return false;
|
||||||
|
printf("[DebugService] TCP Server listening on port %u\n", controlPort);
|
||||||
|
if (!udpSocket.Open()) return false;
|
||||||
|
printf("[DebugService] UDP Streamer socket opened\n");
|
||||||
|
if (threadService.Start() != ErrorManagement::NoError) return false;
|
||||||
|
if (streamerService.Start() != ErrorManagement::NoError) return false;
|
||||||
|
printf("[DebugService] Worker threads started.\n");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::PatchRegistry() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::ProcessSignal(DebugSignalInfo* s, uint32 size, uint64 timestamp) {
|
||||||
|
if (s == NULL_PTR(DebugSignalInfo*)) return;
|
||||||
|
if (s->isForcing) CopySignal(s->memoryAddress, s->forcedValue, size);
|
||||||
|
if (s->isTracing) {
|
||||||
|
if (s->decimationFactor <= 1) (void)traceBuffer.Push(s->internalID, timestamp, s->memoryAddress, size);
|
||||||
|
else {
|
||||||
|
if (s->decimationCounter == 0) { (void)traceBuffer.Push(s->internalID, timestamp, s->memoryAddress, size); s->decimationCounter = s->decimationFactor - 1; }
|
||||||
|
else s->decimationCounter--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::RegisterBroker(DebugSignalInfo** signalPointers, uint32 numSignals, MemoryMapBroker* broker, volatile bool* anyActiveFlag) {
|
||||||
|
mutex.FastLock();
|
||||||
|
for (uint32 i=0; i<numberOfBrokers; i++) { if (brokers[i].broker == broker) { mutex.FastUnLock(); return; } }
|
||||||
|
if (numberOfBrokers < MAX_BROKERS) {
|
||||||
|
printf("[DebugService] Registering Broker %u (%u signals, anyActiveFlag=%p)\n", numberOfBrokers, numSignals, (void*)anyActiveFlag);
|
||||||
|
brokers[numberOfBrokers].signalPointers = signalPointers;
|
||||||
|
brokers[numberOfBrokers].numSignals = numSignals;
|
||||||
|
brokers[numberOfBrokers].broker = broker;
|
||||||
|
brokers[numberOfBrokers].anyActiveFlag = anyActiveFlag;
|
||||||
|
brokers[numberOfBrokers].currentSetIdx = 0;
|
||||||
|
for (uint32 j=0; j<2; j++) {
|
||||||
|
brokers[numberOfBrokers].sets[j].numForced = 0; brokers[numberOfBrokers].sets[j].numTraced = 0;
|
||||||
|
brokers[numberOfBrokers].sets[j].forcedSignals = NULL_PTR(SignalExecuteInfo*); brokers[numberOfBrokers].sets[j].tracedSignals = NULL_PTR(SignalExecuteInfo*);
|
||||||
|
}
|
||||||
|
numberOfBrokers++;
|
||||||
|
}
|
||||||
|
mutex.FastUnLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AdoptOrphans(ReferenceContainer *container, DebugService* service) {
|
||||||
|
if (!container) return;
|
||||||
|
for (uint32 i=0; i<container->Size(); i++) {
|
||||||
|
Reference child = container->Get(i);
|
||||||
|
if (child.IsValid()) {
|
||||||
|
DebugBrokerI* b = dynamic_cast<DebugBrokerI*>(child.operator->());
|
||||||
|
if (b && !b->IsLinked()) {
|
||||||
|
b->SetService(service);
|
||||||
|
}
|
||||||
|
ReferenceContainer *inner = dynamic_cast<ReferenceContainer*>(child.operator->());
|
||||||
|
if (inner) AdoptOrphans(inner, service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::UpdateBrokersActiveStatus() {
|
||||||
|
AdoptOrphans(ObjectRegistryDatabase::Instance(), this);
|
||||||
|
for (uint32 i = 0; i < numberOfBrokers; i++) {
|
||||||
|
uint32 nextIdx = (brokers[i].currentSetIdx + 1) % 2;
|
||||||
|
BrokerActiveSet& nextSet = brokers[i].sets[nextIdx];
|
||||||
|
uint32 forcedCount = 0; uint32 tracedCount = 0;
|
||||||
|
for (uint32 j = 0; j < brokers[i].numSignals; j++) {
|
||||||
|
DebugSignalInfo *s = brokers[i].signalPointers[j];
|
||||||
|
if (s != NULL_PTR(DebugSignalInfo*)) {
|
||||||
|
if (s->isForcing) forcedCount++;
|
||||||
|
if (s->isTracing) tracedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SignalExecuteInfo* newForced = (forcedCount > 0) ? new SignalExecuteInfo[forcedCount] : NULL_PTR(SignalExecuteInfo*);
|
||||||
|
SignalExecuteInfo* newTraced = (tracedCount > 0) ? new SignalExecuteInfo[tracedCount] : NULL_PTR(SignalExecuteInfo*);
|
||||||
|
uint32 fIdx = 0; uint32 tIdx = 0;
|
||||||
|
for (uint32 j = 0; j < brokers[i].numSignals; j++) {
|
||||||
|
DebugSignalInfo *s = brokers[i].signalPointers[j];
|
||||||
|
if (s != NULL_PTR(DebugSignalInfo*)) {
|
||||||
|
uint32 size = (brokers[i].broker != NULL_PTR(MemoryMapBroker*)) ? brokers[i].broker->GetCopyByteSize(j) : 4;
|
||||||
|
if (s->isForcing) { newForced[fIdx].memoryAddress = s->memoryAddress; newForced[fIdx].forcedValue = s->forcedValue; newForced[fIdx].size = size; fIdx++; }
|
||||||
|
if (s->isTracing) { newTraced[tIdx].memoryAddress = s->memoryAddress; newTraced[tIdx].internalID = s->internalID; newTraced[tIdx].size = size; tIdx++; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SignalExecuteInfo* oldForced = nextSet.forcedSignals; SignalExecuteInfo* oldTraced = nextSet.tracedSignals;
|
||||||
|
nextSet.forcedSignals = newForced; nextSet.tracedSignals = newTraced; nextSet.numForced = forcedCount; nextSet.numTraced = tracedCount;
|
||||||
|
Atomic::Exchange((int32*)&brokers[i].currentSetIdx, (int32)nextIdx);
|
||||||
|
if (brokers[i].anyActiveFlag) *(brokers[i].anyActiveFlag) = (forcedCount > 0 || tracedCount > 0);
|
||||||
|
if (oldForced) delete[] oldForced; if (oldTraced) delete[] oldTraced;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugSignalInfo* DebugService::RegisterSignal(void* memoryAddress, TypeDescriptor type, const char8* name) {
|
||||||
|
mutex.FastLock();
|
||||||
|
DebugSignalInfo* res = NULL_PTR(DebugSignalInfo*); uint32 sigIdx = 0xFFFFFFFF;
|
||||||
|
for (uint32 i=0; i<numberOfAliases; i++) {
|
||||||
|
if (aliases[i].name == name) {
|
||||||
|
sigIdx = aliases[i].signalIndex; res = &signals[sigIdx];
|
||||||
|
if (res->memoryAddress == NULL && memoryAddress != NULL) res->memoryAddress = memoryAddress;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res == NULL_PTR(DebugSignalInfo*) && numberOfSignals < MAX_SIGNALS) {
|
||||||
|
sigIdx = numberOfSignals; res = &signals[numberOfSignals];
|
||||||
|
res->memoryAddress = memoryAddress; res->type = type; res->name = name;
|
||||||
|
res->isTracing = false; res->isForcing = false; res->internalID = numberOfSignals;
|
||||||
|
res->decimationFactor = 1; res->decimationCounter = 0; numberOfSignals++;
|
||||||
|
}
|
||||||
|
if (sigIdx != 0xFFFFFFFF && numberOfAliases < MAX_ALIASES) {
|
||||||
|
bool foundAlias = false;
|
||||||
|
for (uint32 i=0; i<numberOfAliases; i++) { if (aliases[i].name == name) { foundAlias = true; break; } }
|
||||||
|
if (!foundAlias) { aliases[numberOfAliases].name = name; aliases[numberOfAliases].signalIndex = sigIdx; numberOfAliases++; }
|
||||||
|
}
|
||||||
|
mutex.FastUnLock(); return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RecursivePopulate(ReferenceContainer *container, DebugService* service) {
|
||||||
|
if (!container) return;
|
||||||
|
for (uint32 i=0; i<container->Size(); i++) {
|
||||||
|
Reference child = container->Get(i);
|
||||||
|
if (child.IsValid()) {
|
||||||
|
DataSourceI *ds = dynamic_cast<DataSourceI*>(child.operator->());
|
||||||
|
if (ds) {
|
||||||
|
StreamString dsPath;
|
||||||
|
if (DebugService::GetFullObjectName(*ds, dsPath)) {
|
||||||
|
for (uint32 j=0; j<ds->GetNumberOfSignals(); j++) {
|
||||||
|
StreamString sname; (void)ds->GetSignalName(j, sname);
|
||||||
|
StreamString fullName = dsPath; fullName += "."; fullName += sname;
|
||||||
|
service->RegisterSignal(NULL, ds->GetSignalType(j), fullName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReferenceContainer *inner = dynamic_cast<ReferenceContainer*>(child.operator->());
|
||||||
|
if (inner) RecursivePopulate(inner, service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::Discover(BasicTCPSocket *client) {
|
||||||
|
if (client) {
|
||||||
|
RecursivePopulate(ObjectRegistryDatabase::Instance(), this);
|
||||||
|
StreamString json; json = "{\n \"Signals\": [\n";
|
||||||
|
mutex.FastLock();
|
||||||
|
for (uint32 i = 0; i < numberOfAliases; i++) {
|
||||||
|
DebugSignalInfo &sig = signals[aliases[i].signalIndex];
|
||||||
|
const char8* typeName = TypeDescriptor::GetTypeNameFromTypeDescriptor(sig.type);
|
||||||
|
StreamString line;
|
||||||
|
line.Printf(" {\"name\": \"%s\", \"id\": %u, \"type\": \"%s\", \"ready\": %s}",
|
||||||
|
aliases[i].name.Buffer(), sig.internalID, typeName ? typeName : "Unknown", (sig.memoryAddress != NULL) ? "true" : "false");
|
||||||
|
json += line; if (i < numberOfAliases - 1) json += ","; json += "\n";
|
||||||
|
}
|
||||||
|
mutex.FastUnLock();
|
||||||
|
json += " ]\n}\nOK DISCOVER\n"; uint32 s = json.Size(); (void)client->Write(json.Buffer(), s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::HandleCommand(StreamString cmd, BasicTCPSocket *client) {
|
||||||
|
StreamString token; cmd.Seek(0); char8 term; const char8* delims = " \r\n";
|
||||||
|
if (cmd.GetToken(token, delims, term)) {
|
||||||
|
if (token == "FORCE") {
|
||||||
|
StreamString name, val;
|
||||||
|
if (cmd.GetToken(name, delims, term) && cmd.GetToken(val, delims, term)) {
|
||||||
|
uint32 count = ForceSignal(name.Buffer(), val.Buffer());
|
||||||
|
if (client) { StreamString resp; resp.Printf("OK FORCE %u\n", count); uint32 s = resp.Size(); (void)client->Write(resp.Buffer(), s); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (token == "UNFORCE") {
|
||||||
|
StreamString name; if (cmd.GetToken(name, delims, term)) {
|
||||||
|
uint32 count = UnforceSignal(name.Buffer());
|
||||||
|
if (client) { StreamString resp; resp.Printf("OK UNFORCE %u\n", count); uint32 s = resp.Size(); (void)client->Write(resp.Buffer(), s); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (token == "TRACE") {
|
||||||
|
StreamString name, state, decim;
|
||||||
|
if (cmd.GetToken(name, delims, term) && cmd.GetToken(state, delims, term)) {
|
||||||
|
bool enable = (state == "1"); uint32 d = 1;
|
||||||
|
if (cmd.GetToken(decim, delims, term)) {
|
||||||
|
AnyType decimVal(UnsignedInteger32Bit, 0u, &d); AnyType decimStr(CharString, 0u, decim.Buffer()); (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(); (void)client->Write(resp.Buffer(), s); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (token == "DISCOVER") Discover(client);
|
||||||
|
else if (token == "PAUSE") { SetPaused(true); if (client) { uint32 s = 3; (void)client->Write("OK\n", s); } }
|
||||||
|
else if (token == "RESUME") { SetPaused(false); if (client) { uint32 s = 3; (void)client->Write("OK\n", s); } }
|
||||||
|
else if (token == "TREE") {
|
||||||
|
StreamString json; json = "{\"Name\": \"Root\", \"Class\": \"ObjectRegistryDatabase\", \"Children\": [\n";
|
||||||
|
(void)ExportTree(ObjectRegistryDatabase::Instance(), json); json += "\n]}\nOK TREE\n";
|
||||||
|
uint32 s = json.Size(); if (client) (void)client->Write(json.Buffer(), s);
|
||||||
|
}
|
||||||
|
else if (token == "INFO") { StreamString path; if (cmd.GetToken(path, delims, term)) InfoNode(path.Buffer(), client); }
|
||||||
|
else if (token == "LS") {
|
||||||
|
StreamString path; if (cmd.GetToken(path, delims, term)) ListNodes(path.Buffer(), client); else ListNodes(NULL_PTR(const char8*), client);
|
||||||
|
}
|
||||||
|
UpdateBrokersActiveStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugService::InfoNode(const char8* path, BasicTCPSocket *client) {
|
||||||
|
if (!client) return;
|
||||||
|
Reference ref = ObjectRegistryDatabase::Instance()->Find(path); StreamString json = "{";
|
||||||
|
if (ref.IsValid()) {
|
||||||
|
json += "\"Name\": \""; EscapeJson(ref->GetName(), json); json += "\", \"Class\": \""; EscapeJson(ref->GetClassProperties()->GetName(), json); json += "\"";
|
||||||
|
ConfigurationDatabase db; if (ref->ExportData(db)) {
|
||||||
|
json += ", \"Config\": {"; db.MoveToRoot(); uint32 nChildren = db.GetNumberOfChildren();
|
||||||
|
for (uint32 i=0; i<nChildren; i++) {
|
||||||
|
const char8* cname = db.GetChildName(i); AnyType at = db.GetType(cname); char8 valBuf[1024]; AnyType strType(CharString, 0u, valBuf); strType.SetNumberOfElements(0, 1024);
|
||||||
|
if (TypeConvert(strType, at)) { json += "\""; EscapeJson(cname, json); json += "\": \""; EscapeJson(valBuf, json); json += "\""; if (i < nChildren - 1) json += ", "; }
|
||||||
|
}
|
||||||
|
json += "}";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mutex.FastLock(); bool found = false;
|
||||||
|
for (uint32 i=0; i<numberOfAliases; i++) {
|
||||||
|
if (aliases[i].name == path || SuffixMatch(aliases[i].name.Buffer(), path)) {
|
||||||
|
DebugSignalInfo &s = signals[aliases[i].signalIndex]; const char8* tname = TypeDescriptor::GetTypeNameFromTypeDescriptor(s.type);
|
||||||
|
json.Printf("\"Name\": \"%s\", \"Class\": \"Signal\", \"Type\": \"%s\", \"ID\": %d", s.name.Buffer(), tname ? tname : "Unknown", s.internalID); found = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mutex.FastUnLock(); if (!found) json += "\"Error\": \"Object not found\"";
|
||||||
|
}
|
||||||
|
json += "}\nOK INFO\n"; uint32 s = json.Size(); (void)client->Write(json.Buffer(), s);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 DebugService::ExportTree(ReferenceContainer *container, StreamString &json) {
|
||||||
|
if (container == NULL_PTR(ReferenceContainer*)) return 0;
|
||||||
|
uint32 size = container->Size(); uint32 validCount = 0;
|
||||||
|
for (uint32 i = 0u; i < size; i++) {
|
||||||
|
Reference child = container->Get(i);
|
||||||
|
if (child.IsValid()) {
|
||||||
|
if (validCount > 0u) json += ",\n";
|
||||||
|
StreamString nodeJson; const char8* cname = child->GetName(); if (cname == NULL_PTR(const char8*)) cname = "unnamed";
|
||||||
|
nodeJson += "{\"Name\": \""; EscapeJson(cname, nodeJson); nodeJson += "\", \"Class\": \""; EscapeJson(child->GetClassProperties()->GetName(), nodeJson); nodeJson += "\"";
|
||||||
|
ReferenceContainer *inner = dynamic_cast<ReferenceContainer*>(child.operator->());
|
||||||
|
DataSourceI *ds = dynamic_cast<DataSourceI*>(child.operator->());
|
||||||
|
GAM *gam = dynamic_cast<GAM*>(child.operator->());
|
||||||
|
if ((inner != NULL_PTR(ReferenceContainer*)) || (ds != NULL_PTR(DataSourceI*)) || (gam != NULL_PTR(GAM*))) {
|
||||||
|
nodeJson += ", \"Children\": [\n"; uint32 subCount = 0u;
|
||||||
|
if (inner != NULL_PTR(ReferenceContainer*)) subCount += ExportTree(inner, nodeJson);
|
||||||
|
if (ds != NULL_PTR(DataSourceI*)) {
|
||||||
|
uint32 nSignals = ds->GetNumberOfSignals();
|
||||||
|
for (uint32 j = 0u; j < nSignals; j++) {
|
||||||
|
if (subCount > 0u) nodeJson += ",\n";
|
||||||
|
subCount++; StreamString sname; (void)ds->GetSignalName(j, sname);
|
||||||
|
const char8* stype = TypeDescriptor::GetTypeNameFromTypeDescriptor(ds->GetSignalType(j));
|
||||||
|
uint8 dims = 0u; (void)ds->GetSignalNumberOfDimensions(j, dims);
|
||||||
|
uint32 elems = 0u; (void)ds->GetSignalNumberOfElements(j, elems);
|
||||||
|
nodeJson += "{\"Name\": \""; EscapeJson(sname.Buffer(), nodeJson); nodeJson += "\", \"Class\": \"Signal\", \"Type\": \""; EscapeJson(stype ? stype : "Unknown", nodeJson); nodeJson.Printf("\", \"Dimensions\": %d, \"Elements\": %u}", dims, elems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gam != NULL_PTR(GAM*)) {
|
||||||
|
uint32 nIn = gam->GetNumberOfInputSignals();
|
||||||
|
for (uint32 j = 0u; j < nIn; j++) {
|
||||||
|
if (subCount > 0u) nodeJson += ",\n";
|
||||||
|
subCount++; StreamString sname; (void)gam->GetSignalName(InputSignals, j, sname);
|
||||||
|
const char8* stype = TypeDescriptor::GetTypeNameFromTypeDescriptor(gam->GetSignalType(InputSignals, j));
|
||||||
|
uint32 dims = 0u; (void)gam->GetSignalNumberOfDimensions(InputSignals, j, dims);
|
||||||
|
uint32 elems = 0u; (void)gam->GetSignalNumberOfElements(InputSignals, j, elems);
|
||||||
|
nodeJson += "{\"Name\": \"In."; EscapeJson(sname.Buffer(), nodeJson); nodeJson += "\", \"Class\": \"InputSignal\", \"Type\": \""; EscapeJson(stype ? stype : "Unknown", nodeJson); nodeJson.Printf("\", \"Dimensions\": %u, \"Elements\": %u}", dims, elems);
|
||||||
|
}
|
||||||
|
uint32 nOut = gam->GetNumberOfOutputSignals();
|
||||||
|
for (uint32 j = 0u; j < nOut; j++) {
|
||||||
|
if (subCount > 0u) nodeJson += ",\n";
|
||||||
|
subCount++; StreamString sname; (void)gam->GetSignalName(OutputSignals, j, sname);
|
||||||
|
const char8* stype = TypeDescriptor::GetTypeNameFromTypeDescriptor(gam->GetSignalType(OutputSignals, j));
|
||||||
|
uint32 dims = 0u; (void)gam->GetSignalNumberOfDimensions(OutputSignals, j, dims);
|
||||||
|
uint32 elems = 0u; (void)gam->GetSignalNumberOfElements(OutputSignals, j, elems);
|
||||||
|
nodeJson += "{\"Name\": \"Out."; EscapeJson(sname.Buffer(), nodeJson); nodeJson += "\", \"Class\": \"OutputSignal\", \"Type\": \""; EscapeJson(stype ? stype : "Unknown", nodeJson); nodeJson.Printf("\", \"Dimensions\": %u, \"Elements\": %u}", dims, elems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodeJson += "\n]";
|
||||||
|
}
|
||||||
|
nodeJson += "}"; json += nodeJson; validCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,11 +35,6 @@ TcpLogger::~TcpLogger() {
|
|||||||
clientsMutex.FastUnLock();
|
clientsMutex.FastUnLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TcpLogger::ExportData(StructuredDataI & data) {
|
|
||||||
bool ok = data.Write("Port", static_cast<uint32>(port));
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TcpLogger::Initialise(StructuredDataI & data) {
|
bool TcpLogger::Initialise(StructuredDataI & data) {
|
||||||
if (!ReferenceContainer::Initialise(data)) return false;
|
if (!ReferenceContainer::Initialise(data)) return false;
|
||||||
|
|
||||||
@@ -97,65 +92,63 @@ ErrorManagement::ErrorType TcpLogger::Execute(ExecutionInfo & info) {
|
|||||||
return ErrorManagement::NoError;
|
return ErrorManagement::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each Execute() call does one cycle. The MARTe2 framework loops Execute()
|
while (info.GetStage() == ExecutionInfo::MainStage) {
|
||||||
// so we must NOT spin in an infinite internal loop here — doing so prevents
|
// 1. Check for new connections
|
||||||
// the framework from ever delivering the TerminationStage and causes
|
BasicTCPSocket *newClient = server.WaitConnection(1);
|
||||||
// Stop() to time out, leaving threads running after the destructor.
|
if (newClient != NULL_PTR(BasicTCPSocket *)) {
|
||||||
|
clientsMutex.FastLock();
|
||||||
// 1. Check for new connections (1 ms timeout → returns promptly)
|
bool added = false;
|
||||||
BasicTCPSocket *newClient = server.WaitConnection(1);
|
for (uint32 i=0; i<MAX_CLIENTS; i++) {
|
||||||
if (newClient != NULL_PTR(BasicTCPSocket *)) {
|
if (activeClients[i] == NULL_PTR(BasicTCPSocket*)) {
|
||||||
clientsMutex.FastLock();
|
activeClients[i] = newClient;
|
||||||
bool added = false;
|
added = true;
|
||||||
for (uint32 i=0; i<MAX_CLIENTS; i++) {
|
break;
|
||||||
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 queued entries 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();
|
||||||
|
if (!added) {
|
||||||
|
newClient->Close();
|
||||||
|
delete newClient;
|
||||||
|
} else {
|
||||||
|
(void)newClient->SetBlocking(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
clientsMutex.FastUnLock();
|
|
||||||
readIdx = (readIdx + 1) % QUEUE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hadData) {
|
// 2. Stream data to clients
|
||||||
// Brief wait so we don't busy-spin; return so Stop() can take effect
|
bool hadData = false;
|
||||||
(void)eventSem.Wait(TimeoutType(10));
|
while (readIdx != writeIdx) {
|
||||||
eventSem.Reset();
|
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;
|
return ErrorManagement::NoError;
|
||||||
}
|
}
|
||||||
+37
-200
@@ -1,219 +1,56 @@
|
|||||||
# Tutorial: Observability and Debugging with the MARTe2 Debug Suite
|
# Tutorial: High-Speed Observability with MARTe2 Debug GUI
|
||||||
|
|
||||||
This guide covers both transport options. Choose the one that fits your workflow:
|
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.
|
||||||
|
|
||||||
| | `WebDebugService` | `DebugService` |
|
## 1. Environment Setup
|
||||||
|---|---|---|
|
|
||||||
| **Client** | Any web browser | Rust native GUI |
|
|
||||||
| **Setup** | Config only | Config + `cargo run` |
|
|
||||||
| **Best for** | Quick inspection, remote access | High-performance plots, scripted tooling |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Part A — Web UI (`WebDebugService`)
|
|
||||||
|
|
||||||
### A.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
|
```bash
|
||||||
cd /path/to/your/marte2/project
|
./run_debug_app.sh
|
||||||
source /path/to/marte_debug/env.sh
|
|
||||||
```
|
```
|
||||||
|
*Note: You should see logs indicating the `DebugService` has started on port 8080 and `TcpLogger` on port 8082.*
|
||||||
|
|
||||||
### A.2 Add `WebDebugService` to Your Config
|
### Start the GUI Client
|
||||||
|
In a new terminal window, navigate to the client directory and run the GUI:
|
||||||
Add the service as a **sibling** of the `+App` node (not inside it):
|
|
||||||
|
|
||||||
```text
|
|
||||||
+WebDebugService = {
|
|
||||||
Class = WebDebugService
|
|
||||||
HttpPort = 8090
|
|
||||||
}
|
|
||||||
|
|
||||||
+App = {
|
|
||||||
Class = RealTimeApplication
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart your application. You should see:
|
|
||||||
```
|
|
||||||
[WebDebugService] HTTP server listening on port 8090
|
|
||||||
```
|
|
||||||
|
|
||||||
### A.3 Open the Web UI
|
|
||||||
|
|
||||||
Navigate to `http://localhost:8090` in any browser. The UI connects automatically via SSE.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.4 Exploring the Object Tree
|
|
||||||
|
|
||||||
The **Application Tree** panel on the left mirrors your live ORD hierarchy.
|
|
||||||
|
|
||||||
1. Expand `Root → App → Data` to find data sources.
|
|
||||||
2. Click **Info** next to any node to see its class, config, and signals in the details panel.
|
|
||||||
3. Click **List** to expand just the immediate children without recursing.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.5 Real-Time Signal Tracing
|
|
||||||
|
|
||||||
1. Locate a signal in the tree, e.g. `Root.App.Data.Timer.Counter`.
|
|
||||||
2. Click **Trace** next to the signal. The signal appears in the **Traced Signals** list with
|
|
||||||
its live last value.
|
|
||||||
3. Click **Plot** to open it in the real-time Chart.js graph. Use the **Follow** toggle to
|
|
||||||
keep the time axis scrolling.
|
|
||||||
4. To set the sampling decimation (e.g. every 10th sample), use the command box at the bottom
|
|
||||||
of the page:
|
|
||||||
```
|
|
||||||
TRACE App.Data.Timer.Counter 1 10
|
|
||||||
```
|
|
||||||
5. Click **Trace** again (or send `TRACE … 0`) to stop.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.6 Signal Forcing
|
|
||||||
|
|
||||||
1. Find a GAM output signal, e.g. `Root.App.Data.DDB.Counter`.
|
|
||||||
2. Click **Force**. A modal dialog appears.
|
|
||||||
3. Enter a value (e.g. `9999`) and click **Apply**.
|
|
||||||
4. The signal is locked at that value every RT cycle.
|
|
||||||
5. Click **Unforce** (or use the **Active Controls** panel) to release.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.7 Breakpoints
|
|
||||||
|
|
||||||
1. Click **Break** next to a signal.
|
|
||||||
2. Select an operator (`>`, `<`, `==`, etc.) and enter a threshold.
|
|
||||||
3. When the condition fires, the application pauses automatically. The status bar shows
|
|
||||||
**PAUSED** and the GAM name where execution stopped.
|
|
||||||
4. Use **Step** to advance one cycle at a time, or **Resume** to continue.
|
|
||||||
5. Click **Break OFF** to clear the breakpoint.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.8 Execution Stepping
|
|
||||||
|
|
||||||
While paused (after a breakpoint or manual **Pause**):
|
|
||||||
|
|
||||||
1. Enter a step count in the **Step** box (e.g. `5`) and click **Step**.
|
|
||||||
2. The RT loop runs exactly 5 output-broker cycles, then pauses again.
|
|
||||||
3. The status SSE event (`{"type":"status","remaining":…}`) keeps the UI updated.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.9 Signal Monitoring
|
|
||||||
|
|
||||||
Monitoring polls a signal at a slow rate without using the RT trace path — useful for
|
|
||||||
`DataSourceI` signals not connected to any GAM.
|
|
||||||
|
|
||||||
1. Click **Monitor** next to a signal.
|
|
||||||
2. Enter a poll period in milliseconds (e.g. `500`).
|
|
||||||
3. The signal's current value arrives via SSE every 500 ms as a `{"type":"monitor",…}` event.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### A.10 Log Viewer
|
|
||||||
|
|
||||||
The **Logs** panel at the bottom shows every `REPORT_ERROR` call forwarded as SSE events.
|
|
||||||
Use the level buttons (D / I / W / E) to filter by severity, or type a keyword to search.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Part B — Rust Native GUI (`DebugService`)
|
|
||||||
|
|
||||||
### B.1 Environment Setup
|
|
||||||
|
|
||||||
```bash
|
|
||||||
source /path/to/marte_debug/env.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### B.2 Add `DebugService` to Your Config
|
|
||||||
|
|
||||||
```text
|
|
||||||
+DebugService = {
|
|
||||||
Class = DebugService
|
|
||||||
ControlPort = 8080
|
|
||||||
UdpPort = 8081
|
|
||||||
LogPort = 8082
|
|
||||||
}
|
|
||||||
|
|
||||||
+App = {
|
|
||||||
Class = RealTimeApplication
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### B.3 Start the GUI Client
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd Tools/gui_client
|
cd Tools/gui_client
|
||||||
cargo run --release
|
cargo run --release
|
||||||
```
|
```
|
||||||
|
|
||||||
The GUI connects to `localhost:8080` automatically and requests the tree on startup.
|
## 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.
|
||||||
|
|
||||||
### B.4 Exploring the Object Tree
|
## 3. Real-Time Signal Tracing (Oscilloscope)
|
||||||
|
Tracing allows you to see signal values exactly as they exist in the real-time memory map.
|
||||||
|
|
||||||
The **Application Tree** panel on the left shows the live ORD.
|
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.
|
||||||
|
|
||||||
1. Expand `Root → App → Data`.
|
## 4. Signal Forcing (Manual Override)
|
||||||
2. Click **ℹ Info** next to any node to see its JSON config in the bottom-left pane.
|
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.
|
||||||
|
|
||||||
### B.5 Real-Time Signal Tracing (Oscilloscope)
|
## 5. Advanced Controls
|
||||||
|
|
||||||
1. Locate `Root.App.Data.Timer.Counter`.
|
### Global Pause
|
||||||
2. Click **📈 Trace**. The **Oscilloscope** panel begins plotting.
|
If you need to "freeze" the entire application to inspect a specific state:
|
||||||
3. The **UDP Packets** counter in the top bar increments — confirming high-speed telemetry
|
- Click **⏸ Pause** in the top bar. The real-time threads will halt at the start of their next cycle.
|
||||||
on port 8081.
|
- Click **▶ Resume** to restart the execution.
|
||||||
4. Drag additional signals from the **Traced Signals** list into the oscilloscope panel for
|
|
||||||
multi-signal overlay.
|
|
||||||
|
|
||||||
---
|
### Log Terminal
|
||||||
|
The bottom panel displays every `REPORT_ERROR` event from the C++ framework, powered by the standalone `TcpLogger` service.
|
||||||
### B.6 Signal Forcing
|
- **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.
|
||||||
1. Find `Root.App.Data.DDB.Counter`.
|
|
||||||
2. Click **⚡ Force**.
|
|
||||||
3. Enter a value (e.g. `9999`) and click **Apply Force**.
|
|
||||||
4. The oscilloscope plot immediately jumps to and holds at `9999`.
|
|
||||||
5. Click **❌** in the **Active Controls** panel to release the force.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### B.7 Global Pause and Resume
|
|
||||||
|
|
||||||
- Click **⏸ Pause** in the top bar to halt all RT threads.
|
|
||||||
- Click **▶ Resume** to continue.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### B.8 Log Terminal
|
|
||||||
|
|
||||||
The bottom panel shows all `REPORT_ERROR` events forwarded from `TcpLogger` (port 8082).
|
|
||||||
|
|
||||||
- **Regex Filter:** Type a keyword (e.g. `Timer`) to isolate events.
|
|
||||||
- **⏸ Pause Logs:** Stop scrolling while continuing to capture.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Part C — Scripted / Programmatic Access
|
|
||||||
|
|
||||||
Both transports accept plain text commands. You can use `nc` or any TCP client:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# DebugService
|
|
||||||
echo -e "DISCOVER\nTRACE App.Data.DDB.Counter 1" | nc localhost 8080
|
|
||||||
|
|
||||||
# WebDebugService
|
|
||||||
curl -s -X POST http://localhost:8090/api/command \
|
|
||||||
-H "Content-Type: text/plain" \
|
|
||||||
-d "DISCOVER"
|
|
||||||
```
|
|
||||||
|
|
||||||
For the full command reference see [API.md](API.md).
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
+DebugService = {
|
||||||
|
Class = DebugService
|
||||||
|
ControlPort = 8080
|
||||||
|
UdpPort = 8081
|
||||||
|
StreamIP = "127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
+LoggerService = {
|
||||||
|
Class = LoggerService
|
||||||
|
CPUs = 0x1
|
||||||
|
+DebugConsumer = {
|
||||||
|
Class = TcpLogger
|
||||||
|
Port = 8082
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+App = {
|
+App = {
|
||||||
Class = RealTimeApplication
|
Class = RealTimeApplication
|
||||||
+Functions = {
|
+Functions = {
|
||||||
@@ -17,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
OutputSignals = {
|
OutputSignals = {
|
||||||
Counter = {
|
Counter = {
|
||||||
DataSource = SyncDB
|
DataSource = DDB
|
||||||
Type = uint32
|
Type = uint32
|
||||||
}
|
}
|
||||||
Time = {
|
Time = {
|
||||||
@@ -26,30 +42,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+CGAM = {
|
|
||||||
Class = ConstantGAM
|
|
||||||
OutputSignals = {
|
|
||||||
Test = {
|
|
||||||
DataSource = DDB2
|
|
||||||
Type = float32
|
|
||||||
Default = 0.123
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+GAM2 = {
|
+GAM2 = {
|
||||||
Class = IOGAM
|
Class = IOGAM
|
||||||
InputSignals = {
|
InputSignals = {
|
||||||
Counter = {
|
Counter = {
|
||||||
DataSource = TimerSlow
|
DataSource = TimerSlow
|
||||||
Frequency = 1
|
Frequency = 10
|
||||||
}
|
}
|
||||||
Time = {
|
Time = {
|
||||||
DataSource = TimerSlow
|
DataSource = TimerSlow
|
||||||
}
|
}
|
||||||
Test = {
|
|
||||||
DataSource = DDB2
|
|
||||||
Type = float32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
OutputSignals = {
|
OutputSignals = {
|
||||||
Counter = {
|
Counter = {
|
||||||
@@ -60,44 +62,12 @@
|
|||||||
Type = uint32
|
Type = uint32
|
||||||
DataSource = Logger
|
DataSource = Logger
|
||||||
}
|
}
|
||||||
ConstOut = {
|
|
||||||
DataSource = Logger
|
|
||||||
Type = float32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+GAM3 = {
|
|
||||||
Class = IOGAM
|
|
||||||
InputSignals = {
|
|
||||||
Counter = {
|
|
||||||
Frequency = 1
|
|
||||||
Samples = 100
|
|
||||||
Type = uint32
|
|
||||||
DataSource = SyncDB
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutputSignals = {
|
|
||||||
Counter = {
|
|
||||||
DataSource = DDB3
|
|
||||||
NumberOfElements = 100
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+Data = {
|
+Data = {
|
||||||
Class = ReferenceContainer
|
Class = ReferenceContainer
|
||||||
DefaultDataSource = DDB
|
DefaultDataSource = DDB
|
||||||
+SyncDB = {
|
|
||||||
Class = RealTimeThreadSynchronisation
|
|
||||||
Timeout = 200
|
|
||||||
Signals = {
|
|
||||||
Counter = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+Timer = {
|
+Timer = {
|
||||||
Class = LinuxTimer
|
Class = LinuxTimer
|
||||||
Signals = {
|
Signals = {
|
||||||
@@ -140,14 +110,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+DDB2 = {
|
|
||||||
AllowNoProducer = 1
|
|
||||||
Class = GAMDataSource
|
|
||||||
}
|
|
||||||
+DDB3 = {
|
|
||||||
AllowNoProducer = 1
|
|
||||||
Class = GAMDataSource
|
|
||||||
}
|
|
||||||
+DAMS = {
|
+DAMS = {
|
||||||
Class = TimingDataSource
|
Class = TimingDataSource
|
||||||
}
|
}
|
||||||
@@ -164,11 +126,7 @@
|
|||||||
}
|
}
|
||||||
+Thread2 = {
|
+Thread2 = {
|
||||||
Class = RealTimeThread
|
Class = RealTimeThread
|
||||||
Functions = {GAM2 CGAM}
|
Functions = {GAM2}
|
||||||
}
|
|
||||||
+Thread3 = {
|
|
||||||
Class = RealTimeThread
|
|
||||||
Functions = {GAM3}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,12 +136,3 @@
|
|||||||
TimingDataSource = DAMS
|
TimingDataSource = DAMS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+DebugService = {
|
|
||||||
Class = DebugService
|
|
||||||
ControlPort = 8080
|
|
||||||
UdpPort = 8081
|
|
||||||
LogPort = 8082
|
|
||||||
StreamIP = "127.0.0.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
+App = {
|
|
||||||
Class = RealTimeApplication
|
|
||||||
+Functions = {
|
|
||||||
Class = ReferenceContainer
|
|
||||||
+GAM1 = {
|
|
||||||
Class = IOGAM
|
|
||||||
InputSignals = {
|
|
||||||
Counter = {
|
|
||||||
DataSource = Timer
|
|
||||||
Type = uint32
|
|
||||||
Frequency = 1000
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
DataSource = Timer
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutputSignals = {
|
|
||||||
Counter = {
|
|
||||||
DataSource = SyncDB
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
DataSource = DDB
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+CGAM = {
|
|
||||||
Class = ConstantGAM
|
|
||||||
OutputSignals = {
|
|
||||||
Test = {
|
|
||||||
DataSource = DDB2
|
|
||||||
Type = float32
|
|
||||||
Default = 0.123
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+GAM2 = {
|
|
||||||
Class = IOGAM
|
|
||||||
InputSignals = {
|
|
||||||
Counter = {
|
|
||||||
DataSource = TimerSlow
|
|
||||||
Frequency = 1
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
DataSource = TimerSlow
|
|
||||||
}
|
|
||||||
Test = {
|
|
||||||
DataSource = DDB2
|
|
||||||
Type = float32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutputSignals = {
|
|
||||||
Counter = {
|
|
||||||
Type = uint32
|
|
||||||
DataSource = Logger
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
Type = uint32
|
|
||||||
DataSource = Logger
|
|
||||||
}
|
|
||||||
ConstOut = {
|
|
||||||
DataSource = Logger
|
|
||||||
Type = float32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+GAM3 = {
|
|
||||||
Class = IOGAM
|
|
||||||
InputSignals = {
|
|
||||||
Counter = {
|
|
||||||
Frequency = 1
|
|
||||||
Samples = 100
|
|
||||||
Type = uint32
|
|
||||||
DataSource = SyncDB
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutputSignals = {
|
|
||||||
Counter = {
|
|
||||||
DataSource = DDB3
|
|
||||||
NumberOfElements = 100
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+Data = {
|
|
||||||
Class = ReferenceContainer
|
|
||||||
DefaultDataSource = DDB
|
|
||||||
+SyncDB = {
|
|
||||||
Class = RealTimeThreadSynchronisation
|
|
||||||
Timeout = 200
|
|
||||||
Signals = {
|
|
||||||
Counter = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+Timer = {
|
|
||||||
Class = LinuxTimer
|
|
||||||
Signals = {
|
|
||||||
Counter = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+TimerSlow = {
|
|
||||||
Class = LinuxTimer
|
|
||||||
Signals = {
|
|
||||||
Counter = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
Time = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+Logger = {
|
|
||||||
Class = LoggerDataSource
|
|
||||||
Signals = {
|
|
||||||
CounterCopy = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
TimeCopy = {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+DDB = {
|
|
||||||
AllowNoProducer = 1
|
|
||||||
Class = GAMDataSource
|
|
||||||
Signals = {
|
|
||||||
Counter= {
|
|
||||||
Type = uint32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+DDB2 = {
|
|
||||||
AllowNoProducer = 1
|
|
||||||
Class = GAMDataSource
|
|
||||||
}
|
|
||||||
+DDB3 = {
|
|
||||||
AllowNoProducer = 1
|
|
||||||
Class = GAMDataSource
|
|
||||||
}
|
|
||||||
+DAMS = {
|
|
||||||
Class = TimingDataSource
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+States = {
|
|
||||||
Class = ReferenceContainer
|
|
||||||
+State1 = {
|
|
||||||
Class = RealTimeState
|
|
||||||
+Threads = {
|
|
||||||
Class = ReferenceContainer
|
|
||||||
+Thread1 = {
|
|
||||||
Class = RealTimeThread
|
|
||||||
Functions = {GAM1}
|
|
||||||
}
|
|
||||||
+Thread2 = {
|
|
||||||
Class = RealTimeThread
|
|
||||||
Functions = {GAM2 CGAM}
|
|
||||||
}
|
|
||||||
+Thread3 = {
|
|
||||||
Class = RealTimeThread
|
|
||||||
Functions = {GAM3}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+Scheduler = {
|
|
||||||
Class = GAMScheduler
|
|
||||||
TimingDataSource = DAMS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+DebugService = {
|
|
||||||
Class = WebDebugService
|
|
||||||
HttpPort = 8090
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
#include "DebugService.h"
|
||||||
|
#include "DebugBrokerWrapper.h"
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "StandardParser.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
|
||||||
|
class ManualDebugMemoryMapInputBroker : public DebugMemoryMapInputBroker {
|
||||||
|
public:
|
||||||
|
virtual bool Execute() {
|
||||||
|
if (infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
using MemoryMapBroker::copyTable;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MockDS : public DataSourceI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
MockDS() { SetName("MockDS"); }
|
||||||
|
virtual bool AllocateMemory() { return true; }
|
||||||
|
virtual uint32 GetNumberOfMemoryBuffers() { return 1; }
|
||||||
|
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void *&signalAddress) {
|
||||||
|
static uint32 val = 0;
|
||||||
|
signalAddress = &val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual const char8 *GetBrokerName(StructuredDataI &data, const SignalDirection direction) { return "MemoryMapInputBroker"; }
|
||||||
|
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers, const char8 *const functionName, void *const gamMem) { return true; }
|
||||||
|
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers, const char8 *const functionName, void *const gamMem) { return true; }
|
||||||
|
virtual bool PrepareNextState(const char8 *const currentStateName, const char8 *const nextStateName) { return true; }
|
||||||
|
virtual bool Synchronise() { return true; }
|
||||||
|
};
|
||||||
|
CLASS_REGISTER(MockDS, "1.0")
|
||||||
|
|
||||||
|
void RunTest() {
|
||||||
|
printf("--- Broker Execute Path Test (Isolated) ---\n");
|
||||||
|
|
||||||
|
DebugService* service = new DebugService();
|
||||||
|
service->traceBuffer.Init(1024 * 1024);
|
||||||
|
ConfigurationDatabase cfg;
|
||||||
|
cfg.Write("ControlPort", (uint32)0);
|
||||||
|
cfg.Write("StreamPort", (uint32)0);
|
||||||
|
assert(service->Initialise(cfg));
|
||||||
|
|
||||||
|
ObjectRegistryDatabase::Instance()->Insert(Reference(service));
|
||||||
|
|
||||||
|
MockDS ds;
|
||||||
|
uint32 gamMem = 42;
|
||||||
|
|
||||||
|
ManualDebugMemoryMapInputBroker* broker = new ManualDebugMemoryMapInputBroker();
|
||||||
|
broker->service = service;
|
||||||
|
|
||||||
|
printf("Manually bootstrapping Broker for testing...\n");
|
||||||
|
broker->copyTable = new MemoryMapBrokerCopyTableEntry[1];
|
||||||
|
broker->copyTable[0].copySize = 4;
|
||||||
|
broker->copyTable[0].dataSourcePointer = &gamMem;
|
||||||
|
broker->copyTable[0].gamPointer = &gamMem;
|
||||||
|
broker->copyTable[0].type = UnsignedInteger32Bit;
|
||||||
|
|
||||||
|
DebugSignalInfo** sigPtrs = NULL;
|
||||||
|
DebugBrokerHelper::InitSignals(NULL_PTR(BrokerI*), ds, service, sigPtrs, 1, broker->copyTable, "TestGAM", InputSignals, &broker->anyActive);
|
||||||
|
broker->infoPtr = &service->brokers[service->numberOfBrokers - 1];
|
||||||
|
|
||||||
|
printf("Broker ready. Registered signals in service: %u\n", service->numberOfSignals);
|
||||||
|
|
||||||
|
printf("Executing IDLE cycle...\n");
|
||||||
|
broker->Execute();
|
||||||
|
assert(service->traceBuffer.Count() == 0);
|
||||||
|
|
||||||
|
printf("Manually enabling TRACE for first signal...\n");
|
||||||
|
// Directly enable tracing on the signal info to bypass name matching
|
||||||
|
service->signals[0].isTracing = true;
|
||||||
|
service->signals[0].decimationFactor = 1;
|
||||||
|
service->signals[0].decimationCounter = 0;
|
||||||
|
|
||||||
|
printf("Updating brokers active status...\n");
|
||||||
|
service->UpdateBrokersActiveStatus();
|
||||||
|
assert(broker->anyActive == true);
|
||||||
|
|
||||||
|
printf("Executing TRACE cycle...\n");
|
||||||
|
broker->Execute();
|
||||||
|
|
||||||
|
uint32 rbCount = service->traceBuffer.Count();
|
||||||
|
printf("Trace Buffer Count: %u\n", rbCount);
|
||||||
|
|
||||||
|
if (rbCount > 0) {
|
||||||
|
printf("SUCCESS: Data reached Trace Buffer via Broker!\n");
|
||||||
|
uint32 rid, rsize; uint64 rts; uint32 rval;
|
||||||
|
assert(service->traceBuffer.Pop(rid, rts, &rval, rsize, 4));
|
||||||
|
printf("Value popped: %u (ID=%u, TS=%lu)\n", rval, rid, rts);
|
||||||
|
assert(rval == 42);
|
||||||
|
} else {
|
||||||
|
printf("FAILURE: Trace Buffer is still empty.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectRegistryDatabase::Instance()->Purge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MARTe::RunTest();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
add_executable(IntegrationTest main.cpp)
|
||||||
|
target_link_libraries(IntegrationTest marte_dev ${MARTe2_LIB})
|
||||||
|
|
||||||
|
add_executable(TraceTest TraceTest.cpp)
|
||||||
|
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})
|
||||||
|
|
||||||
|
add_executable(PerformanceTest PerformanceTest.cpp)
|
||||||
|
target_link_libraries(PerformanceTest marte_dev ${MARTe2_LIB})
|
||||||
|
|
||||||
|
add_executable(BrokerExecuteTest BrokerExecuteTest.cpp)
|
||||||
|
target_link_libraries(BrokerExecuteTest marte_dev ${MARTe2_LIB})
|
||||||
|
|
||||||
|
add_executable(FinalValidationTest FinalValidationTest.cpp)
|
||||||
|
target_link_libraries(FinalValidationTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${LinuxTimer_LIB} ${LoggerDataSource_LIB})
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "StandardParser.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
#include "GlobalObjectsDatabase.h"
|
|
||||||
#include "RealTimeApplication.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace MARTe;
|
|
||||||
|
|
||||||
const char8 * const config_command_text =
|
|
||||||
"DebugService = {"
|
|
||||||
" Class = DebugService "
|
|
||||||
" ControlPort = 8100 "
|
|
||||||
" UdpPort = 8101 "
|
|
||||||
" StreamIP = \"127.0.0.1\" "
|
|
||||||
" MyCustomField = \"HelloConfig\" "
|
|
||||||
"}"
|
|
||||||
"App = {"
|
|
||||||
" Class = RealTimeApplication "
|
|
||||||
" +Functions = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" +GAM1 = {"
|
|
||||||
" Class = IOGAM "
|
|
||||||
" CustomGAMField = \"GAMValue\" "
|
|
||||||
" InputSignals = {"
|
|
||||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 PVName = \"PROC:VAR:1\" }"
|
|
||||||
" Time = { DataSource = Timer Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" OutputSignals = {"
|
|
||||||
" Counter = { DataSource = DDB Type = uint32 }"
|
|
||||||
" Time = { DataSource = DDB Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" +Data = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" +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 }"
|
|
||||||
"}";
|
|
||||||
|
|
||||||
static bool SendCommandAndGetReply(uint16 port, const char8* cmd, StreamString &reply) {
|
|
||||||
BasicTCPSocket client;
|
|
||||||
if (!client.Open()) return false;
|
|
||||||
if (!client.Connect("127.0.0.1", port)) return false;
|
|
||||||
|
|
||||||
uint32 s = StringHelper::Length(cmd);
|
|
||||||
if (!client.Write(cmd, s)) return false;
|
|
||||||
|
|
||||||
char buffer[4096];
|
|
||||||
uint32 size = 4096;
|
|
||||||
TimeoutType timeout(2000000); // 2s
|
|
||||||
if (client.Read(buffer, size, timeout)) {
|
|
||||||
reply.Write(buffer, size);
|
|
||||||
client.Close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
client.Close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestConfigCommands() {
|
|
||||||
printf("--- MARTe2 Config & Metadata Enrichment Test ---\n");
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
|
||||||
StreamString ss = config_command_text;
|
|
||||||
ss.Seek(0);
|
|
||||||
StandardParser parser(ss, cdb);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Application and DebugService (port 8100) initialised.\n");
|
|
||||||
|
|
||||||
// Start the application to trigger broker execution and signal registration
|
|
||||||
ReferenceT<RealTimeApplication> app = ObjectRegistryDatabase::Instance()->Find("App");
|
|
||||||
assert(app.IsValid());
|
|
||||||
assert(app->ConfigureApplication());
|
|
||||||
assert(app->PrepareNextState("State1") == ErrorManagement::NoError);
|
|
||||||
assert(app->StartNextStateExecution() == ErrorManagement::NoError);
|
|
||||||
printf("Application started (for signal registration).\n");
|
|
||||||
Sleep::MSec(500); // Wait for some cycles
|
|
||||||
|
|
||||||
ReferenceT<DebugService> service = ObjectRegistryDatabase::Instance()->Find("DebugService");
|
|
||||||
if (service.IsValid()) {
|
|
||||||
service->SetFullConfig(cdb);
|
|
||||||
}
|
|
||||||
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
// 1. Test CONFIG command
|
|
||||||
{
|
|
||||||
printf("Testing CONFIG command...\n");
|
|
||||||
StreamString reply;
|
|
||||||
assert(SendCommandAndGetReply(8100, "CONFIG\n", reply));
|
|
||||||
printf("\n%s\n", reply.Buffer());
|
|
||||||
// Verify it contains some key parts of the config
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "MyCustomField") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "HelloConfig") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "PROC:VAR:1") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "OK CONFIG") != NULL_PTR(const char8*));
|
|
||||||
printf("SUCCESS: CONFIG command validated.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Test INFO on object with enrichment
|
|
||||||
{
|
|
||||||
printf("Testing INFO on App.Functions.GAM1...\n");
|
|
||||||
StreamString reply;
|
|
||||||
assert(SendCommandAndGetReply(8100, "INFO App.Functions.GAM1\n", reply));
|
|
||||||
// Check standard MARTe fields (Name, Class)
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "\"Name\": \"GAM1\"") != NULL_PTR(const char8*));
|
|
||||||
// Check enriched fields from fullConfig
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "\"CustomGAMField\": \"GAMValue\"") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "OK INFO") != NULL_PTR(const char8*));
|
|
||||||
printf("SUCCESS: Object metadata enrichment validated.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Test INFO on signal with enrichment
|
|
||||||
{
|
|
||||||
printf("Testing INFO on App.Functions.GAM1.In.Counter...\n");
|
|
||||||
StreamString reply;
|
|
||||||
assert(SendCommandAndGetReply(8100, "INFO App.Functions.GAM1.In.Counter\n", reply));
|
|
||||||
|
|
||||||
// Check enriched fields from signal configuration
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "\"Frequency\": \"1000\"") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "\"PVName\": \"PROC:VAR:1\"") != NULL_PTR(const char8*));
|
|
||||||
assert(StringHelper::SearchString(reply.Buffer(), "OK INFO") != NULL_PTR(const char8*));
|
|
||||||
printf("SUCCESS: Signal metadata enrichment validated.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app.IsValid()) {
|
|
||||||
app->StopCurrentStateExecution();
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
#include "DebugService.h"
|
||||||
|
#include "DebugCore.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "StandardParser.h"
|
||||||
|
#include "RealTimeApplication.h"
|
||||||
|
#include "GlobalObjectsDatabase.h"
|
||||||
|
#include "BasicUDPSocket.h"
|
||||||
|
#include "BasicTCPSocket.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
void RunFinalValidation() {
|
||||||
|
printf("--- MARTe2 Debug Final Validation (End-to-End) ---\n");
|
||||||
|
|
||||||
|
ObjectRegistryDatabase::Instance()->Purge();
|
||||||
|
|
||||||
|
// 1. Initialise DebugService FIRST
|
||||||
|
const char8 * const service_cfg =
|
||||||
|
"+DebugService = {"
|
||||||
|
" Class = DebugService "
|
||||||
|
" ControlPort = 8080 "
|
||||||
|
" UdpPort = 8081 "
|
||||||
|
" StreamIP = \"127.0.0.1\" "
|
||||||
|
"}";
|
||||||
|
|
||||||
|
StreamString ssSrv = service_cfg;
|
||||||
|
ssSrv.Seek(0);
|
||||||
|
ConfigurationDatabase cdbSrv;
|
||||||
|
StandardParser parserSrv(ssSrv, cdbSrv);
|
||||||
|
assert(parserSrv.Parse());
|
||||||
|
|
||||||
|
cdbSrv.MoveToRoot();
|
||||||
|
if (cdbSrv.MoveRelative("+DebugService")) {
|
||||||
|
ConfigurationDatabase child;
|
||||||
|
cdbSrv.Copy(child);
|
||||||
|
cdbSrv.MoveToAncestor(1u);
|
||||||
|
Reference ref("DebugService", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||||
|
ref->SetName("DebugService");
|
||||||
|
if (!ref->Initialise(child)) {
|
||||||
|
printf("ERROR: Failed to initialise DebugService\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ObjectRegistryDatabase::Instance()->Insert(ref);
|
||||||
|
printf("[Init] DebugService started.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Minimal App configuration
|
||||||
|
const char8 * const minimal_app_cfg =
|
||||||
|
"+App = {"
|
||||||
|
" Class = RealTimeApplication "
|
||||||
|
" +Functions = {"
|
||||||
|
" Class = ReferenceContainer "
|
||||||
|
" +GAM1 = {"
|
||||||
|
" Class = IOGAM "
|
||||||
|
" InputSignals = {"
|
||||||
|
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
||||||
|
" }"
|
||||||
|
" OutputSignals = {"
|
||||||
|
" Counter = { DataSource = DDB Type = uint32 }"
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" +Data = {"
|
||||||
|
" Class = ReferenceContainer "
|
||||||
|
" DefaultDataSource = DDB "
|
||||||
|
" +Timer = { Class = LinuxTimer SleepTime = 1000 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 = GAMScheduler TimingDataSource = DAMS }"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
StreamString ssApp = minimal_app_cfg;
|
||||||
|
ssApp.Seek(0);
|
||||||
|
ConfigurationDatabase cdbApp;
|
||||||
|
StandardParser parserApp(ssApp, cdbApp);
|
||||||
|
assert(parserApp.Parse());
|
||||||
|
|
||||||
|
cdbApp.MoveToRoot();
|
||||||
|
if (cdbApp.MoveRelative("+App")) {
|
||||||
|
ConfigurationDatabase child;
|
||||||
|
cdbApp.Copy(child);
|
||||||
|
cdbApp.MoveToAncestor(1u);
|
||||||
|
Reference ref("RealTimeApplication", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||||
|
ref->SetName("App");
|
||||||
|
if (ref->Initialise(child)) {
|
||||||
|
ObjectRegistryDatabase::Instance()->Insert(ref);
|
||||||
|
printf("[Init] App object created.\n");
|
||||||
|
} else {
|
||||||
|
printf("ERROR: Failed to initialise App object.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference appRef = ObjectRegistryDatabase::Instance()->Find("App");
|
||||||
|
RealTimeApplication* app = dynamic_cast<RealTimeApplication*>(appRef.operator->());
|
||||||
|
|
||||||
|
// 3. Start Application
|
||||||
|
printf("Configuring Application...\n");
|
||||||
|
if (!app->ConfigureApplication()) {
|
||||||
|
printf("ERROR: ConfigureApplication failed.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Preparing State1...\n");
|
||||||
|
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
||||||
|
printf("ERROR: Failed to prepare State1.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Starting State1 Execution...\n");
|
||||||
|
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
||||||
|
printf("ERROR: Failed to start State1 execution.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Application running. Starting client simulation...\n");
|
||||||
|
Sleep::MSec(1000);
|
||||||
|
|
||||||
|
// 4. Act as Client: Send Commands
|
||||||
|
BasicTCPSocket client;
|
||||||
|
if (client.Connect("127.0.0.1", 8080, TimeoutType(2000))) {
|
||||||
|
printf("[Client] Connected to DebugService.\n");
|
||||||
|
|
||||||
|
// Command 1: TREE
|
||||||
|
printf("[Client] Sending TREE...\n");
|
||||||
|
uint32 cmdLen = 5;
|
||||||
|
client.Write("TREE\n", cmdLen);
|
||||||
|
char buf[4096]; uint32 rsize = 4096;
|
||||||
|
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||||
|
printf("[Client] TREE response received (%u bytes).\n", rsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command 2: DISCOVER
|
||||||
|
printf("[Client] Sending DISCOVER...\n");
|
||||||
|
cmdLen = 9;
|
||||||
|
client.Write("DISCOVER\n", cmdLen);
|
||||||
|
rsize = 4096;
|
||||||
|
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||||
|
buf[rsize] = '\0';
|
||||||
|
printf("[Client] DISCOVER response:\n%s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command 3: TRACE
|
||||||
|
const char* target = "App.Data.Timer.Counter";
|
||||||
|
printf("[Client] Sending TRACE %s 1...\n", target);
|
||||||
|
StreamString traceCmd;
|
||||||
|
traceCmd.Printf("TRACE %s 1\n", target);
|
||||||
|
cmdLen = traceCmd.Size();
|
||||||
|
client.Write(traceCmd.Buffer(), cmdLen);
|
||||||
|
|
||||||
|
rsize = 1024;
|
||||||
|
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||||
|
buf[rsize] = '\0';
|
||||||
|
printf("[Client] TRACE response: %s", buf);
|
||||||
|
}
|
||||||
|
client.Close();
|
||||||
|
} else {
|
||||||
|
printf("ERROR: Client failed to connect to 127.0.0.1:8080\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Verify Telemetry
|
||||||
|
BasicUDPSocket telemListener;
|
||||||
|
assert(telemListener.Open());
|
||||||
|
assert(telemListener.Listen(8081));
|
||||||
|
|
||||||
|
printf("Listening for UDP Telemetry on 8081...\n");
|
||||||
|
uint32 totalSamples = 0;
|
||||||
|
uint64 startBench = HighResolutionTimer::Counter();
|
||||||
|
|
||||||
|
while (totalSamples < 50 && (HighResolutionTimer::Counter() - startBench) * HighResolutionTimer::Period() < 10.0) {
|
||||||
|
char packet[4096];
|
||||||
|
uint32 psize = 4096;
|
||||||
|
if (telemListener.Read(packet, psize, TimeoutType(100))) {
|
||||||
|
if (psize < 20) continue;
|
||||||
|
uint32 magic = *(uint32*)(&packet[0]);
|
||||||
|
if (magic != 0xDA7A57AD) continue;
|
||||||
|
|
||||||
|
uint32 count = *(uint32*)(&packet[16]);
|
||||||
|
uint32 offset = 20;
|
||||||
|
for (uint32 j=0; j<count; j++) {
|
||||||
|
if (offset + 16 > psize) break;
|
||||||
|
uint32 id = *(uint32*)(&packet[offset]);
|
||||||
|
uint64 ts = *(uint64*)(&packet[offset + 4]);
|
||||||
|
uint32 size = *(uint32*)(&packet[offset + 12]);
|
||||||
|
offset += 16;
|
||||||
|
if (offset + size > psize) break;
|
||||||
|
if (size == 4) {
|
||||||
|
uint32 val = *(uint32*)(&packet[offset]);
|
||||||
|
if (totalSamples % 10 == 0) printf("[Telemetry] Sample %u: ID=%u, TS=%lu, Val=%u\n", totalSamples, id, ts, val);
|
||||||
|
totalSamples++;
|
||||||
|
}
|
||||||
|
offset += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalSamples >= 50) {
|
||||||
|
printf("\nSUCCESS: End-to-End pipeline verified with real MARTe2 app!\n");
|
||||||
|
} else {
|
||||||
|
printf("\nFAILURE: Received only %u samples in 10 seconds.\n", totalSamples);
|
||||||
|
}
|
||||||
|
|
||||||
|
app->StopCurrentStateExecution();
|
||||||
|
telemListener.Close();
|
||||||
|
ObjectRegistryDatabase::Instance()->Purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
RunFinalValidation();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,252 +0,0 @@
|
|||||||
#include "ClassRegistryDatabase.h"
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "ErrorManagement.h"
|
|
||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "BasicUDPSocket.h"
|
|
||||||
#include "RealTimeApplication.h"
|
|
||||||
#include "StandardParser.h"
|
|
||||||
#include "TestCommon.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace MARTe;
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
void timeout_handler(int sig) {
|
|
||||||
printf("Test timed out!\n");
|
|
||||||
_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ErrorProcessFunction(const MARTe::ErrorManagement::ErrorInformation &errorInfo, const char8 * const errorDescription) {
|
|
||||||
printf("[MARTe Error] %s: %s\n", errorInfo.className, errorDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Forward declarations of other tests
|
|
||||||
void TestSchedulerControl();
|
|
||||||
void TestFullTracePipeline();
|
|
||||||
void RunValidationTest();
|
|
||||||
void TestConfigCommands();
|
|
||||||
void TestGAMSignalTracing();
|
|
||||||
void TestTreeCommand();
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
signal(SIGALRM, timeout_handler);
|
|
||||||
alarm(180);
|
|
||||||
|
|
||||||
MARTe::ErrorManagement::SetErrorProcessFunction(&ErrorProcessFunction);
|
|
||||||
|
|
||||||
printf("MARTe2 Debug Suite Integration Tests\n");
|
|
||||||
|
|
||||||
printf("\n--- Test 1: Registry Patching ---\n");
|
|
||||||
{
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
DebugService service;
|
|
||||||
ConfigurationDatabase serviceData;
|
|
||||||
serviceData.Write("ControlPort", (uint32)9090);
|
|
||||||
service.Initialise(serviceData);
|
|
||||||
printf("DebugService initialized and Registry Patched.\n");
|
|
||||||
|
|
||||||
ClassRegistryItem *item =
|
|
||||||
ClassRegistryDatabase::Instance()->Find("MemoryMapInputBroker");
|
|
||||||
if (item != NULL_PTR(ClassRegistryItem *)) {
|
|
||||||
Object *obj = item->GetObjectBuilder()->Build(
|
|
||||||
GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
|
||||||
if (obj != NULL_PTR(Object *)) {
|
|
||||||
printf("Instantiated Broker Class: %s\n",
|
|
||||||
obj->GetClassProperties()->GetName());
|
|
||||||
printf("Success: Broker patched and instantiated.\n");
|
|
||||||
} else {
|
|
||||||
printf("Failed to build broker\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("MemoryMapInputBroker not found in registry\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 2: Full Trace Pipeline ---\n");
|
|
||||||
TestFullTracePipeline();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 3: Scheduler Control ---\n");
|
|
||||||
TestSchedulerControl();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 4: 1kHz Lossless Trace Validation ---\n");
|
|
||||||
RunValidationTest();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 5: Config & Metadata Enrichment ---\n");
|
|
||||||
TestConfigCommands();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 6: TREE Command Enhancement ---\n");
|
|
||||||
TestTreeCommand();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\n--- Test 7: Custom MARTe Message (MSG) ---\n");
|
|
||||||
TestMessageCommand();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
printf("\nAll Integration Tests Finished.\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Test Implementation ---
|
|
||||||
|
|
||||||
void TestGAMSignalTracing() {
|
|
||||||
printf("--- Test: GAM Signal Tracing Issue ---\n");
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
|
||||||
StreamString ss = debug_test_config;
|
|
||||||
ss.Seek(0);
|
|
||||||
StandardParser parser(ss, cdb);
|
|
||||||
if (!parser.Parse()) {
|
|
||||||
printf("ERROR: Failed to parse config\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
if (!ref.IsValid()) {
|
|
||||||
printf("ERROR: Could not create object %s of class %s\n", name, className.Buffer());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ref->SetName(name);
|
|
||||||
if (!ref->Initialise(child)) {
|
|
||||||
printf("ERROR: Failed to initialise object %s\n", name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReferenceT<DebugService> service = ObjectRegistryDatabase::Instance()->Find("DebugService");
|
|
||||||
if (!service.IsValid()) {
|
|
||||||
printf("ERROR: DebugService not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
service->SetFullConfig(cdb);
|
|
||||||
|
|
||||||
ReferenceT<RealTimeApplication> app = ObjectRegistryDatabase::Instance()->Find("App");
|
|
||||||
if (!app.IsValid()) {
|
|
||||||
printf("ERROR: App not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!app->ConfigureApplication()) {
|
|
||||||
printf("ERROR: ConfigureApplication failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
|
||||||
printf("ERROR: PrepareNextState failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
|
||||||
printf("ERROR: StartNextStateExecution failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Application started.\n");
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
// Step 1: Discover signals
|
|
||||||
{
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8095, "DISCOVER\n", reply)) {
|
|
||||||
printf("DISCOVER response received (len=%llu)\n", reply.Size());
|
|
||||||
} else {
|
|
||||||
printf("ERROR: DISCOVER failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// Step 2: Trace a DataSource signal (Timer.Counter)
|
|
||||||
printf("\n--- Step 1: Trace DataSource signal (Timer.Counter) ---\n");
|
|
||||||
{
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8095, "TRACE App.Data.Timer.Counter 1\n", reply)) {
|
|
||||||
printf("TRACE response: %s", reply.Buffer());
|
|
||||||
} else {
|
|
||||||
printf("ERROR: TRACE failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// Step 3: Trace a GAM input signal (GAM1.In.Counter)
|
|
||||||
printf("\n--- Step 2: Trace GAM input signal (GAM1.In.Counter) ---\n");
|
|
||||||
{
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8095, "TRACE App.Functions.GAM1.In.Counter 1\n", reply)) {
|
|
||||||
printf("TRACE response: %s", reply.Buffer());
|
|
||||||
} else {
|
|
||||||
printf("ERROR: TRACE failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// Step 4: Try to trace another DataSource signal (TimerSlow.Counter)
|
|
||||||
printf("\n--- Step 3: Try to trace another signal (TimerSlow.Counter) ---\n");
|
|
||||||
{
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8095, "TRACE App.Data.TimerSlow.Counter 1\n", reply)) {
|
|
||||||
printf("TRACE response: %s", reply.Buffer());
|
|
||||||
} else {
|
|
||||||
printf("ERROR: TRACE failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// Step 5: Check if we can still trace more signals
|
|
||||||
printf("\n--- Step 4: Try to trace Logger.Counter ---\n");
|
|
||||||
{
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8095, "TRACE App.Data.Logger.Counter 1\n", reply)) {
|
|
||||||
printf("TRACE response: %s", reply.Buffer());
|
|
||||||
} else {
|
|
||||||
printf("ERROR: TRACE failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// Verify UDP is still receiving data
|
|
||||||
BasicUDPSocket listener;
|
|
||||||
listener.Open();
|
|
||||||
listener.Listen(8096);
|
|
||||||
|
|
||||||
char buffer[1024];
|
|
||||||
uint32 size = 1024;
|
|
||||||
TimeoutType timeout(1000);
|
|
||||||
int packetCount = 0;
|
|
||||||
while (listener.Read(buffer, size, timeout)) {
|
|
||||||
packetCount++;
|
|
||||||
size = 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n--- Results ---\n");
|
|
||||||
if (packetCount > 0) {
|
|
||||||
printf("SUCCESS: Received %d UDP packets.\n", packetCount);
|
|
||||||
} else {
|
|
||||||
printf("FAILURE: No UDP packets received. Possible deadlock or crash.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
app->StopCurrentStateExecution();
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
include Makefile.inc
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
OBJSX = SchedulerTest.x TraceTest.x ValidationTest.x ConfigCommandTest.x TreeCommandTest.x MessageCommandTest.x TestCommon.x
|
|
||||||
|
|
||||||
PACKAGE = Test/Integration
|
|
||||||
|
|
||||||
ROOT_DIR = ../..
|
|
||||||
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Result
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Vec
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/DebugService
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/TCPLogger
|
|
||||||
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L6App
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_Components_DIR)/Source/Components/GAMs/IOGAM
|
|
||||||
INCLUDES += -I$(MARTe2_Components_DIR)/Source/Components/DataSources/LinuxTimer
|
|
||||||
|
|
||||||
LIBRARIES += -L$(MARTe2_DIR)/Build/$(TARGET)/Core -lMARTe2
|
|
||||||
LIBRARIES += -L$(MARTe2_Components_DIR)/Build/$(TARGET)/Components/DataSources/LinuxTimer -lLinuxTimer
|
|
||||||
LIBRARIES += -L$(MARTe2_Components_DIR)/Build/$(TARGET)/Components/GAMs/IOGAM -lIOGAM
|
|
||||||
LIBRARIES += -L$(ROOT_DIR)/Build/$(TARGET)/Components/Interfaces/DebugService -lDebugService
|
|
||||||
LIBRARIES += -L$(ROOT_DIR)/Build/$(TARGET)/Components/Interfaces/TCPLogger -lTcpLogger
|
|
||||||
|
|
||||||
all: $(OBJS) $(BUILD_DIR)/IntegrationTests$(EXEEXT)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
#include "TestCommon.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "StandardParser.h"
|
|
||||||
#include "GlobalObjectsDatabase.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace MARTe;
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
void TestMessageCommand() {
|
|
||||||
printf("--- Test: Custom MARTe Message (MSG) ---\n");
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
|
||||||
const char8 * const msg_test_config =
|
|
||||||
"DebugService = {"
|
|
||||||
" Class = DebugService "
|
|
||||||
" ControlPort = 8120 "
|
|
||||||
" UdpPort = 8121 "
|
|
||||||
" StreamIP = \"127.0.0.1\" "
|
|
||||||
"}";
|
|
||||||
|
|
||||||
StreamString ss = msg_test_config;
|
|
||||||
ss.Seek(0);
|
|
||||||
StandardParser parser(ss, cdb);
|
|
||||||
if (!parser.Parse()) {
|
|
||||||
printf("ERROR: Failed to parse config\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize Service
|
|
||||||
ReferenceT<DebugService> service("DebugService", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
|
||||||
service->SetName("DebugService");
|
|
||||||
|
|
||||||
cdb.MoveToRoot();
|
|
||||||
if (cdb.MoveRelative("DebugService")) {
|
|
||||||
if (!service->Initialise(cdb)) {
|
|
||||||
printf("ERROR: Failed to initialize DebugService\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ObjectRegistryDatabase::Instance()->Insert(service);
|
|
||||||
|
|
||||||
if (ObjectRegistryDatabase::Instance()->Find("DebugService").IsValid()) {
|
|
||||||
printf("DebugService successfully registered in ORD.\n");
|
|
||||||
} else {
|
|
||||||
printf("ERROR: DebugService NOT found in ORD.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Service initialized on port 8120.\n");
|
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8120, "MSG DebugService UnknownFunc 0 Key1=Val1\\nKey2=Val2\n", reply)) {
|
|
||||||
printf("MSG response received: %s", reply.Buffer());
|
|
||||||
if (StringHelper::SearchString(reply.Buffer(), "OK MSG") != NULL_PTR(const char8 *)) {
|
|
||||||
printf("SUCCESS: Asynchronous message dispatched correctly.\n");
|
|
||||||
} else {
|
|
||||||
printf("FAILURE: MSG command returned error.\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("ERROR: MSG command communication failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace MARTe
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
#include "DebugService.h"
|
||||||
|
#include "DebugBrokerWrapper.h"
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "StandardParser.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
void RunBenchmark() {
|
||||||
|
printf("--- MARTe2 Debug Performance Benchmark V5 (Wait-Free/Branchless) ---\n");
|
||||||
|
printf("Testing with 100 signals, 1,000,000 cycles per test.\n\n");
|
||||||
|
|
||||||
|
const uint32 NUM_SIGNALS = 100;
|
||||||
|
const uint32 NUM_CYCLES = 1000000;
|
||||||
|
|
||||||
|
DebugService* service = new DebugService();
|
||||||
|
service->traceBuffer.Init(128 * 1024 * 1024);
|
||||||
|
ConfigurationDatabase cfg;
|
||||||
|
cfg.Write("ControlPort", (uint32)0);
|
||||||
|
cfg.Write("StreamPort", (uint32)0);
|
||||||
|
assert(service->Initialise(cfg));
|
||||||
|
|
||||||
|
volatile uint32 srcMem[NUM_SIGNALS];
|
||||||
|
volatile uint32 dstMem[NUM_SIGNALS];
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) srcMem[i] = i;
|
||||||
|
|
||||||
|
printf("1. Baseline (Pure Copy): ");
|
||||||
|
uint64 start = HighResolutionTimer::Counter();
|
||||||
|
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||||
|
dstMem[i] = srcMem[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint64 end = HighResolutionTimer::Counter();
|
||||||
|
float64 baselineTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||||
|
float64 baselineNs = (baselineTime / NUM_CYCLES) * 1e9;
|
||||||
|
printf("%.3f ms (avg: %.3f ns)\n", baselineTime * 1000.0, baselineNs);
|
||||||
|
|
||||||
|
DebugMemoryMapInputBroker debugBroker;
|
||||||
|
debugBroker.service = service;
|
||||||
|
DebugSignalInfo** ptrs = new DebugSignalInfo*[NUM_SIGNALS];
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||||
|
StreamString name;
|
||||||
|
name = "Sig";
|
||||||
|
// Convert i to string without Printf
|
||||||
|
if (i < 10) { name += (char)('0' + i); }
|
||||||
|
else { name += (char)('0' + (i/10)); name += (char)('0' + (i%10)); }
|
||||||
|
|
||||||
|
ptrs[i] = service->RegisterSignal((void*)&srcMem[i], UnsignedInteger32Bit, name.Buffer());
|
||||||
|
}
|
||||||
|
volatile bool anyActiveFlag = false;
|
||||||
|
service->RegisterBroker(ptrs, NUM_SIGNALS, NULL_PTR(MemoryMapBroker*), &anyActiveFlag);
|
||||||
|
debugBroker.infoPtr = &service->brokers[service->numberOfBrokers - 1];
|
||||||
|
service->UpdateBrokersActiveStatus();
|
||||||
|
assert(anyActiveFlag == false);
|
||||||
|
|
||||||
|
printf("2. Debug Idle (Wait-Free Skip): ");
|
||||||
|
start = HighResolutionTimer::Counter();
|
||||||
|
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) dstMem[i] = srcMem[i];
|
||||||
|
if (anyActiveFlag || service->IsPaused()) {
|
||||||
|
DebugBrokerHelper::Process(service, *debugBroker.infoPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end = HighResolutionTimer::Counter();
|
||||||
|
float64 idleTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||||
|
float64 idleNs = (idleTime / NUM_CYCLES) * 1e9;
|
||||||
|
printf("%.3f ms (avg: %.3f ns) | Delta: +%.3f ns\n",
|
||||||
|
idleTime * 1000.0, idleNs, idleNs - baselineNs);
|
||||||
|
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||||
|
service->signals[i].isTracing = true;
|
||||||
|
}
|
||||||
|
service->UpdateBrokersActiveStatus();
|
||||||
|
assert(anyActiveFlag == true);
|
||||||
|
|
||||||
|
printf("3. Debug Load (100 signals branchless): ");
|
||||||
|
start = HighResolutionTimer::Counter();
|
||||||
|
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||||
|
for(uint32 i=0; i<NUM_SIGNALS; i++) dstMem[i] = srcMem[i];
|
||||||
|
if (anyActiveFlag || service->IsPaused()) {
|
||||||
|
DebugBrokerHelper::Process(service, *debugBroker.infoPtr);
|
||||||
|
}
|
||||||
|
if ((c % 1000) == 0) {
|
||||||
|
uint32 tid, tsize; uint64 tts; uint8 tbuf[16];
|
||||||
|
while(service->traceBuffer.Pop(tid, tts, tbuf, tsize, 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end = HighResolutionTimer::Counter();
|
||||||
|
float64 loadTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||||
|
float64 loadNs = (loadTime / NUM_CYCLES) * 1e9;
|
||||||
|
printf("%.3f ms (avg: %.3f ns) | Delta: +%.3f ns (+%.3f ns/signal)\n",
|
||||||
|
loadTime * 1000.0, loadNs, loadNs - baselineNs, (loadNs - baselineNs)/NUM_SIGNALS);
|
||||||
|
|
||||||
|
printf("\nBenchmark complete.\n");
|
||||||
|
|
||||||
|
delete[] ptrs;
|
||||||
|
delete service;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MARTe::RunBenchmark();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+139
-190
@@ -1,253 +1,202 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "BasicUDPSocket.h"
|
|
||||||
#include "DebugService.h"
|
#include "DebugService.h"
|
||||||
|
#include "DebugCore.h"
|
||||||
#include "ObjectRegistryDatabase.h"
|
#include "ObjectRegistryDatabase.h"
|
||||||
#include "RealTimeApplication.h"
|
|
||||||
#include "StandardParser.h"
|
#include "StandardParser.h"
|
||||||
#include "StreamString.h"
|
#include "StreamString.h"
|
||||||
|
#include "BasicUDPSocket.h"
|
||||||
|
#include "BasicTCPSocket.h"
|
||||||
|
#include "RealTimeApplication.h"
|
||||||
#include "GlobalObjectsDatabase.h"
|
#include "GlobalObjectsDatabase.h"
|
||||||
|
#include "MessageI.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace MARTe;
|
using namespace MARTe;
|
||||||
|
|
||||||
const char8 * const scheduler_config_text =
|
const char8 * const config_text =
|
||||||
"DebugService = {"
|
"+DebugService = {"
|
||||||
" Class = DebugService "
|
" Class = DebugService "
|
||||||
" ControlPort = 8098 "
|
" ControlPort = 8080 "
|
||||||
" UdpPort = 8099 "
|
" UdpPort = 8081 "
|
||||||
" StreamIP = \"127.0.0.1\" "
|
" StreamIP = \"127.0.0.1\" "
|
||||||
"}"
|
"}"
|
||||||
"App = {"
|
"+App = {"
|
||||||
" Class = RealTimeApplication "
|
" Class = RealTimeApplication "
|
||||||
" +Functions = {"
|
" +Functions = {"
|
||||||
" Class = ReferenceContainer "
|
" Class = ReferenceContainer "
|
||||||
" +GAM1 = {"
|
" +GAM1 = {"
|
||||||
" Class = IOGAM "
|
" Class = IOGAM "
|
||||||
" InputSignals = {"
|
" InputSignals = {"
|
||||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
" Counter = {"
|
||||||
" Time = { DataSource = Timer Type = uint32 }"
|
" DataSource = Timer "
|
||||||
|
" Type = uint32 "
|
||||||
|
" }"
|
||||||
" }"
|
" }"
|
||||||
" OutputSignals = {"
|
" OutputSignals = {"
|
||||||
" Counter = { DataSource = DDB Type = uint32 }"
|
" Counter = {"
|
||||||
" Time = { DataSource = DDB Type = uint32 }"
|
" DataSource = DDB "
|
||||||
|
" Type = uint32 "
|
||||||
|
" }"
|
||||||
" }"
|
" }"
|
||||||
" }"
|
" }"
|
||||||
" }"
|
" }"
|
||||||
" +Data = {"
|
" +Data = {"
|
||||||
" Class = ReferenceContainer "
|
" Class = ReferenceContainer "
|
||||||
" DefaultDataSource = DDB "
|
" DefaultDataSource = DDB "
|
||||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } Time = { Type = uint32 } } }"
|
" +Timer = {"
|
||||||
" +DDB = { Class = GAMDataSource Signals = { Counter = { Type = uint32 } Time = { Type = uint32 } } }"
|
" Class = LinuxTimer "
|
||||||
|
" SleepTime = 100000 " // 100ms
|
||||||
|
" Signals = {"
|
||||||
|
" Counter = { Type = uint32 }"
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" +DDB = {"
|
||||||
|
" Class = GAMDataSource "
|
||||||
|
" Signals = { Counter = { Type = uint32 } }"
|
||||||
|
" }"
|
||||||
" +DAMS = { Class = TimingDataSource }"
|
" +DAMS = { Class = TimingDataSource }"
|
||||||
" }"
|
" }"
|
||||||
" +States = {"
|
" +States = {"
|
||||||
" Class = ReferenceContainer "
|
" Class = ReferenceContainer "
|
||||||
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1} } } }"
|
" +State1 = {"
|
||||||
|
" Class = RealTimeState "
|
||||||
|
" +Threads = {"
|
||||||
|
" Class = ReferenceContainer "
|
||||||
|
" +Thread1 = {"
|
||||||
|
" Class = RealTimeThread "
|
||||||
|
" Functions = {GAM1} "
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
" +Scheduler = {"
|
||||||
|
" Class = FastScheduler "
|
||||||
|
" TimingDataSource = DAMS "
|
||||||
" }"
|
" }"
|
||||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
void TestSchedulerControl() {
|
void TestSchedulerControl() {
|
||||||
printf("--- MARTe2 Scheduler Control Test ---\n");
|
printf("--- MARTe2 Scheduler Control Test ---\n");
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
ConfigurationDatabase cdb;
|
||||||
|
StreamString ss = config_text;
|
||||||
|
ss.Seek(0);
|
||||||
|
StandardParser parser(ss, cdb);
|
||||||
|
assert(parser.Parse());
|
||||||
|
assert(ObjectRegistryDatabase::Instance()->Initialise(cdb));
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
ReferenceT<DebugService> service = ObjectRegistryDatabase::Instance()->Find("DebugService");
|
||||||
StreamString ss = scheduler_config_text;
|
assert(service.IsValid());
|
||||||
ss.Seek(0);
|
|
||||||
StandardParser parser(ss, cdb);
|
|
||||||
if (!parser.Parse()) {
|
|
||||||
printf("ERROR: Failed to parse configuration\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cdb.MoveToRoot();
|
ReferenceT<RealTimeApplication> app = ObjectRegistryDatabase::Instance()->Find("App");
|
||||||
uint32 n = cdb.GetNumberOfChildren();
|
assert(app.IsValid());
|
||||||
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;
|
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
||||||
child.Read("Class", className);
|
printf("ERROR: Failed to prepare State1\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Reference ref(className.Buffer(), GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
||||||
if (!ref.IsValid()) {
|
printf("ERROR: Failed to start execution\n");
|
||||||
printf("ERROR: Could not create object %s of class %s\n", name, className.Buffer());
|
return;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
ref->SetName(name);
|
|
||||||
if (!ref->Initialise(child)) {
|
|
||||||
printf("ERROR: Failed to initialise object %s\n", name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReferenceT<DebugService> service =
|
printf("Application started. Waiting for cycles...\n");
|
||||||
ObjectRegistryDatabase::Instance()->Find("DebugService");
|
Sleep::MSec(1000);
|
||||||
if (!service.IsValid()) {
|
|
||||||
printf("ERROR: DebugService not found in registry\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
service->SetFullConfig(cdb);
|
|
||||||
|
|
||||||
ReferenceT<RealTimeApplication> app =
|
// Enable Trace First
|
||||||
ObjectRegistryDatabase::Instance()->Find("App");
|
{
|
||||||
if (!app.IsValid()) {
|
|
||||||
printf("ERROR: App not found in registry\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!app->ConfigureApplication()) {
|
|
||||||
printf("ERROR: ConfigureApplication failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(2000);
|
|
||||||
|
|
||||||
// Enable Trace First - with retry logic
|
|
||||||
{
|
|
||||||
bool connected = false;
|
|
||||||
for (int retry=0; retry<10 && !connected; retry++) {
|
|
||||||
BasicTCPSocket tClient;
|
BasicTCPSocket tClient;
|
||||||
if (tClient.Open()) {
|
if (tClient.Connect("127.0.0.1", 8080)) {
|
||||||
if (tClient.Connect("127.0.0.1", 8098)) {
|
const char* cmd = "TRACE Root.App.Data.Timer.Counter 1\n";
|
||||||
connected = true;
|
uint32 s = StringHelper::Length(cmd);
|
||||||
const char *cmd = "TRACE App.Data.Timer.Counter 1\n";
|
tClient.Write(cmd, s);
|
||||||
uint32 s = StringHelper::Length(cmd);
|
tClient.Close();
|
||||||
tClient.Write(cmd, s);
|
|
||||||
tClient.Close();
|
|
||||||
} else {
|
|
||||||
printf("[SchedulerTest] Connect failed (retry %d)\n", retry);
|
|
||||||
Sleep::MSec(500);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
printf("[SchedulerTest] Open failed (retry %d)\n", retry);
|
printf("WARNING: Could not connect to DebugService to enable trace.\n");
|
||||||
Sleep::MSec(500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connected) {
|
BasicUDPSocket listener;
|
||||||
printf("WARNING: Could not connect to DebugService to enable trace.\n");
|
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");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BasicUDPSocket listener;
|
// Send PAUSE
|
||||||
listener.Open();
|
printf("Sending PAUSE command...\n");
|
||||||
listener.Listen(8099);
|
BasicTCPSocket client;
|
||||||
|
if (client.Connect("127.0.0.1", 8080)) {
|
||||||
// Read current value
|
const char* cmd = "PAUSE\n";
|
||||||
uint32 valBeforePause = 0;
|
uint32 s = StringHelper::Length(cmd);
|
||||||
char buffer[2048];
|
client.Write(cmd, s);
|
||||||
uint32 size = 2048;
|
client.Close();
|
||||||
TimeoutType timeout(1000);
|
} else {
|
||||||
if (listener.Read(buffer, size, timeout)) {
|
|
||||||
// [Header][ID][Size][Value]
|
|
||||||
valBeforePause = *(uint32 *)(&buffer[sizeof(TraceHeader) + 16]);
|
|
||||||
printf("Value before/at pause: %u\n", valBeforePause);
|
|
||||||
} else {
|
|
||||||
printf("WARNING: No data received before pause.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send PAUSE
|
|
||||||
printf("Sending PAUSE command...\n");
|
|
||||||
{
|
|
||||||
bool connected = false;
|
|
||||||
for (int retry=0; retry<10 && !connected; retry++) {
|
|
||||||
BasicTCPSocket client;
|
|
||||||
if (client.Open()) {
|
|
||||||
if (client.Connect("127.0.0.1", 8098)) {
|
|
||||||
connected = true;
|
|
||||||
const char *cmd = "PAUSE\n";
|
|
||||||
uint32 s = StringHelper::Length(cmd);
|
|
||||||
client.Write(cmd, s);
|
|
||||||
client.Close();
|
|
||||||
} else {
|
|
||||||
Sleep::MSec(200);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Sleep::MSec(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!connected) {
|
|
||||||
printf("ERROR: Could not connect to DebugService to send PAUSE.\n");
|
printf("ERROR: Could not connect to DebugService to send PAUSE.\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Sleep::MSec(2000); // Wait 2 seconds
|
Sleep::MSec(2000); // Wait 2 seconds
|
||||||
|
|
||||||
// Read again - should be same or very close if paused
|
// Read again - should be same or very close if paused
|
||||||
uint32 valAfterWait = 0;
|
uint32 valAfterWait = 0;
|
||||||
size = 2048; // Reset size
|
size = 2048; // Reset size
|
||||||
while (listener.Read(buffer, size, TimeoutType(100))) {
|
while(listener.Read(buffer, size, TimeoutType(10))) {
|
||||||
valAfterWait = *(uint32 *)(&buffer[sizeof(TraceHeader) + 16]);
|
valAfterWait = *(uint32*)(&buffer[28]);
|
||||||
size = 2048;
|
size = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Value after 2s wait (drained): %u\n", valAfterWait);
|
printf("Value after 2s wait (drained): %u\n", valAfterWait);
|
||||||
|
|
||||||
// Check if truly paused
|
// Check if truly paused
|
||||||
if (valAfterWait > valBeforePause + 10) {
|
if (valAfterWait > valBeforePause + 5) {
|
||||||
printf(
|
printf("FAILURE: Counter increased significantly while paused! (%u -> %u)\n", valBeforePause, valAfterWait);
|
||||||
"FAILURE: Counter increased significantly while paused! (%u -> %u)\n",
|
} else {
|
||||||
valBeforePause, valAfterWait);
|
printf("SUCCESS: Counter held steady (or close) during pause.\n");
|
||||||
} else {
|
}
|
||||||
printf("SUCCESS: Counter held steady (or close) during pause.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resume
|
// Resume
|
||||||
printf("Sending RESUME command...\n");
|
printf("Sending RESUME command...\n");
|
||||||
{
|
{
|
||||||
bool connected = false;
|
|
||||||
for (int retry=0; retry<10 && !connected; retry++) {
|
|
||||||
BasicTCPSocket rClient;
|
BasicTCPSocket rClient;
|
||||||
if (rClient.Open()) {
|
if (rClient.Connect("127.0.0.1", 8080)) {
|
||||||
if (rClient.Connect("127.0.0.1", 8098)) {
|
const char* cmd = "RESUME\n";
|
||||||
connected = true;
|
uint32 s = StringHelper::Length(cmd);
|
||||||
const char *cmd = "RESUME\n";
|
rClient.Write(cmd, s);
|
||||||
uint32 s = StringHelper::Length(cmd);
|
rClient.Close();
|
||||||
rClient.Write(cmd, s);
|
|
||||||
rClient.Close();
|
|
||||||
} else {
|
|
||||||
Sleep::MSec(200);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Sleep::MSec(200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Sleep::MSec(1000);
|
Sleep::MSec(1000);
|
||||||
|
|
||||||
// Check if increasing
|
// Check if increasing
|
||||||
uint32 valAfterResume = 0;
|
uint32 valAfterResume = 0;
|
||||||
size = 2048;
|
size = 2048;
|
||||||
if (listener.Read(buffer, size, timeout)) {
|
if (listener.Read(buffer, size, timeout)) {
|
||||||
valAfterResume = *(uint32 *)(&buffer[sizeof(TraceHeader) + 16]);
|
valAfterResume = *(uint32*)(&buffer[28]);
|
||||||
printf("Value after resume: %u\n", valAfterResume);
|
printf("Value after resume: %u\n", valAfterResume);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valAfterResume > valAfterWait) {
|
if (valAfterResume > valAfterWait) {
|
||||||
printf("SUCCESS: Execution resumed.\n");
|
printf("SUCCESS: Execution resumed.\n");
|
||||||
} else {
|
} else {
|
||||||
printf("FAILURE: Execution did not resume.\n");
|
printf("FAILURE: Execution did not resume.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
app->StopCurrentStateExecution();
|
app->StopCurrentStateExecution();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
TestSchedulerControl();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
#include "TestCommon.h"
|
|
||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "StringHelper.h"
|
|
||||||
#include "TimeoutType.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
const char8 * const debug_test_config =
|
|
||||||
"DebugService = {"
|
|
||||||
" Class = DebugService "
|
|
||||||
" ControlPort = 8095 "
|
|
||||||
" UdpPort = 8096 "
|
|
||||||
" StreamIP = \"127.0.0.1\" "
|
|
||||||
"}"
|
|
||||||
"App = {"
|
|
||||||
" Class = RealTimeApplication "
|
|
||||||
" +Functions = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" +GAM1 = {"
|
|
||||||
" Class = IOGAM "
|
|
||||||
" InputSignals = {"
|
|
||||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
|
||||||
" }"
|
|
||||||
" OutputSignals = {"
|
|
||||||
" Counter = { DataSource = DDB Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" +GAM2 = {"
|
|
||||||
" Class = IOGAM "
|
|
||||||
" InputSignals = {"
|
|
||||||
" Counter = { DataSource = TimerSlow Type = uint32 Frequency = 10 }"
|
|
||||||
" }"
|
|
||||||
" OutputSignals = {"
|
|
||||||
" Counter = { DataSource = Logger Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" +Data = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" DefaultDataSource = DDB "
|
|
||||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } } }"
|
|
||||||
" +TimerSlow = { Class = LinuxTimer SleepTime = 100000 Signals = { Counter = { Type = uint32 } } }"
|
|
||||||
" +Logger = { Class = LoggerDataSource 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 GAM2} } } }"
|
|
||||||
" }"
|
|
||||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
|
||||||
"}";
|
|
||||||
|
|
||||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply) {
|
|
||||||
BasicTCPSocket client;
|
|
||||||
if (!client.Open()) return false;
|
|
||||||
if (!client.Connect("127.0.0.1", port)) return false;
|
|
||||||
|
|
||||||
uint32 s = StringHelper::Length(cmd);
|
|
||||||
if (!client.Write(cmd, s)) return false;
|
|
||||||
|
|
||||||
char buffer[16384];
|
|
||||||
uint32 size = 16384;
|
|
||||||
TimeoutType timeout(5000);
|
|
||||||
if (client.Read(buffer, size, timeout)) {
|
|
||||||
reply.Write(buffer, size);
|
|
||||||
client.Close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
client.Close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#ifndef TESTCOMMON_H
|
|
||||||
#define TESTCOMMON_H
|
|
||||||
|
|
||||||
#include "CompilerTypes.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
extern const char8 * const debug_test_config;
|
|
||||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply);
|
|
||||||
void TestMessageCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "BasicUDPSocket.h"
|
|
||||||
#include "DebugService.h"
|
#include "DebugService.h"
|
||||||
|
#include "DebugCore.h"
|
||||||
#include "ObjectRegistryDatabase.h"
|
#include "ObjectRegistryDatabase.h"
|
||||||
#include "StandardParser.h"
|
#include "StandardParser.h"
|
||||||
#include "StreamString.h"
|
#include "StreamString.h"
|
||||||
|
#include "BasicUDPSocket.h"
|
||||||
#include "HighResolutionTimer.h"
|
#include "HighResolutionTimer.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -12,22 +12,20 @@ using namespace MARTe;
|
|||||||
|
|
||||||
void TestFullTracePipeline() {
|
void TestFullTracePipeline() {
|
||||||
printf("Starting Full Trace Pipeline Test...\n");
|
printf("Starting Full Trace Pipeline Test...\n");
|
||||||
|
printf("sizeof(TraceHeader) = %lu\n", sizeof(TraceHeader));
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
// 1. Setup Service
|
// 1. Setup Service
|
||||||
DebugService service;
|
DebugService service;
|
||||||
ConfigurationDatabase config;
|
ConfigurationDatabase config;
|
||||||
config.Write("ControlPort", (uint16)8082);
|
config.Write("ControlPort", (uint16)8080);
|
||||||
config.Write("StreamPort", (uint16)8083);
|
config.Write("StreamPort", (uint16)8081);
|
||||||
config.Write("LogPort", (uint16)8084);
|
config.Write("LogPort", (uint16)8082);
|
||||||
config.Write("StreamIP", "127.0.0.1");
|
config.Write("StreamIP", "127.0.0.1");
|
||||||
assert(service.Initialise(config));
|
assert(service.Initialise(config));
|
||||||
Sleep::MSec(500);
|
|
||||||
|
|
||||||
// 2. Register a mock signal
|
// 2. Register a mock signal
|
||||||
uint32 mockValue = 0;
|
uint32 mockValue = 0;
|
||||||
DebugSignalInfo* sig = service.RegisterSignal(&mockValue, UnsignedInteger32Bit, "TraceTest.Signal", 0, 1);
|
DebugSignalInfo* sig = service.RegisterSignal(&mockValue, UnsignedInteger32Bit, "Test.Signal");
|
||||||
assert(sig != NULL_PTR(DebugSignalInfo*));
|
assert(sig != NULL_PTR(DebugSignalInfo*));
|
||||||
printf("Signal registered with ID: %u\n", sig->internalID);
|
printf("Signal registered with ID: %u\n", sig->internalID);
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ void TestFullTracePipeline() {
|
|||||||
// 4. Setup a local UDP listener
|
// 4. Setup a local UDP listener
|
||||||
BasicUDPSocket listener;
|
BasicUDPSocket listener;
|
||||||
assert(listener.Open());
|
assert(listener.Open());
|
||||||
assert(listener.Listen(8083));
|
assert(listener.Listen(8081));
|
||||||
|
|
||||||
// 5. Simulate cycles
|
// 5. Simulate cycles
|
||||||
printf("Simulating cycles...\n");
|
printf("Simulating cycles...\n");
|
||||||
@@ -55,6 +53,12 @@ void TestFullTracePipeline() {
|
|||||||
TimeoutType timeout(1000); // 1s
|
TimeoutType timeout(1000); // 1s
|
||||||
if (listener.Read(buffer, size, timeout)) {
|
if (listener.Read(buffer, size, timeout)) {
|
||||||
printf("SUCCESS: Received %u bytes over UDP!\n", size);
|
printf("SUCCESS: Received %u bytes over UDP!\n", size);
|
||||||
|
for(uint32 i=0; i<size; i++) {
|
||||||
|
printf("%02X ", (uint8)buffer[i]);
|
||||||
|
if((i+1)%4 == 0) printf("| ");
|
||||||
|
if((i+1)%16 == 0) printf("\n");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
TraceHeader *h = (TraceHeader*)buffer;
|
TraceHeader *h = (TraceHeader*)buffer;
|
||||||
printf("Header: Magic=0x%X, Count=%u, Seq=%u\n", h->magic, h->count, h->seq);
|
printf("Header: Magic=0x%X, Count=%u, Seq=%u\n", h->magic, h->count, h->seq);
|
||||||
@@ -64,7 +68,7 @@ void TestFullTracePipeline() {
|
|||||||
uint32 recId = *(uint32*)(&buffer[offset]);
|
uint32 recId = *(uint32*)(&buffer[offset]);
|
||||||
uint64 recTs = *(uint64*)(&buffer[offset + 4]);
|
uint64 recTs = *(uint64*)(&buffer[offset + 4]);
|
||||||
uint32 recSize = *(uint32*)(&buffer[offset + 12]);
|
uint32 recSize = *(uint32*)(&buffer[offset + 12]);
|
||||||
printf("Data: ID=%u, TS=%llu, Size=%u\n", recId, (unsigned long long)recTs, recSize);
|
printf("Data: ID=%u, TS=%lu, Size=%u\n", recId, recTs, recSize);
|
||||||
if (size >= offset + 16 + recSize) {
|
if (size >= offset + 16 + recSize) {
|
||||||
if (recSize == 4) {
|
if (recSize == 4) {
|
||||||
uint32 recVal = *(uint32*)(&buffer[offset + 16]);
|
uint32 recVal = *(uint32*)(&buffer[offset + 16]);
|
||||||
@@ -78,3 +82,8 @@ void TestFullTracePipeline() {
|
|||||||
|
|
||||||
listener.Close();
|
listener.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
TestFullTracePipeline();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "GlobalObjectsDatabase.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
#include "RealTimeApplication.h"
|
|
||||||
#include "StandardParser.h"
|
|
||||||
#include "StreamString.h"
|
|
||||||
#include "TestCommon.h"
|
|
||||||
#include "IOGAM.h"
|
|
||||||
#include "LinuxTimer.h"
|
|
||||||
#include "GAMDataSource.h"
|
|
||||||
#include "TimingDataSource.h"
|
|
||||||
#include "GAMScheduler.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace MARTe;
|
|
||||||
|
|
||||||
void TestTreeCommand() {
|
|
||||||
printf("--- Test: TREE Command Enhancement ---\n");
|
|
||||||
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
Sleep::MSec(2000); // Wait for sockets from previous tests to clear
|
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
|
||||||
// Use unique ports to avoid conflict with other tests
|
|
||||||
const char8 * const tree_test_config =
|
|
||||||
"DebugService = {"
|
|
||||||
" Class = DebugService "
|
|
||||||
" ControlPort = 8110 "
|
|
||||||
" UdpPort = 8111 "
|
|
||||||
" StreamIP = \"127.0.0.1\" "
|
|
||||||
"}"
|
|
||||||
"App = {"
|
|
||||||
" Class = RealTimeApplication "
|
|
||||||
" +Functions = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" +GAM1 = {"
|
|
||||||
" Class = IOGAM "
|
|
||||||
" InputSignals = {"
|
|
||||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
|
||||||
" Time = { DataSource = Timer Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" OutputSignals = {"
|
|
||||||
" Counter = { DataSource = DDB Type = uint32 }"
|
|
||||||
" Time = { DataSource = DDB Type = uint32 }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
" +Data = {"
|
|
||||||
" Class = ReferenceContainer "
|
|
||||||
" DefaultDataSource = DDB "
|
|
||||||
" +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 }"
|
|
||||||
"}";
|
|
||||||
|
|
||||||
StreamString ss = tree_test_config;
|
|
||||||
ss.Seek(0);
|
|
||||||
StandardParser parser(ss, cdb);
|
|
||||||
if (!parser.Parse()) {
|
|
||||||
printf("ERROR: Failed to parse config\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
if (!ref.IsValid()) {
|
|
||||||
printf("ERROR: Could not create object %s of class %s\n", name,
|
|
||||||
className.Buffer());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ref->SetName(name);
|
|
||||||
if (!ref->Initialise(child)) {
|
|
||||||
printf("ERROR: Failed to initialise object %s\n", name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReferenceT<DebugService> service =
|
|
||||||
ObjectRegistryDatabase::Instance()->Find("DebugService");
|
|
||||||
if (!service.IsValid()) {
|
|
||||||
printf("ERROR: DebugService not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
service->SetFullConfig(cdb);
|
|
||||||
|
|
||||||
ReferenceT<RealTimeApplication> app =
|
|
||||||
ObjectRegistryDatabase::Instance()->Find("App");
|
|
||||||
if (!app.IsValid()) {
|
|
||||||
printf("ERROR: App not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!app->ConfigureApplication()) {
|
|
||||||
printf("ERROR: ConfigureApplication failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
|
||||||
printf("ERROR: PrepareNextState failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
|
||||||
printf("ERROR: StartNextStateExecution failed.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Application started.\n");
|
|
||||||
Sleep::MSec(1000);
|
|
||||||
|
|
||||||
// Step 1: Request TREE
|
|
||||||
StreamString reply;
|
|
||||||
if (SendCommandGAM(8110, "TREE\n", reply)) {
|
|
||||||
printf("TREE response received (len=%llu)\n", reply.Size());
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2: SERVICE_INFO
|
|
||||||
printf("\n--- Step 2: SERVICE_INFO ---\n");
|
|
||||||
reply = "";
|
|
||||||
if (SendCommandGAM(8110, "SERVICE_INFO\n", reply)) {
|
|
||||||
printf("SERVICE_INFO response: %s", reply.Buffer());
|
|
||||||
if (StringHelper::SearchString(reply.Buffer(), "TCP_CTRL:8110") != NULL_PTR(const char8 *) &&
|
|
||||||
StringHelper::SearchString(reply.Buffer(), "UDP_STREAM:8111") != NULL_PTR(const char8 *)) {
|
|
||||||
printf("SUCCESS: SERVICE_INFO returned correct ports.\n");
|
|
||||||
} else {
|
|
||||||
printf("FAILURE: SERVICE_INFO returned incorrect data.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 3: MONITOR
|
|
||||||
printf("\n--- Step 3: MONITOR SIGNAL ---\n");
|
|
||||||
reply = "";
|
|
||||||
if (SendCommandGAM(8110, "MONITOR SIGNAL App.Data.Timer.Counter 10\n", reply)) {
|
|
||||||
printf("MONITOR response: %s", reply.Buffer());
|
|
||||||
if (StringHelper::SearchString(reply.Buffer(), "OK MONITOR 1") != NULL_PTR(const char8 *)) {
|
|
||||||
printf("SUCCESS: Signal monitored.\n");
|
|
||||||
} else {
|
|
||||||
printf("FAILURE: Could not monitor signal.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 4: UNMONITOR
|
|
||||||
printf("\n--- Step 4: UNMONITOR SIGNAL ---\n");
|
|
||||||
reply = "";
|
|
||||||
if (SendCommandGAM(8110, "UNMONITOR SIGNAL App.Data.Timer.Counter\n", reply)) {
|
|
||||||
printf("UNMONITOR response: %s", reply.Buffer());
|
|
||||||
if (StringHelper::SearchString(reply.Buffer(), "OK UNMONITOR 1") != NULL_PTR(const char8 *)) {
|
|
||||||
printf("SUCCESS: Signal unmonitored.\n");
|
|
||||||
} else {
|
|
||||||
printf("FAILURE: Could not unmonitor signal.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app->StopCurrentStateExecution();
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
#include "BasicTCPSocket.h"
|
|
||||||
#include "BasicUDPSocket.h"
|
|
||||||
#include "DebugService.h"
|
#include "DebugService.h"
|
||||||
|
#include "DebugCore.h"
|
||||||
#include "ObjectRegistryDatabase.h"
|
#include "ObjectRegistryDatabase.h"
|
||||||
#include "RealTimeApplication.h"
|
|
||||||
#include "StandardParser.h"
|
#include "StandardParser.h"
|
||||||
#include "StreamString.h"
|
#include "StreamString.h"
|
||||||
|
#include "BasicUDPSocket.h"
|
||||||
|
#include "BasicTCPSocket.h"
|
||||||
|
#include "RealTimeApplication.h"
|
||||||
#include "GlobalObjectsDatabase.h"
|
#include "GlobalObjectsDatabase.h"
|
||||||
|
#include "RealTimeLoader.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace MARTe;
|
using namespace MARTe;
|
||||||
|
|
||||||
const char8 * const validation_config =
|
// Removed '+' prefix from names for simpler lookup
|
||||||
|
const char8 * const simple_config =
|
||||||
"DebugService = {"
|
"DebugService = {"
|
||||||
" Class = DebugService "
|
" Class = DebugService "
|
||||||
" ControlPort = 8085 "
|
" ControlPort = 8080 "
|
||||||
" UdpPort = 8086 "
|
" UdpPort = 8081 "
|
||||||
" StreamIP = \"127.0.0.1\" "
|
" StreamIP = \"127.0.0.1\" "
|
||||||
"}"
|
"}"
|
||||||
"App = {"
|
"App = {"
|
||||||
@@ -54,7 +58,7 @@ void RunValidationTest() {
|
|||||||
ObjectRegistryDatabase::Instance()->Purge();
|
ObjectRegistryDatabase::Instance()->Purge();
|
||||||
|
|
||||||
ConfigurationDatabase cdb;
|
ConfigurationDatabase cdb;
|
||||||
StreamString ss = validation_config;
|
StreamString ss = simple_config;
|
||||||
ss.Seek(0);
|
ss.Seek(0);
|
||||||
StandardParser parser(ss, cdb);
|
StandardParser parser(ss, cdb);
|
||||||
assert(parser.Parse());
|
assert(parser.Parse());
|
||||||
@@ -81,7 +85,7 @@ void RunValidationTest() {
|
|||||||
Reference appGeneric = ObjectRegistryDatabase::Instance()->Find("App");
|
Reference appGeneric = ObjectRegistryDatabase::Instance()->Find("App");
|
||||||
|
|
||||||
if (!serviceGeneric.IsValid() || !appGeneric.IsValid()) {
|
if (!serviceGeneric.IsValid() || !appGeneric.IsValid()) {
|
||||||
printf("ERROR: Objects NOT FOUND in ValidationTest\n");
|
printf("ERROR: Objects NOT FOUND even without prefix\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,10 +95,8 @@ void RunValidationTest() {
|
|||||||
assert(service);
|
assert(service);
|
||||||
assert(app);
|
assert(app);
|
||||||
|
|
||||||
service->SetFullConfig(cdb);
|
|
||||||
|
|
||||||
if (!app->ConfigureApplication()) {
|
if (!app->ConfigureApplication()) {
|
||||||
printf("ERROR: ConfigureApplication failed in ValidationTest.\n");
|
printf("ERROR: ConfigureApplication failed.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,46 +104,58 @@ void RunValidationTest() {
|
|||||||
assert(app->StartNextStateExecution() == ErrorManagement::NoError);
|
assert(app->StartNextStateExecution() == ErrorManagement::NoError);
|
||||||
|
|
||||||
printf("Application started at 1kHz. Enabling Traces...\n");
|
printf("Application started at 1kHz. Enabling Traces...\n");
|
||||||
Sleep::MSec(1000);
|
Sleep::MSec(500);
|
||||||
|
|
||||||
if (service->TraceSignal("App.Data.Timer.Counter", true, 1) == 0) {
|
// The registered name in DebugBrokerWrapper depends on GetFullObjectName
|
||||||
printf("ERROR: Failed to enable trace for App.Data.Timer.Counter\n");
|
// With App as root, it should be App.Data.Timer.Counter
|
||||||
}
|
service->TraceSignal("App.Data.Timer.Counter", true, 1);
|
||||||
|
|
||||||
BasicUDPSocket listener;
|
BasicUDPSocket listener;
|
||||||
listener.Open();
|
listener.Open();
|
||||||
listener.Listen(8086);
|
listener.Listen(8081);
|
||||||
|
|
||||||
printf("Validating for 10 seconds...\n");
|
printf("Validating for 10 seconds...\n");
|
||||||
uint32 totalPackets = 0;
|
|
||||||
|
uint32 lastCounter = 0;
|
||||||
|
bool first = true;
|
||||||
uint32 totalSamples = 0;
|
uint32 totalSamples = 0;
|
||||||
uint32 discontinuities = 0;
|
uint32 discontinuities = 0;
|
||||||
uint32 lastValue = 0xFFFFFFFF;
|
uint32 totalPackets = 0;
|
||||||
|
|
||||||
uint64 start = HighResolutionTimer::Counter();
|
float64 startTest = HighResolutionTimer::Counter() * HighResolutionTimer::Period();
|
||||||
float64 elapsed = 0;
|
|
||||||
while (elapsed < 10.0) {
|
while ((HighResolutionTimer::Counter() * HighResolutionTimer::Period() - startTest) < 10.0) {
|
||||||
char buffer[2048];
|
char buffer[4096];
|
||||||
uint32 size = 2048;
|
uint32 size = 4096;
|
||||||
if (listener.Read(buffer, size, TimeoutType(100))) {
|
if (listener.Read(buffer, size, TimeoutType(100))) {
|
||||||
totalPackets++;
|
totalPackets++;
|
||||||
TraceHeader *h = (TraceHeader*)buffer;
|
TraceHeader *h = (TraceHeader*)buffer;
|
||||||
|
if (h->magic != 0xDA7A57AD) continue;
|
||||||
|
|
||||||
uint32 offset = sizeof(TraceHeader);
|
uint32 offset = sizeof(TraceHeader);
|
||||||
for (uint32 i=0; i<h->count; i++) {
|
for (uint32 i=0; i<h->count; i++) {
|
||||||
uint32 recId = *(uint32*)(&buffer[offset]);
|
if (offset + 16 > size) break;
|
||||||
uint32 recSize = *(uint32*)(&buffer[offset + 12]);
|
|
||||||
if (recSize == 4) {
|
uint32 sigId = *(uint32*)(&buffer[offset]);
|
||||||
|
uint32 sigSize = *(uint32*)(&buffer[offset + 12]);
|
||||||
|
|
||||||
|
if (offset + 16 + sigSize > size) break;
|
||||||
|
|
||||||
|
if (sigId == 0 && sigSize == 4) {
|
||||||
uint32 val = *(uint32*)(&buffer[offset + 16]);
|
uint32 val = *(uint32*)(&buffer[offset + 16]);
|
||||||
totalSamples++;
|
if (!first) {
|
||||||
if (lastValue != 0xFFFFFFFF && val != lastValue + 1) {
|
if (val != lastCounter + 1) {
|
||||||
discontinuities++;
|
discontinuities++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastValue = val;
|
lastCounter = val;
|
||||||
|
totalSamples++;
|
||||||
}
|
}
|
||||||
offset += (16 + recSize);
|
|
||||||
|
offset += (16 + sigSize);
|
||||||
}
|
}
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
elapsed = (float64)(HighResolutionTimer::Counter() - start) * HighResolutionTimer::Period();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n--- Test Results ---\n");
|
printf("\n--- Test Results ---\n");
|
||||||
@@ -151,11 +165,17 @@ void RunValidationTest() {
|
|||||||
|
|
||||||
if (totalSamples < 9000) {
|
if (totalSamples < 9000) {
|
||||||
printf("FAILURE: Underflow - samples missing (%u).\n", totalSamples);
|
printf("FAILURE: Underflow - samples missing (%u).\n", totalSamples);
|
||||||
} else if (discontinuities > 50) {
|
} else if (discontinuities > 10) {
|
||||||
printf("FAILURE: Excessive discontinuities detected! (%u)\n", discontinuities);
|
printf("FAILURE: Excessive discontinuities detected! (%u)\n", discontinuities);
|
||||||
} else {
|
} else {
|
||||||
printf("VALIDATION SUCCESSFUL: 1kHz Lossless Tracing Verified.\n");
|
printf("VALIDATION SUCCESSFUL: 1kHz Lossless Tracing Verified.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
app->StopCurrentStateExecution();
|
app->StopCurrentStateExecution();
|
||||||
|
ObjectRegistryDatabase::Instance()->Purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
RunValidationTest();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "DebugService.h"
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
#include "ConfigurationDatabase.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "ClassRegistryDatabase.h"
|
||||||
|
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
void timeout_handler(int sig) {
|
||||||
|
printf("Test timed out!\n");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
signal(SIGALRM, timeout_handler);
|
||||||
|
alarm(5); // 5 seconds timeout
|
||||||
|
printf("MARTe2 Debug Suite Integration Test\n");
|
||||||
|
|
||||||
|
{
|
||||||
|
// 1. Manually trigger Registry Patching
|
||||||
|
DebugService service;
|
||||||
|
ConfigurationDatabase serviceData;
|
||||||
|
serviceData.Write("ControlPort", (uint16)9090);
|
||||||
|
service.Initialise(serviceData);
|
||||||
|
|
||||||
|
printf("DebugService initialized and Registry Patched.\n");
|
||||||
|
|
||||||
|
// 2. Try to create a MemoryMapInputBroker
|
||||||
|
ClassRegistryItem *item = ClassRegistryDatabase::Instance()->Find("MemoryMapInputBroker");
|
||||||
|
if (item != NULL_PTR(ClassRegistryItem *)) {
|
||||||
|
Object *obj = item->GetObjectBuilder()->Build(GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||||
|
if (obj != NULL_PTR(Object *)) {
|
||||||
|
printf("Instantiated Broker Class: %s\n", obj->GetClassProperties()->GetName());
|
||||||
|
printf("Success: Broker patched and instantiated.\n");
|
||||||
|
// delete obj;
|
||||||
|
} else {
|
||||||
|
printf("Failed to build broker\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("MemoryMapInputBroker not found in registry\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("DebugService scope finished.\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
include Makefile.inc
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
SPB = UnitTests.x Integration.x
|
|
||||||
|
|
||||||
PACKAGE = Test
|
|
||||||
|
|
||||||
ROOT_DIR = ..
|
|
||||||
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
all: $(SUBPROJ)
|
|
||||||
echo $(SUBPROJ)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
include_directories(
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L0Types
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L1Portability
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L2Objects
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L3Streams
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Configuration
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Events
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Logger
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L4Messages
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L5FILES
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L5GAMs
|
||||||
|
${MARTe2_DIR}/Source/Core/BareMetal/L6App
|
||||||
|
${MARTe2_DIR}/Source/Core/Scheduler/L1Portability
|
||||||
|
${MARTe2_DIR}/Source/Core/Scheduler/L3Services
|
||||||
|
${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
|
||||||
|
../../Source
|
||||||
|
../../Headers
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB SOURCES "*.cpp")
|
||||||
|
|
||||||
|
add_executable(UnitTests ${SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(UnitTests
|
||||||
|
marte_dev
|
||||||
|
${MARTe2_DIR}/Build/${TARGET}/Core/libMARTe2.so
|
||||||
|
)
|
||||||
@@ -1 +0,0 @@
|
|||||||
include Makefile.inc
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
OBJSX =
|
|
||||||
|
|
||||||
PACKAGE = Test/UnitTests
|
|
||||||
|
|
||||||
ROOT_DIR = ../..
|
|
||||||
|
|
||||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
|
||||||
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Result
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Core/Types/Vec
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/DebugService
|
|
||||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/TCPLogger
|
|
||||||
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
|
||||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
|
||||||
|
|
||||||
LIBRARIES += -L$(MARTe2_DIR)/Build/$(TARGET)/Core -lMARTe2
|
|
||||||
LIBRARIES += -L$(ROOT_DIR)/Build/$(TARGET)/Components/Interfaces/DebugService -lDebugService
|
|
||||||
LIBRARIES += -L$(ROOT_DIR)/Build/$(TARGET)/Components/Interfaces/TCPLogger -lTcpLogger
|
|
||||||
|
|
||||||
all: $(OBJS) $(BUILD_DIR)/UnitTests$(EXEEXT)
|
|
||||||
echo $(OBJS)
|
|
||||||
|
|
||||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
|
||||||
@@ -1,717 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "DebugCore.h"
|
|
||||||
#include "DebugService.h"
|
|
||||||
#include "DebugBrokerWrapper.h"
|
|
||||||
#include "TcpLogger.h"
|
|
||||||
#include "ConfigurationDatabase.h"
|
|
||||||
#include "ObjectRegistryDatabase.h"
|
|
||||||
|
|
||||||
namespace MARTe {
|
|
||||||
|
|
||||||
void TestTcpLogger() {
|
|
||||||
printf("Stability Logger Tests...\n");
|
|
||||||
TcpLogger logger;
|
|
||||||
ConfigurationDatabase config;
|
|
||||||
config.Write("Port", (uint32)0); // Random port
|
|
||||||
assert(logger.Initialise(config));
|
|
||||||
}
|
|
||||||
|
|
||||||
class DebugServiceTest {
|
|
||||||
public:
|
|
||||||
static void TestAll() {
|
|
||||||
printf("Stability Logic Tests...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// 1. Signal logic
|
|
||||||
uint32 val = 0;
|
|
||||||
service.RegisterSignal(&val, UnsignedInteger32Bit, "X.Y.Z", 0, 1);
|
|
||||||
assert(service.TraceSignal("Z", true) == 1);
|
|
||||||
assert(service.ForceSignal("Z", "123") == 1);
|
|
||||||
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1.0e9);
|
|
||||||
service.ProcessSignal(service.signals[0], 4, ts);
|
|
||||||
assert(val == 123);
|
|
||||||
service.UnforceSignal("Z");
|
|
||||||
|
|
||||||
// 2. Commands
|
|
||||||
{ StreamString out; service.HandleCommand("TREE", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("DISCOVER", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("CONFIG", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("PAUSE", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("RESUME", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("LS /", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("INFO X.Y.Z", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("MSG DebugService DummyFunc 0 K=V", out); }
|
|
||||||
|
|
||||||
// 3. Broker Active Status
|
|
||||||
volatile bool active = false;
|
|
||||||
Vec<uint32> indices;
|
|
||||||
Vec<uint32> sizes;
|
|
||||||
FastPollingMutexSem mutex;
|
|
||||||
DebugSignalInfo* ptrs[1] = { service.signals[0] };
|
|
||||||
volatile bool anyBreak = false;
|
|
||||||
Vec<uint32> breakIdx;
|
|
||||||
service.RegisterBroker(ptrs, 1, NULL_PTR(MemoryMapBroker*), &active, &indices, &sizes, &mutex, &anyBreak, &breakIdx);
|
|
||||||
service.UpdateBrokersActiveStatus();
|
|
||||||
assert(active == true);
|
|
||||||
assert(indices.Size() == 1);
|
|
||||||
assert(indices[0] == 0);
|
|
||||||
|
|
||||||
// Helper Process
|
|
||||||
DebugBrokerHelper::Process(&service, ptrs, indices, sizes, mutex, &anyBreak, &breakIdx);
|
|
||||||
|
|
||||||
// 4. Step / per-thread filter
|
|
||||||
// STEP with no thread filter — all threads can consume
|
|
||||||
service.Step(2u, NULL_PTR(const char8 *));
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
assert(service.stepRemaining == 2u);
|
|
||||||
service.ConsumeStepIfNeeded("GAM1", "ThreadA");
|
|
||||||
assert(service.stepRemaining == 1u);
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
service.ConsumeStepIfNeeded("GAM1", "ThreadB");
|
|
||||||
assert(service.stepRemaining == 0u);
|
|
||||||
assert(service.IsPaused());
|
|
||||||
assert(service.pausedAtGam == "GAM1");
|
|
||||||
|
|
||||||
// STEP with a thread filter — only matching thread consumes
|
|
||||||
service.Step(2u, "ThreadA");
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
assert(service.stepThreadFilter == "ThreadA");
|
|
||||||
// ThreadB should be ignored
|
|
||||||
service.ConsumeStepIfNeeded("GAMB", "ThreadB");
|
|
||||||
assert(service.stepRemaining == 2u); // unchanged
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
// ThreadA consumes both credits
|
|
||||||
service.ConsumeStepIfNeeded("GAMA1", "ThreadA");
|
|
||||||
assert(service.stepRemaining == 1u);
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
service.ConsumeStepIfNeeded("GAMA2", "ThreadA");
|
|
||||||
assert(service.stepRemaining == 0u);
|
|
||||||
assert(service.IsPaused());
|
|
||||||
assert(service.pausedAtGam == "GAMA2");
|
|
||||||
|
|
||||||
// STEP with unknown thread (NULL threadName arg to ConsumeStep) is also filtered out
|
|
||||||
service.Step(1u, "ThreadA");
|
|
||||||
service.ConsumeStepIfNeeded("X", NULL_PTR(const char8 *));
|
|
||||||
assert(service.stepRemaining == 1u); // not consumed
|
|
||||||
service.SetPaused(false);
|
|
||||||
service.Step(0u, NULL_PTR(const char8 *));
|
|
||||||
|
|
||||||
// 5. VALUE command — smoke test, no crash
|
|
||||||
{ StreamString out; service.HandleCommand("VALUE X.Y.Z", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("VALUE NoSuchSignal", out); }
|
|
||||||
{ StreamString out; service.HandleCommand("STEP 1 ThreadA", out); }
|
|
||||||
assert(service.stepThreadFilter == "ThreadA");
|
|
||||||
{ StreamString out; service.HandleCommand("STEP 3", out); }
|
|
||||||
assert(service.stepThreadFilter.Size() == 0u);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #4: ForceSignal overflow guard
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestForceSignalOversizeRejected() {
|
|
||||||
printf("FIX #4: ForceSignal oversized signal rejected...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// A 256-element float64 array requires 2048 bytes — exceeds forcedValue[1024].
|
|
||||||
// RegisterSignal itself is fine; the overflow guard is in ForceSignal.
|
|
||||||
float64 bigArray[256];
|
|
||||||
memset(bigArray, 0, sizeof(bigArray));
|
|
||||||
service.RegisterSignal(bigArray, Float64Bit, "Big.Array", 1, 256);
|
|
||||||
|
|
||||||
// ForceSignal must reject the request and return 0 matches applied.
|
|
||||||
// (The signal IS found by alias but the size check must veto it.)
|
|
||||||
uint32 forced = service.ForceSignal("Array", "1.0");
|
|
||||||
assert(forced == 0); // rejected — not forced
|
|
||||||
printf(" -> PASS: oversized force correctly rejected\n");
|
|
||||||
|
|
||||||
// A normal scalar float64 (8 bytes) must still be forceable.
|
|
||||||
float64 scalarVal = 0.0;
|
|
||||||
service.RegisterSignal(&scalarVal, Float64Bit, "Small.Scalar", 0, 1);
|
|
||||||
uint32 forcedSmall = service.ForceSignal("Scalar", "3.14");
|
|
||||||
assert(forcedSmall == 1); // accepted
|
|
||||||
printf(" -> PASS: normal scalar force accepted\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #1: Streamer buffer bounds — Pop maxSize respected
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestStreamerPopMaxSize() {
|
|
||||||
printf("FIX #1: TraceRingBuffer Pop respects maxSize...\n");
|
|
||||||
|
|
||||||
TraceRingBuffer rb;
|
|
||||||
assert(rb.Init(4096));
|
|
||||||
|
|
||||||
// Push a 512-byte sample
|
|
||||||
uint8 bigSample[512];
|
|
||||||
memset(bigSample, 0xAB, sizeof(bigSample));
|
|
||||||
assert(rb.Push(42u, 999u, bigSample, 512u));
|
|
||||||
|
|
||||||
// Pop with a maxSize smaller than the pushed size — must return false
|
|
||||||
// and not overflow the destination buffer.
|
|
||||||
uint8 smallBuf[64];
|
|
||||||
uint32 id = 0, size = 0;
|
|
||||||
uint64 ts = 0;
|
|
||||||
bool ok = rb.Pop(id, ts, smallBuf, size, 64u);
|
|
||||||
assert(!ok); // must be rejected, not a buffer overrun
|
|
||||||
printf(" -> PASS: Pop with insufficient maxSize correctly rejected\n");
|
|
||||||
|
|
||||||
// After skipping the oversized sample the buffer is empty (only one
|
|
||||||
// sample was pushed), so a second Pop must also return false.
|
|
||||||
ok = rb.Pop(id, ts, smallBuf, size, 64u);
|
|
||||||
assert(!ok);
|
|
||||||
printf(" -> PASS: Ring buffer empty after oversized pop skipped\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #5: TraceRingBuffer Pop skips only the oversized entry, not all data
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestRingBufferSkipOversizedEntry() {
|
|
||||||
printf("FIX #5: Oversized Pop skips only that entry, not all data...\n");
|
|
||||||
|
|
||||||
TraceRingBuffer rb;
|
|
||||||
assert(rb.Init(4096));
|
|
||||||
|
|
||||||
// Push sample A (oversized for a 64-byte receiver)
|
|
||||||
uint8 bigSample[512];
|
|
||||||
memset(bigSample, 0xAA, sizeof(bigSample));
|
|
||||||
assert(rb.Push(1u, 100u, bigSample, 512u));
|
|
||||||
|
|
||||||
// Push sample B (fits in 64-byte receiver)
|
|
||||||
uint8 smallSample[4] = {0xDE, 0xAD, 0xBE, 0xEF};
|
|
||||||
assert(rb.Push(2u, 200u, smallSample, 4u));
|
|
||||||
|
|
||||||
uint8 dst[64];
|
|
||||||
uint32 id = 0, sz = 0;
|
|
||||||
uint64 rts = 0;
|
|
||||||
|
|
||||||
// Pop with maxSize=64: sample A (512 bytes) must be skipped, not crash
|
|
||||||
bool ok1 = rb.Pop(id, rts, dst, sz, 64u);
|
|
||||||
assert(!ok1); // A skipped
|
|
||||||
printf(" -> PASS: oversized sample A correctly skipped\n");
|
|
||||||
|
|
||||||
// Sample B (4 bytes) must still be readable — before the fix the whole
|
|
||||||
// ring was discarded so this would also return false.
|
|
||||||
bool ok2 = rb.Pop(id, rts, dst, sz, 64u);
|
|
||||||
assert(ok2);
|
|
||||||
assert(id == 2u);
|
|
||||||
assert(sz == 4u);
|
|
||||||
assert(dst[0] == 0xDE && dst[3] == 0xEF);
|
|
||||||
printf(" -> PASS: subsequent sample B retrieved after A was skipped\n");
|
|
||||||
|
|
||||||
// Buffer should now be empty
|
|
||||||
bool ok3 = rb.Pop(id, rts, dst, sz, 64u);
|
|
||||||
assert(!ok3);
|
|
||||||
printf(" -> PASS: no further samples (buffer empty)\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #3: signalPointers null guard in UpdateBrokers*
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestUpdateBrokersNullSignalPointers() {
|
|
||||||
printf("FIX #3: UpdateBrokers* with null signalPointers — no crash...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// Register a broker whose signalPointers is NULL but numSignals > 0.
|
|
||||||
// Before the fix this dereferenced NULL → segfault.
|
|
||||||
volatile bool active = false;
|
|
||||||
Vec<uint32> indices;
|
|
||||||
Vec<uint32> sizes;
|
|
||||||
FastPollingMutexSem mutex;
|
|
||||||
volatile bool anyBreak = false;
|
|
||||||
Vec<uint32> breakIdx;
|
|
||||||
service.RegisterBroker(NULL_PTR(DebugSignalInfo**), 1u,
|
|
||||||
NULL_PTR(MemoryMapBroker*),
|
|
||||||
&active, &indices, &sizes, &mutex,
|
|
||||||
&anyBreak, &breakIdx);
|
|
||||||
|
|
||||||
// These must not crash
|
|
||||||
service.UpdateBrokersActiveStatus();
|
|
||||||
service.UpdateBrokersBreakStatus();
|
|
||||||
printf(" -> PASS: no crash on null signalPointers\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #9: GetSignalValue — large array truncated at GET_VALUE_MAX_ELEMENTS
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestGetSignalValueTruncation() {
|
|
||||||
printf("FIX #9: GetSignalValue large array capped at %u elements...\n",
|
|
||||||
(unsigned)DebugService::GET_VALUE_MAX_ELEMENTS);
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// Register a 512-element uint8 array (> GET_VALUE_MAX_ELEMENTS = 256)
|
|
||||||
static uint8 bigBuf[512];
|
|
||||||
for (uint32 i = 0; i < 512; i++) bigBuf[i] = (uint8)(i & 0xFF);
|
|
||||||
service.RegisterSignal(bigBuf, UnsignedInteger8Bit, "Big.Signal", 1, 512);
|
|
||||||
|
|
||||||
// VALUE command — smoke test, must not crash or loop
|
|
||||||
{ StreamString out; service.HandleCommand("VALUE Signal", out); }
|
|
||||||
printf(" -> PASS: VALUE on large array completed without hang\n");
|
|
||||||
|
|
||||||
// Verify directly: nElem is capped before the byte limit
|
|
||||||
// The signal has 512 uint8 elements; after fix nElem must be <= 256
|
|
||||||
DebugSignalInfo *sig = service.signals[0];
|
|
||||||
assert(sig->numberOfElements == 512u); // original unchanged
|
|
||||||
// We can't call GetSignalValue with a real socket here, but we can
|
|
||||||
// verify the constant is properly visible and correctly set
|
|
||||||
assert(DebugService::GET_VALUE_MAX_ELEMENTS == 256u);
|
|
||||||
printf(" -> PASS: GET_VALUE_MAX_ELEMENTS constant is %u\n",
|
|
||||||
(unsigned)DebugService::GET_VALUE_MAX_ELEMENTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #6/#8: rate-limit and idle-timeout constants exist and are sane
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestServerConstantsSane() {
|
|
||||||
printf("FIX #6/#8: server protection constants are valid...\n");
|
|
||||||
assert(DebugService::CMD_RATE_LIMIT > 0u);
|
|
||||||
assert(DebugService::CLIENT_IDLE_TIMEOUT_MS > 0u);
|
|
||||||
// Idle timeout must be large enough to not disconnect a healthy client
|
|
||||||
// in a single polling cycle (which is ~100 ms)
|
|
||||||
assert(DebugService::CLIENT_IDLE_TIMEOUT_MS >= 1000u);
|
|
||||||
printf(" -> PASS: CMD_RATE_LIMIT=%u, CLIENT_IDLE_TIMEOUT_MS=%u\n",
|
|
||||||
(unsigned)DebugService::CMD_RATE_LIMIT,
|
|
||||||
(unsigned)DebugService::CLIENT_IDLE_TIMEOUT_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #7: MSG key overflow — oversized key line is skipped, no buffer overrun
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestMsgKeyBoundsCheck() {
|
|
||||||
printf("FIX #7: MSG command oversized key is skipped without crash...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// Build a MSG command whose key is 300 characters long (> keyBuf[256]).
|
|
||||||
// Before the fix the Read() would overflow the 256-byte stack buffer.
|
|
||||||
StreamString cmd = "MSG DebugService DummyFunc 0 ";
|
|
||||||
for (uint32 i = 0; i < 300u; i++) cmd += 'K';
|
|
||||||
cmd += "=value";
|
|
||||||
|
|
||||||
// Must not crash or assert
|
|
||||||
{ StreamString out; service.HandleCommand(cmd, out); }
|
|
||||||
printf(" -> PASS: oversized key handled without buffer overflow\n");
|
|
||||||
|
|
||||||
// A normal-length key should still be accepted (regression check)
|
|
||||||
{ StreamString out; service.HandleCommand("MSG DebugService DummyFunc 0 NormalKey=NormalValue", out); }
|
|
||||||
printf(" -> PASS: normal key not rejected by bounds check\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #10: Multi-segment TCP command buffering via inputBuffer
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestServerInputBuffering() {
|
|
||||||
printf("FIX #10: Multi-segment TCP command buffering...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
// Verify inputBuffer is initialised empty
|
|
||||||
assert(service.inputBuffer.Size() == 0u);
|
|
||||||
printf(" -> PASS: inputBuffer initialised to empty\n");
|
|
||||||
|
|
||||||
// Simulate fragment 1 arriving: "FORCE Signal " (no newline yet)
|
|
||||||
// In the real Server() this would be written via Read(); here we
|
|
||||||
// directly manipulate the carry-over buffer (friend-class access).
|
|
||||||
{
|
|
||||||
(void)service.inputBuffer.Seek(service.inputBuffer.Size());
|
|
||||||
uint32 f1Len = 13u; // length of "FORCE Signal "
|
|
||||||
service.inputBuffer.Write("FORCE Signal ", f1Len);
|
|
||||||
}
|
|
||||||
assert(service.inputBuffer.Size() == 13u);
|
|
||||||
printf(" -> PASS: partial command held in inputBuffer after fragment 1\n");
|
|
||||||
|
|
||||||
// Simulate fragment 2 completing the command: "123\n"
|
|
||||||
{
|
|
||||||
(void)service.inputBuffer.Seek(service.inputBuffer.Size());
|
|
||||||
uint32 f2Len = 4u;
|
|
||||||
service.inputBuffer.Write("123\n", f2Len);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now scan inputBuffer for complete lines — mirrors the Server() loop
|
|
||||||
const char8 *raw = service.inputBuffer.Buffer();
|
|
||||||
uint32 total = (uint32)service.inputBuffer.Size();
|
|
||||||
uint32 lineStart = 0u;
|
|
||||||
uint32 cmdsFound = 0u;
|
|
||||||
char8 cmdBuf[64];
|
|
||||||
memset(cmdBuf, 0, sizeof(cmdBuf));
|
|
||||||
|
|
||||||
for (uint32 pos = 0u; pos < total; pos++) {
|
|
||||||
if (raw[pos] != '\n') continue;
|
|
||||||
uint32 len = pos - lineStart;
|
|
||||||
if (len > 0u && raw[lineStart + len - 1u] == '\r') len--;
|
|
||||||
if (len > 0u) {
|
|
||||||
cmdsFound++;
|
|
||||||
uint32 cp = (len < 63u) ? len : 63u;
|
|
||||||
memcpy(cmdBuf, raw + lineStart, cp);
|
|
||||||
cmdBuf[cp] = '\0';
|
|
||||||
}
|
|
||||||
lineStart = pos + 1u;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(cmdsFound == 1u);
|
|
||||||
// The two fragments assembled into "FORCE Signal 123"
|
|
||||||
assert(strncmp(cmdBuf, "FORCE Signal 123", 16) == 0);
|
|
||||||
printf(" -> PASS: fragmented command reassembled to '%s'\n", cmdBuf);
|
|
||||||
|
|
||||||
// Remainder after the last '\n' should be empty (no trailing bytes)
|
|
||||||
assert(lineStart == total);
|
|
||||||
printf(" -> PASS: no partial remainder after complete command\n");
|
|
||||||
|
|
||||||
// Verify INPUT_BUFFER_MAX constant is reachable
|
|
||||||
assert(DebugService::INPUT_BUFFER_MAX > 4096u);
|
|
||||||
printf(" -> PASS: INPUT_BUFFER_MAX=%u\n",
|
|
||||||
(unsigned)DebugService::INPUT_BUFFER_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #11: Streamer monitored-signal Push protected by tracePushMutex
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestStreamerMonitoredPushSerialised() {
|
|
||||||
printf("FIX #11: Streamer monitored-signal Push uses tracePushMutex...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
uint32 val = 0xDEADBEEF;
|
|
||||||
service.RegisterSignal(&val, UnsignedInteger32Bit, "Mon.Val", 0, 1);
|
|
||||||
assert(service.TraceSignal("Val", true) == 1);
|
|
||||||
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000000.0);
|
|
||||||
|
|
||||||
// Push via ProcessSignal (uses tracePushMutex internally — broker path)
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts);
|
|
||||||
|
|
||||||
// Push directly via tracePushMutex (simulates the Streamer monitored-
|
|
||||||
// signal path after FIX #11 — it now also acquires tracePushMutex so
|
|
||||||
// both push paths are serialised with respect to each other).
|
|
||||||
uint32 monId = 0x80000001u;
|
|
||||||
uint32 monVal = 0x12345678u;
|
|
||||||
service.tracePushMutex.FastLock();
|
|
||||||
(void)service.traceBuffer.Push(monId, ts + 1u, &monVal, 4u);
|
|
||||||
service.tracePushMutex.FastUnLock();
|
|
||||||
|
|
||||||
// Both samples must be present in FIFO order — if there were a race
|
|
||||||
// one or both would be corrupt or missing.
|
|
||||||
uint32 id = 0, sz = 0; uint64 rts = 0; uint8 dst[64];
|
|
||||||
assert(service.traceBuffer.Pop(id, rts, dst, sz, 64u));
|
|
||||||
assert(id == service.signals[0]->internalID);
|
|
||||||
assert(sz == 4u);
|
|
||||||
|
|
||||||
assert(service.traceBuffer.Pop(id, rts, dst, sz, 64u));
|
|
||||||
assert(id == monId);
|
|
||||||
assert(sz == 4u);
|
|
||||||
|
|
||||||
assert(!service.traceBuffer.Pop(id, rts, dst, sz, 64u)); // buffer empty
|
|
||||||
printf(" -> PASS: broker and monitored-signal pushes both retrieved in order\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// FIX #2: tracePushMutex — concurrent Push from two logical threads
|
|
||||||
// (single-threaded simulation: verify no data corruption across two pushes
|
|
||||||
// that would race without the mutex)
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestTracePushSerialised() {
|
|
||||||
printf("FIX #2: Concurrent ProcessSignal serialised via tracePushMutex...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
uint32 valA = 0xAABBCCDD;
|
|
||||||
uint32 valB = 0x11223344;
|
|
||||||
service.RegisterSignal(&valA, UnsignedInteger32Bit, "P.A", 0, 1);
|
|
||||||
service.RegisterSignal(&valB, UnsignedInteger32Bit, "P.B", 0, 1);
|
|
||||||
assert(service.TraceSignal("A", true) == 1);
|
|
||||||
assert(service.TraceSignal("B", true) == 1);
|
|
||||||
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000000.0);
|
|
||||||
|
|
||||||
// Simulate two sequential calls as would happen from two RT threads.
|
|
||||||
// Without tracePushMutex they could interleave and corrupt the ring.
|
|
||||||
service.ProcessSignal(service.signals[0], 4, ts);
|
|
||||||
service.ProcessSignal(service.signals[1], 4, ts + 1u);
|
|
||||||
|
|
||||||
// Both samples must be retrievable in FIFO order with correct IDs.
|
|
||||||
uint32 id, size;
|
|
||||||
uint64 rts;
|
|
||||||
uint8 buf[64];
|
|
||||||
uint32 id0 = service.signals[0]->internalID;
|
|
||||||
uint32 id1 = service.signals[1]->internalID;
|
|
||||||
|
|
||||||
assert(service.traceBuffer.Pop(id, rts, buf, size, 64u));
|
|
||||||
assert(id == id0);
|
|
||||||
assert(size == 4u);
|
|
||||||
|
|
||||||
assert(service.traceBuffer.Pop(id, rts, buf, size, 64u));
|
|
||||||
assert(id == id1);
|
|
||||||
assert(size == 4u);
|
|
||||||
|
|
||||||
printf(" -> PASS: Both samples intact after serialised push\n");
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Fix #2 (Swap): UpdateBrokersActiveStatus publishes all active-signal
|
|
||||||
// indices correctly when multiple signals are tracing/forcing.
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestUpdateBrokersSwapPublishesAllIndices() {
|
|
||||||
printf("Fix #2 (Swap): UpdateBrokersActiveStatus publishes all active indices...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
uint32 v0 = 0, v1 = 0, v2 = 0;
|
|
||||||
service.RegisterSignal(&v0, UnsignedInteger32Bit, "S.X", 0, 1);
|
|
||||||
service.RegisterSignal(&v1, UnsignedInteger32Bit, "S.Y", 0, 1);
|
|
||||||
service.RegisterSignal(&v2, UnsignedInteger32Bit, "S.Z", 0, 1);
|
|
||||||
|
|
||||||
// Enable tracing on X and Z (not Y)
|
|
||||||
assert(service.TraceSignal("X", true) == 1);
|
|
||||||
assert(service.TraceSignal("Z", true) == 1);
|
|
||||||
|
|
||||||
volatile bool active = false;
|
|
||||||
Vec<uint32> indices;
|
|
||||||
Vec<uint32> sizes;
|
|
||||||
FastPollingMutexSem mutex;
|
|
||||||
volatile bool anyBreak = false;
|
|
||||||
Vec<uint32> breakIdx;
|
|
||||||
DebugSignalInfo *ptrs[3] = {
|
|
||||||
service.signals[0], service.signals[1], service.signals[2]
|
|
||||||
};
|
|
||||||
service.RegisterBroker(ptrs, 3u, NULL_PTR(MemoryMapBroker *),
|
|
||||||
&active, &indices, &sizes, &mutex,
|
|
||||||
&anyBreak, &breakIdx);
|
|
||||||
|
|
||||||
service.UpdateBrokersActiveStatus();
|
|
||||||
|
|
||||||
// After Swap the broker's activeIndices must hold exactly indices 0 and 2
|
|
||||||
assert(active == true);
|
|
||||||
assert(indices.Size() == 2u);
|
|
||||||
// indices are in order of signal position in the broker (0 then 2)
|
|
||||||
assert(indices[0] == 0u);
|
|
||||||
assert(indices[1] == 2u);
|
|
||||||
printf(" -> PASS: Swap correctly published 2 active indices out of 3\n");
|
|
||||||
|
|
||||||
// Disable one; Swap again — only index 0 should remain
|
|
||||||
assert(service.TraceSignal("Z", false) == 1);
|
|
||||||
service.UpdateBrokersActiveStatus();
|
|
||||||
assert(indices.Size() == 1u);
|
|
||||||
assert(indices[0] == 0u);
|
|
||||||
printf(" -> PASS: After disabling Z, only index 0 remains\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Fix #3 (copy-before-unlock): break evaluation still works after the
|
|
||||||
// copy-indices-then-unlock refactor in DebugBrokerHelper::Process().
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestBreakEvaluationAfterLockRelease() {
|
|
||||||
printf("Fix #3 (copy-before-unlock): break evaluation works after lock release...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
uint32 val = 5u;
|
|
||||||
service.RegisterSignal(&val, UnsignedInteger32Bit, "Brk.Val", 0, 1);
|
|
||||||
|
|
||||||
// Set break: pause when Val > 3
|
|
||||||
assert(service.SetBreak("Val", BREAK_GT, 3.0) == 1u);
|
|
||||||
service.UpdateBrokersBreakStatus();
|
|
||||||
|
|
||||||
volatile bool active = false;
|
|
||||||
Vec<uint32> indices;
|
|
||||||
Vec<uint32> sizes;
|
|
||||||
FastPollingMutexSem mutex;
|
|
||||||
volatile bool anyBreak = false;
|
|
||||||
Vec<uint32> breakIdx;
|
|
||||||
DebugSignalInfo *ptrs[1] = { service.signals[0] };
|
|
||||||
service.RegisterBroker(ptrs, 1u, NULL_PTR(MemoryMapBroker *),
|
|
||||||
&active, &indices, &sizes, &mutex,
|
|
||||||
&anyBreak, &breakIdx);
|
|
||||||
|
|
||||||
// UpdateBrokersBreakStatus must propagate the break flag to the broker
|
|
||||||
service.UpdateBrokersBreakStatus();
|
|
||||||
assert(anyBreak == true);
|
|
||||||
assert(breakIdx.Size() == 1u);
|
|
||||||
|
|
||||||
// Process() copies break indices, releases lock, evaluates break.
|
|
||||||
// val = 5 > 3 — service must become paused.
|
|
||||||
DebugBrokerHelper::Process(&service, ptrs, indices, sizes, mutex,
|
|
||||||
&anyBreak, &breakIdx);
|
|
||||||
assert(service.IsPaused());
|
|
||||||
printf(" -> PASS: break condition triggered correctly via copy-before-unlock path\n");
|
|
||||||
|
|
||||||
// Reset; change value below threshold — must NOT pause.
|
|
||||||
service.SetPaused(false);
|
|
||||||
val = 1u;
|
|
||||||
DebugBrokerHelper::Process(&service, ptrs, indices, sizes, mutex,
|
|
||||||
&anyBreak, &breakIdx);
|
|
||||||
assert(!service.IsPaused());
|
|
||||||
printf(" -> PASS: value below threshold does not trigger break\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Fix #4 (atomic decimation): decimationFactor > 1 causes exactly one Push
|
|
||||||
// after factor calls to ProcessSignal.
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
static void TestDecimationCounterAtomic() {
|
|
||||||
printf("Fix #4 (atomic decimation): one push per decimation factor...\n");
|
|
||||||
ObjectRegistryDatabase::Instance()->Purge();
|
|
||||||
|
|
||||||
DebugService service;
|
|
||||||
assert(service.traceBuffer.Init(1024 * 1024));
|
|
||||||
ConfigurationDatabase cfg;
|
|
||||||
cfg.Write("ControlPort", (uint32)0);
|
|
||||||
cfg.Write("StreamPort", (uint32)0);
|
|
||||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
|
||||||
assert(service.Initialise(cfg));
|
|
||||||
|
|
||||||
uint32 val = 0x42424242u;
|
|
||||||
service.RegisterSignal(&val, UnsignedInteger32Bit, "Dec.Val", 0, 1);
|
|
||||||
// TraceSignal with decimation = 3
|
|
||||||
assert(service.TraceSignal("Val", true, 3u) == 1u);
|
|
||||||
assert(service.signals[0]->decimationFactor == 3u);
|
|
||||||
|
|
||||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() *
|
|
||||||
HighResolutionTimer::Period() * 1000000.0);
|
|
||||||
|
|
||||||
// Calls 1 and 2 — counter advances but no push
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts);
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts + 1u);
|
|
||||||
|
|
||||||
uint32 id, sz; uint64 rts; uint8 buf[64];
|
|
||||||
bool hasData = service.traceBuffer.Pop(id, rts, buf, sz, 64u);
|
|
||||||
assert(!hasData); // no sample yet
|
|
||||||
printf(" -> PASS: no push after 2 calls with decimation=3\n");
|
|
||||||
|
|
||||||
// Call 3 — counter reaches factor, one push occurs
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts + 2u);
|
|
||||||
hasData = service.traceBuffer.Pop(id, rts, buf, sz, 64u);
|
|
||||||
assert(hasData);
|
|
||||||
assert(id == service.signals[0]->internalID);
|
|
||||||
assert(sz == 4u);
|
|
||||||
printf(" -> PASS: exactly one push after %u calls with decimation=3\n", 3u);
|
|
||||||
|
|
||||||
// Call 4 and 5 — no push again
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts + 3u);
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts + 4u);
|
|
||||||
hasData = service.traceBuffer.Pop(id, rts, buf, sz, 64u);
|
|
||||||
assert(!hasData);
|
|
||||||
printf(" -> PASS: no push for calls 4 and 5 (decimation reset)\n");
|
|
||||||
|
|
||||||
// Call 6 — second push
|
|
||||||
service.ProcessSignal(service.signals[0], 4u, ts + 5u);
|
|
||||||
hasData = service.traceBuffer.Pop(id, rts, buf, sz, 64u);
|
|
||||||
assert(hasData);
|
|
||||||
printf(" -> PASS: second push on call 6\n");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
void timeout_handler(int sig) {
|
|
||||||
printf("Test timed out!\n");
|
|
||||||
_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
signal(SIGALRM, timeout_handler);
|
|
||||||
alarm(10);
|
|
||||||
printf("--- MARTe2 Debug Suite COVERAGE V34 ---\n");
|
|
||||||
MARTe::TestTcpLogger();
|
|
||||||
MARTe::DebugServiceTest::TestAll();
|
|
||||||
// FIX #1, #2, #4
|
|
||||||
MARTe::DebugServiceTest::TestForceSignalOversizeRejected();
|
|
||||||
MARTe::DebugServiceTest::TestStreamerPopMaxSize();
|
|
||||||
MARTe::DebugServiceTest::TestTracePushSerialised();
|
|
||||||
// FIX #3, #6, #7, #8, #9
|
|
||||||
MARTe::DebugServiceTest::TestUpdateBrokersNullSignalPointers();
|
|
||||||
MARTe::DebugServiceTest::TestGetSignalValueTruncation();
|
|
||||||
MARTe::DebugServiceTest::TestServerConstantsSane();
|
|
||||||
MARTe::DebugServiceTest::TestMsgKeyBoundsCheck();
|
|
||||||
// FIX #5, #10, #11
|
|
||||||
MARTe::DebugServiceTest::TestRingBufferSkipOversizedEntry();
|
|
||||||
MARTe::DebugServiceTest::TestServerInputBuffering();
|
|
||||||
MARTe::DebugServiceTest::TestStreamerMonitoredPushSerialised();
|
|
||||||
// Fix #2 (Swap), Fix #3 (copy-before-unlock), Fix #4 (atomic decimation)
|
|
||||||
MARTe::DebugServiceTest::TestUpdateBrokersSwapPublishesAllIndices();
|
|
||||||
MARTe::DebugServiceTest::TestBreakEvaluationAfterLockRelease();
|
|
||||||
MARTe::DebugServiceTest::TestDecimationCounterAtomic();
|
|
||||||
printf("\nCOVERAGE V34 PASSED!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "DebugCore.h"
|
||||||
|
#include "DebugService.h"
|
||||||
|
#include "DebugBrokerWrapper.h"
|
||||||
|
#include "TcpLogger.h"
|
||||||
|
#include "ConfigurationDatabase.h"
|
||||||
|
#include "ObjectRegistryDatabase.h"
|
||||||
|
#include "StandardParser.h"
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
#include "Sleep.h"
|
||||||
|
#include "BasicTCPSocket.h"
|
||||||
|
#include "HighResolutionTimer.h"
|
||||||
|
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
|
||||||
|
class DebugServiceTest {
|
||||||
|
public:
|
||||||
|
static void TestAll() {
|
||||||
|
printf("Stability Logic Tests...\n");
|
||||||
|
|
||||||
|
DebugService service;
|
||||||
|
assert(service.traceBuffer.Init(1024 * 1024));
|
||||||
|
|
||||||
|
ConfigurationDatabase cfg;
|
||||||
|
cfg.Write("ControlPort", (uint32)0);
|
||||||
|
cfg.Write("StreamPort", (uint32)0);
|
||||||
|
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
||||||
|
assert(service.Initialise(cfg));
|
||||||
|
|
||||||
|
// 1. Signal logic
|
||||||
|
uint32 val = 0;
|
||||||
|
service.RegisterSignal(&val, UnsignedInteger32Bit, "X.Y.Z");
|
||||||
|
assert(service.TraceSignal("Z", true) == 1);
|
||||||
|
assert(service.ForceSignal("Z", "123") == 1);
|
||||||
|
|
||||||
|
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0);
|
||||||
|
service.ProcessSignal(&service.signals[0], 4, ts);
|
||||||
|
assert(val == 123);
|
||||||
|
service.UnforceSignal("Z");
|
||||||
|
|
||||||
|
// 2. Commands
|
||||||
|
service.HandleCommand("TREE", NULL_PTR(BasicTCPSocket*));
|
||||||
|
service.HandleCommand("DISCOVER", NULL_PTR(BasicTCPSocket*));
|
||||||
|
service.HandleCommand("PAUSE", NULL_PTR(BasicTCPSocket*));
|
||||||
|
service.HandleCommand("RESUME", NULL_PTR(BasicTCPSocket*));
|
||||||
|
service.HandleCommand("LS /", NULL_PTR(BasicTCPSocket*));
|
||||||
|
|
||||||
|
// 3. Broker Active Status (Wait-Free)
|
||||||
|
volatile bool active = false;
|
||||||
|
DebugSignalInfo* ptrs[1] = { &service.signals[0] };
|
||||||
|
service.RegisterBroker(ptrs, 1, NULL_PTR(MemoryMapBroker*), &active);
|
||||||
|
service.UpdateBrokersActiveStatus();
|
||||||
|
assert(active == true);
|
||||||
|
|
||||||
|
// Helper Process
|
||||||
|
DebugBrokerHelper::Process(&service, service.brokers[0]);
|
||||||
|
|
||||||
|
// 4. Object Hierarchy branches
|
||||||
|
service.HandleCommand("INFO X.Y.Z", NULL_PTR(BasicTCPSocket*));
|
||||||
|
|
||||||
|
StreamString fullPath;
|
||||||
|
DebugService::GetFullObjectName(service, fullPath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void TestTcpLogger() {
|
||||||
|
printf("Stability Logger Tests...\n");
|
||||||
|
TcpLogger logger;
|
||||||
|
ConfigurationDatabase cfg;
|
||||||
|
cfg.Write("Port", (uint16)0);
|
||||||
|
if (logger.Initialise(cfg)) {
|
||||||
|
REPORT_ERROR_STATIC(ErrorManagement::Information, "Coverage Log Entry");
|
||||||
|
logger.ConsumeLogMessage(NULL_PTR(LoggerPage*));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestRingBuffer() {
|
||||||
|
printf("Stability RingBuffer Tests...\n");
|
||||||
|
TraceRingBuffer rb;
|
||||||
|
rb.Init(1024);
|
||||||
|
uint32 val = 0;
|
||||||
|
rb.Push(1, 100, &val, 4);
|
||||||
|
uint32 id, size; uint64 ts;
|
||||||
|
rb.Pop(id, ts, &val, size, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
printf("--- MARTe2 Debug Suite COVERAGE V29 ---\n");
|
||||||
|
MARTe::TestTcpLogger();
|
||||||
|
MARTe::DebugServiceTest::TestAll();
|
||||||
|
printf("\nCOVERAGE V29 PASSED!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,17 @@
|
|||||||
|
module marte_debug_cli
|
||||||
|
|
||||||
|
go 1.25.7
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gdamore/tcell/v2 v2.13.8
|
||||||
|
github.com/rivo/tview v0.42.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gdamore/encoding v1.0.1 // indirect
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
|
||||||
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
|
golang.org/x/term v0.37.0 // indirect
|
||||||
|
golang.org/x/text v0.31.0 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||||
|
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||||
|
github.com/gdamore/tcell/v2 v2.13.8 h1:Mys/Kl5wfC/GcC5Cx4C2BIQH9dbnhnkPgS9/wF3RlfU=
|
||||||
|
github.com/gdamore/tcell/v2 v2.13.8/go.mod h1:+Wfe208WDdB7INEtCsNrAN6O2m+wsTPk1RAovjaILlo=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
|
github.com/rivo/tview v0.42.0 h1:b/ftp+RxtDsHSaynXTbJb+/n/BxDEi+W3UfF5jILK6c=
|
||||||
|
github.com/rivo/tview v0.42.0/go.mod h1:cSfIYfhpSGCjp3r/ECJb+GKS7cGJnqV8vfjQPwoXyfY=
|
||||||
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||||
|
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||||
|
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@@ -0,0 +1,498 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gdamore/tcell/v2"
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
)
|
||||||
|
|
||||||
|
// --- Models ---
|
||||||
|
|
||||||
|
type Signal struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
ID uint32 `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DiscoverResponse struct {
|
||||||
|
Signals []Signal `json:"Signals"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TraceValue struct {
|
||||||
|
Value string
|
||||||
|
LastUpdate time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type AppState struct {
|
||||||
|
Signals map[string]Signal
|
||||||
|
IDToSignal map[uint32]string
|
||||||
|
ForcedSignals map[string]string
|
||||||
|
TracedSignals map[string]TraceValue
|
||||||
|
mu sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
var state = AppState{
|
||||||
|
Signals: make(map[string]Signal),
|
||||||
|
IDToSignal: make(map[uint32]string),
|
||||||
|
ForcedSignals: make(map[string]string),
|
||||||
|
TracedSignals: make(map[string]TraceValue),
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- UI Components ---
|
||||||
|
|
||||||
|
var (
|
||||||
|
app *tview.Application
|
||||||
|
forcedPane *tview.Table
|
||||||
|
tracedPane *tview.Table
|
||||||
|
statusPane *tview.TextView
|
||||||
|
frameworkLogPane *tview.TextView
|
||||||
|
cmdInput *tview.InputField
|
||||||
|
mainFlex *tview.Flex
|
||||||
|
)
|
||||||
|
|
||||||
|
// logToStatus prints command output WITHOUT timestamp
|
||||||
|
func logToStatus(msg string) {
|
||||||
|
fmt.Fprintf(statusPane, "%s\n", msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// logToFramework prints framework logs WITH timestamp
|
||||||
|
func logToFramework(level, msg string) {
|
||||||
|
color := "white"
|
||||||
|
switch level {
|
||||||
|
case "FatalError", "OSError", "ParametersError":
|
||||||
|
color = "red"
|
||||||
|
case "Warning":
|
||||||
|
color = "yellow"
|
||||||
|
case "Information":
|
||||||
|
color = "green"
|
||||||
|
case "Debug":
|
||||||
|
color = "blue"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(frameworkLogPane, "[%s] [[%s]%s[-]] %s\n", time.Now().Format("15:04:05.000"), color, level, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Network Logic ---
|
||||||
|
|
||||||
|
var (
|
||||||
|
tcpConn net.Conn
|
||||||
|
tcpMu sync.Mutex
|
||||||
|
responseChan = make(chan string, 2000)
|
||||||
|
connected = false
|
||||||
|
)
|
||||||
|
|
||||||
|
func connectAndMonitor(addr string) {
|
||||||
|
for {
|
||||||
|
conn, err := net.Dial("tcp", addr)
|
||||||
|
if err != nil {
|
||||||
|
app.QueueUpdateDraw(func() { statusPane.SetText("[red]Connection failed, retrying...\n") })
|
||||||
|
connected = false
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc, ok := conn.(*net.TCPConn); ok {
|
||||||
|
tc.SetNoDelay(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
tcpConn = conn
|
||||||
|
connected = true
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[green]Connected to DebugService (TCP 8080)") })
|
||||||
|
|
||||||
|
go discover()
|
||||||
|
|
||||||
|
buf := make([]byte, 4096)
|
||||||
|
var line strings.Builder
|
||||||
|
for {
|
||||||
|
n, err := conn.Read(buf)
|
||||||
|
if err != nil {
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]TCP Disconnected: " + err.Error()) })
|
||||||
|
connected = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if buf[i] == '\n' {
|
||||||
|
fullLine := strings.TrimSpace(line.String())
|
||||||
|
line.Reset()
|
||||||
|
|
||||||
|
if strings.HasPrefix(fullLine, "LOG ") {
|
||||||
|
parts := strings.SplitN(fullLine[4:], " ", 2)
|
||||||
|
if len(parts) == 2 {
|
||||||
|
app.QueueUpdateDraw(func() { logToFramework(parts[0], parts[1]) })
|
||||||
|
}
|
||||||
|
} else if fullLine != "" {
|
||||||
|
select {
|
||||||
|
case responseChan <- fullLine:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line.WriteByte(buf[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tcpConn.Close()
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func startUDPListener(port int) {
|
||||||
|
addr, _ := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", port))
|
||||||
|
udpConn, err := net.ListenUDP("udp", addr)
|
||||||
|
if err != nil {
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus(fmt.Sprintf("UDP Error: %v", err)) })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer udpConn.Close()
|
||||||
|
|
||||||
|
buf := make([]byte, 2048)
|
||||||
|
for {
|
||||||
|
n, _, err := udpConn.ReadFromUDP(buf)
|
||||||
|
if err != nil || n < 20 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
magic := binary.LittleEndian.Uint32(buf[0:4])
|
||||||
|
if magic != 0xDA7A57AD {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
count := binary.LittleEndian.Uint32(buf[16:20])
|
||||||
|
offset := 20
|
||||||
|
now := time.Now()
|
||||||
|
for i := uint32(0); i < count; i++ {
|
||||||
|
if offset+8 > n {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
id := binary.LittleEndian.Uint32(buf[offset : offset+4])
|
||||||
|
size := binary.LittleEndian.Uint32(buf[offset+4 : offset+8])
|
||||||
|
offset += 8
|
||||||
|
if offset+int(size) > n {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
data := buf[offset : offset+int(size)]
|
||||||
|
offset += int(size)
|
||||||
|
|
||||||
|
state.mu.Lock()
|
||||||
|
if name, ok := state.IDToSignal[id]; ok {
|
||||||
|
valStr := ""
|
||||||
|
if size == 4 {
|
||||||
|
valStr = fmt.Sprintf("%d", binary.LittleEndian.Uint32(data))
|
||||||
|
} else if size == 8 {
|
||||||
|
valStr = fmt.Sprintf("%d", binary.LittleEndian.Uint64(data))
|
||||||
|
} else {
|
||||||
|
valStr = fmt.Sprintf("%X", data)
|
||||||
|
}
|
||||||
|
state.TracedSignals[name] = TraceValue{Value: valStr, LastUpdate: now}
|
||||||
|
}
|
||||||
|
state.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
app.QueueUpdateDraw(func() { updateTracedPane() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func discover() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
if !connected {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("Discovering signals...") })
|
||||||
|
|
||||||
|
// Drain old responses
|
||||||
|
for len(responseChan) > 0 {
|
||||||
|
<-responseChan
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(tcpConn, "DISCOVER\n")
|
||||||
|
|
||||||
|
var jsonBlock strings.Builder
|
||||||
|
timeout := time.After(5 * time.Second)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case line := <-responseChan:
|
||||||
|
if line == "OK DISCOVER" {
|
||||||
|
goto parsed
|
||||||
|
}
|
||||||
|
jsonBlock.WriteString(line)
|
||||||
|
case <-timeout:
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]Discovery Timeout") })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parsed:
|
||||||
|
var resp DiscoverResponse
|
||||||
|
if err := json.Unmarshal([]byte(jsonBlock.String()), &resp); err == nil {
|
||||||
|
state.mu.Lock()
|
||||||
|
state.IDToSignal = make(map[uint32]string)
|
||||||
|
for _, s := range resp.Signals {
|
||||||
|
state.Signals[s.Name] = s
|
||||||
|
state.IDToSignal[s.ID] = s.Name
|
||||||
|
}
|
||||||
|
state.mu.Unlock()
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus(fmt.Sprintf("Discovered %d signals", len(resp.Signals))) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- UI Updates ---
|
||||||
|
|
||||||
|
func updateForcedPane() {
|
||||||
|
forcedPane.Clear()
|
||||||
|
forcedPane.SetCell(0, 0, tview.NewTableCell("Signal").SetTextColor(tcell.ColorYellow).SetAttributes(tcell.AttrBold))
|
||||||
|
forcedPane.SetCell(0, 1, tview.NewTableCell("Value").SetTextColor(tcell.ColorYellow).SetAttributes(tcell.AttrBold))
|
||||||
|
state.mu.RLock()
|
||||||
|
defer state.mu.RUnlock()
|
||||||
|
keys := make([]string, 0, len(state.ForcedSignals))
|
||||||
|
for k := range state.ForcedSignals {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for i, k := range keys {
|
||||||
|
forcedPane.SetCell(i+1, 0, tview.NewTableCell(k))
|
||||||
|
forcedPane.SetCell(i+1, 1, tview.NewTableCell(state.ForcedSignals[k]).SetTextColor(tcell.ColorGreen))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateTracedPane() {
|
||||||
|
tracedPane.Clear()
|
||||||
|
tracedPane.SetCell(0, 0, tview.NewTableCell("Signal").SetTextColor(tcell.ColorBlue).SetAttributes(tcell.AttrBold))
|
||||||
|
tracedPane.SetCell(0, 1, tview.NewTableCell("Value").SetTextColor(tcell.ColorBlue).SetAttributes(tcell.AttrBold))
|
||||||
|
tracedPane.SetCell(0, 2, tview.NewTableCell("Last Update").SetTextColor(tcell.ColorBlue).SetAttributes(tcell.AttrBold))
|
||||||
|
state.mu.RLock()
|
||||||
|
defer state.mu.RUnlock()
|
||||||
|
keys := make([]string, 0, len(state.TracedSignals))
|
||||||
|
for k := range state.TracedSignals {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for i, k := range keys {
|
||||||
|
tv := state.TracedSignals[k]
|
||||||
|
tracedPane.SetCell(i+1, 0, tview.NewTableCell(k))
|
||||||
|
tracedPane.SetCell(i+1, 1, tview.NewTableCell(tv.Value))
|
||||||
|
tracedPane.SetCell(i+1, 2, tview.NewTableCell(tv.LastUpdate.Format("15:04:05.000")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Command Handler ---
|
||||||
|
|
||||||
|
func handleInput(text string) {
|
||||||
|
parts := strings.Fields(text)
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd := strings.ToUpper(parts[0])
|
||||||
|
args := parts[1:]
|
||||||
|
if !connected && cmd != "EXIT" && cmd != "QUIT" && cmd != "CLEAR" {
|
||||||
|
logToStatus("[red]Not connected to server")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch cmd {
|
||||||
|
case "LS":
|
||||||
|
path := ""
|
||||||
|
if len(args) > 0 {
|
||||||
|
path = args[0]
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
for len(responseChan) > 0 {
|
||||||
|
<-responseChan
|
||||||
|
}
|
||||||
|
fmt.Fprintf(tcpConn, "LS %s\n", path)
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus(fmt.Sprintf("Listing nodes under %s...", path)) })
|
||||||
|
timeout := time.After(2 * time.Second)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case line := <-responseChan:
|
||||||
|
if line == "OK LS" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus(line) })
|
||||||
|
case <-timeout:
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]LS Timeout") })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
case "FORCE":
|
||||||
|
if len(args) < 2 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
path, val := args[0], args[1]
|
||||||
|
go func() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
fmt.Fprintf(tcpConn, "FORCE %s %s\n", path, val)
|
||||||
|
select {
|
||||||
|
case resp := <-responseChan:
|
||||||
|
app.QueueUpdateDraw(func() {
|
||||||
|
logToStatus("Server: " + resp)
|
||||||
|
state.mu.Lock()
|
||||||
|
state.ForcedSignals[path] = val
|
||||||
|
state.mu.Unlock()
|
||||||
|
updateForcedPane()
|
||||||
|
})
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]Server Timeout") })
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
case "UNFORCE":
|
||||||
|
if len(args) < 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
path := args[0]
|
||||||
|
go func() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
fmt.Fprintf(tcpConn, "UNFORCE %s\n", path)
|
||||||
|
select {
|
||||||
|
case resp := <-responseChan:
|
||||||
|
app.QueueUpdateDraw(func() {
|
||||||
|
logToStatus("Server: " + resp)
|
||||||
|
state.mu.Lock()
|
||||||
|
delete(state.ForcedSignals, path)
|
||||||
|
state.mu.Unlock()
|
||||||
|
updateForcedPane()
|
||||||
|
})
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]Server Timeout") })
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
case "TRACE":
|
||||||
|
if len(args) < 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
path := args[0]
|
||||||
|
decim := "1"
|
||||||
|
if len(args) > 1 {
|
||||||
|
decim = args[1]
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
fmt.Fprintf(tcpConn, "TRACE %s 1 %s\n", path, decim)
|
||||||
|
select {
|
||||||
|
case resp := <-responseChan:
|
||||||
|
app.QueueUpdateDraw(func() {
|
||||||
|
logToStatus("Server: " + resp)
|
||||||
|
state.mu.Lock()
|
||||||
|
state.TracedSignals[path] = TraceValue{Value: "...", LastUpdate: time.Now()}
|
||||||
|
state.mu.Unlock()
|
||||||
|
updateTracedPane()
|
||||||
|
})
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]Server Timeout") })
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
case "UNTRACE":
|
||||||
|
if len(args) < 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
path := args[0]
|
||||||
|
go func() {
|
||||||
|
tcpMu.Lock()
|
||||||
|
defer tcpMu.Unlock()
|
||||||
|
fmt.Fprintf(tcpConn, "UNTRACE %s\n", path)
|
||||||
|
select {
|
||||||
|
case resp := <-responseChan:
|
||||||
|
app.QueueUpdateDraw(func() {
|
||||||
|
logToStatus("Server: " + resp)
|
||||||
|
state.mu.Lock()
|
||||||
|
delete(state.TracedSignals, path)
|
||||||
|
state.mu.Unlock()
|
||||||
|
updateTracedPane()
|
||||||
|
})
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
app.QueueUpdateDraw(func() { logToStatus("[red]Server Timeout") })
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
case "DISCOVER":
|
||||||
|
go discover()
|
||||||
|
case "CLEAR":
|
||||||
|
statusPane.Clear()
|
||||||
|
frameworkLogPane.Clear()
|
||||||
|
case "EXIT", "QUIT":
|
||||||
|
app.Stop()
|
||||||
|
default:
|
||||||
|
logToStatus("Unknown command: " + cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app = tview.NewApplication()
|
||||||
|
|
||||||
|
forcedPane = tview.NewTable()
|
||||||
|
forcedPane.SetBorders(true)
|
||||||
|
forcedPane.SetTitle(" Forced Signals ")
|
||||||
|
forcedPane.SetBorder(true)
|
||||||
|
|
||||||
|
tracedPane = tview.NewTable()
|
||||||
|
tracedPane.SetBorders(true)
|
||||||
|
tracedPane.SetTitle(" Traced Signals (Live) ")
|
||||||
|
tracedPane.SetBorder(true)
|
||||||
|
|
||||||
|
statusPane = tview.NewTextView()
|
||||||
|
statusPane.SetDynamicColors(true)
|
||||||
|
statusPane.SetRegions(true)
|
||||||
|
statusPane.SetWordWrap(true)
|
||||||
|
statusPane.SetChangedFunc(func() {
|
||||||
|
statusPane.ScrollToEnd()
|
||||||
|
app.Draw()
|
||||||
|
})
|
||||||
|
statusPane.SetTitle(" CLI Status / Command Output ")
|
||||||
|
statusPane.SetBorder(true)
|
||||||
|
|
||||||
|
frameworkLogPane = tview.NewTextView()
|
||||||
|
frameworkLogPane.SetDynamicColors(true)
|
||||||
|
frameworkLogPane.SetRegions(true)
|
||||||
|
frameworkLogPane.SetWordWrap(true)
|
||||||
|
frameworkLogPane.SetChangedFunc(func() {
|
||||||
|
frameworkLogPane.ScrollToEnd()
|
||||||
|
app.Draw()
|
||||||
|
})
|
||||||
|
frameworkLogPane.SetTitle(" MARTe2 Framework Logs ")
|
||||||
|
frameworkLogPane.SetBorder(true)
|
||||||
|
|
||||||
|
cmdInput = tview.NewInputField()
|
||||||
|
cmdInput.SetLabel("marte_debug> ")
|
||||||
|
cmdInput.SetFieldWidth(0)
|
||||||
|
cmdInput.SetDoneFunc(func(key tcell.Key) {
|
||||||
|
if key == tcell.KeyEnter {
|
||||||
|
text := cmdInput.GetText()
|
||||||
|
if text != "" {
|
||||||
|
handleInput(text)
|
||||||
|
cmdInput.SetText("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
flexTop := tview.NewFlex()
|
||||||
|
flexTop.SetDirection(tview.FlexColumn)
|
||||||
|
flexTop.AddItem(forcedPane, 0, 1, false)
|
||||||
|
flexTop.AddItem(tracedPane, 0, 1, false)
|
||||||
|
flexTop.AddItem(statusPane, 0, 1, false)
|
||||||
|
|
||||||
|
mainFlex = tview.NewFlex()
|
||||||
|
mainFlex.SetDirection(tview.FlexRow)
|
||||||
|
mainFlex.AddItem(flexTop, 0, 2, false)
|
||||||
|
mainFlex.AddItem(frameworkLogPane, 0, 1, false)
|
||||||
|
mainFlex.AddItem(cmdInput, 1, 0, true)
|
||||||
|
|
||||||
|
go connectAndMonitor("127.0.0.1:8080")
|
||||||
|
go startUDPListener(8081)
|
||||||
|
|
||||||
|
if err := app.SetRoot(mainFlex, true).EnableMouse(true).Run(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
BINARY := marte2-web-client
|
|
||||||
GIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
||||||
TIMESTAMP := $(shell date -u +%Y%m%d-%H%M%S)
|
|
||||||
VERSION := $(GIT_HASH)-$(TIMESTAMP)
|
|
||||||
|
|
||||||
LDFLAGS := -X main.buildVersion=$(VERSION)
|
|
||||||
|
|
||||||
.PHONY: all build clean
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o $(BINARY) .
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BINARY)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
module marte2-web-client
|
|
||||||
|
|
||||||
go 1.21
|
|
||||||
|
|
||||||
require github.com/gorilla/websocket v1.5.1
|
|
||||||
|
|
||||||
require golang.org/x/net v0.17.0 // indirect
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
|
||||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
|
||||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
|
||||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"embed"
|
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
|
||||||
"io/fs"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
)
|
|
||||||
|
|
||||||
// buildVersion is injected at link time:
|
|
||||||
//
|
|
||||||
// go build -ldflags "-X main.buildVersion=$(git rev-parse --short HEAD)"
|
|
||||||
var buildVersion = "dev"
|
|
||||||
|
|
||||||
//go:embed static
|
|
||||||
var staticFiles embed.FS
|
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{
|
|
||||||
CheckOrigin: func(r *http.Request) bool { return true },
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Wire message types
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type InMsg struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Data json.RawMessage `json:"data,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConnectData struct {
|
|
||||||
Host string `json:"host"`
|
|
||||||
Port int `json:"port"`
|
|
||||||
UDPPort int `json:"udp_port"`
|
|
||||||
LogPort int `json:"log_port"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CmdData struct {
|
|
||||||
Cmd string `json:"cmd"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Hub – fan-out WS messages to all connected browsers
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type Hub struct {
|
|
||||||
mu sync.RWMutex
|
|
||||||
clients map[*WSClient]struct{}
|
|
||||||
marte *MarteClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func newHub() *Hub {
|
|
||||||
return &Hub{clients: make(map[*WSClient]struct{})}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hub) add(c *WSClient) {
|
|
||||||
h.mu.Lock()
|
|
||||||
h.clients[c] = struct{}{}
|
|
||||||
h.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hub) remove(c *WSClient) {
|
|
||||||
h.mu.Lock()
|
|
||||||
delete(h.clients, c)
|
|
||||||
h.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hub) broadcast(msg []byte) {
|
|
||||||
h.mu.RLock()
|
|
||||||
defer h.mu.RUnlock()
|
|
||||||
for c := range h.clients {
|
|
||||||
select {
|
|
||||||
case c.send <- msg:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// WSClient – one browser tab
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type WSClient struct {
|
|
||||||
hub *Hub
|
|
||||||
conn *websocket.Conn
|
|
||||||
send chan []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *WSClient) writePump() {
|
|
||||||
ticker := time.NewTicker(30 * time.Second)
|
|
||||||
defer func() {
|
|
||||||
ticker.Stop()
|
|
||||||
c.conn.Close()
|
|
||||||
}()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case msg, ok := <-c.send:
|
|
||||||
c.conn.SetWriteDeadline(time.Now().Add(10 * time.Second))
|
|
||||||
if !ok {
|
|
||||||
c.conn.WriteMessage(websocket.CloseMessage, []byte{})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := c.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case <-ticker.C:
|
|
||||||
c.conn.SetWriteDeadline(time.Now().Add(10 * time.Second))
|
|
||||||
if err := c.conn.WriteMessage(websocket.PingMessage, nil); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *WSClient) readPump() {
|
|
||||||
defer func() {
|
|
||||||
c.hub.remove(c)
|
|
||||||
c.conn.Close()
|
|
||||||
}()
|
|
||||||
c.conn.SetReadLimit(256 * 1024)
|
|
||||||
c.conn.SetReadDeadline(time.Now().Add(60 * time.Second))
|
|
||||||
c.conn.SetPongHandler(func(string) error {
|
|
||||||
c.conn.SetReadDeadline(time.Now().Add(60 * time.Second))
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
for {
|
|
||||||
_, raw, err := c.conn.ReadMessage()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
c.conn.SetReadDeadline(time.Now().Add(60 * time.Second))
|
|
||||||
|
|
||||||
var in InMsg
|
|
||||||
if err := json.Unmarshal(raw, &in); err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c.handleIncoming(in)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *WSClient) handleIncoming(in InMsg) {
|
|
||||||
m := c.hub.marte
|
|
||||||
switch in.Type {
|
|
||||||
case "connect":
|
|
||||||
var d ConnectData
|
|
||||||
if err := json.Unmarshal(in.Data, &d); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if d.Host == "" {
|
|
||||||
d.Host = "127.0.0.1"
|
|
||||||
}
|
|
||||||
if d.Port == 0 {
|
|
||||||
d.Port = 8080
|
|
||||||
}
|
|
||||||
if d.UDPPort == 0 {
|
|
||||||
d.UDPPort = 8081
|
|
||||||
}
|
|
||||||
if d.LogPort == 0 {
|
|
||||||
d.LogPort = 8082
|
|
||||||
}
|
|
||||||
log.Printf("[WS] connect request host=%s cmd=%d udp=%d log=%d",
|
|
||||||
d.Host, d.Port, d.UDPPort, d.LogPort)
|
|
||||||
m.Connect(d.Host, d.Port, d.UDPPort, d.LogPort)
|
|
||||||
|
|
||||||
case "disconnect":
|
|
||||||
log.Printf("[WS] disconnect request")
|
|
||||||
m.Disconnect()
|
|
||||||
|
|
||||||
case "cmd":
|
|
||||||
var d CmdData
|
|
||||||
if err := json.Unmarshal(in.Data, &d); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.SendCommand(d.Cmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// HTTP handler
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func wsHandler(hub *Hub, w http.ResponseWriter, r *http.Request) {
|
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("upgrade:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c := &WSClient{hub: hub, conn: conn, send: make(chan []byte, 256)}
|
|
||||||
hub.add(c)
|
|
||||||
|
|
||||||
// Send current connection status to newly joined client.
|
|
||||||
if hub.marte.IsConnected() {
|
|
||||||
b, _ := json.Marshal(map[string]any{"type": "connected"})
|
|
||||||
c.send <- b
|
|
||||||
// Also push current signal list if already discovered.
|
|
||||||
hub.marte.SendCachedState(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
go c.writePump()
|
|
||||||
c.readPump() // blocks until client disconnects
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// main
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
addr := flag.String("addr", ":7777", "HTTP listen address")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
hub := newHub()
|
|
||||||
hub.marte = newMarteClient(hub)
|
|
||||||
|
|
||||||
sub, err := fs.Sub(staticFiles, "static")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
fileServer := http.FileServer(http.FS(sub))
|
|
||||||
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
wsHandler(hub, w, r)
|
|
||||||
})
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// Serve index.html for the root path explicitly.
|
|
||||||
if r.URL.Path == "/" {
|
|
||||||
data, err := staticFiles.ReadFile("static/index.html")
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, "not found", http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
||||||
w.Write(data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fileServer.ServeHTTP(w, r)
|
|
||||||
})
|
|
||||||
|
|
||||||
log.Printf("MARTe2 Web Debug Client build=%s listening on %s", buildVersion, *addr)
|
|
||||||
log.Fatal(http.ListenAndServe(*addr, nil))
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,763 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"encoding/binary"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"math"
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Signal metadata (populated by DISCOVER)
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type SignalMeta struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
ID uint32 `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Dimensions uint8 `json:"dimensions"`
|
|
||||||
Elements uint32 `json:"elements"`
|
|
||||||
Names []string // canonical + alias names mapping to this ID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Outbound WS message helpers
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type TelemetrySample struct {
|
|
||||||
ID uint32 `json:"id"`
|
|
||||||
Names []string `json:"names"`
|
|
||||||
Ts float64 `json:"ts"`
|
|
||||||
Values []float64 `json:"values"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func broadcast(hub *Hub, v any) {
|
|
||||||
b, err := json.Marshal(v)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
hub.broadcast(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// MarteClient
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type MarteClient struct {
|
|
||||||
hub *Hub
|
|
||||||
|
|
||||||
mu sync.Mutex
|
|
||||||
tcpConn net.Conn
|
|
||||||
writer *bufio.Writer
|
|
||||||
|
|
||||||
cmdMu sync.Mutex // serialise TCP writes
|
|
||||||
|
|
||||||
sigMu sync.RWMutex
|
|
||||||
signals map[uint32]*SignalMeta // id -> meta
|
|
||||||
|
|
||||||
baseTs uint64
|
|
||||||
baseTsSet bool
|
|
||||||
basesMu sync.Mutex
|
|
||||||
|
|
||||||
connected int32 // atomic bool
|
|
||||||
|
|
||||||
lastWriteMs int64 // atomic; updated on every TCP write, used by keepalive
|
|
||||||
|
|
||||||
stopCh chan struct{}
|
|
||||||
|
|
||||||
// accumulates signals across DISCOVER_PART chunks; merged on final DISCOVER
|
|
||||||
discoverAcc []discoverSignalJSON
|
|
||||||
|
|
||||||
// cached last-known ports (updated by SERVICE_INFO)
|
|
||||||
host string
|
|
||||||
cmdPort int
|
|
||||||
udpPort int
|
|
||||||
logPort int
|
|
||||||
}
|
|
||||||
|
|
||||||
func newMarteClient(hub *Hub) *MarteClient {
|
|
||||||
return &MarteClient{
|
|
||||||
hub: hub,
|
|
||||||
signals: make(map[uint32]*SignalMeta),
|
|
||||||
stopCh: make(chan struct{}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) IsConnected() bool {
|
|
||||||
return atomic.LoadInt32(&m.connected) == 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendCachedState sends the current signal list to a freshly connected browser.
|
|
||||||
func (m *MarteClient) SendCachedState(c *WSClient) {
|
|
||||||
m.sigMu.RLock()
|
|
||||||
defer m.sigMu.RUnlock()
|
|
||||||
if len(m.signals) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sigs := make([]*SignalMeta, 0, len(m.signals))
|
|
||||||
for _, s := range m.signals {
|
|
||||||
sigs = append(sigs, s)
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(map[string]any{"type": "signal_cache", "signals": sigs})
|
|
||||||
select {
|
|
||||||
case c.send <- b:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Connect / Disconnect
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func (m *MarteClient) Connect(host string, cmdPort, udpPort, logPort int) {
|
|
||||||
m.Disconnect()
|
|
||||||
|
|
||||||
m.mu.Lock()
|
|
||||||
m.host = host
|
|
||||||
m.cmdPort = cmdPort
|
|
||||||
m.udpPort = udpPort
|
|
||||||
m.logPort = logPort
|
|
||||||
m.stopCh = make(chan struct{})
|
|
||||||
m.mu.Unlock()
|
|
||||||
|
|
||||||
go m.runTCP(host, cmdPort)
|
|
||||||
go m.runUDP(host, udpPort)
|
|
||||||
go m.runLog(host, logPort)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) Disconnect() {
|
|
||||||
m.mu.Lock()
|
|
||||||
select {
|
|
||||||
case <-m.stopCh:
|
|
||||||
// already closed
|
|
||||||
default:
|
|
||||||
close(m.stopCh)
|
|
||||||
}
|
|
||||||
if m.tcpConn != nil {
|
|
||||||
m.tcpConn.Close()
|
|
||||||
m.tcpConn = nil
|
|
||||||
}
|
|
||||||
m.mu.Unlock()
|
|
||||||
|
|
||||||
atomic.StoreInt32(&m.connected, 0)
|
|
||||||
m.basesMu.Lock()
|
|
||||||
m.baseTsSet = false
|
|
||||||
m.basesMu.Unlock()
|
|
||||||
m.discoverAcc = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) stopped() bool {
|
|
||||||
select {
|
|
||||||
case <-m.stopCh:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// TCP command channel
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func (m *MarteClient) runTCP(host string, port int) {
|
|
||||||
addr := fmt.Sprintf("%s:%d", host, port)
|
|
||||||
for !m.stopped() {
|
|
||||||
conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
|
|
||||||
if err != nil {
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
conn.(*net.TCPConn).SetNoDelay(true)
|
|
||||||
|
|
||||||
m.mu.Lock()
|
|
||||||
m.tcpConn = conn
|
|
||||||
m.writer = bufio.NewWriter(conn)
|
|
||||||
m.mu.Unlock()
|
|
||||||
|
|
||||||
atomic.StoreInt32(&m.connected, 1)
|
|
||||||
broadcast(m.hub, map[string]any{"type": "connected"})
|
|
||||||
|
|
||||||
// Send SERVICE_INFO to auto-discover ports
|
|
||||||
m.writeCmd("SERVICE_INFO")
|
|
||||||
|
|
||||||
go m.runKeepalive()
|
|
||||||
|
|
||||||
m.readLoop(conn)
|
|
||||||
|
|
||||||
atomic.StoreInt32(&m.connected, 0)
|
|
||||||
broadcast(m.hub, map[string]any{"type": "disconnected"})
|
|
||||||
|
|
||||||
m.mu.Lock()
|
|
||||||
m.tcpConn = nil
|
|
||||||
m.writer = nil
|
|
||||||
m.mu.Unlock()
|
|
||||||
|
|
||||||
if !m.stopped() {
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) writeCmd(cmd string) {
|
|
||||||
m.cmdMu.Lock()
|
|
||||||
defer m.cmdMu.Unlock()
|
|
||||||
m.mu.Lock()
|
|
||||||
w := m.writer
|
|
||||||
m.mu.Unlock()
|
|
||||||
if w == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Printf("[→MARTe] %s", cmd)
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "log", "time": time.Now().Format("15:04:05.000"),
|
|
||||||
"level": "CMD", "message": fmt.Sprintf("→ %s", cmd),
|
|
||||||
})
|
|
||||||
w.WriteString(cmd + "\n")
|
|
||||||
w.Flush()
|
|
||||||
atomic.StoreInt64(&m.lastWriteMs, time.Now().UnixMilli())
|
|
||||||
}
|
|
||||||
|
|
||||||
// runKeepalive sends INFO every 20 s when no other command has been written
|
|
||||||
// in the last 20 s, keeping the DebugService 30 s idle timer from firing.
|
|
||||||
func (m *MarteClient) runKeepalive() {
|
|
||||||
ticker := time.NewTicker(20 * time.Second)
|
|
||||||
defer ticker.Stop()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-m.stopCh:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if !m.IsConnected() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
idleMs := time.Now().UnixMilli() - atomic.LoadInt64(&m.lastWriteMs)
|
|
||||||
if idleMs >= 20_000 {
|
|
||||||
m.writeCmd("INFO")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) SendCommand(cmd string) {
|
|
||||||
m.writeCmd(cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) readLoop(conn net.Conn) {
|
|
||||||
scanner := bufio.NewScanner(conn)
|
|
||||||
scanner.Buffer(make([]byte, 8*1024*1024), 8*1024*1024)
|
|
||||||
|
|
||||||
var jsonAcc strings.Builder
|
|
||||||
inJSON := false
|
|
||||||
|
|
||||||
for scanner.Scan() {
|
|
||||||
if m.stopped() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
line := scanner.Text()
|
|
||||||
trimmed := strings.TrimSpace(line)
|
|
||||||
if trimmed == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect start of JSON block
|
|
||||||
if !inJSON && strings.HasPrefix(trimmed, "{") {
|
|
||||||
inJSON = true
|
|
||||||
jsonAcc.Reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
if inJSON {
|
|
||||||
jsonAcc.WriteString(trimmed)
|
|
||||||
tag, done := detectJSONDone(trimmed)
|
|
||||||
if done {
|
|
||||||
inJSON = false
|
|
||||||
raw := jsonAcc.String()
|
|
||||||
// Strip trailing sentinel
|
|
||||||
idx := strings.Index(raw, "OK "+tag)
|
|
||||||
if idx >= 0 {
|
|
||||||
raw = strings.TrimSpace(raw[:idx])
|
|
||||||
}
|
|
||||||
m.handleJSONResponse(tag, raw)
|
|
||||||
jsonAcc.Reset()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m.handleTextLine(trimmed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// detectJSONDone returns (tag, true) when the line is exactly "OK <TAG>".
|
|
||||||
// DISCOVER_PART must appear before DISCOVER so partial chunks are not mistaken
|
|
||||||
// for the final chunk (though with exact matching this is not strictly
|
|
||||||
// necessary; kept for clarity).
|
|
||||||
func detectJSONDone(line string) (string, bool) {
|
|
||||||
tags := []string{
|
|
||||||
"DISCOVER_PART", "DISCOVER", "TREE", "INFO", "CONFIG", "STEP_STATUS",
|
|
||||||
"VALUE", "MSG", "TRACE", "FORCE", "UNFORCE", "BREAK",
|
|
||||||
"PAUSE", "RESUME", "STEP", "MONITOR", "UNMONITOR", "LS",
|
|
||||||
}
|
|
||||||
for _, t := range tags {
|
|
||||||
if line == "OK "+t {
|
|
||||||
return t, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) handleJSONResponse(tag, data string) {
|
|
||||||
log.Printf("[←MARTe] %s %d bytes", tag, len(data))
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "log", "time": time.Now().Format("15:04:05.000"),
|
|
||||||
"level": "RESP", "message": fmt.Sprintf("← %s (%d B)", tag, len(data)),
|
|
||||||
})
|
|
||||||
switch tag {
|
|
||||||
case "DISCOVER_PART":
|
|
||||||
// Accumulate this chunk; do NOT broadcast — we wait for the final chunk.
|
|
||||||
var resp discoverResp
|
|
||||||
if err := json.Unmarshal([]byte(data), &resp); err != nil {
|
|
||||||
log.Printf("[DISCOVER_PART] parse error: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.discoverAcc = append(m.discoverAcc, resp.Signals...)
|
|
||||||
log.Printf("[DISCOVER_PART] accumulated %d signals (total so far: %d)",
|
|
||||||
len(resp.Signals), len(m.discoverAcc))
|
|
||||||
return
|
|
||||||
|
|
||||||
case "DISCOVER":
|
|
||||||
// Merge any previously accumulated part-chunks with this final chunk.
|
|
||||||
var resp discoverResp
|
|
||||||
if err := json.Unmarshal([]byte(data), &resp); err != nil {
|
|
||||||
log.Printf("[DISCOVER] parse error: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
all := append(m.discoverAcc, resp.Signals...)
|
|
||||||
m.discoverAcc = nil
|
|
||||||
m.parseDiscoverSignals(all)
|
|
||||||
// Re-marshal the merged list so the browser gets a single consistent blob.
|
|
||||||
merged, _ := json.Marshal(discoverResp{Signals: all})
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "response", "tag": "DISCOVER", "data": string(merged),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
|
|
||||||
case "TREE":
|
|
||||||
// Parse server-side and stream pre-digested flat-node batches to the
|
|
||||||
// browser so it never has to JSON.parse a multi-MB string.
|
|
||||||
go m.sendTreeBatches(data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "response",
|
|
||||||
"tag": tag,
|
|
||||||
"data": data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// TREE streaming
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// TreeNode mirrors the DebugService TREE JSON structure.
|
|
||||||
type TreeNode struct {
|
|
||||||
Name string `json:"Name"`
|
|
||||||
Class string `json:"Class"`
|
|
||||||
IsTraceable bool `json:"IsTraceable"`
|
|
||||||
IsForcable bool `json:"IsForcable"`
|
|
||||||
Elements uint32 `json:"Elements"`
|
|
||||||
Children []*TreeNode `json:"Children"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// FlatNode is a pre-digested, compact representation sent to the browser.
|
|
||||||
type FlatNode struct {
|
|
||||||
Path string `json:"p"`
|
|
||||||
Name string `json:"n"`
|
|
||||||
Class string `json:"c"`
|
|
||||||
Parent string `json:"par"`
|
|
||||||
Tr bool `json:"tr,omitempty"`
|
|
||||||
Fo bool `json:"fo,omitempty"`
|
|
||||||
El uint32 `json:"el,omitempty"`
|
|
||||||
HasCh bool `json:"ch,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func flattenTree(node *TreeNode, parentPath string, out *[]FlatNode) {
|
|
||||||
path := node.Name
|
|
||||||
if parentPath != "" {
|
|
||||||
path = parentPath + "." + node.Name
|
|
||||||
}
|
|
||||||
hasCh := len(node.Children) > 0
|
|
||||||
*out = append(*out, FlatNode{
|
|
||||||
Path: path,
|
|
||||||
Name: node.Name,
|
|
||||||
Class: node.Class,
|
|
||||||
Parent: parentPath,
|
|
||||||
Tr: node.IsTraceable,
|
|
||||||
Fo: node.IsForcable,
|
|
||||||
El: node.Elements,
|
|
||||||
HasCh: hasCh,
|
|
||||||
})
|
|
||||||
for _, c := range node.Children {
|
|
||||||
flattenTree(c, path, out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sendTreeBatches parses the raw TREE JSON and streams compact FlatNode
|
|
||||||
// batches to all browsers. Each browser processes one batch per animation
|
|
||||||
// frame, keeping the UI responsive during large tree loads.
|
|
||||||
func (m *MarteClient) sendTreeBatches(raw string) {
|
|
||||||
var root TreeNode
|
|
||||||
if err := json.Unmarshal([]byte(raw), &root); err != nil {
|
|
||||||
log.Printf("[TREE] parse error: %v — falling back to raw JSON", err)
|
|
||||||
broadcast(m.hub, map[string]any{"type": "response", "tag": "TREE", "data": raw})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var nodes []FlatNode
|
|
||||||
if root.Name == "Root" && len(root.Children) > 0 {
|
|
||||||
for _, c := range root.Children {
|
|
||||||
flattenTree(c, "", &nodes)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
flattenTree(&root, "", &nodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
total := len(nodes)
|
|
||||||
log.Printf("[TREE] streaming %d flat nodes to browser", total)
|
|
||||||
broadcast(m.hub, map[string]any{"type": "tree_clear", "total": total})
|
|
||||||
|
|
||||||
const batchSize = 50
|
|
||||||
for i := 0; i < total; i += batchSize {
|
|
||||||
end := i + batchSize
|
|
||||||
if end > total {
|
|
||||||
end = total
|
|
||||||
}
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "tree_batch",
|
|
||||||
"nodes": nodes[i:end],
|
|
||||||
"done": end == total,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) handleTextLine(line string) {
|
|
||||||
if strings.HasPrefix(line, "OK SERVICE_INFO") {
|
|
||||||
// OK SERVICE_INFO TCP_CTRL:8110 UDP_STREAM:8111 TCP_LOG:8082 STATE:RUNNING
|
|
||||||
parts := strings.Fields(line)
|
|
||||||
newUDP, newLog := 0, 0
|
|
||||||
for _, p := range parts {
|
|
||||||
if strings.HasPrefix(p, "UDP_STREAM:") {
|
|
||||||
fmt.Sscanf(p[11:], "%d", &newUDP)
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(p, "TCP_LOG:") {
|
|
||||||
fmt.Sscanf(p[8:], "%d", &newLog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Always forward as a response so the browser can display it.
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "response",
|
|
||||||
"tag": "SERVICE_INFO",
|
|
||||||
"data": line[len("OK SERVICE_INFO "):],
|
|
||||||
})
|
|
||||||
if newUDP > 0 || newLog > 0 {
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "service_config",
|
|
||||||
"udp_port": newUDP,
|
|
||||||
"log_port": newLog,
|
|
||||||
})
|
|
||||||
// Restart UDP/log workers with updated ports if they differ
|
|
||||||
m.mu.Lock()
|
|
||||||
host := m.host
|
|
||||||
oldUDP := m.udpPort
|
|
||||||
oldLog := m.logPort
|
|
||||||
if newUDP > 0 {
|
|
||||||
m.udpPort = newUDP
|
|
||||||
}
|
|
||||||
if newLog > 0 {
|
|
||||||
m.logPort = newLog
|
|
||||||
}
|
|
||||||
m.mu.Unlock()
|
|
||||||
if newUDP > 0 && newUDP != oldUDP {
|
|
||||||
go m.runUDP(host, newUDP)
|
|
||||||
}
|
|
||||||
if newLog > 0 && newLog != oldLog {
|
|
||||||
go m.runLog(host, newLog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Forward all text lines to browsers.
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "text_line",
|
|
||||||
"data": line,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// DISCOVER parsing
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
type discoverSignalJSON struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
ID uint32 `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Dimensions uint8 `json:"dimensions"`
|
|
||||||
Elements uint32 `json:"elements"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type discoverResp struct {
|
|
||||||
Signals []discoverSignalJSON `json:"Signals"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarteClient) parseDiscoverSignals(sigs []discoverSignalJSON) {
|
|
||||||
m.sigMu.Lock()
|
|
||||||
defer m.sigMu.Unlock()
|
|
||||||
m.signals = make(map[uint32]*SignalMeta, len(sigs))
|
|
||||||
for _, s := range sigs {
|
|
||||||
el := s.Elements
|
|
||||||
if el == 0 {
|
|
||||||
el = 1
|
|
||||||
}
|
|
||||||
// Multiple DISCOVER entries can share the same ID (canonical DataSource
|
|
||||||
// path + one GAM alias per broker). Merge them into one SignalMeta so
|
|
||||||
// that Names carries every alias. This is required for the telemetry
|
|
||||||
// receiver to match whichever name the user traced.
|
|
||||||
if existing, ok := m.signals[s.ID]; ok {
|
|
||||||
existing.Names = append(existing.Names, s.Name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
meta := &SignalMeta{
|
|
||||||
Name: s.Name,
|
|
||||||
ID: s.ID,
|
|
||||||
Type: s.Type,
|
|
||||||
Dimensions: s.Dimensions,
|
|
||||||
Elements: el,
|
|
||||||
Names: []string{s.Name},
|
|
||||||
}
|
|
||||||
m.signals[s.ID] = meta
|
|
||||||
}
|
|
||||||
log.Printf("[DISCOVER] registered %d unique signals from %d entries", len(m.signals), len(sigs))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// UDP telemetry
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const udpMagic uint32 = 0xDA7A57AD
|
|
||||||
|
|
||||||
func (m *MarteClient) runUDP(host string, port int) {
|
|
||||||
addr := fmt.Sprintf("0.0.0.0:%d", port)
|
|
||||||
udpAddr, err := net.ResolveUDPAddr("udp4", addr)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
conn, err := net.ListenUDP("udp4", udpAddr)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer conn.Close()
|
|
||||||
conn.SetReadBuffer(10 * 1024 * 1024)
|
|
||||||
conn.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
|
|
||||||
|
|
||||||
buf := make([]byte, 65535)
|
|
||||||
var lastSeq uint32
|
|
||||||
var hasLastSeq bool
|
|
||||||
var totalPkts uint64
|
|
||||||
var dropped uint64
|
|
||||||
|
|
||||||
for !m.stopped() {
|
|
||||||
conn.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
|
|
||||||
n, _, err := conn.ReadFromUDP(buf)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if n < 20 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if binary.LittleEndian.Uint32(buf[0:4]) != udpMagic {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
seq := binary.LittleEndian.Uint32(buf[4:8])
|
|
||||||
if hasLastSeq && seq > lastSeq+1 {
|
|
||||||
dropped += uint64(seq - lastSeq - 1)
|
|
||||||
}
|
|
||||||
lastSeq = seq
|
|
||||||
hasLastSeq = true
|
|
||||||
|
|
||||||
totalPkts++
|
|
||||||
if totalPkts%500 == 0 {
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "udp_stats",
|
|
||||||
"packets": totalPkts,
|
|
||||||
"dropped": dropped,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
count := binary.LittleEndian.Uint32(buf[16:20])
|
|
||||||
offset := 20
|
|
||||||
|
|
||||||
// Resolve base timestamp once per packet.
|
|
||||||
m.basesMu.Lock()
|
|
||||||
if !m.baseTsSet && n >= 20+12 {
|
|
||||||
m.baseTs = binary.LittleEndian.Uint64(buf[20+4 : 20+12])
|
|
||||||
m.baseTsSet = true
|
|
||||||
}
|
|
||||||
baseTs := m.baseTs
|
|
||||||
baseTsSet := m.baseTsSet
|
|
||||||
m.basesMu.Unlock()
|
|
||||||
|
|
||||||
m.sigMu.RLock()
|
|
||||||
samples := make([]TelemetrySample, 0, count)
|
|
||||||
for i := uint32(0); i < count; i++ {
|
|
||||||
if offset+16 > n {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
id := binary.LittleEndian.Uint32(buf[offset : offset+4])
|
|
||||||
tsRaw := binary.LittleEndian.Uint64(buf[offset+4 : offset+12])
|
|
||||||
size := binary.LittleEndian.Uint32(buf[offset+12 : offset+16])
|
|
||||||
offset += 16
|
|
||||||
|
|
||||||
if offset+int(size) > n {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
dataSlice := buf[offset : offset+int(size)]
|
|
||||||
offset += int(size)
|
|
||||||
|
|
||||||
tsS := 0.0
|
|
||||||
if baseTsSet && tsRaw >= baseTs {
|
|
||||||
tsS = float64(tsRaw-baseTs) / 1_000_000.0
|
|
||||||
}
|
|
||||||
|
|
||||||
meta, ok := m.signals[id]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
elements := meta.Elements
|
|
||||||
if elements == 0 {
|
|
||||||
elements = 1
|
|
||||||
}
|
|
||||||
typeSize := uint32(size)
|
|
||||||
if elements > 0 {
|
|
||||||
typeSize = uint32(size) / elements
|
|
||||||
}
|
|
||||||
vals := make([]float64, 0, elements)
|
|
||||||
t := meta.Type
|
|
||||||
|
|
||||||
for e := uint32(0); e < elements; e++ {
|
|
||||||
off := e * typeSize
|
|
||||||
if off+typeSize > uint32(len(dataSlice)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
elem := dataSlice[off : off+typeSize]
|
|
||||||
vals = append(vals, parseTypedValue(elem, typeSize, t))
|
|
||||||
}
|
|
||||||
|
|
||||||
samples = append(samples, TelemetrySample{
|
|
||||||
ID: id,
|
|
||||||
Names: meta.Names,
|
|
||||||
Ts: tsS,
|
|
||||||
Values: vals,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
m.sigMu.RUnlock()
|
|
||||||
|
|
||||||
if len(samples) > 0 {
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "telemetry",
|
|
||||||
"seq": seq,
|
|
||||||
"signals": samples,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseTypedValue(data []byte, size uint32, t string) float64 {
|
|
||||||
switch size {
|
|
||||||
case 1:
|
|
||||||
if strings.Contains(t, "u") {
|
|
||||||
return float64(data[0])
|
|
||||||
}
|
|
||||||
return float64(int8(data[0]))
|
|
||||||
case 2:
|
|
||||||
if len(data) < 2 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
v := binary.LittleEndian.Uint16(data[:2])
|
|
||||||
if strings.Contains(t, "u") {
|
|
||||||
return float64(v)
|
|
||||||
}
|
|
||||||
return float64(int16(v))
|
|
||||||
case 4:
|
|
||||||
if len(data) < 4 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
v := binary.LittleEndian.Uint32(data[:4])
|
|
||||||
if strings.Contains(t, "float") || strings.Contains(t, "float32") {
|
|
||||||
return float64(math.Float32frombits(v))
|
|
||||||
}
|
|
||||||
if strings.Contains(t, "u") {
|
|
||||||
return float64(v)
|
|
||||||
}
|
|
||||||
return float64(int32(v))
|
|
||||||
case 8:
|
|
||||||
if len(data) < 8 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
v := binary.LittleEndian.Uint64(data[:8])
|
|
||||||
if strings.Contains(t, "float") || strings.Contains(t, "float64") || strings.Contains(t, "double") {
|
|
||||||
return math.Float64frombits(v)
|
|
||||||
}
|
|
||||||
if strings.Contains(t, "u") {
|
|
||||||
return float64(v)
|
|
||||||
}
|
|
||||||
return float64(int64(v))
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// TCP log channel
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
func (m *MarteClient) runLog(host string, port int) {
|
|
||||||
addr := fmt.Sprintf("%s:%d", host, port)
|
|
||||||
for !m.stopped() {
|
|
||||||
conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
|
|
||||||
if err != nil {
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
scanner := bufio.NewScanner(conn)
|
|
||||||
for scanner.Scan() {
|
|
||||||
if m.stopped() {
|
|
||||||
conn.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
line := strings.TrimSpace(scanner.Text())
|
|
||||||
if strings.HasPrefix(line, "LOG ") {
|
|
||||||
rest := line[4:]
|
|
||||||
idx := strings.Index(rest, " ")
|
|
||||||
if idx < 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
level := rest[:idx]
|
|
||||||
msg := rest[idx+1:]
|
|
||||||
broadcast(m.hub, map[string]any{
|
|
||||||
"type": "log",
|
|
||||||
"time": time.Now().Format("15:04:05.000"),
|
|
||||||
"level": level,
|
|
||||||
"message": msg,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
conn.Close()
|
|
||||||
if !m.stopped() {
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
||||||
<rect width="32" height="32" rx="5" fill="#1e1e2e"/>
|
|
||||||
<!-- oscilloscope grid lines -->
|
|
||||||
<line x1="2" y1="16" x2="30" y2="16" stroke="#313244" stroke-width="0.8"/>
|
|
||||||
<line x1="16" y1="3" x2="16" y2="29" stroke="#313244" stroke-width="0.8"/>
|
|
||||||
<!-- waveform -->
|
|
||||||
<polyline points="2,16 7,16 9,7 12,25 16,7 20,25 23,16 25,16 27,11 30,11"
|
|
||||||
fill="none" stroke="#89b4fa" stroke-width="2"
|
|
||||||
stroke-linejoin="round" stroke-linecap="round"/>
|
|
||||||
<!-- scope bezel -->
|
|
||||||
<rect x="1" y="1" width="30" height="30" rx="4"
|
|
||||||
fill="none" stroke="#45475a" stroke-width="1.5"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 638 B |
@@ -1,412 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>MARTe2 Debug Client</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="favicon.svg">
|
|
||||||
<link rel="stylesheet" href="uplot.min.css">
|
|
||||||
<style>
|
|
||||||
*{box-sizing:border-box;margin:0;padding:0}
|
|
||||||
html,body{height:100%;overflow:hidden;font-family:'Segoe UI',system-ui,sans-serif;font-size:12px;background:#1e1e2e;color:#cdd6f4}
|
|
||||||
|
|
||||||
/* ── layout ── */
|
|
||||||
#app{display:flex;flex-direction:column;height:100vh}
|
|
||||||
#toolbar{display:flex;align-items:center;gap:6px;padding:4px 8px;background:#181825;border-bottom:1px solid #313244;flex-shrink:0;flex-wrap:wrap}
|
|
||||||
#main{display:flex;flex:1;overflow:hidden}
|
|
||||||
#left-panel{width:240px;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid #313244;overflow:hidden}
|
|
||||||
#center-panel{flex:1;overflow:hidden;display:flex;flex-direction:column;gap:6px;padding:6px}
|
|
||||||
#right-panel{width:260px;flex-shrink:0;display:flex;flex-direction:column;border-left:1px solid #313244;overflow:hidden}
|
|
||||||
#log-panel{height:160px;flex-shrink:0;border-top:1px solid #313244;display:flex;flex-direction:column;overflow:hidden}
|
|
||||||
|
|
||||||
/* ── toolbar ── */
|
|
||||||
.tb-group{display:flex;align-items:center;gap:4px;padding:0 6px;border-right:1px solid #313244}
|
|
||||||
.tb-group:last-child{border-right:none}
|
|
||||||
input[type=text],input[type=number]{background:#313244;border:1px solid #45475a;color:#cdd6f4;padding:2px 6px;border-radius:4px;width:100px}
|
|
||||||
input[type=number]{width:60px}
|
|
||||||
button{background:#313244;border:1px solid #45475a;color:#cdd6f4;padding:2px 8px;border-radius:4px;cursor:pointer;white-space:nowrap}
|
|
||||||
button:hover{background:#45475a}
|
|
||||||
button.active{background:#89b4fa;color:#1e1e2e;border-color:#89b4fa}
|
|
||||||
button.danger{background:#f38ba8;color:#1e1e2e;border-color:#f38ba8}
|
|
||||||
button.warn{background:#fab387;color:#1e1e2e;border-color:#fab387}
|
|
||||||
button.ok{background:#a6e3a1;color:#1e1e2e;border-color:#a6e3a1}
|
|
||||||
label{color:#a6adc8;user-select:none}
|
|
||||||
#conn-status{width:8px;height:8px;border-radius:50%;background:#f38ba8;display:inline-block;flex-shrink:0;vertical-align:middle}
|
|
||||||
#conn-status.ok{background:#a6e3a1}
|
|
||||||
#udp-stats{color:#585b70;font-size:11px;margin-left:4px}
|
|
||||||
|
|
||||||
/* ── dropdown menus ── */
|
|
||||||
.menu-wrap{position:relative}
|
|
||||||
.dropdown{position:absolute;top:calc(100% + 4px);left:0;z-index:200;background:#1e1e2e;border:1px solid #45475a;border-radius:6px;padding:8px;min-width:260px;display:none;flex-direction:column;gap:6px;box-shadow:0 4px 16px rgba(0,0,0,.5)}
|
|
||||||
.dropdown.open{display:flex}
|
|
||||||
.menu-sep{border:none;border-top:1px solid #313244;margin:2px 0}
|
|
||||||
.menu-row{display:flex;gap:6px;align-items:center}
|
|
||||||
.menu-row input[type=text]{flex:1;min-width:0;width:auto}
|
|
||||||
.menu-row input[type=number]{width:64px}
|
|
||||||
.menu-btn-row{display:flex;gap:6px}
|
|
||||||
.menu-btn-row button{flex:1}
|
|
||||||
|
|
||||||
/* ── panels ── */
|
|
||||||
.panel-header{padding:4px 8px;background:#181825;border-bottom:1px solid #313244;font-weight:600;color:#89b4fa;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
|
|
||||||
.panel-search{padding:4px;border-bottom:1px solid #313244;flex-shrink:0}
|
|
||||||
.panel-search input{width:100%;background:#313244;border:1px solid #45475a;color:#cdd6f4;padding:3px 6px;border-radius:4px}
|
|
||||||
.panel-body{flex:1;overflow-y:auto}
|
|
||||||
.panel-toggle{background:transparent;border:none;color:#585b70;cursor:pointer;padding:0 2px;font-size:11px;line-height:1}
|
|
||||||
.panel-toggle:hover{color:#cdd6f4;background:transparent}
|
|
||||||
|
|
||||||
/* ── collapsible panels ── */
|
|
||||||
#left-panel{transition:width .15s;position:relative}
|
|
||||||
#left-panel.collapsed{width:0!important;border:none;overflow:hidden}
|
|
||||||
#right-panel{transition:width .15s;position:relative}
|
|
||||||
#right-panel.collapsed{width:0!important;border:none;overflow:hidden}
|
|
||||||
#log-panel{transition:height .15s}
|
|
||||||
#log-panel.collapsed{height:28px;overflow:hidden}
|
|
||||||
/* collapse/resize strips */
|
|
||||||
.panel-strip{width:6px;flex-shrink:0;display:flex;align-items:center;justify-content:center;cursor:col-resize;background:#181825;border:none;color:#585b70;font-size:9px;user-select:none;position:relative}
|
|
||||||
.panel-strip::after{content:'';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:2px;height:32px;background:#45475a;border-radius:1px;pointer-events:none}
|
|
||||||
.panel-strip:hover{background:#313244}
|
|
||||||
.panel-strip:hover::after{background:#89b4fa}
|
|
||||||
#left-strip{border-right:1px solid #313244}
|
|
||||||
#right-strip{border-left:1px solid #313244}
|
|
||||||
|
|
||||||
/* ── tree ── */
|
|
||||||
.tree-node{padding:1px 0}
|
|
||||||
.tree-leaf{display:flex;align-items:center;gap:2px;padding:1px 4px;cursor:default;user-select:none}
|
|
||||||
.tree-leaf:hover{background:#313244}
|
|
||||||
.tree-leaf.selected{background:#45475a}
|
|
||||||
.tree-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
||||||
.tree-class{color:#585b70;font-size:10px;flex-shrink:0}
|
|
||||||
details>summary{list-style:none;cursor:pointer;padding:1px 4px;display:flex;align-items:center;gap:4px;user-select:none}
|
|
||||||
details>summary:hover{background:#313244}
|
|
||||||
details>summary::before{content:'▶';font-size:9px;color:#585b70;width:10px;flex-shrink:0}
|
|
||||||
details[open]>summary::before{content:'▼'}
|
|
||||||
details>.children{padding-left:14px}
|
|
||||||
.tree-btn{background:transparent;border:1px solid #45475a;color:#a6adc8;padding:0 4px;border-radius:3px;cursor:pointer;font-size:10px;line-height:14px}
|
|
||||||
.tree-btn:hover{background:#45475a;color:#cdd6f4}
|
|
||||||
.tree-btn.t{border-color:#89b4fa;color:#89b4fa}
|
|
||||||
.tree-btn.f{border-color:#a6e3a1;color:#a6e3a1}
|
|
||||||
.tree-btn.b{border-color:#fab387;color:#fab387}
|
|
||||||
|
|
||||||
/* ── right panel tabs ── */
|
|
||||||
.tabs{display:flex;border-bottom:1px solid #313244;flex-shrink:0}
|
|
||||||
.tab{flex:1;padding:4px;text-align:center;cursor:pointer;color:#585b70;border-bottom:2px solid transparent}
|
|
||||||
.tab.active{color:#89b4fa;border-bottom-color:#89b4fa}
|
|
||||||
.tab-content{display:none;flex:1;overflow-y:auto;flex-direction:column}
|
|
||||||
.tab-content.active{display:flex}
|
|
||||||
|
|
||||||
/* ── signal items (right panel) ── */
|
|
||||||
.sig-item{display:flex;align-items:center;gap:4px;padding:3px 6px;border-bottom:1px solid #181825}
|
|
||||||
.sig-item:hover{background:#313244}
|
|
||||||
.sig-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}
|
|
||||||
.sig-val{color:#a6e3a1;font-size:11px;min-width:60px;text-align:right;font-family:monospace}
|
|
||||||
.sig-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
|
|
||||||
|
|
||||||
/* ── plots ── */
|
|
||||||
.plot-card{background:#181825;border:1px solid #313244;border-radius:6px;overflow:hidden;flex:1;min-height:160px;display:flex;flex-direction:column}
|
|
||||||
.plot-card.drop-active{border-color:#89b4fa}
|
|
||||||
.plot-header{display:flex;align-items:center;gap:6px;padding:4px 8px;background:#11111b;border-bottom:1px solid #313244;flex-shrink:0}
|
|
||||||
.plot-title{font-weight:600;color:#89b4fa;flex:1}
|
|
||||||
.plot-series-bar{display:flex;flex-wrap:wrap;gap:4px;padding:3px 8px;background:#11111b;border-bottom:1px solid #313244;flex-shrink:0}
|
|
||||||
.plot-series-bar:empty{display:none;padding:0;border:none}
|
|
||||||
.series-chip{display:inline-flex;align-items:center;gap:3px;background:#1e1e2e;border:1px solid #45475a;border-radius:10px;padding:1px 3px 1px 6px;font-size:10px}
|
|
||||||
.series-chip-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}
|
|
||||||
.series-chip-name{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#cdd6f4}
|
|
||||||
.series-chip-rm{background:transparent;border:none;color:#585b70;cursor:pointer;padding:0 2px;font-size:12px;line-height:1}
|
|
||||||
.series-chip-rm:hover{color:#f38ba8;background:transparent}
|
|
||||||
.plot-drop{flex:1;display:flex;align-items:center;justify-content:center;color:#45475a;border:2px dashed #313244;margin:8px;border-radius:4px}
|
|
||||||
.plot-drop.over{border-color:#89b4fa;color:#89b4fa}
|
|
||||||
.uplot-wrap{flex:1;min-height:0;padding:2px 4px 4px;display:flex;flex-direction:column}
|
|
||||||
|
|
||||||
/* ── logs ── */
|
|
||||||
#log-toolbar{display:flex;align-items:center;gap:6px;padding:3px 8px;background:#181825;border-bottom:1px solid #313244;flex-shrink:0}
|
|
||||||
#log-body{flex:1;overflow-y:auto;font-family:monospace;font-size:11px;padding:2px 0}
|
|
||||||
.log-line{padding:1px 8px;display:flex;gap:8px}
|
|
||||||
.log-time{color:#585b70;flex-shrink:0}
|
|
||||||
.log-lvl{flex-shrink:0;min-width:50px;font-weight:600}
|
|
||||||
.log-msg{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
|
|
||||||
.log-line.DEBUG .log-lvl{color:#89b4fa}
|
|
||||||
.log-line.INFO .log-lvl{color:#a6e3a1}
|
|
||||||
.log-line.WARNING .log-lvl{color:#fab387}
|
|
||||||
.log-line.ERROR,.log-line.FatalError,.log-line.FATAL{background:#2d1b1b}
|
|
||||||
.log-line.ERROR .log-lvl,.log-line.FatalError .log-lvl,.log-line.FATAL .log-lvl{color:#f38ba8}
|
|
||||||
.log-hidden{display:none}
|
|
||||||
|
|
||||||
/* ── dialogs ── */
|
|
||||||
.dialog-overlay{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:100}
|
|
||||||
.dialog{background:#1e1e2e;border:1px solid #45475a;border-radius:8px;padding:16px;min-width:320px;max-width:500px}
|
|
||||||
.dialog h3{margin-bottom:12px;color:#89b4fa}
|
|
||||||
.dialog label{display:block;margin-bottom:4px;color:#a6adc8}
|
|
||||||
.dialog input,.dialog select,.dialog textarea{width:100%;background:#313244;border:1px solid #45475a;color:#cdd6f4;padding:4px 8px;border-radius:4px;margin-bottom:10px}
|
|
||||||
.dialog textarea{height:80px;resize:vertical;font-family:monospace}
|
|
||||||
.dialog .btns{display:flex;gap:8px;justify-content:flex-end;margin-top:4px}
|
|
||||||
.dialog select option{background:#1e1e2e}
|
|
||||||
.form-row{display:flex;gap:8px}
|
|
||||||
.form-row>*{flex:1}
|
|
||||||
.form-check{display:flex;align-items:center;gap:8px;margin-bottom:10px}
|
|
||||||
.form-check input[type=checkbox]{width:auto;margin:0}
|
|
||||||
.form-check label{margin:0;color:#a6adc8}
|
|
||||||
|
|
||||||
/* ── step status bar ── */
|
|
||||||
#step-bar{background:#2d2b45;border-bottom:1px solid #313244;padding:4px 8px;display:none;align-items:center;gap:8px;flex-shrink:0}
|
|
||||||
#step-bar.visible{display:flex}
|
|
||||||
|
|
||||||
/* ── scrollbars ── */
|
|
||||||
::-webkit-scrollbar{width:6px;height:6px}
|
|
||||||
::-webkit-scrollbar-track{background:#181825}
|
|
||||||
::-webkit-scrollbar-thumb{background:#45475a;border-radius:3px}
|
|
||||||
::-webkit-scrollbar-thumb:hover{background:#585b70}
|
|
||||||
|
|
||||||
/* ── misc ── */
|
|
||||||
.empty-hint{padding:16px;color:#45475a;text-align:center}
|
|
||||||
.break-item{padding:3px 6px;border-bottom:1px solid #181825;display:flex;align-items:center;gap:4px;font-size:11px}
|
|
||||||
.break-sig{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#fab387}
|
|
||||||
.msg-item{padding:3px 6px;border-bottom:1px solid #181825;font-size:11px}
|
|
||||||
.msg-status{width:14px;text-align:center;flex-shrink:0}
|
|
||||||
select{background:#313244;border:1px solid #45475a;color:#cdd6f4;padding:2px 4px;border-radius:4px}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app">
|
|
||||||
|
|
||||||
<!-- ═══ TOOLBAR ═══ -->
|
|
||||||
<div id="toolbar">
|
|
||||||
|
|
||||||
<!-- Connection menu -->
|
|
||||||
<div class="menu-wrap tb-group">
|
|
||||||
<button id="conn-menu-btn" onclick="toggleMenu('conn-dropdown')">
|
|
||||||
<span id="conn-status"></span> Connection ▾
|
|
||||||
</button>
|
|
||||||
<div class="dropdown" id="conn-dropdown">
|
|
||||||
<div class="menu-row">
|
|
||||||
<input type="text" id="host" value="127.0.0.1" placeholder="host" style="flex:2">
|
|
||||||
<input type="number" id="port" value="8080" placeholder="ctrl" style="width:60px">
|
|
||||||
<button id="btn-connect" onclick="toggleConnect()">Connect</button>
|
|
||||||
</div>
|
|
||||||
<div class="menu-row" id="port-manual-row" style="display:none">
|
|
||||||
<label style="color:#a6adc8;font-size:11px;flex-shrink:0">UDP:</label>
|
|
||||||
<input type="number" id="udp-port" value="8081" placeholder="udp" style="width:72px">
|
|
||||||
<label style="color:#a6adc8;font-size:11px;flex-shrink:0">Log:</label>
|
|
||||||
<input type="number" id="log-port" value="8082" placeholder="log" style="width:72px">
|
|
||||||
</div>
|
|
||||||
<div class="menu-row">
|
|
||||||
<label class="form-check" style="margin:0;font-size:11px">
|
|
||||||
<input type="checkbox" id="auto-ports" checked onchange="toggleAutoPorts(this.checked)">
|
|
||||||
<span style="color:#a6adc8">Auto ports (SERVICE_INFO)</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<hr class="menu-sep">
|
|
||||||
<div class="menu-btn-row">
|
|
||||||
<button onclick="discoverCmd()">Discover</button>
|
|
||||||
<button onclick="treeCmd()">Tree</button>
|
|
||||||
<button onclick="serviceInfoCmd()">Info</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tb-group">
|
|
||||||
<button id="btn-pause" onclick="togglePause()">⏸ Pause</button>
|
|
||||||
<button onclick="openStepDialog()">⚙ Step</button>
|
|
||||||
</div>
|
|
||||||
<div class="tb-group">
|
|
||||||
<button onclick="addPlot()">+ Plot</button>
|
|
||||||
</div>
|
|
||||||
<div class="tb-group">
|
|
||||||
<button onclick="openForceDialog()">⚡ Force</button>
|
|
||||||
<button onclick="openBreakDialog()">🔴 Break</button>
|
|
||||||
<button onclick="openMsgDialog()">✉ Msg</button>
|
|
||||||
</div>
|
|
||||||
<div class="tb-group" style="border:none;margin-left:auto">
|
|
||||||
<span id="udp-stats" style="color:#585b70;font-size:11px">0 pkts</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ═══ STEP STATUS BAR ═══ -->
|
|
||||||
<div id="step-bar">
|
|
||||||
<span>⏹ PAUSED at <b id="paused-gam">—</b></span>
|
|
||||||
<span id="step-remaining"></span>
|
|
||||||
<select id="step-thread" style="width:120px"></select>
|
|
||||||
<button onclick="step(1)">Step 1</button>
|
|
||||||
<button onclick="step(5)">Step 5</button>
|
|
||||||
<button onclick="step(20)">Step 20</button>
|
|
||||||
<button class="ok" onclick="togglePause()">▶ Resume</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ═══ MAIN ═══ -->
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<!-- LEFT: object tree -->
|
|
||||||
<div id="left-panel">
|
|
||||||
<div class="panel-header">
|
|
||||||
<span>Object Tree</span>
|
|
||||||
<button style="font-size:10px;padding:1px 6px" onclick="sendCmd('TREE')">↻</button>
|
|
||||||
</div>
|
|
||||||
<div class="panel-search"><input id="tree-search" oninput="filterTree(this.value)" placeholder="Search…"></div>
|
|
||||||
<div class="panel-body" id="tree-body">
|
|
||||||
<div class="empty-hint">Connect to MARTe2 then click Tree</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Left resize/collapse strip -->
|
|
||||||
<div id="left-strip" class="panel-strip" title="Drag to resize · Click to collapse"></div>
|
|
||||||
|
|
||||||
<!-- CENTER: plots -->
|
|
||||||
<div id="center-panel">
|
|
||||||
<div class="empty-hint" id="no-plots-hint">Add a plot panel to begin — drag signals from the tree or traced list</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Right resize/collapse strip -->
|
|
||||||
<div id="right-strip" class="panel-strip" title="Drag to resize · Click to collapse"></div>
|
|
||||||
|
|
||||||
<!-- RIGHT: tabs -->
|
|
||||||
<div id="right-panel">
|
|
||||||
<div class="tabs">
|
|
||||||
<div class="tab active" onclick="switchTab('traced')">Traced</div>
|
|
||||||
<div class="tab" onclick="switchTab('forced')">Forced</div>
|
|
||||||
<div class="tab" onclick="switchTab('breaks')">Breaks</div>
|
|
||||||
<div class="tab" onclick="switchTab('msgs')">Msgs</div>
|
|
||||||
</div>
|
|
||||||
<div class="tab-content active" id="tab-traced">
|
|
||||||
<div class="empty-hint" id="no-traced-hint">No signals traced</div>
|
|
||||||
</div>
|
|
||||||
<div class="tab-content" id="tab-forced">
|
|
||||||
<div class="empty-hint" id="no-forced-hint">No signals forced</div>
|
|
||||||
</div>
|
|
||||||
<div class="tab-content" id="tab-breaks">
|
|
||||||
<div class="empty-hint" id="no-breaks-hint">No breakpoints set</div>
|
|
||||||
</div>
|
|
||||||
<div class="tab-content" id="tab-msgs">
|
|
||||||
<div class="empty-hint" id="no-msgs-hint">No messages sent</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ═══ LOGS ═══ -->
|
|
||||||
<div id="log-panel">
|
|
||||||
<div id="log-toolbar">
|
|
||||||
<button class="panel-toggle" title="Collapse logs" onclick="togglePanel('log-panel','▼','▲',this)" id="log-toggle-btn">▼</button>
|
|
||||||
<span style="font-weight:600;color:#89b4fa">Logs</span>
|
|
||||||
<label><input type="checkbox" id="lf-debug" checked onchange="renderLogs()"> Debug</label>
|
|
||||||
<label><input type="checkbox" id="lf-info" checked onchange="renderLogs()"> Info</label>
|
|
||||||
<label><input type="checkbox" id="lf-warn" checked onchange="renderLogs()"> Warn</label>
|
|
||||||
<label><input type="checkbox" id="lf-error" checked onchange="renderLogs()"> Error</label>
|
|
||||||
<input type="text" id="log-filter" placeholder="Filter…" oninput="renderLogs()" style="width:150px">
|
|
||||||
<button onclick="logs=[];renderLogs()" style="margin-left:auto">Clear</button>
|
|
||||||
<label><input type="checkbox" id="log-autoscroll" checked> Auto-scroll</label>
|
|
||||||
</div>
|
|
||||||
<div id="log-body"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div><!-- #app -->
|
|
||||||
|
|
||||||
<!-- ═══ DIALOGS ═══ -->
|
|
||||||
|
|
||||||
<!-- Force dialog -->
|
|
||||||
<div class="dialog-overlay" id="dlg-force" style="display:none" onclick="if(event.target===this)closeDlg('dlg-force')">
|
|
||||||
<div class="dialog">
|
|
||||||
<h3>⚡ Force Signal</h3>
|
|
||||||
<label>Signal</label>
|
|
||||||
<input id="force-sig" list="force-sig-list" placeholder="Signal path…">
|
|
||||||
<datalist id="force-sig-list"></datalist>
|
|
||||||
<label>Value</label>
|
|
||||||
<input id="force-val" placeholder="e.g. 42">
|
|
||||||
<div class="btns">
|
|
||||||
<button onclick="closeDlg('dlg-force')">Cancel</button>
|
|
||||||
<button class="active" onclick="doForce()">Force</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<!-- Unforce confirm -->
|
|
||||||
<div class="dialog-overlay" id="dlg-unforce" style="display:none" onclick="if(event.target===this)closeDlg('dlg-unforce')">
|
|
||||||
<div class="dialog">
|
|
||||||
<h3>Remove Force</h3>
|
|
||||||
<p id="unforce-msg" style="margin-bottom:12px;color:#cdd6f4"></p>
|
|
||||||
<div class="btns">
|
|
||||||
<button onclick="closeDlg('dlg-unforce')">Cancel</button>
|
|
||||||
<button class="danger" onclick="doUnforce()">Unforce</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<!-- Break dialog -->
|
|
||||||
<div class="dialog-overlay" id="dlg-break" style="display:none" onclick="if(event.target===this)closeDlg('dlg-break')">
|
|
||||||
<div class="dialog">
|
|
||||||
<h3>🔴 Set Breakpoint</h3>
|
|
||||||
<label>Signal</label>
|
|
||||||
<input id="break-sig" list="break-sig-list" placeholder="Signal path…">
|
|
||||||
<datalist id="break-sig-list"></datalist>
|
|
||||||
<div class="form-row">
|
|
||||||
<div>
|
|
||||||
<label>Operator</label>
|
|
||||||
<select id="break-op">
|
|
||||||
<option>></option><option>>=</option>
|
|
||||||
<option><</option><option><=</option>
|
|
||||||
<option>==</option><option>!=</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label>Threshold</label>
|
|
||||||
<input id="break-thresh" placeholder="0">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="btns">
|
|
||||||
<button onclick="closeDlg('dlg-break')">Cancel</button>
|
|
||||||
<button class="active" onclick="doBreak()">Set Break</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<!-- Message dialog -->
|
|
||||||
<div class="dialog-overlay" id="dlg-msg" style="display:none" onclick="if(event.target===this)closeDlg('dlg-msg')">
|
|
||||||
<div class="dialog">
|
|
||||||
<h3>✉ Send Message</h3>
|
|
||||||
<label>Destination</label>
|
|
||||||
<input id="msg-dest" list="msg-dest-list" placeholder="e.g. App.Functions.GAM1">
|
|
||||||
<datalist id="msg-dest-list"></datalist>
|
|
||||||
<label>Function</label>
|
|
||||||
<input id="msg-func" placeholder="FunctionName">
|
|
||||||
<label>Payload (key=value lines)</label>
|
|
||||||
<textarea id="msg-payload" placeholder="Key = Value Key2 = Value2"></textarea>
|
|
||||||
<div class="form-check">
|
|
||||||
<input type="checkbox" id="msg-wait">
|
|
||||||
<label for="msg-wait">Wait for reply</label>
|
|
||||||
</div>
|
|
||||||
<div class="btns">
|
|
||||||
<button onclick="closeDlg('dlg-msg')">Cancel</button>
|
|
||||||
<button class="active" onclick="doSendMsg()">Send</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<!-- Info dialog -->
|
|
||||||
<div class="dialog-overlay" id="dlg-info" style="display:none" onclick="if(event.target===this)closeDlg('dlg-info')">
|
|
||||||
<div class="dialog" style="max-width:600px;width:90vw">
|
|
||||||
<h3 id="info-title">Info</h3>
|
|
||||||
<pre id="info-body" style="background:#11111b;padding:8px;border-radius:4px;overflow:auto;max-height:400px;font-size:11px;color:#cdd6f4;white-space:pre-wrap"></pre>
|
|
||||||
<div class="btns" style="margin-top:12px">
|
|
||||||
<button onclick="closeDlg('dlg-info')">Close</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<!-- Step dialog -->
|
|
||||||
<div class="dialog-overlay" id="dlg-step" style="display:none" onclick="if(event.target===this)closeDlg('dlg-step')">
|
|
||||||
<div class="dialog">
|
|
||||||
<h3>⚙ Step Execution</h3>
|
|
||||||
<div class="form-row">
|
|
||||||
<div>
|
|
||||||
<label>Count</label>
|
|
||||||
<input type="number" id="step-count" value="1" min="1">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label>Thread (optional)</label>
|
|
||||||
<input id="step-thread-inp" list="step-thread-list" placeholder="all">
|
|
||||||
<datalist id="step-thread-list"></datalist>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="btns">
|
|
||||||
<button onclick="closeDlg('dlg-step')">Cancel</button>
|
|
||||||
<button class="active" onclick="doStep()">Step</button>
|
|
||||||
</div>
|
|
||||||
</div></div>
|
|
||||||
|
|
||||||
<script src="uplot.min.js"></script>
|
|
||||||
<script src="app.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
|
|
||||||
-2
File diff suppressed because one or more lines are too long
+299
-2462
File diff suppressed because it is too large
Load Diff
Generated
+431
@@ -0,0 +1,431 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_system_properties"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.20.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.2.56"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
|
||||||
|
dependencies = [
|
||||||
|
"find-msvc-tools",
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
|
||||||
|
dependencies = [
|
||||||
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
|
"num-traits",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core-foundation-sys"
|
||||||
|
version = "0.8.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "find-msvc-tools"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.65"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"log",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.90"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.182"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.29"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pipeline_validator"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"socket2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.149"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"serde",
|
||||||
|
"serde_core",
|
||||||
|
"zmij",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "socket2"
|
||||||
|
version = "0.5.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.117"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.113"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.113"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.113"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.113"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.62.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement",
|
||||||
|
"windows-interface",
|
||||||
|
"windows-link",
|
||||||
|
"windows-result",
|
||||||
|
"windows-strings",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.60.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.59.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zmij"
|
||||||
|
version = "1.0.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "pipeline_validator"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
socket2 = "0.5"
|
||||||
|
chrono = "0.4"
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
use std::io::{Read, Write};
|
||||||
|
use std::net::{TcpStream, UdpSocket};
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct Signal {
|
||||||
|
name: String,
|
||||||
|
id: u32,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
sig_type: String,
|
||||||
|
ready: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
struct DiscoverResponse {
|
||||||
|
#[serde(rename = "Signals")]
|
||||||
|
signals: Vec<Signal>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("--- MARTe2 Debug Pipeline Validator ---");
|
||||||
|
|
||||||
|
// 1. Connect to TCP Control Port
|
||||||
|
let mut stream = match TcpStream::connect("127.0.0.1:8080") {
|
||||||
|
Ok(s) => {
|
||||||
|
println!("[TCP] Connected to DebugService on 8080");
|
||||||
|
s
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("[TCP] FAILED to connect: {}", e);
|
||||||
|
println!("Check if 'run_debug_app.sh' is running.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
stream.set_read_timeout(Some(Duration::from_secs(2))).unwrap();
|
||||||
|
|
||||||
|
// 2. DISCOVER signals
|
||||||
|
println!("[TCP] Sending DISCOVER...");
|
||||||
|
stream.write_all(b"DISCOVER\n").unwrap();
|
||||||
|
|
||||||
|
let mut buf = [0u8; 8192];
|
||||||
|
let n = stream.read(&mut buf).unwrap();
|
||||||
|
let resp = String::from_utf8_lossy(&buf[..n]);
|
||||||
|
|
||||||
|
// Split JSON from OK DISCOVER terminator
|
||||||
|
let json_part = resp.split("OK DISCOVER").next().unwrap_or("").trim();
|
||||||
|
let discovery: DiscoverResponse = match serde_json::from_str(json_part) {
|
||||||
|
Ok(d) => d,
|
||||||
|
Err(e) => {
|
||||||
|
println!("[TCP] Discovery Parse Error: {}", e);
|
||||||
|
println!("Raw Response: {}", resp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("[TCP] Found {} signals.", discovery.signals.len());
|
||||||
|
let mut counter_id = None;
|
||||||
|
for s in &discovery.signals {
|
||||||
|
println!("[TCP] Signal: {} (ID={}, Ready={})", s.name, s.id, s.ready);
|
||||||
|
if s.name.contains("Timer.Counter") {
|
||||||
|
println!("[TCP] Target found: {} (ID={})", s.name, s.id);
|
||||||
|
counter_id = Some(s.id);
|
||||||
|
|
||||||
|
// 3. Enable TRACE
|
||||||
|
println!("[TCP] Enabling TRACE for {}...", s.name);
|
||||||
|
stream.write_all(format!("TRACE {} 1\n", s.name).as_bytes()).unwrap();
|
||||||
|
let mut t_buf = [0u8; 1024];
|
||||||
|
let tn = stream.read(&mut t_buf).unwrap();
|
||||||
|
println!("[TCP] TRACE Response: {}", String::from_utf8_lossy(&t_buf[..tn]).trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if counter_id.is_none() {
|
||||||
|
println!("[TCP] ERROR: Counter signal not found in discovery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Listen for UDP Telemetry
|
||||||
|
let socket = UdpSocket::bind("0.0.0.0:8081").expect("Could not bind UDP socket");
|
||||||
|
socket.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||||
|
println!("[UDP] Listening for telemetry on 8081...");
|
||||||
|
|
||||||
|
let mut samples_received = 0;
|
||||||
|
let mut last_val: Option<u32> = None;
|
||||||
|
let mut last_ts: Option<u64> = None;
|
||||||
|
let start_wait = Instant::now();
|
||||||
|
|
||||||
|
while samples_received < 20 && start_wait.elapsed().as_secs() < 10 {
|
||||||
|
let mut u_buf = [0u8; 4096];
|
||||||
|
if let Ok(n) = socket.recv(&mut u_buf) {
|
||||||
|
if n < 20 { continue; }
|
||||||
|
|
||||||
|
// Validate Header
|
||||||
|
let magic = u32::from_le_bytes(u_buf[0..4].try_into().unwrap());
|
||||||
|
if magic != 0xDA7A57AD { continue; }
|
||||||
|
|
||||||
|
let count = u32::from_le_bytes(u_buf[16..20].try_into().unwrap());
|
||||||
|
let mut offset = 20;
|
||||||
|
|
||||||
|
for _ in 0..count {
|
||||||
|
if offset + 16 > n { break; }
|
||||||
|
let id = u32::from_le_bytes(u_buf[offset..offset+4].try_into().unwrap());
|
||||||
|
let ts = u64::from_le_bytes(u_buf[offset+4..offset+12].try_into().unwrap());
|
||||||
|
let size = u32::from_le_bytes(u_buf[offset+12..offset+16].try_into().unwrap());
|
||||||
|
offset += 16;
|
||||||
|
|
||||||
|
if offset + size as usize > n { break; }
|
||||||
|
|
||||||
|
if id == counter_id.unwrap() && size == 4 {
|
||||||
|
let val = u32::from_le_bytes(u_buf[offset..offset+4].try_into().unwrap());
|
||||||
|
println!("[UDP] Match! ID={} TS={} VAL={}", id, ts, val);
|
||||||
|
|
||||||
|
if let Some(lt) = last_ts {
|
||||||
|
if ts <= lt { println!("[UDP] WARNING: Non-monotonic timestamp!"); }
|
||||||
|
}
|
||||||
|
if let Some(lv) = last_val {
|
||||||
|
if val == lv { println!("[UDP] WARNING: Stale value detected."); }
|
||||||
|
}
|
||||||
|
|
||||||
|
last_ts = Some(ts);
|
||||||
|
last_val = Some(val);
|
||||||
|
samples_received += 1;
|
||||||
|
}
|
||||||
|
offset += size as usize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if samples_received >= 20 {
|
||||||
|
println!("\n[RESULT] SUCCESS: Telemetry pipeline is fully functional!");
|
||||||
|
} else {
|
||||||
|
println!("\n[RESULT] FAILURE: Received only {} samples.", samples_received);
|
||||||
|
}
|
||||||
|
}
|
||||||
+394
@@ -0,0 +1,394 @@
|
|||||||
|
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
|
||||||
|
[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] SleepNature was not set. Using Default.
|
||||||
|
[Information] Phase was not configured, using default 0
|
||||||
|
[Warning] ExecutionMode not specified using: IndependentThread
|
||||||
|
[Warning] CPUMask not specified using: 255
|
||||||
|
[Warning] StackSize not specified using: 262144
|
||||||
|
[Information] No timer provider specified. Falling back to HighResolutionTimeProvider
|
||||||
|
[Information] Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
|
||||||
|
[Information] Inner initialization succeeded
|
||||||
|
[Information] Backward compatibility parameters injection unnecessary
|
||||||
|
[Information] SleepNature was not set. Using Default.
|
||||||
|
[Information] Phase was not configured, using default 0
|
||||||
|
[Warning] ExecutionMode not specified using: IndependentThread
|
||||||
|
[Warning] CPUMask not specified using: 255
|
||||||
|
[Warning] StackSize not specified using: 262144
|
||||||
|
[Information] No timer provider specified. Falling back to HighResolutionTimeProvider
|
||||||
|
[Information] Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
|
||||||
|
[Information] Inner initialization succeeded
|
||||||
|
[Information] Backward compatibility parameters injection unnecessary
|
||||||
|
[Information] No CPUs defined for the RealTimeThread Thread1
|
||||||
|
[Information] No StackSize defined for the RealTimeThread Thread1
|
||||||
|
[Information] No CPUs defined for the RealTimeThread Thread2
|
||||||
|
[Information] No StackSize defined for the RealTimeThread Thread2
|
||||||
|
[Information] LoaderPostInit not set
|
||||||
|
[Debug] Finished updating the signal database
|
||||||
|
[Information] Going to rtAppBuilder.ConfigureAfterInitialisation()
|
||||||
|
[Information] Going to InitialiseSignalsDatabase
|
||||||
|
[Debug] Updating the signal database
|
||||||
|
[Debug] Finished updating the signal database
|
||||||
|
[Information] Going to FlattenSignalsDatabases
|
||||||
|
[Information] Caching introspection signals
|
||||||
|
[Information] Flattening functions input signals
|
||||||
|
[Debug] Updating the signal database
|
||||||
|
[Debug] Finished updating the signal database
|
||||||
|
[Debug] Updating the signal database
|
||||||
|
[Debug] Updating the signal database
|
||||||
|
[Debug] Finished 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
|
||||||
|
[Debug] Updating the signal database
|
||||||
|
[Debug] Finished updating the signal database
|
||||||
|
[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
|
||||||
|
[Information] Going to ResolveStates
|
||||||
|
[Information] Resolving state State1
|
||||||
|
[Information] Resolving thread container Threads
|
||||||
|
[Information] Resolving thread State1.Thread1
|
||||||
|
[Information] Resolving GAM1
|
||||||
|
[Information] Resolving thread State1.Thread2
|
||||||
|
[Information] Resolving GAM2
|
||||||
|
[Information] Going to ResolveDataSources
|
||||||
|
[Information] Resolving for function GAM1 [idx: 0]
|
||||||
|
[Information] Resolving 2 signals
|
||||||
|
[Information] Resolving 2 signals
|
||||||
|
[Information] Resolving for function GAM2 [idx: 1]
|
||||||
|
[Information] Resolving 2 signals
|
||||||
|
[Information] Resolving 2 signals
|
||||||
|
[DebugBrokerBuilder] Built MemoryMapSynchronisedInputBroker
|
||||||
|
[DebugBrokerBuilder] Built MemoryMapInputBroker
|
||||||
|
[Information] Going to VerifyDataSourcesSignals
|
||||||
|
[Information] Verifying signals for Timer
|
||||||
|
[Information] Verifying signals for TimerSlow
|
||||||
|
[Information] Verifying signals for Logger
|
||||||
|
[Information] Verifying signals for DDB
|
||||||
|
[Information] Verifying signals for DAMS
|
||||||
|
[Information] Going to VerifyConsumersAndProducers
|
||||||
|
[Information] Verifying consumers and producers for Timer
|
||||||
|
[Information] Verifying consumers and producers for TimerSlow
|
||||||
|
[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
|
||||||
|
[Information] Creating broker MemoryMapSynchronisedInputBroker for GAM2 and signal Counter(0)
|
||||||
|
[DebugBrokerBuilder] Built MemoryMapSynchronisedInputBroker
|
||||||
|
[Debug] Purging dataSourcesIndexesCache. Number of children:4
|
||||||
|
[Debug] Purging functionsIndexesCache. Number of children:2
|
||||||
|
[Debug] Purging dataSourcesSignalIndexCache. Number of children:4
|
||||||
|
[Debug] Purging dataSourcesFunctionIndexesCache. Number of children:1
|
||||||
|
[Debug] Purging functionsMemoryIndexesCache. Number of children:1
|
||||||
|
[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
|
||||||
|
[DebugBrokerBuilder] Built MemoryMapInputBroker
|
||||||
|
[DebugBrokerBuilder] Built MemoryMapOutputBroker
|
||||||
|
[Information] Creating broker MemoryMapInputBroker for GAM2 and signal Time(1)
|
||||||
|
[Information] Getting input brokers for TimerSlow
|
||||||
|
[Information] Getting output brokers for TimerSlow
|
||||||
|
[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 = 1000.000000
|
||||||
|
[Information] Frequency found = 1000.000000
|
||||||
|
[Information] The timer will be set using a frequency of 1000.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
|
||||||
|
[Information] Frequency found = 10.000000
|
||||||
|
[Information] Frequency found = 10.000000
|
||||||
|
[Information] The timer will be set using a frequency of 10.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)
|
||||||
|
[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] Started application in state State1
|
||||||
|
[Information] Application starting
|
||||||
|
[Information] Counter [0:0]:1
|
||||||
|
[Information] Time [0:0]:0
|
||||||
|
[Information] Counter [0:0]:2
|
||||||
|
[Information] Time [0:0]:200000
|
||||||
|
[Information] Counter [0:0]:3
|
||||||
|
[Information] Time [0:0]:300000
|
||||||
|
[Information] Counter [0:0]:4
|
||||||
|
[Information] Time [0:0]:400000
|
||||||
|
[DebugService] Discover called. Instance: 0x7fd54d967010
|
||||||
|
[DebugService] Found existing broker: GAM1.InputBroker.MemoryMapSynchronisedInputBroker (MemoryMapSynchronisedInputBroker)
|
||||||
|
[DebugService] Found existing broker: GAM1.InputBroker.MemoryMapInputBroker (MemoryMapInputBroker)
|
||||||
|
[DebugService] Found existing broker: GAM2.InputBroker.MemoryMapSynchronisedInputBroker (MemoryMapSynchronisedInputBroker)
|
||||||
|
[DebugService] Found existing broker: GAM2.InputBroker.MemoryMapInputBroker (MemoryMapInputBroker)
|
||||||
|
[DebugService] Found existing broker: (null) (MemoryMapOutputBroker)
|
||||||
|
[DebugService] Registry Scan: Current Signals=19, Brokers=0
|
||||||
|
[Debug] Tracing state for App.Data.Timer.Counter (ID: 0, Mem: (nil)) set to 1
|
||||||
|
[Debug] WARNING: Signal App.Data.Timer.Counter is NOT associated with any active broker!
|
||||||
|
[Information] Counter [0:0]:5
|
||||||
|
[Information] Time [0:0]:500000
|
||||||
|
[Information] Counter [0:0]:6
|
||||||
|
[Information] Time [0:0]:600000
|
||||||
|
[Information] Counter [0:0]:7
|
||||||
|
[Information] Time [0:0]:700000
|
||||||
|
[Information] Counter [0:0]:8
|
||||||
|
[Information] Time [0:0]:800000
|
||||||
|
[Information] Counter [0:0]:9
|
||||||
|
[Information] Time [0:0]:900000
|
||||||
|
[Information] Counter [0:0]:10
|
||||||
|
[Information] Time [0:0]:1000000
|
||||||
|
[Information] Counter [0:0]:11
|
||||||
|
[Information] Time [0:0]:1100000
|
||||||
|
[Information] Counter [0:0]:12
|
||||||
|
[Information] Time [0:0]:1200000
|
||||||
|
[Information] Counter [0:0]:13
|
||||||
|
[Information] Time [0:0]:1300000
|
||||||
|
[Information] Counter [0:0]:14
|
||||||
|
[Information] Time [0:0]:1400000
|
||||||
|
[Information] Counter [0:0]:15
|
||||||
|
[Information] Time [0:0]:1500000
|
||||||
|
[Information] Counter [0:0]:16
|
||||||
|
[Information] Time [0:0]:1600000
|
||||||
|
[Information] Counter [0:0]:17
|
||||||
|
[Information] Time [0:0]:1700000
|
||||||
|
[Information] Counter [0:0]:18
|
||||||
|
[Information] Time [0:0]:1800000
|
||||||
|
[Information] Counter [0:0]:19
|
||||||
|
[Information] Time [0:0]:1900000
|
||||||
|
[Information] Counter [0:0]:20
|
||||||
|
[Information] Time [0:0]:2000000
|
||||||
|
[Information] Counter [0:0]:21
|
||||||
|
[Information] Time [0:0]:2100000
|
||||||
|
[Information] Counter [0:0]:22
|
||||||
|
[Information] Time [0:0]:2200000
|
||||||
|
[Information] Counter [0:0]:23
|
||||||
|
[Information] Time [0:0]:2300000
|
||||||
|
[Information] Counter [0:0]:24
|
||||||
|
[Information] Time [0:0]:2400000
|
||||||
|
[Information] Counter [0:0]:25
|
||||||
|
[Information] Time [0:0]:2500000
|
||||||
|
[Information] Counter [0:0]:26
|
||||||
|
[Information] Time [0:0]:2600000
|
||||||
|
[Information] Counter [0:0]:27
|
||||||
|
[Information] Time [0:0]:2700000
|
||||||
|
[Information] Counter [0:0]:28
|
||||||
|
[Information] Time [0:0]:2800000
|
||||||
|
[Information] Counter [0:0]:29
|
||||||
|
[Information] Time [0:0]:2900000
|
||||||
|
[Information] Counter [0:0]:30
|
||||||
|
[Information] Time [0:0]:3000000
|
||||||
|
[Information] Counter [0:0]:31
|
||||||
|
[Information] Time [0:0]:3100000
|
||||||
|
[Information] Counter [0:0]:32
|
||||||
|
[Information] Time [0:0]:3200000
|
||||||
|
[Information] Counter [0:0]:33
|
||||||
|
[Information] Time [0:0]:3300000
|
||||||
|
[Information] Counter [0:0]:34
|
||||||
|
[Information] Time [0:0]:3400000
|
||||||
|
[Information] Counter [0:0]:35
|
||||||
|
[Information] Time [0:0]:3500000
|
||||||
|
[Information] Counter [0:0]:36
|
||||||
|
[Information] Time [0:0]:3600000
|
||||||
|
[Information] Counter [0:0]:37
|
||||||
|
[Information] Time [0:0]:3700000
|
||||||
|
[Information] Counter [0:0]:38
|
||||||
|
[Information] Time [0:0]:3800000
|
||||||
|
[Information] Counter [0:0]:39
|
||||||
|
[Information] Time [0:0]:3900000
|
||||||
|
[Information] Counter [0:0]:40
|
||||||
|
[Information] Time [0:0]:4000000
|
||||||
|
[Information] Counter [0:0]:41
|
||||||
|
[Information] Time [0:0]:4100000
|
||||||
|
[Information] Counter [0:0]:42
|
||||||
|
[Information] Time [0:0]:4200000
|
||||||
|
[Information] Counter [0:0]:43
|
||||||
|
[Information] Time [0:0]:4300000
|
||||||
|
[Information] Counter [0:0]:44
|
||||||
|
[Information] Time [0:0]:4400000
|
||||||
|
[Information] Counter [0:0]:45
|
||||||
|
[Information] Time [0:0]:4500000
|
||||||
|
[Information] Counter [0:0]:46
|
||||||
|
[Information] Time [0:0]:4600000
|
||||||
|
[Information] Counter [0:0]:47
|
||||||
|
[Information] Time [0:0]:4700000
|
||||||
|
[Information] Counter [0:0]:48
|
||||||
|
[Information] Time [0:0]:4800000
|
||||||
|
[Information] Counter [0:0]:49
|
||||||
|
[Information] Time [0:0]:4900000
|
||||||
|
[Information] Counter [0:0]:50
|
||||||
|
[Information] Time [0:0]:5000000
|
||||||
|
[Information] Counter [0:0]:51
|
||||||
|
[Information] Time [0:0]:5100000
|
||||||
|
[Information] Counter [0:0]:52
|
||||||
|
[Information] Time [0:0]:5200000
|
||||||
|
[Information] Counter [0:0]:53
|
||||||
|
[Information] Time [0:0]:5300000
|
||||||
|
[Information] Counter [0:0]:54
|
||||||
|
[Information] Time [0:0]:5400000
|
||||||
|
[Information] Counter [0:0]:55
|
||||||
|
[Information] Time [0:0]:5500000
|
||||||
|
[Information] Counter [0:0]:56
|
||||||
|
[Information] Time [0:0]:5600000
|
||||||
|
[Information] Counter [0:0]:57
|
||||||
|
[Information] Time [0:0]:5700000
|
||||||
|
[Information] Counter [0:0]:58
|
||||||
|
[Information] Time [0:0]:5800000
|
||||||
|
[Information] Counter [0:0]:59
|
||||||
|
[Information] Time [0:0]:5900000
|
||||||
|
[Information] Counter [0:0]:60
|
||||||
|
[Information] Time [0:0]:6000000
|
||||||
|
[Information] Counter [0:0]:61
|
||||||
|
[Information] Time [0:0]:6100000
|
||||||
|
[Information] Counter [0:0]:62
|
||||||
|
[Information] Time [0:0]:6200000
|
||||||
|
[Information] Counter [0:0]:63
|
||||||
|
[Information] Time [0:0]:6300000
|
||||||
|
[Information] Counter [0:0]:64
|
||||||
|
[Information] Time [0:0]:6400000
|
||||||
|
[Information] Counter [0:0]:65
|
||||||
|
[Information] Time [0:0]:6500000
|
||||||
|
[Information] Counter [0:0]:66
|
||||||
|
[Information] Time [0:0]:6600000
|
||||||
|
[Information] Counter [0:0]:67
|
||||||
|
[Information] Time [0:0]:6700000
|
||||||
|
[Information] Counter [0:0]:68
|
||||||
|
[Information] Time [0:0]:6800000
|
||||||
|
[Information] Counter [0:0]:69
|
||||||
|
[Information] Time [0:0]:6900000
|
||||||
|
[Information] Counter [0:0]:70
|
||||||
|
[Information] Time [0:0]:7000000
|
||||||
|
[Information] Counter [0:0]:71
|
||||||
|
[Information] Time [0:0]:7100000
|
||||||
|
[Information] Counter [0:0]:72
|
||||||
|
[Information] Time [0:0]:7200000
|
||||||
|
[Information] Counter [0:0]:73
|
||||||
|
[Information] Time [0:0]:7300000
|
||||||
|
[Information] Counter [0:0]:74
|
||||||
|
[Information] Time [0:0]:7400000
|
||||||
|
[Information] Counter [0:0]:75
|
||||||
|
[Information] Time [0:0]:7500000
|
||||||
|
[Information] Counter [0:0]:76
|
||||||
|
[Information] Time [0:0]:7600000
|
||||||
|
[Information] Counter [0:0]:77
|
||||||
|
[Information] Time [0:0]:7700000
|
||||||
|
[Information] Counter [0:0]:78
|
||||||
|
[Information] Time [0:0]:7800000
|
||||||
|
[Information] Counter [0:0]:79
|
||||||
|
[Information] Time [0:0]:7900000
|
||||||
|
[Information] Counter [0:0]:80
|
||||||
|
[Information] Time [0:0]:8000000
|
||||||
|
[Information] Counter [0:0]:81
|
||||||
|
[Information] Time [0:0]:8100000
|
||||||
|
[Information] Counter [0:0]:82
|
||||||
|
[Information] Time [0:0]:8200000
|
||||||
|
[Information] Counter [0:0]:83
|
||||||
|
[Information] Time [0:0]:8300000
|
||||||
|
[Information] Counter [0:0]:84
|
||||||
|
[Information] Time [0:0]:8400000
|
||||||
|
[Information] Counter [0:0]:85
|
||||||
|
[Information] Time [0:0]:8500000
|
||||||
|
[Information] Counter [0:0]:86
|
||||||
|
[Information] Time [0:0]:8600000
|
||||||
|
[Information] Counter [0:0]:87
|
||||||
|
[Information] Time [0:0]:8700000
|
||||||
|
[Information] Counter [0:0]:88
|
||||||
|
[Information] Time [0:0]:8800000
|
||||||
|
[Information] Counter [0:0]:89
|
||||||
|
[Information] Time [0:0]:8900000
|
||||||
|
[Information] Counter [0:0]:90
|
||||||
|
[Information] Time [0:0]:9000000
|
||||||
|
[Information] Counter [0:0]:91
|
||||||
|
[Information] Time [0:0]:9100000
|
||||||
|
[Information] Counter [0:0]:92
|
||||||
|
[Information] Time [0:0]:9200000
|
||||||
|
[Information] Counter [0:0]:93
|
||||||
|
[Information] Time [0:0]:9300000
|
||||||
|
[Information] Counter [0:0]:94
|
||||||
|
[Information] Time [0:0]:9400000
|
||||||
|
[Information] Counter [0:0]:95
|
||||||
|
[Information] Time [0:0]:9500000
|
||||||
|
[Information] Counter [0:0]:96
|
||||||
|
[Information] Time [0:0]:9600000
|
||||||
|
[Information] Counter [0:0]:97
|
||||||
|
[Information] Time [0:0]:9700000
|
||||||
|
[Information] Counter [0:0]:98
|
||||||
|
[Information] Time [0:0]:9800000
|
||||||
|
[Information] Counter [0:0]:99
|
||||||
|
[Information] Time [0:0]:9900000
|
||||||
|
[Information] Counter [0:0]:100
|
||||||
|
[Information] Time [0:0]:10000000
|
||||||
|
[Information] Counter [0:0]:101
|
||||||
|
[Information] Time [0:0]:10100000
|
||||||
|
[Information] Counter [0:0]:102
|
||||||
|
[Information] Time [0:0]:10200000
|
||||||
|
[Information] Counter [0:0]:103
|
||||||
|
[Information] Time [0:0]:10300000
|
||||||
|
[Information] Counter [0:0]:104
|
||||||
|
[Information] Time [0:0]:10400000
|
||||||
|
[Information] Counter [0:0]:105
|
||||||
|
[Information] Time [0:0]:10500000
|
||||||
|
[Information] Counter [0:0]:106
|
||||||
|
[Information] Time [0:0]:10600000
|
||||||
|
[Information] Counter [0:0]:107
|
||||||
|
[Information] Time [0:0]:10700000
|
||||||
|
[Information] Counter [0:0]:108
|
||||||
|
[Information] Time [0:0]:10800000
|
||||||
|
[Information] Counter [0:0]:109
|
||||||
|
[Information] Time [0:0]:10900000
|
||||||
|
[Information] Counter [0:0]:110
|
||||||
|
[Information] Time [0:0]:11000000
|
||||||
|
./run_debug_app.sh: line 40: 325075 Killed "$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
|
||||||
+386
-161
@@ -1,187 +1,412 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"file": "TcpLogger.cpp",
|
"file": "CMakeCCompilerId.c",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"/usr/bin/g++",
|
"cc",
|
||||||
"-c",
|
"CMakeCCompilerId.c"
|
||||||
"-I.",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L0Types",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L2Objects",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L3Streams",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Logger",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Configuration",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L3Services",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4LoggerService",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L3Streams",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wall",
|
|
||||||
"-std=c++98",
|
|
||||||
"-Werror",
|
|
||||||
"-Wno-invalid-offsetof",
|
|
||||||
"-Wno-unused-variable",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-frtti",
|
|
||||||
"-DMARTe2_TEST_ENVIRONMENT=GTest",
|
|
||||||
"-DARCHITECTURE=x86_gcc",
|
|
||||||
"-DENVIRONMENT=Linux",
|
|
||||||
"-DUSE_PTHREAD",
|
|
||||||
"-pthread",
|
|
||||||
"-Wno-deprecated-declarations",
|
|
||||||
"-Wno-unused-value",
|
|
||||||
"-g",
|
|
||||||
"-ggdb",
|
|
||||||
"TcpLogger.cpp",
|
|
||||||
"-o",
|
|
||||||
"../../../..//Build/x86-linux/Components/Interfaces/TCPLogger/TcpLogger.o"
|
|
||||||
],
|
],
|
||||||
"directory": "/home/martino/Projects/marte_debug/Source/Components/Interfaces/TCPLogger",
|
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/4.2.3/CompilerIdC"
|
||||||
"output": "../../../..//Build/x86-linux/Components/Interfaces/TCPLogger/TcpLogger.o"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "DebugService.cpp",
|
"file": "CMakeCXXCompilerId.cpp",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"/usr/bin/g++",
|
"c++",
|
||||||
"-c",
|
"CMakeCXXCompilerId.cpp"
|
||||||
"-I../../../..//Source/Core/Types/Result",
|
|
||||||
"-I../../../..//Source/Core/Types/Vec",
|
|
||||||
"-I../../../..//Source/Components/Interfaces/TCPLogger",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L0Types",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L2Objects",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L3Streams",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Logger",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Configuration",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L3Services",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4LoggerService",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L3Streams",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wall",
|
|
||||||
"-std=c++98",
|
|
||||||
"-Werror",
|
|
||||||
"-Wno-invalid-offsetof",
|
|
||||||
"-Wno-unused-variable",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-frtti",
|
|
||||||
"-DMARTe2_TEST_ENVIRONMENT=GTest",
|
|
||||||
"-DARCHITECTURE=x86_gcc",
|
|
||||||
"-DENVIRONMENT=Linux",
|
|
||||||
"-DUSE_PTHREAD",
|
|
||||||
"-pthread",
|
|
||||||
"-Wno-deprecated-declarations",
|
|
||||||
"-Wno-unused-value",
|
|
||||||
"-g",
|
|
||||||
"-ggdb",
|
|
||||||
"DebugService.cpp",
|
|
||||||
"-o",
|
|
||||||
"../../../..//Build/x86-linux/Components/Interfaces/DebugService/DebugService.o"
|
|
||||||
],
|
],
|
||||||
"directory": "/home/martino/Projects/marte_debug/Source/Components/Interfaces/DebugService",
|
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/4.2.3/CompilerIdCXX"
|
||||||
"output": "../../../..//Build/x86-linux/Components/Interfaces/DebugService/DebugService.o"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "DebugServiceBase.cpp",
|
"file": "/usr/share/cmake/Modules/CMakeCCompilerABI.c",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"/usr/bin/g++",
|
"cc",
|
||||||
"-c",
|
"-v",
|
||||||
"-I../../../..//Source/Core/Types/Result",
|
|
||||||
"-I../../../..//Source/Core/Types/Vec",
|
|
||||||
"-I../../../..//Source/Components/Interfaces/TCPLogger",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L0Types",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L2Objects",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L3Streams",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Logger",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Configuration",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L3Services",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4LoggerService",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L3Streams",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wall",
|
|
||||||
"-std=c++98",
|
|
||||||
"-Werror",
|
|
||||||
"-Wno-invalid-offsetof",
|
|
||||||
"-Wno-unused-variable",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-frtti",
|
|
||||||
"-DMARTe2_TEST_ENVIRONMENT=GTest",
|
|
||||||
"-DARCHITECTURE=x86_gcc",
|
|
||||||
"-DENVIRONMENT=Linux",
|
|
||||||
"-DUSE_PTHREAD",
|
|
||||||
"-pthread",
|
|
||||||
"-Wno-deprecated-declarations",
|
|
||||||
"-Wno-unused-value",
|
|
||||||
"-g",
|
|
||||||
"-ggdb",
|
|
||||||
"DebugServiceBase.cpp",
|
|
||||||
"-o",
|
"-o",
|
||||||
"../../../..//Build/x86-linux/Components/Interfaces/DebugService/DebugServiceBase.o"
|
"CMakeFiles/cmTC_a4cfb.dir/CMakeCCompilerABI.c.o",
|
||||||
|
"-c",
|
||||||
|
"/usr/share/cmake/Modules/CMakeCCompilerABI.c"
|
||||||
],
|
],
|
||||||
"directory": "/home/martino/Projects/marte_debug/Source/Components/Interfaces/DebugService",
|
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-xo4CnB",
|
||||||
"output": "../../../..//Build/x86-linux/Components/Interfaces/DebugService/DebugServiceBase.o"
|
"output": "CMakeFiles/cmTC_a4cfb.dir/CMakeCCompilerABI.c.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "WebDebugService.cpp",
|
"file": "/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"/usr/bin/g++",
|
"c++",
|
||||||
|
"-v",
|
||||||
|
"-o",
|
||||||
|
"CMakeFiles/cmTC_f4fc4.dir/CMakeCXXCompilerABI.cpp.o",
|
||||||
"-c",
|
"-c",
|
||||||
"-I../../../..//Source/Components/Interfaces/TCPLogger",
|
"/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp"
|
||||||
"-I../../../..//Source/Components/Interfaces/DebugService",
|
],
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L0Types",
|
"directory": "/home/martino/Projects/marte_debug/Build/CMakeFiles/CMakeScratch/TryCompile-tgsqrG",
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L1Portability",
|
"output": "CMakeFiles/cmTC_f4fc4.dir/CMakeCXXCompilerABI.cpp.o"
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L2Objects",
|
},
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L3Streams",
|
{
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Messages",
|
"file": "/home/martino/Projects/marte_debug/Source/DebugFastScheduler.cpp",
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Logger",
|
"arguments": [
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L4Configuration",
|
"c++",
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/BareMetal/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L3Services",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4Messages",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L4LoggerService",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/Scheduler/L5GAMs",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L1Portability",
|
|
||||||
"-I/home/martino/workspace/MARTe2/Source/Core/FileSystem/L3Streams",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wall",
|
|
||||||
"-std=c++98",
|
|
||||||
"-Werror",
|
|
||||||
"-Wno-invalid-offsetof",
|
|
||||||
"-Wno-unused-variable",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-frtti",
|
|
||||||
"-DMARTe2_TEST_ENVIRONMENT=GTest",
|
|
||||||
"-DARCHITECTURE=x86_gcc",
|
"-DARCHITECTURE=x86_gcc",
|
||||||
"-DENVIRONMENT=Linux",
|
"-DENVIRONMENT=Linux",
|
||||||
|
"-DMARTe2_TEST_ENVIRONMENT=GTest",
|
||||||
"-DUSE_PTHREAD",
|
"-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",
|
"-pthread",
|
||||||
"-Wno-deprecated-declarations",
|
|
||||||
"-Wno-unused-value",
|
|
||||||
"-g",
|
"-g",
|
||||||
"-ggdb",
|
"-fPIC",
|
||||||
"WebDebugService.cpp",
|
"-MD",
|
||||||
|
"-MT",
|
||||||
|
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o",
|
||||||
|
"-MF",
|
||||||
|
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o.d",
|
||||||
"-o",
|
"-o",
|
||||||
"../../../..//Build/x86-linux/Components/Interfaces/WebDebugService/WebDebugService.o"
|
"CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o",
|
||||||
|
"-c",
|
||||||
|
"/home/martino/Projects/marte_debug/Source/DebugFastScheduler.cpp"
|
||||||
],
|
],
|
||||||
"directory": "/home/martino/Projects/marte_debug/Source/Components/Interfaces/WebDebugService",
|
"directory": "/home/martino/Projects/marte_debug/Build",
|
||||||
"output": "../../../..//Build/x86-linux/Components/Interfaces/WebDebugService/WebDebugService.o"
|
"output": "CMakeFiles/marte_dev.dir/Source/DebugFastScheduler.cpp.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"file": "/home/martino/Projects/marte_debug/Source/DebugService.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/DebugService.cpp.o",
|
||||||
|
"-MF",
|
||||||
|
"CMakeFiles/marte_dev.dir/Source/DebugService.cpp.o.d",
|
||||||
|
"-o",
|
||||||
|
"CMakeFiles/marte_dev.dir/Source/DebugService.cpp.o",
|
||||||
|
"-c",
|
||||||
|
"/home/martino/Projects/marte_debug/Source/DebugService.cpp"
|
||||||
|
],
|
||||||
|
"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": [
|
||||||
|
"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",
|
||||||
|
"-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",
|
||||||
|
"-MF",
|
||||||
|
"CMakeFiles/UnitTests.dir/main.cpp.o.d",
|
||||||
|
"-o",
|
||||||
|
"CMakeFiles/UnitTests.dir/main.cpp.o",
|
||||||
|
"-c",
|
||||||
|
"/home/martino/Projects/marte_debug/Test/UnitTests/main.cpp"
|
||||||
|
],
|
||||||
|
"directory": "/home/martino/Projects/marte_debug/Build/Test/UnitTests",
|
||||||
|
"output": "CMakeFiles/UnitTests.dir/main.cpp.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"file": "/home/martino/Projects/marte_debug/Test/Integration/main.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/IntegrationTest.dir/main.cpp.o",
|
||||||
|
"-MF",
|
||||||
|
"CMakeFiles/IntegrationTest.dir/main.cpp.o.d",
|
||||||
|
"-o",
|
||||||
|
"CMakeFiles/IntegrationTest.dir/main.cpp.o",
|
||||||
|
"-c",
|
||||||
|
"/home/martino/Projects/marte_debug/Test/Integration/main.cpp"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# Get the directory of this script
|
|
||||||
set -l DIR (dirname (realpath (status -f)))
|
|
||||||
|
|
||||||
set -gx MARTe2_DIR $DIR/dependency/MARTe2
|
|
||||||
set -gx MARTe2_Components_DIR $DIR/dependency/MARTe2-components
|
|
||||||
set -gx TARGET x86-linux
|
|
||||||
|
|
||||||
# Update LD_LIBRARY_PATH
|
|
||||||
if not set -q LD_LIBRARY_PATH
|
|
||||||
set -gx LD_LIBRARY_PATH ""
|
|
||||||
end
|
|
||||||
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$MARTe2_DIR/Build/$TARGET/Core"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$DIR/Build/$TARGET/Components/Interfaces/DebugService"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$DIR/Build/$TARGET/Components/Interfaces/TCPLogger"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LinuxTimer"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LoggerDataSource"
|
|
||||||
set -gx LD_LIBRARY_PATH "$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/GAMs/IOGAM"
|
|
||||||
|
|
||||||
echo "MARTe2 Environment Set (MARTe2_DIR=$MARTe2_DIR)"
|
|
||||||
echo "MARTe2 Components Environment Set (MARTe2_Components_DIR=$MARTe2_Components_DIR)"
|
|
||||||
@@ -2,15 +2,10 @@
|
|||||||
# Get the directory of this script
|
# Get the directory of this script
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
export MARTe2_DIR=$HOME/workspace/MARTe2
|
export MARTe2_DIR=$DIR/dependency/MARTe2
|
||||||
export MARTe2_Components_DIR=$HOME/workspace/MARTe2-components
|
export MARTe2_Components_DIR=$DIR/dependency/MARTe2-components
|
||||||
export TARGET=x86-linux
|
export TARGET=x86-linux
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_DIR/Build/$TARGET/Core
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_DIR/Build/$TARGET/Core
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIR/Build/$TARGET/Components/Interfaces/DebugService
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIR/Build/$TARGET/Components/Interfaces/TCPLogger
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LinuxTimer
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/DataSources/LoggerDataSource
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/$TARGET/Components/GAMs/IOGAM
|
|
||||||
echo "MARTe2 Environment Set (MARTe2_DIR=$MARTe2_DIR)"
|
echo "MARTe2 Environment Set (MARTe2_DIR=$MARTe2_DIR)"
|
||||||
echo "MARTe2 Components Environment Set (MARTe2_Components_DIR=$MARTe2_Components_DIR)"
|
echo "MARTe2 Components Environment Set (MARTe2_Components_DIR=$MARTe2_Components_DIR)"
|
||||||
|
|||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Load environment
|
||||||
|
. ./env.sh
|
||||||
|
|
||||||
|
# Clean build directory
|
||||||
|
rm -rf Build_Coverage
|
||||||
|
|
||||||
|
# Build with coverage
|
||||||
|
mkdir -p Build_Coverage
|
||||||
|
cd Build_Coverage
|
||||||
|
cmake .. -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
# Reset coverage data
|
||||||
|
lcov --directory . --zerocounters
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
./Test/UnitTests/UnitTests
|
||||||
|
|
||||||
|
# Capture coverage data
|
||||||
|
lcov --directory . --capture --output-file coverage.info --ignore-errors inconsistent
|
||||||
|
|
||||||
|
# Filter out system and MARTe2 internal headers
|
||||||
|
lcov --remove coverage.info '/usr/*' '*/dependency/*' '*/Test/*' --output-file coverage_filtered.info --ignore-errors inconsistent
|
||||||
|
|
||||||
|
# Generate report
|
||||||
|
genhtml coverage_filtered.info --output-directory out --ignore-errors inconsistent
|
||||||
|
|
||||||
|
# Display summary
|
||||||
|
lcov --list coverage_filtered.info --ignore-errors inconsistent
|
||||||
+7
-34
@@ -11,16 +11,13 @@ fi
|
|||||||
|
|
||||||
# 2. Paths
|
# 2. Paths
|
||||||
MARTE_EX="${MARTe2_DIR}/Build/${TARGET}/App/MARTeApp.ex"
|
MARTE_EX="${MARTe2_DIR}/Build/${TARGET}/App/MARTeApp.ex"
|
||||||
BUILD_DIR="$(pwd)/Build/${TARGET}"
|
DEBUG_LIB="$(pwd)/Build/libmarte_dev.so"
|
||||||
|
|
||||||
# Our plugin libraries
|
|
||||||
DEBUG_LIB="${BUILD_DIR}/Components/Interfaces/DebugService/libDebugService.so"
|
|
||||||
TCPLOGGER_LIB="${BUILD_DIR}/Components/Interfaces/TCPLogger/libTcpLogger.so"
|
|
||||||
|
|
||||||
# Component library base search path
|
# Component library base search path
|
||||||
COMPONENTS_BUILD_DIR="${MARTe2_Components_DIR}/Build/${TARGET}/Components"
|
COMPONENTS_BUILD_DIR="${MARTe2_Components_DIR}/Build/${TARGET}/Components"
|
||||||
|
|
||||||
# DYNAMICALLY FIND ALL COMPONENT DIRS and add to LD_LIBRARY_PATH
|
# 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)
|
ALL_COMPONENT_DIRS=$(find "$COMPONENTS_BUILD_DIR" -type d)
|
||||||
for dir in $ALL_COMPONENT_DIRS; do
|
for dir in $ALL_COMPONENT_DIRS; do
|
||||||
if ls "$dir"/*.so >/dev/null 2>&1; then
|
if ls "$dir"/*.so >/dev/null 2>&1; then
|
||||||
@@ -29,39 +26,15 @@ for dir in $ALL_COMPONENT_DIRS; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Ensure our build dir and core dir are included
|
# Ensure our build dir and core dir are included
|
||||||
export LD_LIBRARY_PATH="${BUILD_DIR}/Components/Interfaces/DebugService:${BUILD_DIR}/Components/Interfaces/TCPLogger:${MARTe2_DIR}/Build/${TARGET}/Core:${LD_LIBRARY_PATH}"
|
export LD_LIBRARY_PATH="$(pwd)/Build:${LD_LIBRARY_PATH}"
|
||||||
|
|
||||||
# 3. Cleanup
|
# 3. Cleanup
|
||||||
echo "Cleaning up lingering processes..."
|
echo "Cleaning up lingering processes..."
|
||||||
pkill -9 MARTeApp.ex
|
pkill -9 MARTeApp.ex
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# 4. Validate libraries exist
|
# 4. Launch Application
|
||||||
for lib in "$DEBUG_LIB" "$TCPLOGGER_LIB"; do
|
|
||||||
if [ ! -f "$lib" ]; then
|
|
||||||
echo "ERROR: Library not found: $lib"
|
|
||||||
echo "Run: make -f Makefile.gcc core"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 5. Launch Application
|
|
||||||
echo "Launching standard MARTeApp.ex with debug_test.cfg..."
|
echo "Launching standard MARTeApp.ex with debug_test.cfg..."
|
||||||
# LD_PRELOAD ensures our classes are registered before the config is parsed.
|
# PRELOAD ensures our DebugService class is available to the registry early
|
||||||
# MARTeApp.ex does not use dlopen for plugins — preloading is the standard approach.
|
export LD_PRELOAD="$(pwd)/Build/libmarte_dev.so"
|
||||||
# All required component .so files are collected via the find loop into LD_PRELOAD too.
|
|
||||||
PRELOAD_LIBS="${DEBUG_LIB}:${TCPLOGGER_LIB}"
|
|
||||||
|
|
||||||
# Collect any additional component .so files referenced by the config
|
|
||||||
for lib in \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/RealTimeThreadSynchronisation/RealTimeThreadSynchronisation.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/LinuxTimer/LinuxTimer.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/LoggerDataSource/LoggerDataSource.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/GAMs/IOGAM/IOGAM.so"; do
|
|
||||||
if [ -f "$lib" ]; then
|
|
||||||
PRELOAD_LIBS="${PRELOAD_LIBS}:${lib}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
export LD_PRELOAD="${PRELOAD_LIBS}"
|
|
||||||
"$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
|
"$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
|
||||||
|
|||||||
+9
-11
@@ -1,16 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Get the directory of this script
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
export MARTe2_DIR=/home/martino/Projects/marte_debug/dependency/MARTe2
|
||||||
source $DIR/env.sh
|
export TARGET=x86-linux
|
||||||
|
|
||||||
echo "Cleaning up old instances..."
|
echo "Cleaning up old instances..."
|
||||||
pkill -9 IntegrationTests
|
pkill -9 IntegrationTest
|
||||||
pkill -9 UnitTests
|
pkill -9 ValidationTest
|
||||||
sleep 1
|
pkill -9 SchedulerTest
|
||||||
|
pkill -9 main
|
||||||
|
sleep 2
|
||||||
|
|
||||||
echo "Starting MARTe2 Unit Tests..."
|
|
||||||
$DIR/Build/$TARGET/Test/UnitTests/UnitTests/UnitTests.ex
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Starting MARTe2 Integration Tests..."
|
echo "Starting MARTe2 Integration Tests..."
|
||||||
$DIR/Build/$TARGET/Test/Integration/Integration/IntegrationTests.ex
|
./Build/Test/Integration/ValidationTest
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
BUILD_DIR="$(pwd)/Build/${TARGET}"
|
|
||||||
|
|
||||||
# Our plugin libraries
|
|
||||||
WEB_DEBUG_LIB="${BUILD_DIR}/Components/Interfaces/WebDebugService/libWebDebugService.so"
|
|
||||||
TCPLOGGER_LIB="${BUILD_DIR}/Components/Interfaces/TCPLogger/libTcpLogger.so"
|
|
||||||
|
|
||||||
# Component library base search path
|
|
||||||
COMPONENTS_BUILD_DIR="${MARTe2_Components_DIR}/Build/${TARGET}/Components"
|
|
||||||
|
|
||||||
# DYNAMICALLY FIND ALL COMPONENT DIRS and add to 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="${BUILD_DIR}/Components/Interfaces/WebDebugService:${BUILD_DIR}/Components/Interfaces/TCPLogger:${MARTe2_DIR}/Build/${TARGET}/Core:${LD_LIBRARY_PATH}"
|
|
||||||
|
|
||||||
# 3. Cleanup
|
|
||||||
echo "Cleaning up lingering processes..."
|
|
||||||
pkill -9 MARTeApp.ex
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
# 4. Validate libraries exist
|
|
||||||
for lib in "$WEB_DEBUG_LIB" "$TCPLOGGER_LIB"; do
|
|
||||||
if [ ! -f "$lib" ]; then
|
|
||||||
echo "ERROR: Library not found: $lib"
|
|
||||||
echo "Run: make -f Makefile.gcc core"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 5. Launch Application
|
|
||||||
echo "Launching standard MARTeApp.ex with webdebug_test.cfg (WebDebugService on port 8090)..."
|
|
||||||
# LD_PRELOAD ensures our classes are registered before the config is parsed.
|
|
||||||
# MARTeApp.ex does not use dlopen for plugins — preloading is the standard approach.
|
|
||||||
# All required component .so files are collected via the find loop into LD_PRELOAD too.
|
|
||||||
PRELOAD_LIBS="${WEB_DEBUG_LIB}:${TCPLOGGER_LIB}"
|
|
||||||
|
|
||||||
# Collect any additional component .so files referenced by the config
|
|
||||||
for lib in \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/RealTimeThreadSynchronisation/RealTimeThreadSynchronisation.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/LinuxTimer/LinuxTimer.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/DataSources/LoggerDataSource/LoggerDataSource.so" \
|
|
||||||
"${COMPONENTS_BUILD_DIR}/GAMs/IOGAM/IOGAM.so"; do
|
|
||||||
if [ -f "$lib" ]; then
|
|
||||||
PRELOAD_LIBS="${PRELOAD_LIBS}:${lib}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
export LD_PRELOAD="${PRELOAD_LIBS}"
|
|
||||||
"$MARTE_EX" -f Test/Configurations/webdebug_test.cfg -l RealTimeLoader -s State1
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
Project Specification: MARTe2 Universal Observability & Debugging Suite
|
||||||
|
|
||||||
|
Version: 1.1
|
||||||
|
|
||||||
|
Date: 2023-10-27
|
||||||
|
|
||||||
|
Status: Active / Implemented
|
||||||
|
|
||||||
|
1. Executive Summary
|
||||||
|
|
||||||
|
This project implements a "Zero-Code-Change" observability and debugging layer for the MARTe2 real-time framework. The system allows developers to Trace, Force, and Monitor any signal in a running MARTe2 application without modifying existing source code.
|
||||||
|
|
||||||
|
2. System Architecture
|
||||||
|
|
||||||
|
- The Universal Debug Service (C++ Core): A singleton MARTe2 Object that patches the registry and manages communication.
|
||||||
|
- The Broker Injection Layer (C++ Templates): Templated wrappers that intercept Copy() calls for tracing, forcing, and execution control.
|
||||||
|
- The Remote Analyser (Rust/egui): A high-performance, multi-threaded GUI for visualization and control.
|
||||||
|
|
||||||
|
3. Functional Requirements
|
||||||
|
|
||||||
|
3.1 Execution Control
|
||||||
|
- REQ-25: Execution Control (Pause/Resume): The system SHALL provide a mechanism to pause and resume the execution of all patched real-time threads (via Brokers), allowing for static inspection of the system state.
|
||||||
|
|
||||||
|
3.2 Discovery
|
||||||
|
- REQ-24: Tree Exploration: The GUI client SHALL request the full application tree upon connection and display it in a hierarchical tree view.
|
||||||
|
- TREE Command: Returns a recursive JSON structure representing the entire application tree, including signal metadata (Type, Dimensions, Elements).
|
||||||
|
|
||||||
|
3.3 Multi-Threaded Client (REQ-23)
|
||||||
|
- Port 8080 (TCP): Commands and Metadata.
|
||||||
|
- Port 8082 (TCP): Independent Real-Time Log Stream.
|
||||||
|
- Port 8081 (UDP): High-Speed Telemetry for Oscilloscope.
|
||||||
|
|
||||||
|
4. Communication Protocol
|
||||||
|
|
||||||
|
- LS [Path]: List nodes.
|
||||||
|
- TREE: Full recursive JSON application map.
|
||||||
|
- PAUSE / RESUME: Execution control.
|
||||||
|
- TRACE <Signal> <1/0> [Decimation]: Telemetry control.
|
||||||
|
- FORCE <Signal> <Value>: Persistent signal override.
|
||||||
|
- UNFORCE <Signal>: Remove override.
|
||||||
|
- LOG <Level> <Msg>: Port 8082 streaming format.
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import socket
|
|
||||||
import time
|
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
import signal
|
|
||||||
|
|
||||||
# Start server
|
|
||||||
print("Starting server...")
|
|
||||||
proc = subprocess.Popen(
|
|
||||||
["./run_debug_app.sh"],
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
cwd="/home/martino/Projects/marte_debug",
|
|
||||||
env=os.environ,
|
|
||||||
)
|
|
||||||
|
|
||||||
time.sleep(5) # Wait for server to start
|
|
||||||
|
|
||||||
print("Connecting to server...")
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
s.settimeout(3)
|
|
||||||
s.connect(("127.0.0.1", 8080))
|
|
||||||
|
|
||||||
# Send TREE
|
|
||||||
s.sendall(b"TREE\n")
|
|
||||||
print("Sent TREE")
|
|
||||||
|
|
||||||
# Send DISCOVER immediately (like GUI does)
|
|
||||||
s.sendall(b"DISCOVER\n")
|
|
||||||
print("Sent DISCOVER")
|
|
||||||
|
|
||||||
# Wait and read
|
|
||||||
time.sleep(1)
|
|
||||||
data = b""
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
chunk = s.recv(4096)
|
|
||||||
if not chunk:
|
|
||||||
break
|
|
||||||
data += chunk
|
|
||||||
except:
|
|
||||||
break
|
|
||||||
|
|
||||||
print(f"Got {len(data)} bytes")
|
|
||||||
print("Contains OK TREE:", b"OK TREE" in data)
|
|
||||||
print("Contains OK DISCOVER:", b"OK DISCOVER" in data)
|
|
||||||
|
|
||||||
s.close()
|
|
||||||
proc.terminate()
|
|
||||||
proc.wait()
|
|
||||||
print("Done")
|
|
||||||
Reference in New Issue
Block a user