this does not make sense
Some checks failed
EIVE/eive-obsw/pipeline/pr-v2.1.0-dev There was a failure building this commit

This commit is contained in:
Robin Müller 2023-05-15 15:15:58 +02:00
parent 178a2183a2
commit 17df79b0d6
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
8 changed files with 243 additions and 228 deletions

View File

@ -10,10 +10,10 @@
#include <linux/com/SyrlinksComHandler.h> #include <linux/com/SyrlinksComHandler.h>
#include <linux/payload/PlocMemoryDumper.h> #include <linux/payload/PlocMemoryDumper.h>
#include <linux/payload/PlocMpsocHandler.h> #include <linux/payload/PlocMpsocHandler.h>
#include <linux/payload/PlocMpsocHelper.h> #include <linux/payload/PlocMpsocSpecialComHelper.h>
#include <linux/payload/PlocSupervisorHandler.h> #include <linux/payload/PlocSupervisorHandler.h>
#include <linux/payload/ScexUartReader.h> #include <linux/payload/ScexUartReader.h>
#include <linux/payload/plocMpscoDefs.h> #include <linux/payload/plocMpsocHelpers.h>
#include <linux/power/CspComIF.h> #include <linux/power/CspComIF.h>
#include <mission/acs/GyrL3gCustomHandler.h> #include <mission/acs/GyrL3gCustomHandler.h>
#include <mission/acs/MgmLis3CustomHandler.h> #include <mission/acs/MgmLis3CustomHandler.h>
@ -623,8 +623,8 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit
new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
serial::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); serial::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL);
mpsocCookie->setNoFixedSizeReply(); mpsocCookie->setNoFixedSizeReply();
auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER);
auto* mpsocHandler = new PlocMPSoCHandler( auto* mpsocHandler = new PlocMpsocHandler(
objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper, objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper,
Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), objects::PLOC_SUPERVISOR_HANDLER); Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), objects::PLOC_SUPERVISOR_HANDLER);
mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);

View File

