ElektraInitiative / opensesame

3 stars 5 forks source link

panic in conv_vec_to_value_u().unwrap #133

Open markus2330 opened 9 months ago

markus2330 commented 9 months ago

Maybe on too strong wind?

Jän 06 11:31:59 messstation opensesame[13532]: thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: ()', /home/jenkins/workspace/opensesame_fixes/src/clima_sensor_us.rs:255:72
Jän 06 11:31:59 messstation opensesame[13532]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@fel115 do you have an idea what this could be? Any progress on the blog for Olimex?

fel115 commented 9 months ago

Yes, it seems that in line 249 the value of the clima sensor is 0xFFFFFFFF which is the error code for unsigned 32. So before using the Air Temp and Mean Wind Speed values we need to check if the conv_vec_to_value_s or conv_vec_to_value_s have any error.

Replace https://github.com/ElektraInitiative/opensesame/blob/177e14fd1ad29c04c1a838fc01f01b43150c5eae/src/clima_sensor_us.rs#L252C1-L256 with these lines.

match conv_vec_to_value_s((response_temp[0], response_temp[1]) {
    Ok(value) => {temp = value as 32 / 10.0;},
    Err(_) => ()
}

match conv_vec_to_value_u((response_wind[0], response_wind[1]) {
    Ok(value) => {wind = value as 32 / 10.0;},
    Err(_) => ()
}

According to the blog for Olimex, I will try to finish that in February.

markus2330 commented 9 months ago

Thx for looking into it and creating the PR!

According to the blog for Olimex, I will try to finish that in February.

Sounds like a plan. :rocket: