Skip to content

Commit

Permalink
Fixed sim enum frequency check
Browse files Browse the repository at this point in the history
  • Loading branch information
harrison-e committed Dec 16, 2024
1 parent da3147f commit 39a1e3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/calypso-cangen/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ fn validate_msg(_msg: CANMsg) -> Result<(), Vec<CANSpecError>> {
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,
Expand Down

0 comments on commit 39a1e3f

Please sign in to comment.