From 39a1e3f2d8ac311a532e140149e184555c158cd3 Mon Sep 17 00:00:00 2001 From: harry Date: Mon, 16 Dec 2024 16:37:02 -0500 Subject: [PATCH] Fixed sim enum frequency check --- libs/calypso-cangen/src/validate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/calypso-cangen/src/validate.rs b/libs/calypso-cangen/src/validate.rs index ff95a9f..d721381 100644 --- a/libs/calypso-cangen/src/validate.rs +++ b/libs/calypso-cangen/src/validate.rs @@ -130,11 +130,11 @@ fn validate_msg(_msg: CANMsg) -> Result<(), Vec> { for _field in _msg.fields { let _name = _field.name.clone(); - // Check Sim enum frequencies add to 1 + // Check Sim enum frequencies add to 1 (roughly, f32s are approximate) if let Some(Sim::SimEnum { options }) = _field.sim { let mut _sim_total: f32 = 0.0; options.iter().for_each(|opt| { _sim_total += opt[1]; }); - if _sim_total != 1.0 { + if (_sim_total - 1.0).abs() > 0.00001 { _errors.push(CANSpecError::FieldSimEnumFrequencySum( _name.clone(), _sim_total,