small safety mechanism for time
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@ -173,8 +173,19 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
timeval time = {};
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
||||
// Update the system time here for now. NTP seems to be unable to do so for whatever reason
|
||||
settimeofday(&time, nullptr);
|
||||
std::time_t t = std::time(nullptr);
|
||||
if (time.tv_sec == t) {
|
||||
timeIsConstantCounter++;
|
||||
} else {
|
||||
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) {
|
||||
// Update the system time here for now. NTP seems to be unable to do so for whatever reason
|
||||
settimeofday(&time, nullptr);
|
||||
}
|
||||
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
|
Reference in New Issue
Block a user