@ -2,7 +2,8 @@ target_sources(
${OBSW_NAME} ${OBSW_NAME}
PUBLIC PlocMemoryDumper.cpp PUBLIC PlocMemoryDumper.cpp
PlocMpsocHandler.cpp PlocMpsocHandler.cpp
PlocMpsocHelper.cpp PlocMpsocSpecialComHelper.cpp
plocMpsocHelpers.cpp
PlocSupervisorHandler.cpp PlocSupervisorHandler.cpp
PlocSupvUartMan.cpp PlocSupvUartMan.cpp
ScexDleParser.cpp ScexDleParser.cpp

View File

@ -8,8 +8,8 @@
#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/datapool/PoolReadGuard.h"
#include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/CRC.h"
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, CookieIF* comCookie, PlocMpsocSpecialComHelper* plocMPSoCHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler) Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
: DeviceHandlerBase(objectId, uartComIFid, comCookie), : DeviceHandlerBase(objectId, uartComIFid, comCookie),
hkReport(this), hkReport(this),
@ -27,9 +27,9 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
} }
PlocMPSoCHandler::~PlocMPSoCHandler() {} PlocMpsocHandler::~PlocMpsocHandler() {}
ReturnValue_t PlocMPSoCHandler::initialize() { ReturnValue_t PlocMpsocHandler::initialize() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = DeviceHandlerBase::initialize(); result = DeviceHandlerBase::initialize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -54,8 +54,8 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
return result; return result;
} }
result = manager->subscribeToEventRange( result = manager->subscribeToEventRange(
eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED), eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED),
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from " sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
@ -78,7 +78,7 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
return result; return result;
} }
void PlocMPSoCHandler::performOperationHook() { void PlocMpsocHandler::performOperationHook() {
if (commandIsPending and cmdCountdown.hasTimedOut()) { if (commandIsPending and cmdCountdown.hasTimedOut()) {
commandIsPending = false; commandIsPending = false;
// TODO: Better returnvalue? // TODO: Better returnvalue?
@ -107,7 +107,7 @@ void PlocMPSoCHandler::performOperationHook() {
} }
} }
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) { const uint8_t* data, size_t size) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
switch (actionId) { switch (actionId) {
@ -176,7 +176,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
} }
void PlocMPSoCHandler::doStartUp() { void PlocMpsocHandler::doStartUp() {
if (startupState == StartupState::IDLE) { if (startupState == StartupState::IDLE) {
startupState = StartupState::HW_INIT; startupState = StartupState::HW_INIT;
} }
@ -220,7 +220,7 @@ void PlocMPSoCHandler::doStartUp() {
} }
} }
void PlocMPSoCHandler::doShutDown() { void PlocMpsocHandler::doShutDown() {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#if not OBSW_MPSOC_JTAG_BOOT == 1 #if not OBSW_MPSOC_JTAG_BOOT == 1
switch (powerState) { switch (powerState) {
@ -248,7 +248,7 @@ void PlocMPSoCHandler::doShutDown() {
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
} }
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (not commandIsPending and not plocMPSoCHelperExecuting) { if (not commandIsPending and not plocMPSoCHelperExecuting) {
*id = mpsoc::TC_GET_HK_REPORT; *id = mpsoc::TC_GET_HK_REPORT;
commandIsPending = true; commandIsPending = true;
@ -258,11 +258,11 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id)
return NOTHING_TO_SEND; return NOTHING_TO_SEND;
} }
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PlocMpsocHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return NOTHING_TO_SEND; return NOTHING_TO_SEND;
} }
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, ReturnValue_t PlocMpsocHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData, const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
@ -353,7 +353,7 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
return result; return result;
} }
void PlocMPSoCHandler::fillCommandAndReplyMap() { void PlocMpsocHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(mpsoc::TC_MEM_WRITE); this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
this->insertInCommandMap(mpsoc::TC_MEM_READ); this->insertInCommandMap(mpsoc::TC_MEM_READ);
this->insertInCommandMap(mpsoc::TC_FLASHDELETE); this->insertInCommandMap(mpsoc::TC_FLASHDELETE);
@ -383,7 +383,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE); this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE);
} }
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, ReturnValue_t PlocMpsocHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) { DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@ -454,7 +454,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t PlocMpsocHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
switch (id) { switch (id) {
@ -499,14 +499,14 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
return result; return result;
} }
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { void PlocMpsocHandler::setNormalDatapoolEntriesInvalid() {
PoolReadGuard pg(&hkReport); PoolReadGuard pg(&hkReport);
hkReport.setValidity(false, true); hkReport.setValidity(false, true);
} }
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } uint32_t PlocMpsocHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t PlocMpsocHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus);
localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode);
@ -547,7 +547,7 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) { void PlocMpsocHandler::handleEvent(EventMessage* eventMessage) {
object_id_t objectId = eventMessage->getReporter(); object_id_t objectId = eventMessage->getReporter();
switch (objectId) { switch (objectId) {
case objects::PLOC_MPSOC_HELPER: { case objects::PLOC_MPSOC_HELPER: {
@ -560,7 +560,7 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
} }
} }
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount); mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
@ -572,7 +572,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount); mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
@ -585,7 +585,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return MPSoCReturnValuesIF::NAME_TOO_LONG; return MPSoCReturnValuesIF::NAME_TOO_LONG;
@ -601,7 +601,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount); mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
@ -613,7 +613,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() { ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount); mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
result = tcReplayStop.buildPacket(); result = tcReplayStop.buildPacket();
@ -624,7 +624,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount); mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
@ -636,7 +636,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount); mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
result = tcDownlinkPwrOff.buildPacket(); result = tcDownlinkPwrOff.buildPacket();
@ -647,7 +647,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() {
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
ReturnValue_t result = tcGetHkReport.buildPacket(); ReturnValue_t result = tcGetHkReport.buildPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -657,7 +657,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount); mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
@ -669,7 +669,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() { ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount); mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
result = tcModeReplay.buildPacket(); result = tcModeReplay.buildPacket();
@ -680,7 +680,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() { ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount); mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
result = tcModeIdle.buildPacket(); result = tcModeIdle.buildPacket();
@ -691,7 +691,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount); mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
@ -704,7 +704,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen);
@ -715,7 +715,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
@ -726,7 +726,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen);
@ -737,7 +737,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandDat
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
@ -748,7 +748,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() {
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
ReturnValue_t result = tcModeSnapshot.buildPacket(); ReturnValue_t result = tcModeSnapshot.buildPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -758,21 +758,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() {
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHandler::finishTcPrep(size_t packetLen) { void PlocMpsocHandler::finishTcPrep(size_t packetLen) {
nextReplyId = mpsoc::ACK_REPORT; nextReplyId = mpsoc::ACK_REPORT;
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = packetLen; rawPacketLen = packetLen;
sequenceCount++; sequenceCount++;
} }
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
if (CRC::crc16ccitt(start, foundLen) != 0) { if (CRC::crc16ccitt(start, foundLen) != 0) {
return MPSoCReturnValuesIF::CRC_FAILURE; return MPSoCReturnValuesIF::CRC_FAILURE;
} }
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT); result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
@ -792,7 +792,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
case mpsoc::apid::ACK_FAILURE: { case mpsoc::apid::ACK_FAILURE: {
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
DeviceCommandId_t commandId = getPendingCommand(); DeviceCommandId_t commandId = getPendingCommand();
uint16_t status = getStatus(data); uint16_t status = mpsoc::getStatusFromRawData(data);
sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl;
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId, status); triggerEvent(ACK_FAILURE, commandId, status);
@ -817,7 +817,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT); result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
@ -842,7 +842,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
if (commandId == DeviceHandlerIF::NO_COMMAND_ID) { if (commandId == DeviceHandlerIF::NO_COMMAND_ID) {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
} }
uint16_t status = getStatus(data); uint16_t status = mpsoc::getStatusFromRawData(data);
sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(EXE_FAILURE, commandId, status); triggerEvent(EXE_FAILURE, commandId, status);
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
@ -860,7 +860,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { ReturnValue_t PlocMpsocHandler::handleMemoryReadReport(const uint8_t* data) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize); result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) { if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
@ -876,7 +876,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { ReturnValue_t PlocMpsocHandler::handleGetHkReport(const uint8_t* data) {
ReturnValue_t result = verifyPacket(data, foundPacketLen); ReturnValue_t result = verifyPacket(data, foundPacketLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -1054,7 +1054,7 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t PlocMpsocHandler::handleCamCmdRpt(const uint8_t* data) {
ReturnValue_t result = verifyPacket(data, foundPacketLen); ReturnValue_t result = verifyPacket(data, foundPacketLen);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) { if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
@ -1074,7 +1074,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, ReturnValue_t PlocMpsocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies, bool useAlternateId, uint8_t expectedReplies, bool useAlternateId,
DeviceCommandId_t alternateReplyID) { DeviceCommandId_t alternateReplyID) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@ -1190,7 +1190,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHandler::setNextReplyId() { void PlocMpsocHandler::setNextReplyId() {
switch (getPendingCommand()) { switch (getPendingCommand()) {
case mpsoc::TC_MEM_READ: case mpsoc::TC_MEM_READ:
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
@ -1210,7 +1210,7 @@ void PlocMPSoCHandler::setNextReplyId() {
} }
} }
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t PlocMpsocHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0; size_t replyLen = 0;
if (nextReplyId == mpsoc::NONE) { if (nextReplyId == mpsoc::NONE) {
@ -1251,7 +1251,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
return replyLen; return replyLen;
} }
ReturnValue_t PlocMPSoCHandler::doSendReadHook() { ReturnValue_t PlocMpsocHandler::doSendReadHook() {
// Prevent DHB from polling UART during commands executed by the mpsoc helper task // Prevent DHB from polling UART during commands executed by the mpsoc helper task
if (plocMPSoCHelperExecuting) { if (plocMPSoCHelperExecuting) {
return returnvalue::FAILED; return returnvalue::FAILED;
@ -1259,11 +1259,11 @@ ReturnValue_t PlocMPSoCHandler::doSendReadHook() {
return returnvalue::OK; return returnvalue::OK;
} }
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; } MessageQueueIF* PlocMpsocHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; } void PlocMpsocHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, void PlocMpsocHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
ReturnValue_t returnCode) { ReturnValue_t returnCode) {
switch (actionId) { switch (actionId) {
case supv::START_MPSOC: { case supv::START_MPSOC: {
@ -1286,11 +1286,11 @@ void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
} }
} }
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
return; return;
} }
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) {
if (actionId != supv::EXE_REPORT) { if (actionId != supv::EXE_REPORT) {
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
<< "ID" << std::endl; << "ID" << std::endl;
@ -1311,11 +1311,11 @@ void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
} }
} }
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { void PlocMpsocHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
handleActionCommandFailure(actionId); handleActionCommandFailure(actionId);
} }
void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, void PlocMpsocHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
DeviceCommandId_t replyId) { DeviceCommandId_t replyId) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@ -1341,7 +1341,7 @@ void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
} }
} }
void PlocMPSoCHandler::disableAllReplies() { void PlocMpsocHandler::disableAllReplies() {
using namespace mpsoc; using namespace mpsoc;
DeviceReplyMap::iterator iter; DeviceReplyMap::iterator iter;
@ -1404,7 +1404,7 @@ void PlocMPSoCHandler::disableAllReplies() {
nextReplyId = mpsoc::NONE; nextReplyId = mpsoc::NONE;
} }
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { void PlocMpsocHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId); DeviceReplyIter iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) { if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
@ -1421,7 +1421,7 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_
info->isExecuting = false; info->isExecuting = false;
} }
void PlocMPSoCHandler::disableExeReportReply() { void PlocMpsocHandler::disableExeReportReply() {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
DeviceReplyInfo* info = &(iter->second); DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0; info->delayCycles = 0;
@ -1430,11 +1430,7 @@ void PlocMPSoCHandler::disableExeReportReply() {
info->command->second.expectedReplies = 0; info->command->second.expectedReplies = 0;
} }
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) {
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
}
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
switch (actionId) { switch (actionId) {
case supv::ACK_REPORT: case supv::ACK_REPORT:
case supv::EXE_REPORT: case supv::EXE_REPORT:
@ -1467,20 +1463,20 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
return; return;
} }
LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) { LocalPoolDataSetBase* PlocMpsocHandler::getDataSetHandle(sid_t sid) {
if (sid == hkReport.getSid()) { if (sid == hkReport.getSid()) {
return &hkReport; return &hkReport;
} }
return nullptr; return nullptr;
} }
bool PlocMPSoCHandler::dontCheckQueue() { bool PlocMpsocHandler::dontCheckQueue() {
// The TC and TMs need to be handled strictly sequentially, so while a command is pending, // The TC and TMs need to be handled strictly sequentially, so while a command is pending,
// more specifically while replies are still expected, do not check the queue.s // more specifically while replies are still expected, do not check the queue.s
return commandIsPending; return commandIsPending;
} }
void PlocMPSoCHandler::cmdDoneHandler(bool success, ReturnValue_t result) { void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
commandIsPending = false; commandIsPending = false;
auto commandIter = deviceCommandMap.find(getPendingCommand()); auto commandIter = deviceCommandMap.find(getPendingCommand());
if (commandIter != deviceCommandMap.end()) { if (commandIter != deviceCommandMap.end()) {

View File

@ -1,9 +1,9 @@
#ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ #ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
#define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ #define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
#include <linux/payload/PlocMpsocHelper.h> #include <linux/payload/PlocMpsocSpecialComHelper.h>
#include <linux/payload/mpsocRetvals.h> #include <linux/payload/mpsocRetvals.h>
#include <linux/payload/plocMpscoDefs.h> #include <linux/payload/plocMpsocHelpers.h>
#include <linux/payload/plocSupvDefs.h> #include <linux/payload/plocSupvDefs.h>
#include <string> #include <string>
@ -31,7 +31,7 @@
* NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER. * NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER.
* @author J. Meier, R. Mueller * @author J. Meier, R. Mueller
*/ */
class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -44,10 +44,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
* module in the programmable logic * module in the programmable logic
* @param supervisorHandler Object ID of the supervisor handler * @param supervisorHandler Object ID of the supervisor handler
*/ */
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch,
object_id_t supervisorHandler); object_id_t supervisorHandler);
virtual ~PlocMPSoCHandler(); virtual ~PlocMpsocHandler();
virtual ReturnValue_t initialize() override; virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override; const uint8_t* data, size_t size) override;
@ -106,7 +106,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
static const uint16_t APID_MASK = 0x7FF; static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const uint8_t STATUS_OFFSET = 10;
mpsoc::HkReport hkReport; mpsoc::HkReport hkReport;
@ -163,7 +162,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
SerialComIF* uartComIf = nullptr; SerialComIF* uartComIf = nullptr;
PlocMPSoCHelper* plocMPSoCHelper = nullptr; PlocMpsocSpecialComHelper* plocMPSoCHelper = nullptr;
Gpio uartIsolatorSwitch; Gpio uartIsolatorSwitch;
object_id_t supervisorHandler = 0; object_id_t supervisorHandler = 0;
CommandActionHelper commandActionHelper; CommandActionHelper commandActionHelper;
@ -299,8 +298,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcModeReplay(); ReturnValue_t prepareTcModeReplay();
uint16_t getStatus(const uint8_t* data);
void cmdDoneHandler(bool success, ReturnValue_t result); void cmdDoneHandler(bool success, ReturnValue_t result);
void handleActionCommandFailure(ActionId_t actionId); void handleActionCommandFailure(ActionId_t actionId);

