diff --git a/CHANGELOG.md b/CHANGELOG.md index 07dde78..f051359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org). +## [1.5.0] - 2025-12-18 + + - Fix bug that caused a variable number of blocks at the end of a file to not be decoded + - Limit the number of threads used for small files + - Update TDF definitions + ## [1.4.1] - 2025-11-27 - Update MacOS signing certificate diff --git a/Cargo.lock b/Cargo.lock index 10a39b2..dade723 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "infuse_decoder" -version = "1.4.1" +version = "1.5.0" dependencies = [ "blocks", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index d02909a..aff99ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "infuse_decoder" -version = "1.4.1" +version = "1.5.0" edition = "2024" [[bin]] diff --git a/scripts/tdf.json b/scripts/tdf.json index 504fc9e..c6ca8d0 100644 --- a/scripts/tdf.json +++ b/scripts/tdf.json @@ -567,6 +567,26 @@ } ] }, + "8": { + "name": "SOC_TEMPERATURE", + "description": "SoC die temperature", + "fields": [ + { + "name": "temperature", + "type": "int16_t", + "description": "SoC die temperature (centidegrees)", + "display": { + "fmt": "float", + "digits": 2, + "postfix": "deg" + }, + "conversion": { + "m": 0.01, + "c": 0 + } + } + ] + }, "10": { "name": "ACC_2G", "description": "Accelerometer +-2G", @@ -1437,7 +1457,7 @@ { "name": "h_speed_acc", "type": "uint32_t", - "description": "Horizonal speed accuracy estimate", + "description": "Horizontal speed accuracy estimate", "display": { "postfix": "m/s" }, @@ -1461,7 +1481,7 @@ { "name": "v_speed_acc", "type": "uint32_t", - "description": "Horizonal speed accuracy estimate", + "description": "Horizontal speed accuracy estimate", "display": { "postfix": "m/s" }, diff --git a/src/lib.rs b/src/lib.rs index 12cf6fe..d1288ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ use chrono::SecondsFormat; use itertools::Itertools; use memmap::Mmap; -use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::fs::File; use std::io::{self, BufRead, BufReader, BufWriter, Cursor, Write}; use std::path::PathBuf; @@ -275,13 +275,11 @@ pub fn run( (f, s) }; - let mut num_workers = num_cpus::get(); let num_blocks = size / blocks::BLOCK_SIZE; - if num_blocks < num_workers { - num_workers = 1; - } + let max_workers = (num_blocks / 100) + 1; + let num_workers = std::cmp::min(max_workers, num_cpus::get()); let blocks_per_worker = num_blocks / num_workers; - let trailing = num_blocks % blocks_per_worker; + let trailing = num_blocks - (blocks_per_worker * num_workers); args.decode_reporter.start("Decoding blocks", num_blocks); diff --git a/tdf/src/decoders.rs b/tdf/src/decoders.rs index 47589f8..82f68e7 100644 --- a/tdf/src/decoders.rs +++ b/tdf/src/decoders.rs @@ -12,6 +12,7 @@ pub fn tdf_name(tdf_id: &u16) -> String 5 => String::from("TIME_SYNC"), 6 => String::from("REBOOT_INFO"), 7 => String::from("ANNOUNCE_V2"), + 8 => String::from("SOC_TEMPERATURE"), 10 => String::from("ACC_2G"), 11 => String::from("ACC_4G"), 12 => String::from("ACC_8G"), @@ -77,6 +78,7 @@ pub fn tdf_fields(tdf_id: &u16) -> Vec<&'static str> 5 => vec!["source","shift"], 6 => vec!["reason","hardware_flags","count","uptime","param_1","param_2","thread"], 7 => vec!["application","major","minor","revision","build_num","board_crc","kv_crc","blocks","uptime","reboots","flags"], + 8 => vec!["temperature"], 10 => vec!["x","y","z"], 11 => vec!["x","y","z"], 12 => vec!["x","y","z"], @@ -230,6 +232,11 @@ pub fn tdf_read_into_str(tdf_id: &u16, size: u8, cursor: &mut Cursor<&[u8]>) -> cursor.read_u16::()?, cursor.read_u8()?, )), + 8 => + Ok(format!( + "{}", + cursor.read_i16::()? as f64 / 100.0, + )), 10 => Ok(format!( "{},{},{}",