bugfix for GPS handler
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop Build queued...

This commit is contained in:
Robin Müller 2023-02-05 13:13:09 +01:00
parent 9bcc424d86
commit 10378ef1bb
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
7 changed files with 49 additions and 43 deletions

View File

@ -23,7 +23,7 @@
#include "linux/boardtest/UartTestClass.h" #include "linux/boardtest/UartTestClass.h"
#include "linux/callbacks/gpioCallbacks.h" #include "linux/callbacks/gpioCallbacks.h"
#include "linux/csp/CspComIF.h" #include "linux/csp/CspComIF.h"
#include "linux/devices/GPSHyperionLinuxController.h" #include "linux/devices/GpsHyperionLinuxController.h"
#include "linux/devices/ScexUartReader.h" #include "linux/devices/ScexUartReader.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.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.gpioComIF = gpioComIF;
RESET_ARGS_GNSS.waitPeriodMs = 100; RESET_ARGS_GNSS.waitPeriodMs = 100;
auto gpsCtrl = 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); gpsCtrl->setResetPinTriggerFunction(gps::triggerGpioResetPin, &RESET_ARGS_GNSS);
AcsBoardHelper acsBoardHelper = AcsBoardHelper( AcsBoardHelper acsBoardHelper = AcsBoardHelper(

View File

@ -121,8 +121,8 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
fdir = new SusFdir(objects::SUS_5_N_LOC_XFYMZB_PT_ZB); fdir = new SusFdir(objects::SUS_5_N_LOC_XFYMZB_PT_ZB);
susHandlers[5]->setCustomFdir(fdir); susHandlers[5]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE,
spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[6] = susHandlers[6] =
new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SPI_MAIN_COM_IF, spiCookie); 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); fdir = new SusFdir(objects::SUS_6_R_LOC_XFYBZM_PT_XF);

View File

