|
| 1 | +# Architecture — iSMART Gateway Simulator |
| 2 | + |
| 3 | +## 1. Overview |
| 4 | + |
| 5 | +The iSMART Gateway Simulator is a multi-language IoT gateway that: |
| 6 | +- Parses CAN-bus telemetry from a SocketCAN interface (C firmware + Python) |
| 7 | +- Validates telemetry integrity using CRC-32C (Rust embedded crate) |
| 8 | +- Buffers samples in a lock-free SPSC ring buffer (Rust) |
| 9 | +- Exposes processed telemetry over HTTP/SSE (Python REST API) |
| 10 | +- Renders a minimal Wayland dashboard (Python + PySide6, headless-capable) |
| 11 | + |
| 12 | +## 2. Governance |
| 13 | + |
| 14 | +This project is governed by specsmith (AEE spec 0.11.3) in YAML-first mode. |
| 15 | +All requirements and tests are canonical in `docs/requirements/` and `docs/tests/`. |
| 16 | +REQUIREMENTS.md and TESTS.md are derived artifacts — do not edit them directly. |
| 17 | + |
| 18 | +## 3. Firmware Layer (C) |
| 19 | + |
| 20 | +The `firmware/c/` directory contains a bare-metal CAN frame parser targeting |
| 21 | +embedded Linux (SocketCAN). It handles: |
| 22 | +- Standard 11-bit CAN 2.0A identifiers |
| 23 | +- Extended 29-bit CAN 2.0B identifiers |
| 24 | +- DLC validation and frame timestamp |
| 25 | + |
| 26 | +No dynamic memory allocation is used in the real-time CAN path. |
| 27 | + |
| 28 | +## 4. Embedded RT Layer (Rust) |
| 29 | + |
| 30 | +The `firmware/rust/` crate provides: |
| 31 | +- `TelemetryRecord` with CRC-32C integrity (REQ-003) |
| 32 | +- `RingBuffer<T, N>` lock-free SPSC with overflow-drop semantics (REQ-004) |
| 33 | + |
| 34 | +The Rust crate is `no_std` compatible and compiled to a static library |
| 35 | +that the Python layer links via ctypes (future work). |
| 36 | + |
| 37 | +## 5. API Layer (Python) |
| 38 | + |
| 39 | +`src/ismart_core/` implements: |
| 40 | +- `can/frame.py` — SocketCAN frame parser (REQ-001) |
| 41 | +- `sensor/adc.py` — ADC median filter (REQ-002) |
| 42 | +- `gateway.py` — HTTP/SSE REST server (REQ-005, REQ-006) |
| 43 | + |
| 44 | +The gateway gracefully falls back to synthetic mock data when vcan0 is absent. |
| 45 | + |
| 46 | +## 6. Display Layer (Python) |
| 47 | + |
| 48 | +`src/ismart_core/display/` (planned): a PySide6/Wayland EGL stub that renders |
| 49 | +a minimal telemetry dashboard. Headless mode activates automatically when |
| 50 | +DISPLAY and WAYLAND_DISPLAY environment variables are unset (REQ-007). |
| 51 | + |
| 52 | +## 7. Test Strategy |
| 53 | + |
| 54 | +- Unit tests: pytest (Python) + cargo test (Rust), run on every push |
| 55 | +- Integration tests: pytest with live gateway server fixture |
| 56 | +- CLI tests: specsmith audit/sync/validate assertions in CI |
| 57 | +- Manual tests: Wayland headless mode (TEST-010) |
0 commit comments