added test to retrieve pdu config
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-08-26 14:28:06 +02:00
parent e804d433aa
commit 8c110460a6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
24 changed files with 185 additions and 170 deletions

View File

@ -467,6 +467,7 @@ endif()
if(ADD_GOMSPACE_CLIENTS)
target_link_libraries(${OBSW_NAME} PRIVATE ${LIB_GOMSPACE_CLIENTS})
target_link_libraries(${LIB_EIVE_MISSION} PRIVATE ${LIB_GOMSPACE_CLIENTS})
target_link_libraries(${LIB_DUMMIES} PRIVATE ${LIB_GOMSPACE_CLIENTS})
endif()
if(EIVE_ADD_ETL_LIB)

View File

@ -129,9 +129,7 @@ ArduinoComIF::~ArduinoComIF() {
CloseHandle(hCom);
#endif
}
ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) {
return returnvalue::OK;
}
ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { return returnvalue::OK; }
ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) {
ArduinoCookie *arduinoCookie = dynamic_cast<ArduinoCookie *>(cookie);

View File

@ -8,6 +8,7 @@
#include <gps.h>
#include <libgpsmm.h>
#include <param/param_string.h>
#include <param/rparam_client.h>
#include <cstdio>
#include <ctime>
@ -50,6 +51,21 @@ ReturnValue_t Q7STestTask::performOneShotAction() {
}
}
if (DO_TEST_GOMSPACE_GET_CONFIG) {
uint8_t p60pdu_node = 3;
param_index_t requestStruct{};
requestStruct.table = p60pdu_config;
requestStruct.mem_id = P60PDU_PARAM;
uint8_t hk_mem[P60PDU_PARAM_SIZE];
requestStruct.count = p60pdu_config_count;
requestStruct.size = P60PDU_PARAM_SIZE;
requestStruct.physaddr = hk_mem;
int result = rparam_get_full_table(&requestStruct, p60pdu_node, P60_PORT_RPARAM,
requestStruct.mem_id, 1000);
param_list(&requestStruct, 1);
return (result == 0);
}
// testJsonLibDirect();
// testDummyParams();
if (doTestProtHandler) {

View File

@ -17,6 +17,7 @@ class Q7STestTask : public TestTask {
bool doTestSdCard = false;
bool doTestScratchApi = false;
static constexpr bool DO_TEST_GOMSPACE_API = false;
static constexpr bool DO_TEST_GOMSPACE_GET_CONFIG = true;
bool doTestGpsShm = false;
bool doTestGpsSocket = false;
bool doTestProtHandler = false;

View File

@ -20,7 +20,6 @@
#include "linux/boardtest/UartTestClass.h"
#include "linux/callbacks/gpioCallbacks.h"
#include "linux/csp/CspComIF.h"
#include "mission/csp/CspCookie.h"
#include "linux/devices/GPSHyperionLinuxController.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
@ -35,6 +34,7 @@
#include "linux/obc/PdecHandler.h"
#include "linux/obc/Ptme.h"
#include "linux/obc/PtmeConfig.h"
#include "mission/csp/CspCookie.h"
#include "mission/system/RwAssembly.h"
#include "mission/system/fdir/AcsBoardFdir.h"
#include "mission/system/fdir/GomspacePowerFdir.h"
@ -158,10 +158,10 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua
}
void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher) {
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK, 500);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1, 500);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2, 500);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU, 500);
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_SIZE, addresses::P60DOCK, 500);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_SIZE, addresses::PDU1, 500);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_SIZE, addresses::PDU2, 500);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_SIZE, addresses::ACU, 500);
auto p60Fdir = new GomspacePowerFdir(objects::P60DOCK_HANDLER);
P60DockHandler* p60dockhandler =

View File

