# API Documentation

## 1. TCP Control Interface (Port 8080)

### 1.1 `TREE`
Retrieves the full object hierarchy.
- **Request:** `TREE
`
- **Response:** `JSON_OBJECT
OK TREE
`

### 1.2 `DISCOVER`
Lists all registrable signals and their metadata.
- **Request:** `DISCOVER
`
- **Response:** `{"Signals": [...]}
OK DISCOVER
`

### 1.3 `TRACE <path> <state>`
Enables/disables telemetry for a signal.
- **Example:** `TRACE App.Data.Timer.Counter 1
`
- **Response:** `OK TRACE <match_count>
`

### 1.4 `FORCE <path> <value>`
Overrides a signal value in memory.
- **Example:** `FORCE App.Data.DDB.Signal 123.4
`
- **Response:** `OK FORCE <match_count>
`

### 1.5 `PAUSE` / `RESUME`
Controls global execution state via the Scheduler.
- **Request:** `PAUSE
`
- **Response:** `OK
`

---

## 2. UDP Telemetry Format (Port 8081)

Telemetry packets are Little-Endian and use `#pragma pack(1)`.

### 2.1 TraceHeader (20 Bytes)
| Offset | Type   | Name      | Description |
| :---   | :---   | :---      | :--- |
| 0      | uint32 | magic     | Always `0xDA7A57AD` |
| 4      | uint32 | seq       | Incremental sequence number |
| 8      | uint64 | timestamp | High-resolution timestamp |
| 16     | uint32 | count     | Number of samples in payload |

### 2.2 Sample Entry
| Offset | Type   | Name | Description |
| :---   | :---   | :--- | :--- |
| 0      | uint32 | id   | Internal Signal ID (from `DISCOVER`) |
| 4      | uint32 | size | Data size in bytes |
| 8      | Bytes  | data | Raw signal memory |
