GPSHyperionController adapted

This commit is contained in:
Ulrich Mohr 2022-07-27 22:02:37 +02:00
parent eeaef13916
commit c8f4f0b03e
5 changed files with 43 additions and 29 deletions

View File

@ -4,11 +4,7 @@
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/tasks/TaskFactory.h"
ReturnValue_t gps::triggerGpioResetPin(const uint8_t* actionData, size_t len, void* args) {
// At least one byte which denotes which GPS to reset is required
if (len < 1 or actionData == nullptr) {
return HasActionsIF::INVALID_PARAMETERS;
}
ReturnValue_t gps::triggerGpioResetPin(uint8_t gpsId, void* args) {
ResetArgs* resetArgs = reinterpret_cast<ResetArgs*>(args);
if (args == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
@ -16,10 +12,8 @@ ReturnValue_t gps::triggerGpioResetPin(const uint8_t* actionData, size_t len, vo
if (resetArgs->gpioComIF == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
gpioId_t gpioId;
if (actionData[0] == 0) {
gpioId = gpioIds::GNSS_0_NRESET;
} else {
gpioId_t gpioId = gpioIds::GNSS_0_NRESET;
if (gpsId == 1) {
gpioId = gpioIds::GNSS_1_NRESET;
}
resetArgs->gpioComIF->pullLow(gpioId);

View File

@ -11,7 +11,7 @@ struct ResetArgs {
namespace gps {
ReturnValue_t triggerGpioResetPin(const uint8_t* actionData, size_t len, void* args);
ReturnValue_t triggerGpioResetPin(uint8_t gpsId, void* args);
}

View File

@ -53,23 +53,20 @@ ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
switch (actionId) {
case (GpsHyperion::TRIGGER_RESET_PIN_GNSS): {
ReturnValue_t GPSHyperionLinuxController::executeAction(Action *action) {
return action->handle();
}
ReturnValue_t GPSHyperionLinuxController::handleAction(GPSHyperionLinuxAction * action) {
if (resetCallback != nullptr) {
PoolReadGuard pg(&gpsSet);
// Set HK entries invalid
gpsSet.setValidity(false, true);
resetCallback(data, size, resetCallbackArgs);
resetCallback(static_cast<uint8_t>(action->gpsId.value), resetCallbackArgs);
return HasActionsIF::EXECUTION_FINISHED;
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {

View File

@ -2,10 +2,11 @@
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
#include "commonSubsystemIds.h"
#include "devicedefinitions/GPSHyperionLinuxDefinitions.h"
#include "fsfw/FSFW.h"
#include "fsfw/controller/ExtendedControllerBase.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
#ifdef FSFW_OSAL_LINUX
#include <gps.h>
@ -30,7 +31,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
bool debugHyperionGps = false);
virtual ~GPSHyperionLinuxController();
using gpioResetFunction_t = ReturnValue_t (*)(const uint8_t* actionData, size_t len, void* args);
using gpioResetFunction_t = ReturnValue_t (*)(uint8_t gpsId, void* args);
void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void* args);
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
@ -38,8 +39,8 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
ReturnValue_t executeAction(Action* action) override;
ReturnValue_t handleAction(GPSHyperionLinuxAction * action);
ReturnValue_t initialize() override;
protected:
@ -65,6 +66,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
int32_t noModeSetCntr = 0;
uint32_t timeIsConstantCounter = 0;
Countdown timeUpdateCd = Countdown(60);
GPSHyperionLinuxAction action = GPSHyperionLinuxAction(this);
void readGpsDataFromGpsd();
};

View File

@ -0,0 +1,21 @@
#include <fsfw/action/MinMaxParameter.h>
#include <fsfw/action/TemplateAction.h>
#include <fsfw/introspection/Enum.h>
#include "mission/devices/devicedefinitions/GPSDefinitions.h"
class GPSHyperionLinuxController;
FSFW_ENUM(GPSHyperionLinuxCommands, DeviceCommandId_t,
((TRIGGER_RESET_PIN_GNSS, GpsHyperion::TRIGGER_RESET_PIN_GNSS, "Trigger Reset Pin")))
class GPSHyperionLinuxAction
: public TemplateAction<GPSHyperionLinuxController, GPSHyperionLinuxAction,
GPSHyperionLinuxCommands> {
public:
FSFW_ENUM(GpsIDs, uint8_t, ((GPS_0, 0, "GPS 0"))((GPS_1, 1, "GPS 1")))
GPSHyperionLinuxAction(GPSHyperionLinuxController *owner)
: TemplateAction(owner, GPSHyperionLinuxCommands::TRIGGER_RESET_PIN_GNSS){};
Parameter<GpsIDs> gpsId = Parameter<GpsIDs>::createParameter(this, "GPS ID");
};