Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and test

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y doctest-dev
- name: Configure
run: >-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
-DFLIGHT_LOG_BUILD_EXAMPLES=ON
-DFLIGHT_LOG_ENABLE_UNIT_TESTS=ON
- name: Build
run: cmake --build build --parallel 2
- name: Test
run: ctest --test-dir build --output-on-failure
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build*/
/install/
/CMakeUserPresets.json
/.cache/
.DS_Store
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.16)

project(FlightLogInspector VERSION 0.1.0 LANGUAGES CXX)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CTest)

option(FLIGHT_LOG_BUILD_EXAMPLES "Build the reader and writer examples" OFF)
option(FLIGHT_LOG_ENABLE_UNIT_TESTS "Build unit tests using an installed doctest package" OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

add_library(flight_log
src/data_container.cpp
src/messages.cpp
src/reader.cpp
src/simple_writer.cpp
src/writer.cpp
)
add_library(flight_log::flight_log ALIAS flight_log)
target_compile_features(flight_log PUBLIC cxx_std_17)
target_include_directories(flight_log PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(flight_log PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})

add_executable(flight-log-inspector src/main.cpp)
target_link_libraries(flight-log-inspector PRIVATE flight_log::flight_log)

if(FLIGHT_LOG_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(BUILD_TESTING)
add_subdirectory(tests)
endif()

set(flight_log_cmake_dir "${CMAKE_INSTALL_LIBDIR}/cmake/flight_log")
configure_package_config_file(cmake/flight_logConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/flight_logConfig.cmake
INSTALL_DESTINATION ${flight_log_cmake_dir}
)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/flight_logConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(TARGETS flight-log-inspector RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS flight_log EXPORT flight_logTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT flight_logTargets NAMESPACE flight_log:: DESTINATION ${flight_log_cmake_dir})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/flight_logConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/flight_logConfigVersion.cmake
DESTINATION ${flight_log_cmake_dir}
)
install(FILES LICENSE NOTICE DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/flight-log-inspector)
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Contributing

## Before you start

Open an issue for changes that affect the log format, public API, or CLI behavior. Include a
small reproducible example when reporting a parsing issue.

## Workflow

1. Create a topic branch from the default branch.
2. Keep each pull request focused on one logical change.
3. Build the project, run CTest with `FLIGHT_LOG_ENABLE_UNIT_TESTS=ON`, and document the inputs
you used to verify the change.
4. Match the surrounding C++ style. Add tests for new behavior in `tests/`.

Prefer generated or minimized test logs when adding fixtures. Include the source and license
information for any third-party material in [NOTICE](NOTICE).

Contributions are distributed under the terms in [LICENSE](LICENSE).
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, PX4 Development Team
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 changes: 43 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
NOTICE

Flight Log Inspector incorporates BSD 3-Clause-licensed code and test
fixtures from ulog_cpp, published by the PX4 Development Team.

Source repository: https://github.com/PX4/ulog_cpp
Source snapshot: ff74c6f2fb2e0c48b727f03865eea56ec7f56969

The original LICENSE is reproduced verbatim. The derived C++ files
retain their SPDX identifiers and refer here for file copyright notices.
The three ULog fixtures in tests/log_files/ are unchanged copies of the
snapshot's test/log_files/ files. Identifying strings inside these logs
are recorded device metadata, topic names, and log messages.

Copyright (c) 2026 cpp-hardtech for project-specific modifications.

Copyright declarations by file

Copyright (c) 2023 PX4 Development Team.
src/data_container.cpp
src/main.cpp
src/messages.cpp
src/reader.cpp
src/simple_writer.cpp
src/writer.cpp
include/flight_log/data_container.hpp
include/flight_log/data_handler_interface.hpp
include/flight_log/exception.hpp
include/flight_log/messages.hpp
include/flight_log/raw_messages.hpp
include/flight_log/reader.hpp
include/flight_log/simple_writer.hpp
include/flight_log/subscription.hpp
include/flight_log/utils.hpp
include/flight_log/writer.hpp
examples/ulog_data.cpp
examples/ulog_writer.cpp
tests/main.cpp
tests/read_api_test.cpp
tests/ulog_parsing_test.cpp

Copyright (c) 2025 PX4 Development Team.
examples/ulog_streamed_parsing.cpp
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# flight-log-inspector
Inspect ULog flight recordings and verify log quality from the command line.
# Flight Log Inspector

Flight Log Inspector reads recorded ULog (`.ulg`) flight telemetry. Use the command-line tool
to inspect topic instances and their sample counts, message layouts, metadata, initial and
default parameters, text messages, and logging dropouts. A C++ library exposes typed samples,
incremental parsing, and log writing.

## Requirements

- A C++17 compiler, CMake 3.16 or newer, and a little-endian system.
- Optional: an installed doctest CMake package for the C++ unit tests.

## Build

```sh
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/install"
cmake --build build --parallel
ctest --test-dir build --output-on-failure
cmake --install build
```

The CLI, library, and default CLI tests build without external dependencies. Set
`-DFLIGHT_LOG_ENABLE_UNIT_TESTS=ON` to include the C++ test suite and
`-DFLIGHT_LOG_BUILD_EXAMPLES=ON` to build the reader and writer examples. Set
`-DBUILD_TESTING=OFF` to skip test registration.

## Quick start

```sh
./install/bin/flight-log-inspector tests/log_files/sample_log_small.ulg
```

In the topic listing, `sensor_combined (0) - 1298` means instance 0 has 1,298 samples.
Parsing warnings go to standard error. A fatal parse error or an unreadable file produces a
nonzero exit status. The CLI keeps samples in memory while it builds the report. The C++
reader can process chunks incrementally for large logs. Logs with appended data segments
may yield partial results.

## C++ library

Point `CMAKE_PREFIX_PATH` to the installation directory, then link the library in your project.

```cmake
find_package(flight_log CONFIG REQUIRED)
target_link_libraries(my_tool PRIVATE flight_log::flight_log)
```

Public headers are under `flight_log/`. The [examples](examples/) show typed sample access,
streaming reads, and file writing.

## Contributing and license

See [CONTRIBUTING.md](CONTRIBUTING.md). The project is distributed under the BSD 3-Clause
License in [LICENSE](LICENSE). Source and fixture attribution are recorded in [NOTICE](NOTICE).
3 changes: 3 additions & 0 deletions cmake/flight_logConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/flight_logTargets.cmake")
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
foreach(example IN ITEMS ulog_data ulog_streamed_parsing ulog_writer)
add_executable(${example} ${example}.cpp)
target_link_libraries(${example} PRIVATE flight_log::flight_log)
endforeach()
124 changes: 124 additions & 0 deletions examples/ulog_data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/****************************************************************************
* See NOTICE for the copyright declaration for this file.
* SPDX-License-Identifier: BSD-3-Clause
****************************************************************************/

#include <fstream>
#include <iostream>
#include <string>
#include <flight_log/data_container.hpp>
#include <flight_log/reader.hpp>

// Example of how to use the typed data API for accessing topic data

int main(int argc, char** argv)
{
if (argc < 2) {
printf("Usage: %s <file.ulg>\n", argv[0]);
return -1;
}
FILE* file = fopen(argv[1], "rb");
if (!file) {
printf("opening file failed\n");
return -1;
}
uint8_t buffer[4096];
int bytes_read;
const auto data_container =
std::make_shared<flight_log::DataContainer>(flight_log::DataContainer::StorageConfig::FullLog);
flight_log::Reader reader{data_container};
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file)) > 0) {
reader.readChunk(buffer, bytes_read);
}
fclose(file);

