gauteh/sfy

Serialization of temperature from IMU is possibly always skipped

Opened this issue · 1 comments

gauteh commented

I think this gives a double negative:

https://github.com/gauteh/sfy/blob/main/sfy-buoy/src/axl.rs#L68

needs a test, since the notecard does not handle NaN in serialized JSON. Currently the IMU temperature is never sent, which could either mean that this is a bug. Or that there's something disabled in the IMU.

@stianvikanes : maybe something you can look into.

gauteh commented

Suggestion for a test in axl.rs:

    #[test]
    fn temp_not_f32_subnormal() {
        // the notecard does not handle NaN f32's
        let p = AxlPacketMeta::default();

        let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
        dbg!(&v);
        assert!(v.contains("temperature"));


        let mut p = AxlPacketMeta::default();
        p.temperature = f32::NAN;

        let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
        dbg!(&v);
        assert!(!v.contains("temperature"));

        let mut p = AxlPacketMeta::default();
        p.temperature = f32::INFINITY;

        let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
        dbg!(&v);
        assert!(!v.contains("temperature"));
    }