|
1 | 1 | use anyhow::{Context, Result}; |
2 | 2 | use clap::{Arg, Command}; |
3 | 3 | use glob::glob; |
4 | | -use semver::Version; |
5 | 4 | use std::collections::{HashMap, HashSet}; |
6 | 5 | use std::fs; |
7 | 6 | use std::io::Write; |
8 | 7 | use std::path::{Path, PathBuf}; |
9 | 8 |
|
10 | 9 | // Import conversion functions from crate library to avoid code duplication |
11 | 10 | use bbl_parser::conversion::{ |
12 | | - convert_gps_altitude, convert_gps_coordinate, convert_gps_course, convert_gps_speed, |
13 | | - format_failsafe_phase, format_flight_mode_flags, format_state_flags, generate_gpx_timestamp, |
| 11 | + convert_amperage_to_amps, convert_gps_altitude, convert_gps_coordinate, convert_gps_course, |
| 12 | + convert_gps_speed, convert_vbat_to_volts, format_failsafe_phase, format_flight_mode_flags, |
| 13 | + format_state_flags, generate_gpx_timestamp, |
14 | 14 | }; |
15 | 15 |
|
16 | 16 | // Import parser types from crate library |
@@ -2260,59 +2260,6 @@ fn parse_numeric_data(numeric_data: &str) -> Vec<u8> { |
2260 | 2260 | .collect() |
2261 | 2261 | } |
2262 | 2262 |
|
2263 | | -/// Converts raw vbatLatest value to volts using firmware-aware scaling. |
2264 | | -/// |
2265 | | -/// Betaflight < 4.3.0: tenths (0.1V units) |
2266 | | -/// Betaflight >= 4.3.0: hundredths (0.01V units) |
2267 | | -/// EmuFlight: always tenths (0.1V units) |
2268 | | -/// iNav: always hundredths (0.01V units) |
2269 | | -fn convert_vbat_to_volts(raw_value: i32, firmware_revision: &str) -> f32 { |
2270 | | - // Determine scaling factor based on firmware |
2271 | | - let scale_factor = if firmware_revision.contains("EmuFlight") { |
2272 | | - // EmuFlight always uses tenths |
2273 | | - 0.1 |
2274 | | - } else if firmware_revision.contains("iNav") { |
2275 | | - // iNav always uses hundredths |
2276 | | - 0.01 |
2277 | | - } else if firmware_revision.contains("Betaflight") { |
2278 | | - // Betaflight version-dependent scaling |
2279 | | - if let Some(version) = extract_firmware_version(firmware_revision) { |
2280 | | - if version >= Version::new(4, 3, 0) { |
2281 | | - 0.01 // hundredths for >= 4.3.0 |
2282 | | - } else { |
2283 | | - 0.1 // tenths for < 4.3.0 |
2284 | | - } |
2285 | | - } else { |
2286 | | - // Default to modern Betaflight scaling if version can't be parsed |
2287 | | - 0.01 |
2288 | | - } |
2289 | | - } else { |
2290 | | - // Unknown firmware, default to hundredths |
2291 | | - 0.01 |
2292 | | - }; |
2293 | | - |
2294 | | - raw_value as f32 * scale_factor |
2295 | | -} |
2296 | | - |
2297 | | -/// Extract version from firmware revision string |
2298 | | -fn extract_firmware_version(firmware_revision: &str) -> Option<Version> { |
2299 | | - // Parse version from strings like "Betaflight 4.5.1 (77d01ba3b) AT32F435M" |
2300 | | - let words: Vec<&str> = firmware_revision.split_whitespace().collect(); |
2301 | | - for (i, word) in words.iter().enumerate() { |
2302 | | - if word.to_lowercase().contains("betaflight") && i + 1 < words.len() { |
2303 | | - if let Ok(version) = Version::parse(words[i + 1]) { |
2304 | | - return Some(version); |
2305 | | - } |
2306 | | - } |
2307 | | - } |
2308 | | - None |
2309 | | -} |
2310 | | - |
2311 | | -/// Converts raw amperageLatest value to amps (0.01A units) |
2312 | | -fn convert_amperage_to_amps(raw_value: i32) -> f32 { |
2313 | | - raw_value as f32 / 100.0 |
2314 | | -} |
2315 | | - |
2316 | 2263 | fn parse_bbl_file_streaming( |
2317 | 2264 | file_path: &Path, |
2318 | 2265 | debug: bool, |
|
0 commit comments