Skip to main content

LED TIMPANI Controller

C-based LED controller using TIMPANI real-time signal (SIGRTMIN+2).

Overview​

This controller receives periodic signals from TIMPANI-N runtime and toggles an LED accordingly. Unlike sleep-based approaches, signal-based control maintains precise timing even under CPU load.

Architecture​

┌─────────────────────────────────────────────────────────────┐
│ LED TIMPANI Controller │
│ │
│ ┌─────────────────┐ SIGRTMIN+2 ┌─────────────────────┐ │
│ │ Main Thread │◄──────────────│ TIMPANI-N │ │
│ │ (sigtimedwait) │ │ (500ms periodic) │ │
│ └────────┬────────┘ └─────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Arduino LED │ Serial: /dev/arduino_led_timpani │
│ │ (toggle ON/OFF)│ Baud: 115200 │
│ └─────────────────┘ │
│ │
│ ┌─────────────────┐ │
│ │ Worker Thread │ Continuous busy_work (CPU load sim) │
│ │ (busy_work) │ Iterations: BUSY_ITERATIONS env │
│ └─────────────────┘ │
│ │
│ ┌─────────────────┐ │
│ │ Metrics Thread │ HTTP :9101/metrics (Prometheus) │
│ │ (HTTP server) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────┘

Build​

Local Build​

make clean && make

Docker Build​

sudo podman build -t localhost/led-timpani-controller:latest .

Environment Variables​

VariableDefaultDescription
BUSY_ITERATIONS13000000Number of iterations for busy_work loop

Prometheus Metrics​

Exposed on port 9101 at /metrics:

MetricTypeDescription
led_delay_msgaugeTime from signal receipt to LED toggle (ms)
led_interval_msgaugeActual interval between toggles (ms)
led_stategaugeCurrent LED state (0=OFF, 1=ON)
led_signal_countcounterTotal number of LED toggles
curl http://localhost:9101/metrics

Synchronization​

  • Creates /tmp/timpani_start file on first signal (triggers led-normal-controller start)
  • Writes current LED state to /tmp/timpani_led_state (for recovery sync)

Process Name​

Sets process name to led_timpani via prctl(PR_SET_NAME) for TIMPANI-N identification.

Expected Behavior​

ConditionIntervalDelay
No CPU Load~500ms<1ms
High CPU Load~500ms<1ms

Key Point: TIMPANI signal delivery is independent of CPU load, so timing remains precise.