How linux-automation/tacd works
Project type and purpose
• This is a full-stack embedded application:
• A Rust-based monolithic “tacd” daemon running on the LXA-TAC hardware
• A React-based web UI (in web/) that interacts with the daemon via HTTP and MQTT
• A local UI on the TAC’s LCD screen
• Purpose: Bridge between hardware (ADC, GPIO, displays, power regulators, etc.) and users via a local display and a web/API interface.
File structure for architectural components
• Top level:
• src/: the Rust application (“tacd”)
• openapi.yaml: API specification
• demo_files/: reference file layout for embedded runs
• web/: front-end React application
• src/ modules:
• Hardware interfaces (adc.rs, digital_io.rs, backlight.rs, usb_hub.rs, watchdog.rs, temperatures.rs, regulators.rs, etc.)
• broker/: MQTT and REST broker
• http_server/: static file serving & API endpoints
• dbus/: interaction with system services (systemd, networkmanager, hostnamed, rauc)
• ui/: local LCD UI screens, widgets, display driver
• journal.rs: persistent event logging
• watched_tasks.rs: supervisory task runner
• main.rs / system.rs: application entrypoint and orchestration
• web/:
• public/: built assets (index.html, manifest.json)
• src/: TypeScript/React components fetching from HTTP API or MQTT, rendering dashboard, config editors, etc.
README for additional insights
• The daemon supports a “demo_mode” feature flag to stub hardware modules
• Build instructions show separation between host PC (demo_mode) and cross-compiled embedded targets
• The web UI is built independently via npm, output is bundled into the daemon binary
Main components
1. Hardware Layer (LXA TAC)
• ADC sensors, GPIO lines, USB hub, backlight, power regulators, temperature sensors, watchdog
2. tacd Daemon (Rust)
• Hardware Abstraction Modules
• System Core / Task Scheduler (watched_tasks)
• Persistence (journal → state.json)
• DBus Client Subsystem (systemd, networkmanager, hostnamed, rauc)
• Broker Subsystem (MQTT + REST)
• HTTP Server (serves web frontend + OpenAPI endpoints)
• Local UI Module (drives LCD via ui/ screens)
3. Frontends
• Local Display UI (LCD)
• Web UI (React app, served static → communicates over HTTP & optionally WebSocket/MQTT)
• External API clients (scripts, labgrid integration via REST/MQTT)
4. External Services
• MQTT clients/brokers (for remote scripting or monitoring)
• D-Bus system services (systemd, networkmanager, rauc)
• Labgrid environment (from demo_files)
Relationships and interactions
• Hardware → tacd hardware modules (via libiio, GPIO sysfs, etc.)
• tacd system core → schedules modules, reads sensors, writes actuators
• Hardware events & system state → published to:
• Local UI (ui/ screens)
• Broker → MQTT topics + REST endpoints
• Journal → state.json
• HTTP Server:
• Serves static React assets
• Exposes OpenAPI endpoints for status, control
• React Web UI ↔ HTTP Server (REST calls)
• React Web UI ↔ MQTT Broker (real-time updates)
• tacd → D-Bus services for system config, updates, networking
Architectural patterns and design principles
• Modular monolith: clearly separated sub-packages, all compiled into one binary
• Feature flags: “demo_mode” for host-side stubs
• Event-driven / pub-sub internally: hardware events → broker → UIs
• Clear separation between hardware abstraction, core logic, persistence, and presentation layers
Essential elements
• Annotations for feature flags (demo_mode) and cross-compilation target