From e695d82358f7addcfd68cf7d468ebff0d4674917 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 18 Dec 2025 13:28:05 +1000 Subject: [PATCH 1/4] lib: fix trailing block calculation Fix the logic that calculates the leftover blocks to assign to the last worker. Fixes up to `num_cpus::get()` blocks at the end of the file from being ignored. Signed-off-by: Jordan Yates --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 12cf6fe..2325623 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -281,7 +281,7 @@ pub fn run( num_workers = 1; } 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); From 1ada4821fc613de34149fe200d918ec522b540d3 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 18 Dec 2025 13:30:44 +1000 Subject: [PATCH 2/4] lib: minimum blocks per worker Ensure that each worker has at least 100 blocks, rather than spinning up a number of threads that each only decode a handful of blocks for small files. Signed-off-by: Jordan Yates --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2325623..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,11 +275,9 @@ 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 * num_workers); From 1becc4c237581852bdb5b518e80d4930daf76f24 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 18 Dec 2025 13:34:50 +1000 Subject: [PATCH 3/4] tdf: regenerate definitions Regenerate definitions for new TDFs. Signed-off-by: Jordan Yates --- scripts/tdf.json | 24 ++++++++++++++++++++++-- tdf/src/decoders.rs | 7 +++++++ 2 files changed, 29 insertions(+), 2 deletions(-) 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/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!( "{},{},{}", From d719bc59c038630a1cd11a4692c36287572c294d Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 18 Dec 2025 13:37:48 +1000 Subject: [PATCH 4/4] Cargo.toml: `v1.5.0` - 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 Signed-off-by: Jordan Yates --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) 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]]