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
26 changes: 7 additions & 19 deletions src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,19 @@ fn export_flight_data_to_csv(log: &BBLLog, output_path: &Path) -> Result<()> {
.map(|(csv_name, _)| csv_name.clone())
.collect();

// Collect all frames in chronological order
let mut all_frames = Vec::new();

if let Some(ref debug_frames) = log.debug_frames {
// Collect only I, P frames for CSV export (S frames are merged into I/P frames during parsing)
for frame_type in ['I', 'P'] {
if let Some(frames) = debug_frames.get(&frame_type) {
for frame in frames {
all_frames.push((frame.timestamp_us, frame_type, frame));
}
}
// Collect all I and P frames in chronological order
let mut all_frames: Vec<(u64, char, &DecodedFrame)> = Vec::new();

// Use log.frames which contains all parsed frames
for frame in &log.frames {
if frame.frame_type == 'I' || frame.frame_type == 'P' {
all_frames.push((frame.timestamp_us, frame.frame_type, frame));
}
}

// Sort by timestamp
all_frames.sort_by_key(|(timestamp, _, _)| *timestamp);

if all_frames.is_empty() {
// Write at least the sample frames if no debug frames
for frame in &log.sample_frames {
all_frames.push((frame.timestamp_us, frame.frame_type, frame));
}
all_frames.sort_by_key(|(timestamp, _, _)| *timestamp);
}

if all_frames.is_empty() {
return Ok(()); // No data to export
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//!
//! let export_options = ExportOptions::default();
//! let log = parse_bbl_file(Path::new("flight.BBL"), export_options, false).unwrap();
//! println!("Found {} frames", log.sample_frames.len());
//! println!("Found {} frames", log.frames.len());
//! ```

// Module declarations
Expand Down
Loading