Files
bfebbx/tests/test_betaflight_parse.cpp
Kyle Isom b6d3eaad82 Implement bfebbx: Betaflight blackbox extractor
Cross-platform (macOS + Linux) C++17 CLI that extracts a Betaflight FC's
blackbox log in one command: auto-detect the serial port, read craft_name
over the Betaflight CLI, send `msc` to reboot into USB mass storage, wait
for the volume to mount, copy btfl_all.bbl to
<craft_name>_<YYYYMMDD>_<HHMMSS>.bbl, and eject.

Native throughout (termios serial, getmntinfo/proc-mounts mount detection,
DiskArbitration/umount eject); the only subprocess is the Linux udisksctl
eject fallback. Includes CMake/ctest build, unit tests for the pure logic
(naming, craft_name parsing, mount diff, serial via pty, CLI parsing),
README with a manual hardware integration procedure, and design/plan docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 15:13:17 -07:00

17 lines
637 B
C++

#include "../src/betaflight.h"
#include <cassert>
#include <string>
int main() {
using namespace bfebbx;
assert(parseCraftName("craft_name = VROOM\r\n# ").value() == "VROOM");
assert(parseCraftName("# get craft_name\r\ncraft_name = My Quad\r\n# ").value() == "My Quad");
assert(parseCraftName("craft_name = \r\n").value() == ""); // set but blank
assert(parseCraftName(" craft_name=NoSpaces\r\n").value() == "NoSpaces");
assert(!parseCraftName("set craft_name = X\r\n").has_value()); // 'set ' prefix, not a report line
assert(!parseCraftName("# nothing here\r\n").has_value());
return 0;
}