View File

@ -1,4 +1,4 @@
#include <linux/payload/PlocMpsocHelper.h> #include <linux/payload/PlocMpsocSpecialComHelper.h>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@ -11,14 +11,15 @@
using namespace ploc; using namespace ploc;
PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) { PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId)
: SystemObject(objectId) {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer); spParams.maxSize = sizeof(commandBuffer);
} }
PlocMPSoCHelper::~PlocMPSoCHelper() {} PlocMpsocSpecialComHelper::~PlocMpsocSpecialComHelper() {}
ReturnValue_t PlocMPSoCHelper::initialize() { ReturnValue_t PlocMpsocSpecialComHelper::initialize() {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
sdcMan = SdCardManager::instance(); sdcMan = SdCardManager::instance();
if (sdcMan == nullptr) { if (sdcMan == nullptr) {
@ -29,7 +30,7 @@ ReturnValue_t PlocMPSoCHelper::initialize() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
semaphore.acquire(); semaphore.acquire();
while (true) { while (true) {
@ -69,7 +70,7 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) {
} }
} }
ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { ReturnValue_t PlocMpsocSpecialComHelper::setComIF(DeviceCommunicationIF* communicationInterface_) {
uartComIF = dynamic_cast<SerialComIF*>(communicationInterface_); uartComIF = dynamic_cast<SerialComIF*>(communicationInterface_);
if (uartComIF == nullptr) { if (uartComIF == nullptr) {
sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl; sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl;
@ -78,13 +79,14 @@ ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInte
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } void PlocMpsocSpecialComHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { void PlocMpsocSpecialComHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
sequenceCount = sequenceCount_; sequenceCount = sequenceCount_;
} }
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile,
std::string mpsocFile) {
if (internalState != InternalState::IDLE) { if (internalState != InternalState::IDLE) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -96,8 +98,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
return semaphore.release(); return semaphore.release();
} }
ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, ReturnValue_t PlocMpsocSpecialComHelper::startFlashRead(std::string obcFile, std::string mpsocFile,
size_t readFileSize) { size_t readFileSize) {
if (internalState != InternalState::IDLE) { if (internalState != InternalState::IDLE) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -110,21 +112,21 @@ ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string m
return semaphore.release(); return semaphore.release();
} }
void PlocMPSoCHelper::resetHelper() { void PlocMpsocSpecialComHelper::resetHelper() {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
terminate = false; terminate = false;
uartComIF->flushUartRxBuffer(comCookie); uartComIF->flushUartRxBuffer(comCookie);
} }
void PlocMPSoCHelper::stopProcess() { terminate = true; } void PlocMpsocSpecialComHelper::stopProcess() { terminate = true; }
ReturnValue_t PlocMPSoCHelper::performFlashWrite() { ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary); std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary);
if (file.bad()) { if (file.bad()) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
result = flashfopen(); result = flashfopen(mpsoc::FileAccessMode::WRITE);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -172,7 +174,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
return result; return result;
} }
ReturnValue_t PlocMPSoCHelper::performFlashRead() { ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
sif::debug << "performing flash read" << std::endl; sif::debug << "performing flash read" << std::endl;
std::error_code e; std::error_code e;
std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary);
@ -180,7 +182,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
sif::debug << "Sequence count: " << sequenceCount->get() << std::endl; sif::debug << "Sequence count: " << sequenceCount->get() << std::endl;
ReturnValue_t result = flashfopen(); ReturnValue_t result = flashfopen(mpsoc::FileAccessMode::READ);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
return result; return result;
@ -229,12 +231,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() {
return result; return result;
} }
ReturnValue_t PlocMPSoCHelper::flashfopen() { ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
ReturnValue_t result = ReturnValue_t result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mode);
flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -245,7 +246,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::flashfclose() { ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
@ -256,7 +257,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
return handlePacketTransmissionNoReply(flashFclose); return handlePacketTransmissionNoReply(flashFclose);
} }
ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) {
ReturnValue_t result = sendCommand(tc); ReturnValue_t result = sendCommand(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -273,7 +274,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashR
return handleExe(); return handleExe();
} }
ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) {
ReturnValue_t result = sendCommand(tc); ReturnValue_t result = sendCommand(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -285,7 +286,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& t
return handleExe(); return handleExe();
} }
ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -296,7 +297,7 @@ ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHelper::handleAck() { ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = handleTmReception(mpsoc::SIZE_ACK_REPORT); result = handleTmReception(mpsoc::SIZE_ACK_REPORT);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -309,17 +310,18 @@ ReturnValue_t PlocMPSoCHelper::handleAck() {
} }
uint16_t apid = tmPacket.getApid(); uint16_t apid = tmPacket.getApid();
if (apid != mpsoc::apid::ACK_SUCCESS) { if (apid != mpsoc::apid::ACK_SUCCESS) {
handleAckApidFailure(apid); handleAckApidFailure(tmPacket);
return returnvalue::FAILED; return returnvalue::FAILED;
} }
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) { void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& reader) {
uint16_t apid = reader.getApid();
if (apid == mpsoc::apid::ACK_FAILURE) { if (apid == mpsoc::apid::ACK_FAILURE) {
triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState)); uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData());
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure " sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
<< "report" << std::endl; triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState), status);
} else { } else {
triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report " sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report "
@ -327,7 +329,7 @@ void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
} }
} }
ReturnValue_t PlocMPSoCHelper::handleExe() { ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = handleTmReception(mpsoc::SIZE_EXE_REPORT); result = handleTmReception(mpsoc::SIZE_EXE_REPORT);
@ -341,17 +343,18 @@ ReturnValue_t PlocMPSoCHelper::handleExe() {
} }
uint16_t apid = tmPacket.getApid(); uint16_t apid = tmPacket.getApid();
if (apid != mpsoc::apid::EXE_SUCCESS) { if (apid != mpsoc::apid::EXE_SUCCESS) {
handleExeApidFailure(apid); handleExeApidFailure(tmPacket);
return returnvalue::FAILED; return returnvalue::FAILED;
} }
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) { void PlocMpsocSpecialComHelper::handleExeApidFailure(const ploc::SpTmReader& reader) {
uint16_t apid = reader.getApid();
if (apid == mpsoc::apid::EXE_FAILURE) { if (apid == mpsoc::apid::EXE_FAILURE) {
uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData());
sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure "
<< "report" << std::endl;
} else { } else {
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report " sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report "
@ -359,7 +362,7 @@ void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) {
} }
} }
ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) { ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception(size_t remainingBytes) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
size_t readBytes = 0; size_t readBytes = 0;
size_t currentBytes = 0; size_t currentBytes = 0;
@ -382,7 +385,8 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) {
return result; return result;
} }
ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen) { ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile,
size_t expectedReadLen) {
SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
ReturnValue_t result = checkReceivedTm(tmPacket); ReturnValue_t result = checkReceivedTm(tmPacket);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -422,7 +426,7 @@ ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { ReturnValue_t PlocMpsocSpecialComHelper::fileCheck(std::string obcFile) {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
ReturnValue_t result = FilesystemHelper::checkPath(obcFile); ReturnValue_t result = FilesystemHelper::checkPath(obcFile);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -438,8 +442,8 @@ ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string obcFile,
std::string mpsocFile) { std::string mpsocFile) {
ReturnValue_t result = fileCheck(obcFile); ReturnValue_t result = fileCheck(obcFile);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -451,7 +455,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile,
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) {
ReturnValue_t result = reader.checkSize(); ReturnValue_t result = reader.checkSize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed" sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed"
@ -475,7 +479,8 @@ ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) { ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t* readBytes,
size_t requestBytes) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
uint8_t* buffer = nullptr; uint8_t* buffer = nullptr;
result = uartComIF->requestReceiveMessage(comCookie, requestBytes); result = uartComIF->requestReceiveMessage(comCookie, requestBytes);

View File

@ -1,7 +1,7 @@
#ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ #ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
#define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ #define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
#include <linux/payload/plocMpscoDefs.h> #include <linux/payload/plocMpsocHelpers.h>
#include <mission/utility/trace.h> #include <mission/utility/trace.h>
#include <string> #include <string>
@ -23,7 +23,7 @@
* MPSoC and OBC. * MPSoC and OBC.
* @author J. Meier * @author J. Meier
*/ */
class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF {
public: public:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HELPER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HELPER;
@ -82,8 +82,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
FLASH_READ_READLEN_ERROR = 2 FLASH_READ_READLEN_ERROR = 2
}; };
PlocMPSoCHelper(object_id_t objectId); PlocMpsocSpecialComHelper(object_id_t objectId);
virtual ~PlocMPSoCHelper(); virtual ~PlocMpsocSpecialComHelper();
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t performOperation(uint8_t operationCode = 0) override;
@ -175,7 +175,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
void resetHelper(); void resetHelper();
ReturnValue_t performFlashWrite(); ReturnValue_t performFlashWrite();
ReturnValue_t performFlashRead(); ReturnValue_t performFlashRead();
ReturnValue_t flashfopen(); ReturnValue_t flashfopen(mpsoc::FileAccessMode mode);
ReturnValue_t flashfclose(); ReturnValue_t flashfclose();
ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc);
ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc); ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc);
@ -186,8 +186,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
ReturnValue_t handleExe(); ReturnValue_t handleExe();
ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile);
ReturnValue_t fileCheck(std::string obcFile); ReturnValue_t fileCheck(std::string obcFile);
void handleAckApidFailure(uint16_t apid); void handleAckApidFailure(const ploc::SpTmReader& reader);
void handleExeApidFailure(uint16_t apid); void handleExeApidFailure(const ploc::SpTmReader& reader);
ReturnValue_t handleTmReception(size_t remainingBytes); ReturnValue_t handleTmReception(size_t remainingBytes);
ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader);
}; };

