PL PCDU Update Mode Handling #200
@ -173,8 +173,19 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
timeval time = {};
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
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
|
||||
settimeofday(&time, nullptr);
|
||||
}
|
||||
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
|
@ -51,6 +51,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
bool modeCommanded = true;
|
||||
gpsmm myGpsmm;
|
||||
bool debugHyperionGps = false;
|
||||
uint32_t timeIsConstantCounter = 0;
|
||||
|
||||
void readGpsDataFromGpsd();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user