From f948905aa2b60d793547ba3aa627a503cebbae63 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 17:10:51 +0100 Subject: [PATCH 1/5] implemented first switch callback --- bsp_q7s/core/InitMission.cpp | 2 +- fsfw | 2 +- mission/devices/ACUHandler.cpp | 3 +- mission/devices/ACUHandler.h | 3 +- mission/devices/GPSHyperionHandler.cpp | 4 +- mission/devices/GomspaceDeviceHandler.cpp | 22 +++++++--- mission/devices/GomspaceDeviceHandler.h | 11 ++++- mission/devices/PDU1Handler.cpp | 50 +++++++++++++++++++++++ mission/devices/PDU1Handler.h | 7 ++++ 9 files changed, 89 insertions(+), 15 deletions(-) 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); From 79fac2adcb2588b8000b448bef4e34c662ecbd1d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 17:17:06 +0100 Subject: [PATCH 2/5] callbacks are now allowed --- mission/devices/PDU1Handler.cpp | 2 +- mission/devices/PDU1Handler.h | 6 +-- mission/devices/PDU2Handler.cpp | 49 +++++++++++++++++++ mission/devices/PDU2Handler.h | 5 +- .../devicedefinitions/GomspaceDefinitions.h | 3 ++ 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index e7e91fbf..f4bd2839 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -68,7 +68,7 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU1Handler::assignChannelHookFunction(ChannelSwitchHook hook) { +void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { this->channelSwitchHook = hook; } diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 911e65be..fea8395e 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -4,8 +4,6 @@ #include "GomspaceDeviceHandler.h" #include "devicedefinitions/GomspaceDefinitions.h" -using ChannelSwitchHook = void (*)(uint8_t channel, bool on); - /** * @brief This is the device handler for the PDU1. * @@ -29,7 +27,7 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); protected: /** @@ -44,7 +42,7 @@ class PDU1Handler : public GomspaceDeviceHandler { private: /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; - ChannelSwitchHook channelSwitchHook = nullptr; + GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet); diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index b5c34af6..68d903f3 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -49,6 +49,10 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } +void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { + this->channelSwitchHook = hook; +} + void PDU2Handler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; pdu2HkTableDataset.read(); @@ -421,3 +425,48 @@ void PDU2Handler::printHkTable() { << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; } + +ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { + using namespace PDU2; + if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { + switch (unpacker.getAddress()) { + case (CONFIG_ADDRESS_OUT_EN_Q7S): { + channelSwitchHook(0, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): { + channelSwitchHook(1, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_RW): { + channelSwitchHook(2, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): { + channelSwitchHook(3, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): { + channelSwitchHook(4, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): { + channelSwitchHook(5, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): { + channelSwitchHook(6, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): { + channelSwitchHook(7, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): { + channelSwitchHook(8, unpacker.getParameter()[0]); + break; + } + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index 258b616d..20cfd52c 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -26,7 +26,7 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); protected: /** * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. @@ -34,10 +34,11 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; 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 PDU2 */ PDU2::PDU2HkTableDataset pdu2HkTableDataset; + GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index a575747f..64fdd426 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -16,6 +16,9 @@ #include namespace GOMSPACE { + +using ChannelSwitchHook = void (*)(uint8_t channel, bool on); + static const uint16_t IGNORE_CHECKSUM = 0xbb0; /** The size of the header of a gomspace CSP packet. */ static const uint8_t GS_HDR_LENGTH = 12; From 1eb6017a9d2a3660636e1bcca305c27e13698991 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:05:17 +0100 Subject: [PATCH 3/5] callback working --- bsp_q7s/callbacks/CMakeLists.txt | 1 + bsp_q7s/callbacks/pcduSwitchCb.cpp | 32 ++++++++++++ bsp_q7s/callbacks/pcduSwitchCb.h | 14 +++++ bsp_q7s/core/ObjectFactory.cpp | 12 +++-- bsp_q7s/core/ObjectFactory.h | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 3 +- .../pollingSequenceFactory.cpp | 4 +- mission/devices/PDU1Handler.cpp | 22 ++++---- mission/devices/PDU1Handler.h | 3 +- mission/devices/PDU2Handler.cpp | 24 +++++---- mission/devices/PDU2Handler.h | 7 ++- .../devicedefinitions/GomspaceDefinitions.h | 52 +++++++++++++------ 12 files changed, 129 insertions(+), 47 deletions(-) create mode 100644 bsp_q7s/callbacks/pcduSwitchCb.cpp create mode 100644 bsp_q7s/callbacks/pcduSwitchCb.h diff --git a/bsp_q7s/callbacks/CMakeLists.txt b/bsp_q7s/callbacks/CMakeLists.txt index 8c83e26f..a85bf6fb 100644 --- a/bsp_q7s/callbacks/CMakeLists.txt +++ b/bsp_q7s/callbacks/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE rwSpiCallback.cpp gnssCallback.cpp + pcduSwitchCb.cpp ) diff --git a/bsp_q7s/callbacks/pcduSwitchCb.cpp b/bsp_q7s/callbacks/pcduSwitchCb.cpp new file mode 100644 index 00000000..ec5f4dc5 --- /dev/null +++ b/bsp_q7s/callbacks/pcduSwitchCb.cpp @@ -0,0 +1,32 @@ +#include "pcduSwitchCb.h" + +#include + +#include "devices/gpioIds.h" + +void pcdu::switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* args) { + LinuxLibgpioIF* gpioComIF = reinterpret_cast(args); + if (gpioComIF == nullptr) { + return; + } + if (pdu == GOMSPACE::Pdu::PDU1) { + PDU1::SwitchChannels typedChannel = static_cast(channel); + if (typedChannel == PDU1::SwitchChannels::ACS_A_SIDE) { + if (state) { + gpioComIF->pullHigh(gpioIds::GNSS_0_NRESET); + } else { + gpioComIF->pullLow(gpioIds::GNSS_0_NRESET); + } + } + + } else if (pdu == GOMSPACE::Pdu::PDU2) { + PDU2::SwitchChannels typedChannel = static_cast(channel); + if (typedChannel == PDU2::SwitchChannels::ACS_B_SIDE) { + if (state) { + gpioComIF->pullHigh(gpioIds::GNSS_1_NRESET); + } else { + gpioComIF->pullLow(gpioIds::GNSS_1_NRESET); + } + } + } +} diff --git a/bsp_q7s/callbacks/pcduSwitchCb.h b/bsp_q7s/callbacks/pcduSwitchCb.h new file mode 100644 index 00000000..d0f2b748 --- /dev/null +++ b/bsp_q7s/callbacks/pcduSwitchCb.h @@ -0,0 +1,14 @@ +#ifndef BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ +#define BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ + +#include + +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" + +namespace pcdu { + +void switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* args); + +} + +#endif /* BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 69f6dfaf..5867c977 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -3,6 +3,7 @@ #include #include "OBSWConfig.h" +#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" @@ -122,13 +123,14 @@ void ObjectFactory::produce(void* args) { #if BOARD_TE0720 == 0 new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); + createPcduComponents(gpioComIF); createRadSensorComponent(gpioComIF); createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(gpioComIF, uartComIF); -#endif /* OBSW_ADD_ACS_BOARD == 1 */ +#endif + createHeaterComponents(); createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 @@ -234,7 +236,7 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua #endif } -void ObjectFactory::createPcduComponents() { +void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF) { CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK); CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1); CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2); @@ -244,8 +246,10 @@ void ObjectFactory::createPcduComponents() { new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + pdu1handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); + pdu2handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); new PCDUHandler(objects::PCDU_HANDLER, 50); @@ -472,6 +476,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI gpioComIF->addGpios(gpioCookieAcsBoard); +#if OBSW_ADD_ACS_HANDLERS == 1 std::string spiDev = q7s::SPI_DEFAULT_DEV; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, @@ -561,6 +566,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI resetArgsGnss0.waitPeriodMs = 100; auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); +#endif /* OBSW_ADD_ACS_HANDLERS == 1 */ } void ObjectFactory::createHeaterComponents() { diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 47e06e33..8fa4a147 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -13,7 +13,7 @@ void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, SpiComIF** spiComIF); void createTmpComponents(); -void createPcduComponents(); +void createPcduComponents(LinuxLibgpioIF* gpioComIF); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ea26425b..5d501eb6 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -46,7 +46,8 @@ debugging. */ #define OBSW_ADD_PLOC_SUPERVISOR 0 #define OBSW_ADD_PLOC_MPSOC 0 #define OBSW_ADD_SUN_SENSORS 0 -#define OBSW_ADD_ACS_BOARD 0 +#define OBSW_ADD_ACS_BOARD 1 +#define OBSW_ADD_ACS_HANDLERS 0 #define OBSW_ADD_RW 0 #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 814e5c2d..0675cf0d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -435,7 +435,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if OBSW_ADD_ACS_BOARD == 1 +#if OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 bool enableAside = true; bool enableBside = false; if (enableAside) { @@ -501,7 +501,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); } -#endif /* OBSW_ADD_ACS_BOARD == 1 */ +#endif /* OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 */ ReturnValue_t seqCheck = thisSequence->checkSequence(); if (seqCheck != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index f4bd2839..6f2fd01e 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -68,48 +68,50 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { +void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; + this->hookArgs = args; } ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { using namespace PDU1; + GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): { - channelSwitchHook(0, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): { - channelSwitchHook(1, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): { - channelSwitchHook(2, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_MGT): { - channelSwitchHook(3, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): { - channelSwitchHook(4, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): { - channelSwitchHook(5, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PLOC): { - channelSwitchHook(6, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): { - channelSwitchHook(7, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): { - channelSwitchHook(8, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs); break; } } diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index fea8395e..9b60e7e9 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -27,7 +27,7 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args); protected: /** @@ -43,6 +43,7 @@ class PDU1Handler : public GomspaceDeviceHandler { /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; + void* hookArgs = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet); diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 68d903f3..d2d879f8 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -49,8 +49,9 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { - this->channelSwitchHook = hook; +void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { + this->channelSwitchHook = hook; + this->hookArgs = args; } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { @@ -428,42 +429,43 @@ void PDU2Handler::printHkTable() { ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { using namespace PDU2; + GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_Q7S): { - channelSwitchHook(0, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): { - channelSwitchHook(1, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_RW): { - channelSwitchHook(2, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): { - channelSwitchHook(3, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): { - channelSwitchHook(4, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): { - channelSwitchHook(5, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): { - channelSwitchHook(6, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): { - channelSwitchHook(7, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): { - channelSwitchHook(8, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs); break; } } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index 20cfd52c..b721ce58 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -26,7 +26,8 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args); + protected: /** * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. @@ -34,11 +35,13 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + private: /** Dataset for the housekeeping table of the PDU2 */ PDU2::PDU2HkTableDataset pdu2HkTableDataset; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; + void* hookArgs = nullptr; void printHkTable(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 64fdd426..fde4e047 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -1,11 +1,3 @@ -/* - * GomspaceDefinitions.h - * - * @brief This file holds all definitions specific for devices from gomspace. - * @date 20.12.2020 - * @author J. Meier - */ - #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ @@ -17,7 +9,9 @@ namespace GOMSPACE { -using ChannelSwitchHook = void (*)(uint8_t channel, bool on); +enum class Pdu { PDU1, PDU2 }; + +using ChannelSwitchHook = void (*)(Pdu pdu, uint8_t channel, bool on, void* args); static const uint16_t IGNORE_CHECKSUM = 0xbb0; /** The size of the header of a gomspace CSP packet. */ @@ -614,19 +608,32 @@ static const uint8_t HK_TABLE_ENTRIES = 73; namespace PDU1 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 + +enum SwitchChannels : uint8_t { + TCS_BOARD_3V3 = 0, + SYRLINKS = 1, + STR = 2, + MGT = 3, + SUS_NOMINAL = 4, + SOL_CELL_EXPERIMENT = 5, + PLOC = 6, + ACS_A_SIDE = 7, + UNUSED = 8 +}; + /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. */ static const uint16_t CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3 = 0x48; static const uint16_t CONFIG_ADDRESS_OUT_EN_SYRLINKS = 0x49; -static const uint16_t CONFIG_ADDRESS_OUT_EN_STAR_TRACKER = 0x50; -static const uint16_t CONFIG_ADDRESS_OUT_EN_MGT = 0x51; -static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL = 0x52; -static const uint16_t CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP = 0x53; -static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x54; -static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x55; -static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; +static const uint16_t CONFIG_ADDRESS_OUT_EN_STAR_TRACKER = 0x4A; +static const uint16_t CONFIG_ADDRESS_OUT_EN_MGT = 0x4B; +static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL = 0x4C; +static const uint16_t CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP = 0x4D; +static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x4E; +static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x4F; +static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU1. @@ -802,6 +809,19 @@ class PDU1HkTableDataset : public StaticLocalDataSet { namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; + +enum SwitchChannels : uint8_t { + Q7S = 0, + PAYLOAD_PCDU_CH1 = 1, + RW = 2, + TCS_HEATER_IN = 3, + SUS_REDUNDANT = 4, + DEPY_MECHANISM = 5, + PAYLOAD_PCDU_CH6 = 6, + ACS_B_SIDE = 7, + PAYLOAD_CAMERA = 8 +}; + /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. From 68eb7c9271de87b3b978a50c63f3566f68d08d90 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:11:35 +0100 Subject: [PATCH 4/5] removed clang script in root --- apply-clang-format.sh | 11 ----------- bsp_q7s/core/ObjectFactory.cpp | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100755 apply-clang-format.sh diff --git a/apply-clang-format.sh b/apply-clang-format.sh deleted file mode 100755 index 6d77c6e9..00000000 --- a/apply-clang-format.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -if [[ ! -f README.md ]]; then - cd .. -fi - -find ./mission -iname *.h o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./linux -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_q7s -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_linux_board -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_hosted -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./test -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 5867c977..7c089465 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -3,9 +3,9 @@ #include #include "OBSWConfig.h" -#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" From 4913ffa6d46640991e2c68525fecb6c9f2b46003 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:21:17 +0100 Subject: [PATCH 5/5] removed unrelated changes --- mission/devices/GPSHyperionHandler.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 9bea91b0..d49b9db4 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -30,7 +30,7 @@ void GPSHyperionHandler::performControlOperation() { #endif } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return &gpsSet; } +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { @@ -59,7 +59,6 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l 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::SPEED, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); @@ -68,7 +67,6 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); return HasReturnvaluesIF::RETURN_OK;