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:
parent
0ba2caaf61
commit
a8457d7966
@ -173,8 +173,19 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
|||||||
timeval time = {};
|
timeval time = {};
|
||||||
time.tv_sec = gpsSet.unixSeconds.value;
|
time.tv_sec = gpsSet.unixSeconds.value;
|
||||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
||||||
|
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
|
// Update the system time here for now. NTP seems to be unable to do so for whatever reason
|
||||||
settimeofday(&time, nullptr);
|
settimeofday(&time, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
Clock::TimeOfDay_t timeOfDay = {};
|
Clock::TimeOfDay_t timeOfDay = {};
|
||||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||||
gpsSet.year = timeOfDay.year;
|
gpsSet.year = timeOfDay.year;
|
||||||
|
@ -51,6 +51,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
|||||||
bool modeCommanded = true;
|
bool modeCommanded = true;
|
||||||
gpsmm myGpsmm;
|
gpsmm myGpsmm;
|
||||||
bool debugHyperionGps = false;
|
bool debugHyperionGps = false;
|
||||||
|
uint32_t timeIsConstantCounter = 0;
|
||||||
|
|
||||||
void readGpsDataFromGpsd();
|
void readGpsDataFromGpsd();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user