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 2 additions and 26 deletions
Showing only changes of commit 5c4ae861b1 - Show all commits

View File

@ -9,16 +9,13 @@
#include <fstream> #include <fstream>
#endif #endif
#include <cmath> #include <cmath>
#include <ctime>
GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
bool debugHyperionGps) bool debugHyperionGps)
: ExtendedControllerBase(objectId, objects::NO_OBJECT), : ExtendedControllerBase(objectId, objects::NO_OBJECT),
gpsSet(this), gpsSet(this),
myGpsmm(GPSD_SHARED_MEMORY, nullptr), myGpsmm(GPSD_SHARED_MEMORY, nullptr),
debugHyperionGps(debugHyperionGps) { debugHyperionGps(debugHyperionGps) {}
timeUpdateCd.resetTimer();
}
GPSHyperionLinuxController::~GPSHyperionLinuxController() {} GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
@ -79,11 +76,9 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
bool enablePeriodicHk = false;
#if OBSW_ENABLE_PERIODIC_HK == 1 #if OBSW_ENABLE_PERIODIC_HK == 1
enablePeriodicHk = true; poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false);
#endif #endif
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), enablePeriodicHk, 2.0, false);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -177,20 +172,6 @@ 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. 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 = {}; Clock::TimeOfDay_t timeOfDay = {};
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
gpsSet.year = timeOfDay.year; gpsSet.year = timeOfDay.year;
@ -211,9 +192,6 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
std::cout << "Longitude: " << gps->fix.longitude << std::endl; std::cout << "Longitude: " << gps->fix.longitude << std::endl;
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
std::time_t t = std::time(nullptr);
std::tm tm = *std::gmtime(&t);
std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl;
} }
} }
#endif #endif

View File

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