@ -46,20 +46,15 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
static constexpr ReturnValue_t OP_ONGOING = returnvalue::makeCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t ALREADY_ON = returnvalue::makeCode(INTERFACE_ID, 1);
static constexpr ReturnValue_t ALREADY_MOUNTED =
returnvalue::makeCode(INTERFACE_ID, 2);
static constexpr ReturnValue_t ALREADY_MOUNTED = returnvalue::makeCode(INTERFACE_ID, 2);
static constexpr ReturnValue_t ALREADY_OFF = returnvalue::makeCode(INTERFACE_ID, 3);
static constexpr ReturnValue_t STATUS_FILE_NEXISTS =
returnvalue::makeCode(INTERFACE_ID, 10);
static constexpr ReturnValue_t STATUS_FILE_NEXISTS = returnvalue::makeCode(INTERFACE_ID, 10);
static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID =
returnvalue::makeCode(INTERFACE_ID, 11);
static constexpr ReturnValue_t MOUNT_ERROR = returnvalue::makeCode(INTERFACE_ID, 12);
static constexpr ReturnValue_t UNMOUNT_ERROR =
returnvalue::makeCode(INTERFACE_ID, 13);
static constexpr ReturnValue_t SYSTEM_CALL_ERROR =
returnvalue::makeCode(INTERFACE_ID, 14);
static constexpr ReturnValue_t POPEN_CALL_ERROR =
returnvalue::makeCode(INTERFACE_ID, 15);
static constexpr ReturnValue_t UNMOUNT_ERROR = returnvalue::makeCode(INTERFACE_ID, 13);
static constexpr ReturnValue_t SYSTEM_CALL_ERROR = returnvalue::makeCode(INTERFACE_ID, 14);
static constexpr ReturnValue_t POPEN_CALL_ERROR = returnvalue::makeCode(INTERFACE_ID, 15);
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM;

View File

