Merge remote-tracking branch 'origin/mueller/pcdu-switch-callback' into mueller/master
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
2022-01-19 18:42:54 +01:00
17 changed files with 241 additions and 43 deletions

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
#ifndef MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
#define MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#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

View File

@ -1,6 +1,7 @@
#include "PDU1Handler.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include "OBSWConfig.h"
@ -67,6 +68,57 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac
#endif
}
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(pdu, 0, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): {
channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): {
channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_MGT): {
channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): {
channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): {
channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_PLOC): {
channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): {
channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): {
channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs);
break;
}
}
}
return HasReturnvaluesIF::RETURN_OK;
}
void PDU1Handler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
PoolReadGuard pg(&pdu1HkTableDataset);

View File

@ -27,6 +27,8 @@ class PDU1Handler : public GomspaceDeviceHandler {
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args);
protected:
/**
* @brief In MODE_NORMAL, a command will be built periodically by this function.
@ -35,9 +37,13 @@ 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;
GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr;
void* hookArgs = nullptr;
void printHkTable();
void parseHkTableReply(const uint8_t* packet);

View File

@ -49,6 +49,11 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac
#endif
}
void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) {
this->channelSwitchHook = hook;
this->hookArgs = args;
}
void PDU2Handler::parseHkTableReply(const uint8_t *packet) {
uint16_t dataOffset = 0;
pdu2HkTableDataset.read();
@ -421,3 +426,49 @@ void PDU2Handler::printHkTable() {
<< std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right
<< std::endl;
}
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(pdu, 0, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): {
channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_RW): {
channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): {
channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): {
channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): {
channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): {
channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): {
channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs);
break;
}
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): {
channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs);
break;
}
}
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -26,6 +26,7 @@ class PDU2Handler : public GomspaceDeviceHandler {
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args);
protected:
/**
@ -34,10 +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;
private:
/** Dataset for the housekeeping table of the PDU2 */
PDU2::PDU2HkTableDataset pdu2HkTableDataset;
GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr;
void* hookArgs = nullptr;
void printHkTable();

View File

@ -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_
@ -16,6 +8,11 @@
#include <cstdint>
namespace GOMSPACE {
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. */
static const uint8_t GS_HDR_LENGTH = 12;
@ -611,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.
@ -799,6 +809,19 @@ class PDU1HkTableDataset : public StaticLocalDataSet<PDU::HK_TABLE_ENTRIES> {
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.