Ticket Created
over 3 years ago

CIQQA-955

No info in doc how to check invalid sample from sensor history

I have  a strange error on f6pro (but not in mine)  Error Name: System Error in line

x = MAT.round(v);

where v is data field from Toybox.SensorHistory.SensorSample class

I suppose data/v is invalid but how to check it? Doc says:

The Sensor sample may contain invalid data. Make sure to has check for invalid samples. If the samples do not contain data, they will return null.

What has should I use to check sample? Now I check only if null.

Parents
  • At a basic level, you would just do something like:

    if(Toybox has SensorHistory) {
        // Do stuff here with the sensor history samples
    }

    This just ensures the device you're running the app on actually supports SensorHistory. I'm not entirely certain what the docs mean to convey in this case... I suspect it's poorly worded. If the device supports SensorHistory, then there would be no reason to 'has' check the SensorSample objects because they are part of the SensorHistory class.

    You may also want to do something like this:

     if((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getOxygenSaturationHistory)) {

    Even if a device supports SensorHistory, it may not support all of the history types.

    I suspect that neither of these suggestions addresses the error being reported on the fenix 6 Pro. I would expect a null check to be sufficient, but you could also use 'instanceOf' checks to make sure the data you're getting is of the correct type since Math.round expects either a Number, Float, Long, or Double.

Comment
  • At a basic level, you would just do something like:

    if(Toybox has SensorHistory) {
        // Do stuff here with the sensor history samples
    }

    This just ensures the device you're running the app on actually supports SensorHistory. I'm not entirely certain what the docs mean to convey in this case... I suspect it's poorly worded. If the device supports SensorHistory, then there would be no reason to 'has' check the SensorSample objects because they are part of the SensorHistory class.

    You may also want to do something like this:

     if((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getOxygenSaturationHistory)) {

    Even if a device supports SensorHistory, it may not support all of the history types.

    I suspect that neither of these suggestions addresses the error being reported on the fenix 6 Pro. I would expect a null check to be sufficient, but you could also use 'instanceOf' checks to make sure the data you're getting is of the correct type since Math.round expects either a Number, Float, Long, or Double.

Children
  • Of course I do everything you have mentioned but even though obtained value v generate error.

    Value isn't null - I also check it, so I suspected that invalid sample is for example string or something so I've asked about how to check if Toybox.SensorHistory.SensorSample.data is invalid.

    Backtrace form ERA in this example is impossible so I expect that line with MAT.round makes problem. It has happened only once 

    Error Name: System Error
    Occurrences: 1
    First Occurrence: 2022-02-06
    Last Occurrence: 2022-02-06
    Devices:
        fÄ“nix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 20.30