From f603fb633f0b793e98a023fe0d046c517683df84 Mon Sep 17 00:00:00 2001 From: Rahix Date: Sun, 3 Nov 2024 14:27:36 +0100 Subject: [PATCH] Cleaner code to write liveness bit into process image --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/fieldbus.rs | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7adfbb8..a049cd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -304,9 +304,9 @@ dependencies = [ [[package]] name = "process-image" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5af8362e66e347fba28d90c6569235402c7f1b7e41a4a67ed85ca29efade4b0" +checksum = "1c1de5542ea7a8e8654e93e3d00b28c1f3318f95b0f270240685c9eeeb300986" [[package]] name = "profirust" diff --git a/Cargo.toml b/Cargo.toml index c83cc96..a8066e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" env_logger = "0.11.3" linux-embedded-hal = { version = "0.4.0", default-features = false, features = ["i2c"] } log = "0.4.21" -process-image = "0.2.0" +process-image = "0.2.1" [dependencies.profirust] # version = 0.2.0 diff --git a/src/fieldbus.rs b/src/fieldbus.rs index 5f71ce2..11bcae4 100644 --- a/src/fieldbus.rs +++ b/src/fieldbus.rs @@ -181,12 +181,13 @@ fn fieldbus_task(fieldbus_data: Arc>) { for peripheral_info in peripherals.iter() { let peripheral = dp_master.get_mut(peripheral_info.handle); - if peripheral.is_running() { - data.pii[peripheral_info.liveness_bit.0] |= - 1 << peripheral_info.liveness_bit.1; - } else { - data.pii[peripheral_info.liveness_bit.0] &= - !(1 << peripheral_info.liveness_bit.1); + { + let mut liveness_bit = process_image::tag_mut!( + &mut data.pii, + peripheral_info.liveness_bit.0, + peripheral_info.liveness_bit.1 + ); + *liveness_bit = peripheral.is_running(); } if peripheral.is_running() {