From 9cfb2bad51626d90b40106c00685852368300d87 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Mar 2022 17:47:40 +0200 Subject: [PATCH] only set time every 60 seconds --- linux/devices/GPSHyperionLinuxController.cpp | 9 ++++++--- linux/devices/GPSHyperionLinuxController.h | 1 + mission/devices/HeaterHandler.cpp | 4 +--- mission/devices/PCDUHandler.cpp | 4 +--- mission/system/AcsBoardAssembly.cpp | 12 ++++++++---- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index 821946c7..1a1f752e 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -16,7 +16,9 @@ GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, obj : ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), myGpsmm(GPSD_SHARED_MEMORY, nullptr), - debugHyperionGps(debugHyperionGps) {} + debugHyperionGps(debugHyperionGps) { + timeUpdateCd.resetTimer(); +} GPSHyperionLinuxController::~GPSHyperionLinuxController() {} @@ -180,10 +182,11 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { 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) { + // 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 = {}; diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h index d0157f9c..46acb5fc 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GPSHyperionLinuxController.h @@ -52,6 +52,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { gpsmm myGpsmm; bool debugHyperionGps = false; uint32_t timeIsConstantCounter = 0; + Countdown timeUpdateCd = Countdown(60); void readGpsDataFromGpsd(); }; diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 9e97f02a..fcafefd8 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -339,9 +339,7 @@ gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) { MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } -ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { - return RETURN_OK; -} +ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; } ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index e59f2ab7..ab35b52f 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -350,9 +350,7 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO return RETURN_OK; } -ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { - return RETURN_OK; -} +ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; } ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index 6ea701d5..e93d79b8 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -145,13 +145,15 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s if (gpioIF->pullHigh(gpioIds::GNSS_0_NRESET) != HasReturnvaluesIF::RETURN_OK) { #if OBSW_VERBOSE_LEVEL >= 1 sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 0 high (used GNSS)" << std::endl; + "of GNSS 0 high (used GNSS)" + << std::endl; #endif } if (gpioIF->pullLow(gpioIds::GNSS_1_NRESET) != HasReturnvaluesIF::RETURN_OK) { #if OBSW_VERBOSE_LEVEL >= 1 sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 1 low (unused GNSS)" << std::endl; + "of GNSS 1 low (unused GNSS)" + << std::endl; #endif } if (gpioIF->pullLow(gpioIds::GNSS_SELECT) != HasReturnvaluesIF::RETURN_OK) { @@ -180,13 +182,15 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s if (gpioIF->pullHigh(gpioIds::GNSS_1_NRESET) != HasReturnvaluesIF::RETURN_OK) { #if OBSW_VERBOSE_LEVEL >= 1 sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 1 high (used GNSS)" << std::endl; + "of GNSS 1 high (used GNSS)" + << std::endl; #endif } if (gpioIF->pullLow(gpioIds::GNSS_0_NRESET) != HasReturnvaluesIF::RETURN_OK) { #if OBSW_VERBOSE_LEVEL >= 1 sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 0 low (unused GNSS)" << std::endl; + "of GNSS 0 low (unused GNSS)" + << std::endl; #endif } if (gpioIF->pullHigh(gpioIds::GNSS_SELECT) != HasReturnvaluesIF::RETURN_OK) {