@ -33,7 +33,9 @@ ReturnValue_t SusDummy::initialize() {
return returnvalue::OK;
}
ReturnValue_t SusDummy::handleCommandMessage(CommandMessage* message) { return returnvalue::FAILED; }
ReturnValue_t SusDummy::handleCommandMessage(CommandMessage* message) {
return returnvalue::FAILED;
}
void SusDummy::performControlOperation() {
iteration++;

View File

@ -4,9 +4,11 @@
#include <fsfw/serialize/SerializeAdapter.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include <p60pdu.h>
#include <p60acu.h>
#include <p60dock.h>
#include <p60pdu.h>
#include <param/param_string.h>
#include <param/rparam_client.h>
#include "mission/csp/CspCookie.h"
@ -86,7 +88,7 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
uint8_t cspPort;
uint16_t querySize = 0;
if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::DEFAULT_COM_IF) {
if (cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::DEFAULT_COM_IF) {
/* Extract csp port and bytes to query from command buffer */
result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize);
if (result != returnvalue::OK) {
@ -96,6 +98,11 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
cspPort = cspCookie->getCspPort();
querySize = cspCookie->getReplyLen();
}
if (querySize > cspCookie->getMaxReplyLength()) {
sif::error << "Query size " << querySize << " is larger than maximum allowed "
<< cspCookie->getMaxReplyLength() << std::endl;
return returnvalue::FAILED;
}
uint8_t cspAddress = cspCookie->getCspAddress();
switch (cspPort) {
case (CspPorts::CSP_PING): {
@ -108,22 +115,32 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
}
case (CspPorts::P60_PORT_GNDWDT_RESET_ENUM):
case (CspPorts::P60_PORT_RPARAM_ENUM): {
if(cspCookie->getRequest() != SpecialRequestTypes::DEFAULT_COM_IF) {
if (cspCookie->getRequest() != SpecialRequestTypes::DEFAULT_COM_IF) {
param_index_t requestStruct{};
requestStruct.physaddr = cspDeviceMap[cspAddress].data();
if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_PDU_HK) {
if(!p60pdu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
auto req = cspCookie->getRequest();
if (req == GOMSPACE::SpecialRequestTypes::GET_PDU_HK) {
if (!p60pdu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
return returnvalue::FAILED;
}
} else if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_ACU_HK) {
if(!p60acu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
} else if (req == GOMSPACE::SpecialRequestTypes::GET_ACU_HK) {
if (!p60acu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
return returnvalue::FAILED;
}
} else if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_P60DOCK_HK) {
if(!p60dock_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
} else if (req == GOMSPACE::SpecialRequestTypes::GET_P60DOCK_HK) {
if (!p60dock_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
return returnvalue::FAILED;
}
} else if (req == GOMSPACE::SpecialRequestTypes::GET_PDU_CONFIG) {
requestStruct.table = p60pdu_config;
requestStruct.mem_id = P60PDU_PARAM;
requestStruct.count = p60pdu_config_count;
requestStruct.size = P60PDU_PARAM_SIZE;
int result = rparam_get_full_table(&requestStruct, cspAddress, P60_PORT_RPARAM,
requestStruct.mem_id, cspCookie->getTimeout());
param_list(&requestStruct, 1);
return (result == 0);
}
} else {
/* No CSP fixed port was selected. Send data to the specified port and

View File

@ -458,8 +458,7 @@ class TcReplayStart : public TcBase {
static const uint8_t ONCE = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH or
checkPayloadLen() != returnvalue::OK) {
if (commandDataLen != COMMAND_DATA_LENGTH or checkPayloadLen() != returnvalue::OK) {
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}

View File

@ -323,7 +323,8 @@ class StrHelper : public SystemObject, public ExecutableObjectIF {
*
* @param expectedPosition Value of expected position
*
* @return returnvalue::OK if received position matches expected position, otherwise returnvalue::FAILED
* @return returnvalue::OK if received position matches expected position, otherwise
* returnvalue::FAILED
*/
ReturnValue_t checkReplyPosition(uint32_t expectedPosition);

View File

@ -31,9 +31,7 @@
*
* @author J. Meier
*/
class PdecHandler : public SystemObject,
public ExecutableObjectIF,
public HasActionsIF {
class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasActionsIF {
public:
/**
* @brief Constructor

View File

@ -1,38 +1,28 @@
#include "CspCookie.h"
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_, uint32_t timeoutMs)
: maxReplyLength(maxReplyLength_), cspAddress(cspAddress_), timeoutMs(timeoutMs),
: maxReplyLength(maxReplyLength_),
cspAddress(cspAddress_),
timeoutMs(timeoutMs),
reqType(GOMSPACE::DEFAULT_COM_IF) {}
CspCookie::~CspCookie() {}
uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; }
uint8_t CspCookie::getCspAddress() {
return cspAddress;
}
uint8_t CspCookie::getCspAddress() { return cspAddress; }
GOMSPACE::SpecialRequestTypes CspCookie::getRequest() const {
return reqType;
}
GOMSPACE::SpecialRequestTypes CspCookie::getRequest() const { return reqType; }
void CspCookie::setRequest(GOMSPACE::SpecialRequestTypes request, size_t replyLen_) {
reqType = request;
replyLen = replyLen_;
}
uint8_t CspCookie::getCspPort() const {
return cspPort;
}
uint8_t CspCookie::getCspPort() const { return cspPort; }
uint32_t CspCookie::getTimeout() const {
return timeoutMs;
}
uint32_t CspCookie::getTimeout() const { return timeoutMs; }
void CspCookie::setCspPort(uint8_t port) {
cspPort = port;
}
void CspCookie::setCspPort(uint8_t port) { cspPort = port; }
size_t CspCookie::getReplyLen() const {
return replyLen;
}
size_t CspCookie::getReplyLen() const { return replyLen; }

View File

@ -2,9 +2,11 @@
#define LINUX_CSP_CSPCOOKIE_H_
#include <fsfw/devicehandlers/CookieIF.h>
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
#include <cstdint>
#include <cstddef>
#include <cstdint>
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
/**
* @brief This is the cookie for devices supporting the CSP (CubeSat Space
@ -13,7 +15,6 @@
*/
class CspCookie : public CookieIF {
public:
CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_, uint32_t timeoutMs);
virtual ~CspCookie();

View File

@ -1,14 +1,17 @@
#include "ACUHandler.h"
#include "OBSWConfig.h"
#include "p60acu_hk.h"
#include "OBSWConfig.h"
ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, ACU::MAX_CONFIGTABLE_ADDRESS,
ACU::MAX_HKTABLE_ADDRESS, P60ACU_HK_SIZE),
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
coreHk(this),
auxHk(this) {}
auxHk(this) {
cfg.maxConfigTableAddress = ACU::MAX_CONFIGTABLE_ADDRESS;
cfg.maxHkTableAddress = ACU::MAX_HKTABLE_ADDRESS;
cfg.hkTableSize = ACU::HK_TABLE_SIZE;
cfg.cfgTableSize = ACU::CONFIG_TABLE_SIZE;
}
ACUHandler::~ACUHandler() {}
@ -60,32 +63,32 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) {
return res1;
}
for (size_t idx = 0; idx < 6; idx++) {
coreHk.currentInChannels[idx] = as<int16_t>(packet + (idx*2));
coreHk.currentInChannels[idx] = as<int16_t>(packet + (idx * 2));
}
for (size_t idx = 0; idx < 6; idx++) {
coreHk.voltageInChannels[idx] = as<uint16_t>(packet + 0xc + (idx*2));
coreHk.voltageInChannels[idx] = as<uint16_t>(packet + 0xc + (idx * 2));
}
coreHk.vcc = as<uint16_t>(packet + 0x1a);
coreHk.vbat = as<uint16_t>(packet + 0x18);
for (size_t idx = 0; idx < 3; idx++) {
coreHk.temperatures[idx] = as<int16_t>(packet + 0x1c + (idx*2)) * 0.1;
coreHk.temperatures[idx] = as<int16_t>(packet + 0x1c + (idx * 2)) * 0.1;
}
coreHk.mpptMode = packet[0x22];
for (size_t idx = 0; idx < 6; idx++) {
coreHk.vboostInChannels[idx] = as<uint16_t>(packet + 0x24 + (idx*2));
coreHk.vboostInChannels[idx] = as<uint16_t>(packet + 0x24 + (idx * 2));
}
for (size_t idx = 0; idx < 6; idx++) {
coreHk.powerInChannels[idx] = as<uint16_t>(packet + 0x30 + (idx*2));
coreHk.powerInChannels[idx] = as<uint16_t>(packet + 0x30 + (idx * 2));
}
for (size_t idx = 0; idx < 3; idx++) {
auxHk.dacEnables[idx] = *(packet + 0x3c + idx);
}
for (size_t idx = 0; idx < 6; idx++) {
auxHk.dacRawChannelVals[idx] = as<uint16_t>(packet + 0x40 + (idx*2));
auxHk.dacRawChannelVals[idx] = as<uint16_t>(packet + 0x40 + (idx * 2));
}
auxHk.bootCause = as<uint32_t>(packet + 0x50);

View File

@ -38,6 +38,7 @@ class ACUHandler : public GomspaceDeviceHandler {
private:
ACU::CoreHk coreHk;
ACU::AuxHk auxHk;
TableConfig cfg;
bool debugMode = false;
/**

View File

@ -4,25 +4,29 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <cassert>
#include "devicedefinitions/GomSpacePackets.h"
#include "devicedefinitions/powerDefinitions.h"
#include <cassert>
using namespace GOMSPACE;
GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
CookieIF* comCookie, FailureIsolationBase* customFdir,
uint16_t maxConfigTableAddress,
uint16_t maxHkTableAddress, uint16_t hkTableReplySize)
: DeviceHandlerBase(objectId, comIF, comCookie, customFdir),
maxConfigTableAddress(maxConfigTableAddress),
maxHkTableAddress(maxHkTableAddress),
hkTableReplySize(hkTableReplySize) {
CookieIF* comCookie, TableConfig& tableConfig,
FailureIsolationBase* customFdir)
: DeviceHandlerBase(objectId, comIF, comCookie, customFdir), tableCfg(tableConfig) {
if (comCookie == nullptr) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl;
}
}
void GomspaceDeviceHandler::initPduConfigTable() {
tableCfg.maxConfigTableAddress = PDU::MAX_CONFIGTABLE_ADDRESS;
tableCfg.maxHkTableAddress = PDU::MAX_HKTABLE_ADDRESS;
tableCfg.hkTableSize = PDU::HK_TABLE_SIZE;
tableCfg.cfgTableSize = PDU::CONFIG_TABLE_SIZE;
}
GomspaceDeviceHandler::~GomspaceDeviceHandler() {}
void GomspaceDeviceHandler::doStartUp() {}
@ -81,23 +85,28 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
}
case (GOMSPACE::REQUEST_HK_TABLE): {
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF;
if(getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
reqType = SpecialRequestTypes::GET_PDU_HK;
} else if(getObjectId() == objects::ACU_HANDLER) {
} else if (getObjectId() == objects::ACU_HANDLER) {
reqType = SpecialRequestTypes::GET_ACU_HK;
} else if(getObjectId() == objects::P60DOCK_HANDLER) {
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
reqType = SpecialRequestTypes::GET_P60DOCK_HK;
}
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::HK, hkTableReplySize);
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::HK, tableCfg.hkTableSize);
if (result != returnvalue::OK) {
return result;
}
break;
}
case (GOMSPACE::REQUEST_CONFIG_TABLE): {
result = generateRequestFullTableCmd(SpecialRequestTypes::DEFAULT_COM_IF,
GOMSPACE::TableIds::CONFIG, configTableReplySize);
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF;
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
reqType = SpecialRequestTypes::GET_PDU_CONFIG;
} else {
reqType = SpecialRequestTypes::DEFAULT_COM_IF;
}
result =
generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::CONFIG, tableCfg.cfgTableSize);
if (result != returnvalue::OK) {
return result;
}
@ -230,7 +239,7 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm
}
/* Get and check address */
uint16_t address = setParamCacher.getAddress();
if (address > maxConfigTableAddress) {
if (address > tableCfg.maxConfigTableAddress) {
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
<< "action" << std::endl;
return INVALID_ADDRESS;
@ -288,12 +297,12 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
}
/* Get and check address */
uint16_t address = getParamMessage.getAddress();
if (address > maxHkTableAddress and tableId == TableIds::HK) {
if (address > tableCfg.maxHkTableAddress and tableId == TableIds::HK) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "housekeeping table" << std::endl;
return INVALID_ADDRESS;
}
if (address > maxConfigTableAddress and tableId == TableIds::CONFIG) {
if (address > tableCfg.maxConfigTableAddress and tableId == TableIds::CONFIG) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "configuration table" << std::endl;
return INVALID_ADDRESS;
@ -438,30 +447,16 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullTableCmd(SpecialRequestTypes reqType,
uint8_t tableId,
uint8_t tableId,
uint16_t tableReplySize) {
uint16_t querySize = tableReplySize;
if(reqType != SpecialRequestTypes::DEFAULT_COM_IF) {
auto* cspCookie = dynamic_cast<CspCookie*>(comCookie);
cspCookie->setRequest(reqType, tableReplySize);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
} else {
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
ReturnValue_t result = requestFullTableCommand.serialize(
&buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler::generateRequestFullTableCmd Failed to serialize "
"full table request command "
<< std::endl;
return result;
}
rawPacket = cspPacket;
rawPacketLen = cspPacketLen;
if (reqType == SpecialRequestTypes::DEFAULT_COM_IF) {
sif::warning << "Default communication for table requests not implemented anymore" << std::endl;
return returnvalue::FAILED;
}
auto* cspCookie = dynamic_cast<CspCookie*>(comCookie);
cspCookie->setRequest(reqType, tableReplySize);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
rememberRequestedSize = querySize;
rememberCommandId = GOMSPACE::REQUEST_HK_TABLE;
return returnvalue::OK;
@ -480,19 +475,18 @@ ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU
const uint8_t* packet) {
PoolReadGuard pg0(&coreHk);
PoolReadGuard pg1(&auxHk);
if (pg0.getReadResult() != returnvalue::OK or
pg1.getReadResult() != returnvalue::OK) {
if (pg0.getReadResult() != returnvalue::OK or pg1.getReadResult() != returnvalue::OK) {
sif::warning << "Reading PDU1 datasets failed!" << std::endl;
return returnvalue::FAILED;
}
/* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table
* address. */
//dataOffset += 12;
// dataOffset += 12;
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
coreHk.currents[idx] = as<int16_t>(packet + (idx * 2));
}
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
coreHk.voltages[idx] = as<uint16_t>(packet + 0x12 + (idx*2));
coreHk.voltages[idx] = as<uint16_t>(packet + 0x12 + (idx * 2));
}
auxHk.vcc.value = as<int16_t>(packet + 0x24);
auxHk.vbat.value = as<int16_t>(packet + 0x26);
@ -512,7 +506,7 @@ ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU
coreHk.battMode = *(packet + 0x46);
for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) {
auxHk.latchups[idx] = as<uint16_t>(packet + 0x48 + (idx*2));
auxHk.latchups[idx] = as<uint16_t>(packet + 0x48 + (idx * 2));
}
for (uint8_t idx = 0; idx < PDU::DEVICES_NUM; idx++) {

View File

@ -8,6 +8,12 @@
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
#include "returnvalues/classIds.h"
struct TableConfig {
uint16_t maxConfigTableAddress;
uint16_t maxHkTableAddress;
uint16_t hkTableSize;
uint16_t cfgTableSize;
};
/**
* @brief This is the device handler class for all gomspace devices.
*
@ -39,8 +45,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* device.
*/
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir, uint16_t maxConfigTableAddress,
uint16_t maxHkTableAddress, uint16_t hkTableReplySize);
TableConfig &tableConfig, FailureIsolationBase *customFdir);
virtual ~GomspaceDeviceHandler();
/**
@ -58,15 +63,9 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
uint8_t rememberCommandId = GOMSPACE::NONE;
uint8_t cspPacket[MAX_PACKET_LEN];
uint16_t maxConfigTableAddress;
uint16_t maxHkTableAddress;
/** The size of the reply following a full hk table request.*/
uint16_t hkTableReplySize;
uint16_t configTableReplySize;
LocalPoolDataSetBase *hkTableDataset = nullptr;
void initPduConfigTable();
void doStartUp() override;
void doShutDown() override;
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
@ -83,7 +82,8 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullTableCmd(GOMSPACE::SpecialRequestTypes reqType, uint8_t tableId, uint16_t tableSize);
virtual ReturnValue_t generateRequestFullTableCmd(GOMSPACE::SpecialRequestTypes reqType,
uint8_t tableId, uint16_t tableSize);
/**
* This command handles printing the HK table to the console. This is useful for debugging
@ -116,11 +116,13 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
LocalDataPoolManager &poolManager,
std::array<uint8_t, PDU::CHANNELS_LEN> initOutEnb);
template<typename T> T as(const uint8_t*);
template <typename T>
T as(const uint8_t *);
static bool validTableId(uint8_t id);
private:
SetParamMessageUnpacker setParamCacher;
TableConfig &tableCfg;
/**
* @brief Function to generate the command to set a parameter. Command
* will be sent to the ComIF over the rawPacket buffer.
@ -162,9 +164,9 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
ReturnValue_t generateResetWatchdogCmd();
};
template<typename T>
inline T GomspaceDeviceHandler::as(const uint8_t* ptr) {
return *(reinterpret_cast<const T*>(ptr));
template <typename T>
inline T GomspaceDeviceHandler::as(const uint8_t *ptr) {
return *(reinterpret_cast<const T *>(ptr));
}
#endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */

View File

@ -3,15 +3,17 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include "OBSWConfig.h"
#include "p60dock_hk.h"
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir,
P60Dock::MAX_CONFIGTABLE_ADDRESS, P60Dock::MAX_HKTABLE_ADDRESS,
P60DOCK_HK_SIZE),
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
coreHk(this),
auxHk(this) {}
auxHk(this) {
cfg.maxConfigTableAddress = P60Dock::MAX_CONFIGTABLE_ADDRESS;
cfg.maxHkTableAddress = P60Dock::MAX_HKTABLE_ADDRESS;
cfg.hkTableSize = P60Dock::HK_TABLE_SIZE;
cfg.cfgTableSize = P60Dock::CONFIG_TABLE_SIZE;
}
P60DockHandler::~P60DockHandler() {}
@ -33,8 +35,7 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
using namespace P60Dock;
PoolReadGuard pg0(&coreHk);
PoolReadGuard pg1(&auxHk);
if (pg0.getReadResult() != returnvalue::OK or
pg1.getReadResult() != returnvalue::OK) {
if (pg0.getReadResult() != returnvalue::OK or pg1.getReadResult() != returnvalue::OK) {
coreHk.setValidity(false, true);
auxHk.setValidity(false, true);
return;
@ -44,10 +45,10 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
* address.
*/
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
coreHk.currents[idx] = as<int16_t>(packet + (idx*2));
coreHk.currents[idx] = as<int16_t>(packet + (idx * 2));
}
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
coreHk.voltages[idx] = as<uint16_t>(packet + 0x1a + (idx*2));
coreHk.voltages[idx] = as<uint16_t>(packet + 0x1a + (idx * 2));
}
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
coreHk.outputEnables[idx] = *(packet + 0x34 + idx);
@ -75,7 +76,7 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
auxHk.converter5VStatus = *(packet + 0x58);
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
auxHk.latchups[idx] = as<uint16_t>(packet + 0x5a + (idx*2));
auxHk.latchups[idx] = as<uint16_t>(packet + 0x5a + (idx * 2));
}
auxHk.dockVbatVoltageValue = as<uint16_t>(packet + 0x74);
@ -183,8 +184,7 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) {
case (GOMSPACE::PRINT_SWITCH_V_I): {
PoolReadGuard pg0(&coreHk);
PoolReadGuard pg1(&auxHk);
if (pg0.getReadResult() != returnvalue::OK or
pg1.getReadResult() != returnvalue::OK) {
if (pg0.getReadResult() != returnvalue::OK or pg1.getReadResult() != returnvalue::OK) {
break;
}
printHkTableSwitchIV();

View File

@ -52,6 +52,7 @@ class P60DockHandler : public GomspaceDeviceHandler {
private:
P60Dock::CoreHkSet coreHk;
P60Dock::HkTableDataset auxHk;
TableConfig cfg;
bool firstHk = true;
bool debugMode = false;
static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 16;

View File

@ -2,16 +2,16 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <p60pdu_hk.h>
#include "devices/powerSwitcherList.h"
PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS,
PDU::MAX_HKTABLE_ADDRESS, P60PDU_HK_SIZE),
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
coreHk(this),
auxHk(this) {}
auxHk(this) {
initPduConfigTable();
}
PDU1Handler::~PDU1Handler() {}

View File

@ -46,6 +46,7 @@ class PDU1Handler : public GomspaceDeviceHandler {
/** Dataset for the housekeeping table of the PDU1 */
PDU1::Pdu1CoreHk coreHk;
PDU1::Pdu1AuxHk auxHk;
TableConfig cfg;
GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr;
void* hookArgs = nullptr;

View File

@ -2,16 +2,16 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
#include <p60pdu_hk.h>
#include "devices/powerSwitcherList.h"
PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
FailureIsolationBase *customFdir)
: GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS,
PDU::MAX_HKTABLE_ADDRESS, P60PDU_HK_SIZE),
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
coreHk(this),
auxHk(this) {}
auxHk(this) {
initPduConfigTable();
}
PDU2Handler::~PDU2Handler() {}

View File

@ -45,6 +45,7 @@ class PDU2Handler : public GomspaceDeviceHandler {
/** Dataset for the housekeeping table of the PDU2 */
PDU2::Pdu2CoreHk coreHk;
PDU2::Pdu2AuxHk auxHk;
TableConfig cfg;
GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr;
void* hookArgs = nullptr;

View File

@ -9,6 +9,12 @@
#include <cstdint>
#include "devices/powerSwitcherList.h"
#include "p60acu_hk.h"
#include "p60acu_param.h"
#include "p60dock_hk.h"
#include "p60dock_param.h"
#include "p60pdu_hk.h"
#include "p60pdu_param.h"
namespace GOMSPACE {
@ -22,7 +28,7 @@ enum SpecialRequestTypes {
GET_P60DOCK_CONFIG
};
enum CspPorts: uint8_t {
enum CspPorts : uint8_t {
CSP_PING = 1,
CSP_REBOOT = 4,
P60_PORT_RPARAM_ENUM = 7,
@ -234,24 +240,16 @@ enum SwitchChannels : uint8_t {
GS5V = 12
};
/** Max reply size reached when requesting full hk table */
static const uint16_t MAX_REPLY_LENGTH = 407;
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408;
static const uint16_t MAX_HKTABLE_ADDRESS = 187;
// Sources:
// GomSpace library lib/p60-dock_client/include/gs/p60-dock/param
static const uint16_t HK_TABLE_SIZE = 188;
static const uint16_t HK_TABLE_SIZE = P60DOCK_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = P60DOCK_PARAM_SIZE;
static const size_t MAX_REPLY_SIZE = CONFIG_TABLE_SIZE;
static const uint16_t CAL_TABLE = 0xAE;
static const uint16_t CONFIG_TABLE_SIZE = 0x19C;
static const uint8_t HK_TABLE_ENTRIES = 100;
/**
* Requesting the full housekeeping table from the P60 dock will generate a reply comprising
* 402 bytes of data.
*/
static const uint16_t HK_TABLE_REPLY_SIZE = 407;
class CoreHkSet : public StaticLocalDataSet<16> {
public:
CoreHkSet(HasLocalDataPoolIF* owner)
@ -377,12 +375,14 @@ class HkTableDataset : public StaticLocalDataSet<32> {
* @brief Constants common for both PDU1 and PDU2.
*/
namespace PDU {
/** When retrieving full configuration parameter table */
static const uint16_t MAX_REPLY_LENGTH = 318;
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316;
static const uint16_t MAX_HKTABLE_ADDRESS = 141;
/** The size of the csp reply containing the housekeeping table data */
static const uint16_t HK_TABLE_REPLY_SIZE = 303;
static const uint16_t HK_TABLE_SIZE = P60PDU_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = P60PDU_PARAM_SIZE;
/** When retrieving full configuration parameter table */
static const uint16_t MAX_REPLY_SIZE = CONFIG_TABLE_SIZE;
static const uint8_t HK_TABLE_ENTRIES = 73;
static constexpr uint8_t CHANNELS_LEN = 9;
@ -482,13 +482,6 @@ class PduAuxHk : public StaticLocalDataSet<36> {
lp_var_t<uint8_t> csp1WatchdogPingsLeft =
lp_var_t<uint8_t>(sid.objectId, P60System::pool::PDU_WDT_CSP_LEFT2, this);
};
//class HkWrapper {
//public:
// HkWrapper(PduCoreHk& coreHk, PduAuxHk& auxHk) {
//
// }
//};
} // namespace PDU
namespace PDU1 {
@ -591,12 +584,12 @@ class Pdu2AuxHk : public ::PDU::PduAuxHk {
namespace ACU {
/* When receiving full housekeeping (telemetry) table */
static const uint16_t MAX_REPLY_LENGTH = 262;
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 26;
static const uint16_t MAX_HKTABLE_ADDRESS = 120;
static const uint8_t HK_TABLE_ENTRIES = 64;
static const uint16_t HK_TABLE_REPLY_SIZE = 262;
static const uint16_t HK_TABLE_SIZE = P60ACU_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = P60ACU_PARAM_SIZE;
static const size_t MAX_REPLY_SIZE = HK_TABLE_SIZE;
class CoreHk : public StaticLocalDataSet<14> {
public: