only set time every 60 seconds
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
2022-03-29 17:47:40 +02:00
parent a8457d7966
commit 9cfb2bad51
5 changed files with 17 additions and 13 deletions

View File

@ -16,7 +16,9 @@ GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, obj
: ExtendedControllerBase(objectId, objects::NO_OBJECT),
gpsSet(this),
myGpsmm(GPSD_SHARED_MEMORY, nullptr),
debugHyperionGps(debugHyperionGps) {}
debugHyperionGps(debugHyperionGps) {
timeUpdateCd.resetTimer();
}
GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
@ -180,10 +182,11 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
timeIsConstantCounter = 0;
}
// If the received time does not change anymore for whatever reason, do not set it here
// to avoid stale times
if(timeIsConstantCounter < 3) {
// to avoid stale times. Also, don't do it too often often to avoid jumping times
if (timeIsConstantCounter < 3 and timeUpdateCd.hasTimedOut()) {
// Update the system time here for now. NTP seems to be unable to do so for whatever reason
settimeofday(&time, nullptr);
timeUpdateCd.resetTimer();
}
Clock::TimeOfDay_t timeOfDay = {};

View File

@ -52,6 +52,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
gpsmm myGpsmm;
bool debugHyperionGps = false;
uint32_t timeIsConstantCounter = 0;
Countdown timeUpdateCd = Countdown(60);
void readGpsDataFromGpsd();
};