PL PCDU Update Mode Handling #200

Merged
meierj merged 26 commits from mueller/pl-pcdu-update-mode-handling into develop 2022-04-07 11:12:07 +02:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit a8457d7966 - Show all commits

View File

@ -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;

View File

@ -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();
}; };