diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 248b7193..1f68881c 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -2,6 +2,7 @@ #include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" +#include "fsfw/timemanager/Clock.h" #include "lwgps/lwgps.h" @@ -77,9 +78,28 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, // Set all entries valid now, set invalid on case basis if values are sanitized gpsSet.setValidity(true, true); } + // Negative latitude -> South direction gpsSet.latitude.value = gpsData.latitude; + // Negative longitude -> West direction gpsSet.longitude.value = gpsData.latitude; gpsSet.fixMode.value = gpsData.fix_mode; + gpsSet.satInUse.value = gpsData.sats_in_use; + Clock::TimeOfDay_t timeStruct = {}; + timeStruct.day = gpsData.date; + timeStruct.hour = gpsData.hours; + timeStruct.minute = gpsData.minutes; + timeStruct.month = gpsData.month; + timeStruct.second = gpsData.seconds; + // Convert two-digit year to full year (AD) + timeStruct.year = gpsData.year + 2000; + timeval timeval = {}; + Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); + gpsSet.year = timeStruct.year; + gpsSet.month = gpsData.month; + gpsSet.day = gpsData.date; + gpsSet.hours = gpsData.hours; + gpsSet.minutes = gpsData.minutes; + gpsSet.seconds = gpsData.seconds; #if FSFW_HAL_DEBUG_HYPERION_GPS == 1 sif::info << "GPS Data" << std::endl; printf("Valid status: %d\n", gpsData.is_valid); @@ -105,6 +125,18 @@ uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 72433f66..8f147651 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -15,11 +15,26 @@ enum GpsPoolIds: lp_id_t { LONGITUDE = 1, ALTITUDE = 2, FIX_MODE = 3, + SATS_IN_USE = 4, + UNIX_SECONDS = 5, + YEAR = 6, + MONTH = 7, + DAY = 8, + HOURS = 9, + MINUTES = 10, + SECONDS = 11 +}; + +enum GpsFixModes: uint8_t { + INVALID = 0, + NO_FIX = 1, + FIX_2D = 2, + FIX_3D = 3 }; } -class GpsPrimaryDataset: public StaticLocalDataSet<5> { +class GpsPrimaryDataset: public StaticLocalDataSet<18> { public: GpsPrimaryDataset(object_id_t gpsId): StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { @@ -32,6 +47,15 @@ public: GpsHyperion::LONGITUDE, this); lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = lp_var_t(sid.objectId, + GpsHyperion::UNIX_SECONDS, this); private: friend class GPSHyperionHandler; GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner):