Expand description
§Rust ULog Parser
A robust Rust implementation of a parser for the ULog file format, commonly used in PX4 flight stack for logging system data. This parser provides a safe, efficient way to read and process ULog files with strong type checking and error handling.
§Project Status
This project is currently in development, it basically works but I’ll be making changes to the interface as I go.
- Parse ULog files and extract all messages
- Make a nice interface for the parser (in progress)
- Documentation
- Add cli features for the binary (right now it just gives some summary data for a sanity check)
- Add tests (Parity tests are in progress, using pyulog for comparison. The holdup is munging the data to match the format from pyulog)
- Benchmarking
§Features
- Complete implementation of the ULog file format specification
- Support for all ULog message types including:
- Data messages
- Format messages
- Parameter messages
- Logged messages (both plain and tagged)
- Multi messages
- Subscription messages
- Dropout tracking
- Safe handling of nested message types
- Comprehensive error handling
- Zero-copy parsing where possible
- Support for appended data sections
§Usage
Add this to your Cargo.toml
:
[dependencies]
ulog_rs = "0.0.1"
§Basic Example
use std::fs::File;
use ulog_rs::ULogParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open a ULog file
let file = File::open("sample.ulg")?;
// Create parser instance
let parser = ULogParser::parse_reader(file)?;
// Access header information
println!("ULog Header:");
println!(" Version: {}", parser.header().version);
println!(" Timestamp: {} μs", parser.header().timestamp);
println!(" Final Timestamp: {} μs", parser.last_timestamp());
// Access logged messages
for message in parser.logged_messages() {
println!("[{}] {}", message.timestamp, message.message);
}
Ok(())
}
§Project Structure
The project is organized into several modules, each handling specific aspects of ULog parsing:
lib.rs
: Core parser implementation and type definitionsdata_message.rs
: Handles data message parsingdropout_message.rs
: Manages dropout tracking and statisticsformat_message.rs
: Processes message format definitionsinfo_message.rs
: Handles info message parsinglogged_message.rs
: Manages regular logged messagesmulti_message.rs
: Handles multi-part messagesparameter_message.rs
: Processes parameter messagessubscription_message.rs
: Manages message subscriptionstagged_logged_message.rs
: Handles tagged log messages
§API Overview
§Main Parser Interface
The ULog
struct provides the main interface for parsing ULog files:
use ulog_rs::ulog::ULog;
let ulog = ULog::parse_file("sample.ulg")?;
// Access header information
println!("Version: {}", ulog.version);
println!("Timestamp: {} μs", ulog.timestamp);
// Get logged messages
for message in &ulog.logged_messages() {
println!("[{}] {}", message.timestamp, message.message);
}
§Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
§License
MIT License
Modules§
- data_
message - dropout_
message - format_
message - info_
message - logged_
message - multi_
message - parameter_
message - subscription_
message - tagged_
logged_ message - ulog
Structs§
- Flag
Bits Message - A message containing compatibility and incompatibility flags, as well as appended offsets.
The
compat_flags
andincompat_flags
fields are arrays of 8 bytes each, representing compatibility and incompatibility flags for the ULog file. Theappended_offsets
field is an array of 3u64
values representing offsets of appended data in the ULog file. - Message
Header - A header for a ULog message, containing the message size and type.
- ULog
Header - A header for a ULog file, containing the version and timestamp.
- ULog
Parser - A parser for ULog binary data.
Enums§
- ULog
Error - ULog
Type - Represents the type of a ULog value, which can be either a basic type or a nested message type.
- ULog
Value - An enum representing the different data types that can be used in ULog messages. This enum provides variants for various primitive types as well as arrays and nested message types.
- ULog
Value Type - The possible C types that can appear in info messages. This enum represents the different data types that can be used in ULog messages.