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>
62 lines
1.9 KiB
CMake
62 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(bfebbx CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
add_compile_options(-Wall -Wextra)
|
|
|
|
enable_testing()
|
|
|
|
# --- library sources (grows as tasks are added) ---
|
|
add_library(bfebbx_lib
|
|
src/naming.cpp
|
|
src/betaflight.cpp
|
|
src/mounts.cpp
|
|
src/serial.cpp
|
|
src/eject.cpp
|
|
src/cli.cpp
|
|
)
|
|
target_include_directories(bfebbx_lib PUBLIC src)
|
|
|
|
# --- platform-specific linking ---
|
|
if(APPLE)
|
|
target_link_libraries(bfebbx_lib PUBLIC
|
|
"-framework DiskArbitration"
|
|
"-framework CoreFoundation")
|
|
endif()
|
|
|
|
# --- tests ---
|
|
add_executable(test_naming tests/test_naming.cpp)
|
|
target_link_libraries(test_naming PRIVATE bfebbx_lib)
|
|
add_test(NAME naming COMMAND test_naming)
|
|
|
|
add_executable(test_betaflight_parse tests/test_betaflight_parse.cpp)
|
|
target_link_libraries(test_betaflight_parse PRIVATE bfebbx_lib)
|
|
add_test(NAME betaflight_parse COMMAND test_betaflight_parse)
|
|
|
|
add_executable(test_mounts tests/test_mounts.cpp)
|
|
target_link_libraries(test_mounts PRIVATE bfebbx_lib)
|
|
add_test(NAME mounts COMMAND test_mounts)
|
|
|
|
add_executable(test_serial tests/test_serial.cpp)
|
|
target_link_libraries(test_serial PRIVATE bfebbx_lib)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
target_link_libraries(test_serial PRIVATE util) # openpty
|
|
endif()
|
|
add_test(NAME serial COMMAND test_serial)
|
|
|
|
add_executable(test_betaflight_proto tests/test_betaflight_proto.cpp)
|
|
target_link_libraries(test_betaflight_proto PRIVATE bfebbx_lib)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
target_link_libraries(test_betaflight_proto PRIVATE util)
|
|
endif()
|
|
add_test(NAME betaflight_proto COMMAND test_betaflight_proto)
|
|
|
|
# --- main executable ---
|
|
add_executable(bfebbx src/main.cpp)
|
|
target_link_libraries(bfebbx PRIVATE bfebbx_lib)
|
|
|
|
add_executable(test_cli tests/test_cli.cpp)
|
|
target_link_libraries(test_cli PRIVATE bfebbx_lib)
|
|
add_test(NAME cli COMMAND test_cli)
|