Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

how should getXXX handle stale/failed data? #46

Closed
tedder opened this issue Nov 20, 2019 · 4 comments
Closed

how should getXXX handle stale/failed data? #46

tedder opened this issue Nov 20, 2019 · 4 comments

Comments

@tedder
Copy link
Contributor

tedder commented Nov 20, 2019

ignoring the template because this is philisophical, YOLO.

The m.o. of this library is to try to return fresh data using moduleQueried. That's great, but it doesn't leave much room for failure. In other words, take getLatitude:

//Get the current latitude in degrees
//Returns a long representing the number of degrees *10^-7
int32_t SFE_UBLOX_GPS::getLatitude(uint16_t maxWait)
{
  if (moduleQueried.latitude == false)
    getPVT();
  moduleQueried.latitude = false; //Since we are about to give this to user, mark this data as stale

  return (latitude);
}

Now, what if a call to getPVT fails? moduleQueried.latitude will still be false, but we'll just steam right ahead and return.. something. It might be super-super-stale data or the init data, there's no way to know.

I'm using iTOW as a way to sniff "last updated time", but it's a bit of a hack.

Ideas:

  • haveValidData()
  • lastValidUpdateTime()
  • timeSinceLastSuccessfulUpdate()
tedder added a commit to tedder/SparkFun_Ublox_Arduino_Library that referenced this issue Nov 20, 2019
HPPOS isn't necessary to get the iTOW, which is a nice substitute for both a generic epoch and a 'time since last valid communication' from the library (because of sparkfun#40 and sparkfun#46).
@tedder
Copy link
Contributor Author

tedder commented Nov 20, 2019

An example of how this is problematic is when getPVT fails. Imagine calling getYear/getMonth/getDay/getHour etc with getPVT failing. Each one of those will try the call and wait to time out, so calling all those functions takes a huge amount of time.

@nseidle
Copy link
Member

nseidle commented Nov 20, 2019

ignoring template = totes ok.

@tedder - Agreed.

@tve - As the original user of PVT, any thoughts?

@tve
Copy link
Contributor

tve commented Nov 20, 2019

IMHO all the getXXX functions are optimistic and YMMV (designed to make a first encounter of the library easy). If you are concerned about failures why don't you call getPVT explicitly yourself, check the return value, and then proceed to call the appropriate getXXX functions only if the result is OK?

@tedder
Copy link
Contributor Author

tedder commented Dec 17, 2019

Thanks tve. I can do that, for sure. I didn't know that was the m.o. If I get some time to focus on it I'll update docs and perhaps code to encourage that (like getData()). I'll noodle around it.

@tedder tedder closed this as completed Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants