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;