View File

@ -0,0 +1,91 @@
#include "plocMpsocHelpers.h"
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
}
std::string mpsoc::getStatusString(uint16_t status) {
switch (status) {
case (mpsoc::status_code::UNKNOWN_APID): {
return "Unknown APID";
break;
}
case (mpsoc::status_code::INCORRECT_LENGTH): {
return "Incorrect length";
break;
}
case (mpsoc::status_code::INCORRECT_CRC): {
return "Incorrect crc";
break;
}
case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): {
return "Incorrect packet sequence count";
break;
}
case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): {
return "TC not allowed in this mode";
break;
}
case (mpsoc::status_code::TC_EXEUTION_DISABLED): {
return "TC execution disabled";
break;
}
case (mpsoc::status_code::FLASH_MOUNT_FAILED): {
return "Flash mount failed";
break;
}
case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): {
return "Flash file already closed";
break;
}
case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): {
return "Flash file open failed";
break;
}
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
return "Flash file not open";
break;
}
case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): {
return "Flash unmount failed";
break;
}
case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): {
return "Heap allocation failed";
break;
}
case (mpsoc::status_code::INVALID_PARAMETER): {
return "Invalid parameter";
break;
}
case (mpsoc::status_code::NOT_INITIALIZED): {
return "Not initialized";
break;
}
case (mpsoc::status_code::REBOOT_IMMINENT): {
return "Reboot imminent";
break;
}
case (mpsoc::status_code::CORRUPT_DATA): {
return "Corrupt data";
break;
}
case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): {
return "Flash correctable mismatch";
break;
}
case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): {
return "Flash uncorrectable mismatch";
break;
}
case (mpsoc::status_code::DEFAULT_ERROR_CODE): {
return "Default error code";
break;
}
default:
std::stringstream ss;
ss << "0x" << std::hex << status;
return ss.str().c_str();
break;
}
return "";
}

