diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 847cce5f..31dedeba 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -23,7 +23,7 @@ #include "linux/boardtest/UartTestClass.h" #include "linux/callbacks/gpioCallbacks.h" #include "linux/csp/CspComIF.h" -#include "linux/devices/GPSHyperionLinuxController.h" +#include "linux/devices/GpsHyperionLinuxController.h" #include "linux/devices/ScexUartReader.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" @@ -474,7 +474,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo RESET_ARGS_GNSS.gpioComIF = gpioComIF; RESET_ARGS_GNSS.waitPeriodMs = 100; auto gpsCtrl = - new GPSHyperionLinuxController(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); + new GpsHyperionLinuxController(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsCtrl->setResetPinTriggerFunction(gps::triggerGpioResetPin, &RESET_ARGS_GNSS); AcsBoardHelper acsBoardHelper = AcsBoardHelper( diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index cf27972f..469187a6 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -121,8 +121,8 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo fdir = new SusFdir(objects::SUS_5_N_LOC_XFYMZB_PT_ZB); susHandlers[5]->setCustomFdir(fdir); - spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, - spi::SUS_MAX1227_SPI_FREQ); + spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE, + spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); susHandlers[6] = new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SPI_MAIN_COM_IF, spiCookie); fdir = new SusFdir(objects::SUS_6_R_LOC_XFYBZM_PT_XF); diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index a6a909d0..4864e01f 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -1,5 +1,5 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) - target_sources(${OBSW_NAME} PRIVATE GPSHyperionLinuxController.cpp) + target_sources(${OBSW_NAME} PRIVATE GpsHyperionLinuxController.cpp) endif() target_sources( diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp similarity index 85% rename from linux/devices/GPSHyperionLinuxController.cpp rename to linux/devices/GpsHyperionLinuxController.cpp index d112d507..e9832854 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -1,4 +1,4 @@ -#include "GPSHyperionLinuxController.h" +#include "GpsHyperionLinuxController.h" #include @@ -16,26 +16,26 @@ #include #include -GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, +GpsHyperionLinuxController::GpsHyperionLinuxController(object_id_t objectId, object_id_t parentId, bool debugHyperionGps) : ExtendedControllerBase(objectId), gpsSet(this), debugHyperionGps(debugHyperionGps) { timeUpdateCd.resetTimer(); } -GPSHyperionLinuxController::~GPSHyperionLinuxController() { +GpsHyperionLinuxController::~GpsHyperionLinuxController() { gps_stream(&gps, WATCH_DISABLE, nullptr); gps_close(&gps); } -void GPSHyperionLinuxController::performControlOperation() { +void GpsHyperionLinuxController::performControlOperation() { #ifdef FSFW_OSAL_LINUX readGpsDataFromGpsd(); #endif } -LocalPoolDataSetBase *GPSHyperionLinuxController::getDataSetHandle(sid_t sid) { return &gpsSet; } +LocalPoolDataSetBase *GpsHyperionLinuxController::getDataSetHandle(sid_t sid) { return &gpsSet; } -ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_t submode, +ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { if (not modeCommanded) { if (mode == MODE_ON or mode == MODE_OFF) { @@ -54,7 +54,7 @@ ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ return returnvalue::OK; } -ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId, +ReturnValue_t GpsHyperionLinuxController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { switch (actionId) { @@ -72,7 +72,7 @@ ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId, return returnvalue::OK; } -ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( +ReturnValue_t GpsHyperionLinuxController::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); @@ -92,13 +92,13 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( return returnvalue::OK; } -void GPSHyperionLinuxController::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, +void GpsHyperionLinuxController::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { this->resetCallback = resetCallback; resetCallbackArgs = args; } -ReturnValue_t GPSHyperionLinuxController::initialize() { +ReturnValue_t GpsHyperionLinuxController::initialize() { ReturnValue_t result = ExtendedControllerBase::initialize(); if (result != returnvalue::OK) { return result; @@ -127,13 +127,13 @@ ReturnValue_t GPSHyperionLinuxController::initialize() { return result; } -ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *message) { +ReturnValue_t GpsHyperionLinuxController::handleCommandMessage(CommandMessage *message) { return ExtendedControllerBase::handleCommandMessage(message); } #ifdef FSFW_OSAL_LINUX -void GPSHyperionLinuxController::readGpsDataFromGpsd() { +void GpsHyperionLinuxController::readGpsDataFromGpsd() { auto readError = [&](int error) { if (gpsReadFailedSwitch) { gpsReadFailedSwitch = false; @@ -146,27 +146,33 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { if (readMode == ReadModes::SOCKET) { gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr); // Exit if no data is seen in 2 seconds (should not happen) - if (not gps_waiting(&gps, 2000000)) { - return; - } - int result = gps_read(&gps); - if (result == -1) { - readError(result); - return; - } - if (MODE_SET != (MODE_SET & gps.set)) { - if (noModeSetCntr >= 0) { - noModeSetCntr++; + if (gps_waiting(&gps, 2000000)) { + int result = gps_read(&gps); + while (result > 0) { + result = gps_read(&gps); } - if (noModeSetCntr == 10) { - // TODO: Trigger event here - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " - "read for 10 consecutive reads" - << std::endl; - noModeSetCntr = -1; + if (result == -1) { + readError(result); + return; } + if (MODE_SET != (MODE_SET & gps.set)) { + if (mode == MODE_ON) { + 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; + } + // did not event get mode, nothing to see. + return; + } + } + noModeSetCntr = 0; } - noModeSetCntr = 0; } else if (readMode == ReadModes::SHM) { int result = gps_read(&gps); if (result == -1) { @@ -174,10 +180,10 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { return; } } - handleGpsRead(); + handleGpsReadData(); } -ReturnValue_t GPSHyperionLinuxController::handleGpsRead() { +ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { PoolReadGuard pg(&gpsSet); if (pg.getReadResult() != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GpsHyperionLinuxController.h similarity index 92% rename from linux/devices/GPSHyperionLinuxController.h rename to linux/devices/GpsHyperionLinuxController.h index a4c12e57..e0c3dd36 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GpsHyperionLinuxController.h @@ -20,15 +20,15 @@ * This device handler can only be used on Linux system where the gpsd daemon with shared memory * export is running. */ -class GPSHyperionLinuxController : public ExtendedControllerBase { +class GpsHyperionLinuxController : public ExtendedControllerBase { public: static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5; enum ReadModes { SHM = 0, SOCKET = 1 }; - GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, + GpsHyperionLinuxController(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); - virtual ~GPSHyperionLinuxController(); + virtual ~GpsHyperionLinuxController(); using gpioResetFunction_t = ReturnValue_t (*)(const uint8_t* actionData, size_t len, void* args); @@ -49,7 +49,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - ReturnValue_t handleGpsRead(); + ReturnValue_t handleGpsReadData(); private: GpsPrimaryDataset gpsSet; diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 387d08be..0b88cfa5 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -63,7 +63,7 @@ class GpsPrimaryDataset : public StaticLocalDataSet<18> { lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); private: - friend class GPSHyperionLinuxController; + friend class GpsHyperionLinuxController; GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; diff --git a/tmtc b/tmtc index 04f5a769..5e27a22a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 04f5a769629ae79048f68a37d0555e458c9f9a94 +Subproject commit 5e27a22a85acca321cc4ef5067c01924579d2c1e