diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index a5b2b548..96a43a81 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -206,7 +206,7 @@ void initmission::initTasks() { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - //acsCtrl->startTask(); + // acsCtrl->startTask(); sif::info << "Tasks started.." << std::endl; } diff --git a/fsfw b/fsfw index 933da2f6..9b770602 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 933da2f655717b66c1056e764c47a2eee473a137 +Subproject commit 9b77060295c9c32ebfc2e7cf6517eb2e66216191 diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 239a0c7a..60e26302 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -273,7 +273,8 @@ ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localData return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { +ReturnValue_t ACUHandler::childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, + size_t commandDataLen) { switch (cmd) { case PRINT_CHANNEL_STATS: { printChannelStats(); diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 0d93c5fe..f3af5eae 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -28,7 +28,8 @@ class ACUHandler : public GomspaceDeviceHandler { virtual void fillCommandAndReplyMap() override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t* commandData, + size_t commandDataLen) override; private: static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 37b11bcb..9bea91b0 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -30,9 +30,7 @@ void GPSHyperionHandler::performControlOperation() { #endif } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return &gpsSet; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return &gpsSet; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index eea1368a..c2abd330 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -36,7 +36,7 @@ ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandI ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result; + ReturnValue_t result = childCommandHook(deviceCommand, commandData, commandDataLen); switch (deviceCommand) { case (GOMSPACE::PING): { result = generatePingCommand(commandData, commandDataLen); @@ -82,7 +82,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d break; } default: - return deviceSpecificCommand(deviceCommand); + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } return HasReturnvaluesIF::RETURN_OK; } @@ -195,6 +195,10 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm << std::endl; return result; } + result = setParamCallback(setParamMessageUnpacker); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } /* Get and check address */ uint16_t address = setParamMessageUnpacker.getAddress(); if (address > maxConfigTableAddress) { @@ -335,6 +339,16 @@ void GomspaceDeviceHandler::generateRebootCommand() { rawPacketLen = cspPacketLen; } +ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd, + const uint8_t* commandData, + size_t commandDataLen) { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; +} + +ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker) { + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { WatchdogResetCommand watchdogResetCommand; size_t cspPacketLen = 0; @@ -386,10 +400,6 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { } } -ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; -} - void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index c9c08609..22b97ef7 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -1,6 +1,8 @@ #ifndef MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ #define MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ +#include + #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "returnvalues/classIds.h" @@ -101,9 +103,12 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; /** - * @brief Can be used by gomspace devices to implement device specific commands. + * @brief Can be overriden by child classes to implement device specific commands. + * @return Return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED to let this handler handle + * the command or RETURN_OK if the child handles the command */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, + size_t commandDataLen); private: /** @@ -112,6 +117,8 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { */ ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen); + virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker); + /** * @brief Function to generate the command to get a parameter from a * gomspace device. Command will be sent to the ComIF over the diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index a1486588..e7e91fbf 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,6 +1,7 @@ #include "PDU1Handler.h" #include +#include #include "OBSWConfig.h" @@ -67,6 +68,55 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } +void PDU1Handler::assignChannelHookFunction(ChannelSwitchHook hook) { + this->channelSwitchHook = hook; +} + +ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { + using namespace PDU1; + if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { + switch (unpacker.getAddress()) { + case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): { + channelSwitchHook(0, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): { + channelSwitchHook(1, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): { + channelSwitchHook(2, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_MGT): { + channelSwitchHook(3, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): { + channelSwitchHook(4, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): { + channelSwitchHook(5, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PLOC): { + channelSwitchHook(6, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): { + channelSwitchHook(7, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): { + channelSwitchHook(8, unpacker.getParameter()[0]); + break; + } + } + } + return HasReturnvaluesIF::RETURN_OK; +} + void PDU1Handler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; PoolReadGuard pg(&pdu1HkTableDataset); diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 0715b078..911e65be 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -4,6 +4,8 @@ #include "GomspaceDeviceHandler.h" #include "devicedefinitions/GomspaceDefinitions.h" +using ChannelSwitchHook = void (*)(uint8_t channel, bool on); + /** * @brief This is the device handler for the PDU1. * @@ -27,6 +29,8 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; + void assignChannelHookFunction(ChannelSwitchHook hook); + protected: /** * @brief In MODE_NORMAL, a command will be built periodically by this function. @@ -35,9 +39,12 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + private: /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; + ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet);