callbacks are now allowed
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-01-19 17:17:06 +01:00
parent f948905aa2
commit 79fac2adcb
5 changed files with 58 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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();

View File

@ -16,6 +16,9 @@
#include <cstdint>
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;