@ -1,5 +1,5 @@
if(EIVE_BUILD_GPSD_GPS_HANDLER) if(EIVE_BUILD_GPSD_GPS_HANDLER)
target_sources(${OBSW_NAME} PRIVATE GPSHyperionLinuxController.cpp) target_sources(${OBSW_NAME} PRIVATE GpsHyperionLinuxController.cpp)
endif() endif()
target_sources( target_sources(

View File

@ -1,4 +1,4 @@
#include "GPSHyperionLinuxController.h" #include "GpsHyperionLinuxController.h"
#include <fsfw/timemanager/Stopwatch.h> #include <fsfw/timemanager/Stopwatch.h>
@ -16,26 +16,26 @@
#include <cmath> #include <cmath>
#include <ctime> #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), gpsSet(this), debugHyperionGps(debugHyperionGps) { : ExtendedControllerBase(objectId), gpsSet(this), debugHyperionGps(debugHyperionGps) {
timeUpdateCd.resetTimer(); timeUpdateCd.resetTimer();
} }
GPSHyperionLinuxController::~GPSHyperionLinuxController() { GpsHyperionLinuxController::~GpsHyperionLinuxController() {
gps_stream(&gps, WATCH_DISABLE, nullptr); gps_stream(&gps, WATCH_DISABLE, nullptr);
gps_close(&gps); gps_close(&gps);
} }
void GPSHyperionLinuxController::performControlOperation() { void GpsHyperionLinuxController::performControlOperation() {
#ifdef FSFW_OSAL_LINUX #ifdef FSFW_OSAL_LINUX
readGpsDataFromGpsd(); readGpsDataFromGpsd();
#endif #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) { uint32_t *msToReachTheMode) {
if (not modeCommanded) { if (not modeCommanded) {
if (mode == MODE_ON or mode == MODE_OFF) { if (mode == MODE_ON or mode == MODE_OFF) {
@ -54,7 +54,7 @@ ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId, ReturnValue_t GpsHyperionLinuxController::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) { const uint8_t *data, size_t size) {
switch (actionId) { switch (actionId) {
@ -72,7 +72,7 @@ ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( ReturnValue_t GpsHyperionLinuxController::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry<double>({0.0})); localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry<double>({0.0}));
localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry<double>({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry<double>({0.0}));
@ -92,13 +92,13 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
return returnvalue::OK; return returnvalue::OK;
} }
void GPSHyperionLinuxController::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void GpsHyperionLinuxController::setResetPinTriggerFunction(gpioResetFunction_t resetCallback,
void *args) { void *args) {
this->resetCallback = resetCallback; this->resetCallback = resetCallback;
resetCallbackArgs = args; resetCallbackArgs = args;
} }
ReturnValue_t GPSHyperionLinuxController::initialize() { ReturnValue_t GpsHyperionLinuxController::initialize() {
ReturnValue_t result = ExtendedControllerBase::initialize(); ReturnValue_t result = ExtendedControllerBase::initialize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -127,13 +127,13 @@ ReturnValue_t GPSHyperionLinuxController::initialize() {
return result; return result;
} }
ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *message) { ReturnValue_t GpsHyperionLinuxController::handleCommandMessage(CommandMessage *message) {
return ExtendedControllerBase::handleCommandMessage(message); return ExtendedControllerBase::handleCommandMessage(message);
} }
#ifdef FSFW_OSAL_LINUX #ifdef FSFW_OSAL_LINUX
void GPSHyperionLinuxController::readGpsDataFromGpsd() { void GpsHyperionLinuxController::readGpsDataFromGpsd() {
auto readError = [&](int error) { auto readError = [&](int error) {
if (gpsReadFailedSwitch) { if (gpsReadFailedSwitch) {
gpsReadFailedSwitch = false; gpsReadFailedSwitch = false;
@ -146,27 +146,33 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
if (readMode == ReadModes::SOCKET) { if (readMode == ReadModes::SOCKET) {
gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr); gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr);
// Exit if no data is seen in 2 seconds (should not happen) // Exit if no data is seen in 2 seconds (should not happen)
if (not gps_waiting(&gps, 2000000)) { if (gps_waiting(&gps, 2000000)) {
return; int result = gps_read(&gps);
} while (result > 0) {
int result = gps_read(&gps); result = gps_read(&gps);
if (result == -1) {
readError(result);
return;
}
if (MODE_SET != (MODE_SET & gps.set)) {
if (noModeSetCntr >= 0) {
noModeSetCntr++;
} }
if (noModeSetCntr == 10) { if (result == -1) {
// TODO: Trigger event here readError(result);
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " return;
"read for 10 consecutive reads"
<< std::endl;
noModeSetCntr = -1;
} }
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) { } else if (readMode == ReadModes::SHM) {
int result = gps_read(&gps); int result = gps_read(&gps);
if (result == -1) { if (result == -1) {
@ -174,10 +180,10 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
return; return;
} }
} }
handleGpsRead(); handleGpsReadData();
} }
ReturnValue_t GPSHyperionLinuxController::handleGpsRead() { ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
PoolReadGuard pg(&gpsSet); PoolReadGuard pg(&gpsSet);
if (pg.getReadResult() != returnvalue::OK) { if (pg.getReadResult() != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1

View File

@ -20,15 +20,15 @@
* This device handler can only be used on Linux system where the gpsd daemon with shared memory * This device handler can only be used on Linux system where the gpsd daemon with shared memory
* export is running. * export is running.
*/ */
class GPSHyperionLinuxController : public ExtendedControllerBase { class GpsHyperionLinuxController : public ExtendedControllerBase {
public: public:
static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5; static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5;
enum ReadModes { SHM = 0, SOCKET = 1 }; 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); bool debugHyperionGps = false);
virtual ~GPSHyperionLinuxController(); virtual ~GpsHyperionLinuxController();
using gpioResetFunction_t = ReturnValue_t (*)(const uint8_t* actionData, size_t len, void* args); 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, ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override; LocalDataPoolManager& poolManager) override;
ReturnValue_t handleGpsRead(); ReturnValue_t handleGpsReadData();
private: private:
GpsPrimaryDataset gpsSet; GpsPrimaryDataset gpsSet;

View File

@ -63,7 +63,7 @@ class GpsPrimaryDataset : public StaticLocalDataSet<18> {
lp_var_t<uint32_t>(sid.objectId, GpsHyperion::UNIX_SECONDS, this); lp_var_t<uint32_t>(sid.objectId, GpsHyperion::UNIX_SECONDS, this);
private: private:
friend class GPSHyperionLinuxController; friend class GpsHyperionLinuxController;
GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner)
: StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {}
}; };

2
tmtc

@ -1 +1 @@
Subproject commit 04f5a769629ae79048f68a37d0555e458c9f9a94 Subproject commit 5e27a22a85acca321cc4ef5067c01924579d2c1e