View File

@ -13,6 +13,16 @@
namespace mpsoc { namespace mpsoc {
enum FileAccessMode : uint8_t {
OPEN_EXISTING = 0x00,
READ = 0x01,
WRITE = 0x02,
CREATE_NEW = 0x04,
CREATE_ALWAYS = 0x08,
OPEN_ALWAYS = 0x10,
OPEN_APPEND = 0x30
};
static constexpr uint32_t HK_SET_ID = 0; static constexpr uint32_t HK_SET_ID = 0;
namespace poolid { namespace poolid {
@ -140,6 +150,8 @@ static const char NULL_TERMINATOR = '\0';
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7; static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6; static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
static const uint8_t STATUS_OFFSET = 10;
static constexpr size_t CRC_SIZE = 2; static constexpr size_t CRC_SIZE = 2;
/** /**
@ -380,27 +392,24 @@ class FlashFopen : public ploc::SpTcBase {
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} : ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a'; ReturnValue_t createPacket(std::string filename, FileAccessMode mode) {
static const char WRITE = 'w'; accessMode = mode;
static const char READ = 'r';
ReturnValue_t createPacket(std::string filename, char accessMode_) {
accessMode = accessMode_;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE); spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
ReturnValue_t result = checkPayloadLen(); ReturnValue_t result = checkPayloadLen();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
std::memcpy(payloadStart, filename.c_str(), nameSize); std::memcpy(payloadStart, filename.c_str(), nameSize);
*(spParams.buf + nameSize) = NULL_TERMINATOR; payloadStart[nameSize] = NULL_TERMINATOR;
std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode)); payloadStart[255] = NULL_TERMINATOR;
payloadStart[256] = static_cast<uint8_t>(accessMode);
updateSpFields(); updateSpFields();
return calcAndSetCrc(); return calcAndSetCrc();
} }
private: private:
char accessMode = APPEND; FileAccessMode accessMode = FileAccessMode::OPEN_EXISTING;
}; };
/** /**
@ -989,92 +998,8 @@ class HkReport : public StaticLocalDataSet<36> {
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this);
}; };
const char* getStatusString(uint16_t status) { uint16_t getStatusFromRawData(const uint8_t* data);
switch (status) { std::string getStatusString(uint16_t status);
case (mpsoc::status_code::UNKNOWN_APID): {
return "Unknown APID";
break;
}
case (mpsoc::status_code::INCORRECT_LENGTH): {
return "Incorrect length";
break;
}
case (mpsoc::status_code::INCORRECT_CRC): {
return "Incorrect crc";
break;
}
case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): {
return "Incorrect packet sequence count";
break;
}
case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): {
return "TC not allowed in this mode";
break;
}
case (mpsoc::status_code::TC_EXEUTION_DISABLED): {
return "TC execution disabled";
break;
}
case (mpsoc::status_code::FLASH_MOUNT_FAILED): {
return "Flash mount failed";
break;
}
case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): {
return "Flash file already closed";
break;
}
case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): {
return "Flash file open failed";
break;
}
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
return "Flash file not open";
break;
}
case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): {
return "Flash unmount failed";
break;
}
case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): {
return "Heap allocation failed";
break;
}
case (mpsoc::status_code::INVALID_PARAMETER): {
return "Invalid parameter";
break;
}
case (mpsoc::status_code::NOT_INITIALIZED): {
return "Not initialized";
break;
}
case (mpsoc::status_code::REBOOT_IMMINENT): {
return "Reboot imminent";
break;
}
case (mpsoc::status_code::CORRUPT_DATA): {
return "Corrupt data";
break;
}
case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): {
return "Flash correctable mismatch";
break;
}
case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): {
return "Flash uncorrectable mismatch";
break;
}
case (mpsoc::status_code::DEFAULT_ERROR_CODE): {
return "Default error code";
break;
}
default:
std::stringstream ss;
ss << "0x" << std::hex << status;
return ss.str();
break;
}
return "";
}
} // namespace mpsoc } // namespace mpsoc