// Check for errors
if (!data_container->parsingErrors().empty()) {
printf("###### File Parsing Errors ######\n");
for (const auto& parsing_error : data_container->parsingErrors()) {
printf(" %s\n", parsing_error.c_str());
}
}
if (data_container->hadFatalError()) {
printf("Fatal parsing error, exiting\n");
return -1;
}

// Read out some data

// List all subscription names
auto subscription_names = data_container->subscriptionNames();
for (const auto& sub : subscription_names) {
std::cout << sub << "\n";
}
std::cout << "\n";

// Get a particular subscription
if (subscription_names.find("vehicle_status") != subscription_names.end()) {
const auto& subscription = data_container->subscription("vehicle_status");

// Get message format of subscription
auto message_format = subscription->format();
std::cout << "Message format: " << message_format->name() << "\n";

// List all field names
std::cout << "Field names: "
<< "\n";
for (const std::string& field : subscription->fieldNames()) {
std::cout << " " << field << "\n";
}

// Get particular field
try {
auto nav_state_field = subscription->field("nav_state");

// Iterate over all samples
std::cout << "nav_state values: \n ";
for (const auto& sample : *subscription) {
// always correctly extracts the type as defined in the message definition,
// gets cast to the value you put in int.
// This also works for arrays and strings.
auto nav_state = sample[nav_state_field].as<int>();
std::cout << nav_state << ", ";
}
std::cout << "\n";

// get a specific sample
auto sample_12 = subscription->at(12);

// access values by name
auto timestamp = sample_12["timestamp"].as<uint64_t>();

std::cout << "timestamp at sample 12: " << timestamp << "\n";
} catch (const flight_log::AccessException& exception) {
std::cout << "AccessException: " << exception.what() << "\n";
}
} else {
std::cout << "No vehicle_status subscription found\n";
}

if (data_container->messageFormats().find("esc_status") !=
data_container->messageFormats().end()) {
const auto& message_format = data_container->messageFormats().at("esc_status");
std::cout << "Message format: " << message_format->name() << "\n";
for (const auto& field_name : message_format->fieldNames()) {
std::cout << " " << field_name << "\n";
}
} else {
std::cout << "No esc_status message format found\n";
}

if (subscription_names.find("esc_status") != subscription_names.end()) {
try {
auto esc_status = data_container->subscription("esc_status");
for (const auto& sample : *esc_status) {
std::cout << "esc_power: " << sample["esc"][7]["esc_power"].as<int>() << "\n";
}
} catch (const flight_log::AccessException& exception) {
std::cout << "AccessException: " << exception.what() << "\n";
}
} else {
std::cout << "No esc_status subscription found\n";
}
return 0;
}
Loading
Loading