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>
This commit is contained in:
29
tests/test_mounts.cpp
Normal file
29
tests/test_mounts.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "../src/mounts.h"
|
||||
#include <cassert>
|
||||
|
||||
int main() {
|
||||
using namespace bfebbx;
|
||||
|
||||
std::vector<MountEntry> before = {
|
||||
{"/dev/disk1s1", "/"},
|
||||
{"/dev/disk2s1", "/Volumes/Data"},
|
||||
};
|
||||
std::vector<MountEntry> after = before;
|
||||
after.push_back({"/dev/disk5s1", "/Volumes/NO NAME"});
|
||||
|
||||
auto added = diffMounts(before, after);
|
||||
assert(added.size() == 1);
|
||||
assert(added[0].mountpoint == "/Volumes/NO NAME");
|
||||
assert(added[0].device == "/dev/disk5s1");
|
||||
|
||||
// No change -> empty diff
|
||||
assert(diffMounts(before, before).empty());
|
||||
|
||||
// listMounts should at least return the root filesystem on a live system
|
||||
bool sawRoot = false;
|
||||
for (const auto& m : listMounts())
|
||||
if (m.mountpoint == "/") sawRoot = true;
|
||||
assert(sawRoot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user