diff --git a/fsfw b/fsfw index d61fe7db..7f6c8b8b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d61fe7db93b37dd6652dbfee5b7c93f400ac5a11 +Subproject commit 7f6c8b8b123a63546de0d73f0de35900d6c806bf diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index 5a7d9808..1c740f58 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -107,6 +107,7 @@ ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *m } #ifdef FSFW_OSAL_LINUX + void GPSHyperionLinuxController::readGpsDataFromGpsd() { gpsmm gpsmm("localhost", DEFAULT_GPSD_PORT); // The data from the device will generally be read all at once. Therefore, we @@ -125,45 +126,45 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { } // Stopwatch watch; gps_data_t *gps = nullptr; - gps = gpsmm.stream(WATCH_ENABLE | WATCH_JSON); + gpsmm.stream(WATCH_ENABLE | WATCH_JSON); + if(not gpsmm.waiting(50000000)) { + return; + } + gps = gpsmm.read(); if (gps == nullptr) { - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd:: Setting GPSD watch " - "policy failed" - << std::endl; - } - while (gpsmm.waiting(2000)) { - gps = gpsmm.read(); - if (gps == nullptr) { - if (gpsReadFailedSwitch) { - gpsReadFailedSwitch = false; - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" - << std::endl; - } - return; - } - if (MODE_SET != (MODE_SET & gps->set)) { - if (noModeSetCntr >= 0) { - noModeSetCntr++; - } - if (noModeSetCntr == 10) { - // TODO: Trigger event here - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " - "read for 10 consecutive reads" - << std::endl; - noModeSetCntr = -1; - } - return; - } else { - noModeSetCntr = 0; + if (gpsReadFailedSwitch) { + gpsReadFailedSwitch = false; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" + << std::endl; } + return; } - gps = gpsmm.stream(WATCH_DISABLE); + if (MODE_SET != (MODE_SET & gps->set)) { + if (noModeSetCntr >= 0) { + noModeSetCntr++; + } + if (noModeSetCntr == 10) { + // TODO: Trigger event here + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " + "read for 10 consecutive reads" + << std::endl; + noModeSetCntr = -1; + } + return; + } else { + noModeSetCntr = 0; + } + handleGpsRead(gps); +} + + +ReturnValue_t GPSHyperionLinuxController::handleGpsRead(gps_data_t* gps) { PoolReadGuard pg(&gpsSet); if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading dataset failed" << std::endl; #endif - return; + return RETURN_FAILED; } bool validFix = false; @@ -292,5 +293,7 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { std::tm tm = *std::gmtime(&t); std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl; } + return RETURN_OK; } + #endif diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h index 8d0ec0cd..bb9eef09 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GPSHyperionLinuxController.h @@ -47,6 +47,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; + ReturnValue_t handleGpsRead(gps_data_t* gps); private: GpsPrimaryDataset gpsSet; Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000); diff --git a/tmtc b/tmtc index 168b6622..0a47c17f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 168b662288175f9db77a5796a02f38cb66911092 +Subproject commit 0a47c17fa699dc571d2d3e63ec08c9f4cf513f65