Files
firmware/test/test_command_sensor
Claude 773c3a69a2 portduino Sensors: run commands on a worker thread
CommandSensor ran its commands from getMetrics(), on the main loop that
also drives the radio. Each expired sensor could stall the loop for up to
its 2 s timeout, and on Windows, where popen() has no timeout, a command
that never exits froze the node.

- A worker thread re-runs each command every 30 s and stores the result.
  getMetrics() only reads the latest results under a mutex, so it never
  waits on a command.
- The worker never calls LOG_* (portduino's log buffer is not
  thread-safe). It records why a read failed, and getMetrics() logs each
  new result on the main thread, as NativeDiscovery does.
- execCommand() returns an ExecResult instead of logging. exec() logs
  timeouts and start failures for its main-thread callers (HostMetrics).
- The sensor copies its config at init and joins the worker on
  destruction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011C7D9dE4aUYBrGdpPyHs25
2026-11-02 21:23:53 +00:00
..