Skip to content

Commit b1da48d

Browse files
committed
fix: Correct CSV column order to match blackbox_decode format
- energyCumulative (mAh) now positioned after I frame fields, before S frame fields - Fixes critical data integrity issue where analysis tools read wrong columns - Column order now exactly matches blackbox_decode reference implementation - Resolves PNG visualization differences caused by column misalignment
1 parent 7c49ae7 commit b1da48d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,16 @@ impl CsvFieldMap {
222222
csv_field_names.push(csv_name);
223223
}
224224

225-
// S frame fields
225+
// Add computed fields IMMEDIATELY after I frame fields (like blackbox_decode does)
226+
if field_name_to_lookup
227+
.iter()
228+
.any(|(_, lookup)| lookup == "amperageLatest")
229+
{
230+
field_name_to_lookup.push(("energyCumulative (mAh)".to_string(), "".to_string()));
231+
csv_field_names.push("energyCumulative (mAh)".to_string());
232+
}
233+
234+
// S frame fields (with flag formatting)
226235
for field_name in &header.s_frame_def.field_names {
227236
let trimmed = field_name.trim();
228237
if trimmed == "time" {
@@ -242,15 +251,6 @@ impl CsvFieldMap {
242251
// NOTE: G-frame fields excluded from main CSV (will go to separate .gps.csv file in future)
243252
// NOTE: E-frame fields excluded from main CSV (will go to separate .event file in future)
244253

245-
// Add computed fields
246-
if field_name_to_lookup
247-
.iter()
248-
.any(|(_, lookup)| lookup == "amperageLatest")
249-
{
250-
field_name_to_lookup.push(("energyCumulative (mAh)".to_string(), "".to_string()));
251-
csv_field_names.push("energyCumulative (mAh)".to_string());
252-
}
253-
254254
Self {
255255
field_name_to_lookup,
256256
}

0 commit comments

Comments
 (0)