From 17df79b0d60a052f07b636abc7b9c9e8286063c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 15:15:58 +0200 Subject: [PATCH] this does not make sense --- bsp_q7s/core/ObjectFactory.cpp | 8 +- linux/payload/CMakeLists.txt | 3 +- linux/payload/PlocMpsocHandler.cpp | 132 +++++++++--------- linux/payload/PlocMpsocHandler.h | 17 +-- ...lper.cpp => PlocMpsocSpecialComHelper.cpp} | 89 ++++++------ ...ocHelper.h => PlocMpsocSpecialComHelper.h} | 14 +- linux/payload/plocMpsocHelpers.cpp | 91 ++++++++++++ .../{plocMpscoDefs.h => plocMpsocHelpers.h} | 117 +++------------- 8 files changed, 243 insertions(+), 228 deletions(-) rename linux/payload/{PlocMpsocHelper.cpp => PlocMpsocSpecialComHelper.cpp} (81%) rename linux/payload/{PlocMpsocHelper.h => PlocMpsocSpecialComHelper.h} (95%) create mode 100644 linux/payload/plocMpsocHelpers.cpp rename linux/payload/{plocMpscoDefs.h => plocMpsocHelpers.h} (92%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 8fcace4e..17b14b56 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include #include @@ -623,8 +623,8 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, serial::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); - auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); - auto* mpsocHandler = new PlocMPSoCHandler( + auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER); + auto* mpsocHandler = new PlocMpsocHandler( objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), objects::PLOC_SUPERVISOR_HANDLER); mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); diff --git a/linux/payload/CMakeLists.txt b/linux/payload/CMakeLists.txt index 7b2c4486..e697fac6 100644 --- a/linux/payload/CMakeLists.txt +++ b/linux/payload/CMakeLists.txt @@ -2,7 +2,8 @@ target_sources( ${OBSW_NAME} PUBLIC PlocMemoryDumper.cpp PlocMpsocHandler.cpp - PlocMpsocHelper.cpp + PlocMpsocSpecialComHelper.cpp + plocMpsocHelpers.cpp PlocSupervisorHandler.cpp PlocSupvUartMan.cpp ScexDleParser.cpp diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 68dccd86..a07c7871 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -8,8 +8,8 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/globalfunctions/CRC.h" -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, +PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, + CookieIF* comCookie, PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, object_id_t supervisorHandler) : DeviceHandlerBase(objectId, uartComIFid, comCookie), hkReport(this), @@ -27,9 +27,9 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid spParams.buf = commandBuffer; } -PlocMPSoCHandler::~PlocMPSoCHandler() {} +PlocMpsocHandler::~PlocMpsocHandler() {} -ReturnValue_t PlocMPSoCHandler::initialize() { +ReturnValue_t PlocMpsocHandler::initialize() { ReturnValue_t result = returnvalue::OK; result = DeviceHandlerBase::initialize(); if (result != returnvalue::OK) { @@ -54,8 +54,8 @@ ReturnValue_t PlocMPSoCHandler::initialize() { return result; } result = manager->subscribeToEventRange( - eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED), - event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); + eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED), + event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from " @@ -78,7 +78,7 @@ ReturnValue_t PlocMPSoCHandler::initialize() { return result; } -void PlocMPSoCHandler::performOperationHook() { +void PlocMpsocHandler::performOperationHook() { if (commandIsPending and cmdCountdown.hasTimedOut()) { commandIsPending = false; // 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) { ReturnValue_t result = returnvalue::OK; switch (actionId) { @@ -176,7 +176,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } -void PlocMPSoCHandler::doStartUp() { +void PlocMpsocHandler::doStartUp() { if (startupState == StartupState::IDLE) { startupState = StartupState::HW_INIT; } @@ -220,7 +220,7 @@ void PlocMPSoCHandler::doStartUp() { } } -void PlocMPSoCHandler::doShutDown() { +void PlocMpsocHandler::doShutDown() { #ifdef XIPHOS_Q7S #if not OBSW_MPSOC_JTAG_BOOT == 1 switch (powerState) { @@ -248,7 +248,7 @@ void PlocMPSoCHandler::doShutDown() { startupState = StartupState::IDLE; } -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { +ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { if (not commandIsPending and not plocMPSoCHelperExecuting) { *id = mpsoc::TC_GET_HK_REPORT; commandIsPending = true; @@ -258,11 +258,11 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) return NOTHING_TO_SEND; } -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { +ReturnValue_t PlocMpsocHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return NOTHING_TO_SEND; } -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, +ReturnValue_t PlocMpsocHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { spParams.buf = commandBuffer; @@ -353,7 +353,7 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device return result; } -void PlocMPSoCHandler::fillCommandAndReplyMap() { +void PlocMpsocHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_MEM_WRITE); this->insertInCommandMap(mpsoc::TC_MEM_READ); 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); } -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) { ReturnValue_t result = returnvalue::OK; @@ -454,7 +454,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain 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; switch (id) { @@ -499,14 +499,14 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { +void PlocMpsocHandler::setNormalDatapoolEntriesInvalid() { PoolReadGuard pg(&hkReport); 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) { localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); @@ -547,7 +547,7 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc return returnvalue::OK; } -void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) { +void PlocMpsocHandler::handleEvent(EventMessage* eventMessage) { object_id_t objectId = eventMessage->getReporter(); switch (objectId) { 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) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount); @@ -572,7 +572,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemRead tcMemRead(spParams, sequenceCount); @@ -585,7 +585,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { return MPSoCReturnValuesIF::NAME_TOO_LONG; @@ -601,7 +601,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount); @@ -613,7 +613,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() { +ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount); result = tcReplayStop.buildPacket(); @@ -624,7 +624,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount); @@ -636,7 +636,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() { ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount); result = tcDownlinkPwrOff.buildPacket(); @@ -647,7 +647,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { +ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() { mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); ReturnValue_t result = tcGetHkReport.buildPacket(); if (result != returnvalue::OK) { @@ -657,7 +657,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount); @@ -669,7 +669,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() { +ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() { ReturnValue_t result = returnvalue::OK; mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount); result = tcModeReplay.buildPacket(); @@ -680,7 +680,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() { +ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() { ReturnValue_t result = returnvalue::OK; mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount); result = tcModeIdle.buildPacket(); @@ -691,7 +691,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount); @@ -704,7 +704,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); @@ -715,7 +715,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); @@ -726,7 +726,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); @@ -737,7 +737,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandDat return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); @@ -748,7 +748,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { +ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() { mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); ReturnValue_t result = tcModeSnapshot.buildPacket(); if (result != returnvalue::OK) { @@ -758,21 +758,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { return returnvalue::OK; } -void PlocMPSoCHandler::finishTcPrep(size_t packetLen) { +void PlocMpsocHandler::finishTcPrep(size_t packetLen) { nextReplyId = mpsoc::ACK_REPORT; rawPacket = commandBuffer; rawPacketLen = packetLen; 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) { return MPSoCReturnValuesIF::CRC_FAILURE; } return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT); @@ -792,7 +792,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { case mpsoc::apid::ACK_FAILURE: { sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; 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; if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(ACK_FAILURE, commandId, status); @@ -817,7 +817,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; 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) { 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; triggerEvent(EXE_FAILURE, commandId, status); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); @@ -860,7 +860,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleMemoryReadReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; result = verifyPacket(data, tmMemReadReport.rememberRequestedSize); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { @@ -876,7 +876,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleGetHkReport(const uint8_t* data) { ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result != returnvalue::OK) { return result; @@ -1054,7 +1054,7 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { 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); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; @@ -1074,7 +1074,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, +ReturnValue_t PlocMpsocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, uint8_t expectedReplies, bool useAlternateId, DeviceCommandId_t alternateReplyID) { ReturnValue_t result = returnvalue::OK; @@ -1190,7 +1190,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator return returnvalue::OK; } -void PlocMPSoCHandler::setNextReplyId() { +void PlocMpsocHandler::setNextReplyId() { switch (getPendingCommand()) { case mpsoc::TC_MEM_READ: 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; if (nextReplyId == mpsoc::NONE) { @@ -1251,7 +1251,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { return replyLen; } -ReturnValue_t PlocMPSoCHandler::doSendReadHook() { +ReturnValue_t PlocMpsocHandler::doSendReadHook() { // Prevent DHB from polling UART during commands executed by the mpsoc helper task if (plocMPSoCHelperExecuting) { return returnvalue::FAILED; @@ -1259,11 +1259,11 @@ ReturnValue_t PlocMPSoCHandler::doSendReadHook() { 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) { switch (actionId) { 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; } -void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { +void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) { if (actionId != supv::EXE_REPORT) { sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " << "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); } -void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, +void PlocMpsocHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { 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; DeviceReplyMap::iterator iter; @@ -1404,7 +1404,7 @@ void PlocMPSoCHandler::disableAllReplies() { 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); if (iter == deviceReplyMap.end()) { 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; } -void PlocMPSoCHandler::disableExeReportReply() { +void PlocMpsocHandler::disableExeReportReply() { DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); DeviceReplyInfo* info = &(iter->second); info->delayCycles = 0; @@ -1430,11 +1430,7 @@ void PlocMPSoCHandler::disableExeReportReply() { info->command->second.expectedReplies = 0; } -uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { - return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); -} - -void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { +void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) { switch (actionId) { case supv::ACK_REPORT: case supv::EXE_REPORT: @@ -1467,20 +1463,20 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { return; } -LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase* PlocMpsocHandler::getDataSetHandle(sid_t sid) { if (sid == hkReport.getSid()) { return &hkReport; } return nullptr; } -bool PlocMPSoCHandler::dontCheckQueue() { +bool PlocMpsocHandler::dontCheckQueue() { // 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 return commandIsPending; } -void PlocMPSoCHandler::cmdDoneHandler(bool success, ReturnValue_t result) { +void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) { commandIsPending = false; auto commandIter = deviceCommandMap.find(getPendingCommand()); if (commandIter != deviceCommandMap.end()) { diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index dc6ebd99..a42075d8 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -1,9 +1,9 @@ #ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ #define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ -#include +#include #include -#include +#include #include #include @@ -31,7 +31,7 @@ * NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER. * @author J. Meier, R. Mueller */ -class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { +class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { public: /** * @brief Constructor @@ -44,10 +44,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { * module in the programmable logic * @param supervisorHandler Object ID of the supervisor handler */ - PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, - PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, + PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, + PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, object_id_t supervisorHandler); - virtual ~PlocMPSoCHandler(); + virtual ~PlocMpsocHandler(); virtual ReturnValue_t initialize() override; ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, 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 PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const uint8_t STATUS_OFFSET = 10; mpsoc::HkReport hkReport; @@ -163,7 +162,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { SerialComIF* uartComIf = nullptr; - PlocMPSoCHelper* plocMPSoCHelper = nullptr; + PlocMpsocSpecialComHelper* plocMPSoCHelper = nullptr; Gpio uartIsolatorSwitch; object_id_t supervisorHandler = 0; CommandActionHelper commandActionHelper; @@ -299,8 +298,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcModeReplay(); - uint16_t getStatus(const uint8_t* data); - void cmdDoneHandler(bool success, ReturnValue_t result); void handleActionCommandFailure(ActionId_t actionId); diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp similarity index 81% rename from linux/payload/PlocMpsocHelper.cpp rename to linux/payload/PlocMpsocSpecialComHelper.cpp index 66e46c18..6bc338c6 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -11,14 +11,15 @@ using namespace ploc; -PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) { +PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId) + : SystemObject(objectId) { spParams.buf = commandBuffer; spParams.maxSize = sizeof(commandBuffer); } -PlocMPSoCHelper::~PlocMPSoCHelper() {} +PlocMpsocSpecialComHelper::~PlocMpsocSpecialComHelper() {} -ReturnValue_t PlocMPSoCHelper::initialize() { +ReturnValue_t PlocMpsocSpecialComHelper::initialize() { #ifdef XIPHOS_Q7S sdcMan = SdCardManager::instance(); if (sdcMan == nullptr) { @@ -29,7 +30,7 @@ ReturnValue_t PlocMPSoCHelper::initialize() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { +ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) { ReturnValue_t result = returnvalue::OK; semaphore.acquire(); 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(communicationInterface_); if (uartComIF == nullptr) { sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl; @@ -78,13 +79,14 @@ ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInte 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_; } -ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile, + std::string mpsocFile) { if (internalState != InternalState::IDLE) { return returnvalue::FAILED; } @@ -96,8 +98,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string return semaphore.release(); } -ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, - size_t readFileSize) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashRead(std::string obcFile, std::string mpsocFile, + size_t readFileSize) { if (internalState != InternalState::IDLE) { return returnvalue::FAILED; } @@ -110,21 +112,21 @@ ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string m return semaphore.release(); } -void PlocMPSoCHelper::resetHelper() { +void PlocMpsocSpecialComHelper::resetHelper() { spParams.buf = commandBuffer; terminate = false; 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; std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary); if (file.bad()) { return returnvalue::FAILED; } - result = flashfopen(); + result = flashfopen(mpsoc::FileAccessMode::WRITE); if (result != returnvalue::OK) { return result; } @@ -172,7 +174,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { return result; } -ReturnValue_t PlocMPSoCHelper::performFlashRead() { +ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { sif::debug << "performing flash read" << std::endl; std::error_code e; std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); @@ -180,7 +182,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { return returnvalue::FAILED; } sif::debug << "Sequence count: " << sequenceCount->get() << std::endl; - ReturnValue_t result = flashfopen(); + ReturnValue_t result = flashfopen(mpsoc::FileAccessMode::READ); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); return result; @@ -229,12 +231,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { return result; } -ReturnValue_t PlocMPSoCHelper::flashfopen() { +ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); - ReturnValue_t result = - flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND); + ReturnValue_t result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mode); if (result != returnvalue::OK) { return result; } @@ -245,7 +246,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::flashfclose() { +ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); @@ -256,7 +257,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() { return handlePacketTransmissionNoReply(flashFclose); } -ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; @@ -273,7 +274,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashR return handleExe(); } -ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; @@ -285,7 +286,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& t return handleExe(); } -ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { @@ -296,7 +297,7 @@ ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { return result; } -ReturnValue_t PlocMPSoCHelper::handleAck() { +ReturnValue_t PlocMpsocSpecialComHelper::handleAck() { ReturnValue_t result = returnvalue::OK; result = handleTmReception(mpsoc::SIZE_ACK_REPORT); if (result != returnvalue::OK) { @@ -309,17 +310,18 @@ ReturnValue_t PlocMPSoCHelper::handleAck() { } uint16_t apid = tmPacket.getApid(); if (apid != mpsoc::apid::ACK_SUCCESS) { - handleAckApidFailure(apid); + handleAckApidFailure(tmPacket); return returnvalue::FAILED; } 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) { - triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast(internalState)); - sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure " - << "report" << std::endl; + uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); + sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; + triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast(internalState), status); } else { triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast(internalState)); 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; result = handleTmReception(mpsoc::SIZE_EXE_REPORT); @@ -341,17 +343,18 @@ ReturnValue_t PlocMPSoCHelper::handleExe() { } uint16_t apid = tmPacket.getApid(); if (apid != mpsoc::apid::EXE_SUCCESS) { - handleExeApidFailure(apid); + handleExeApidFailure(tmPacket); return returnvalue::FAILED; } 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) { + uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); + sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast(internalState)); - sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure " - << "report" << std::endl; } else { triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast(internalState)); 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; size_t readBytes = 0; size_t currentBytes = 0; @@ -382,7 +385,8 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) { 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()); ReturnValue_t result = checkReceivedTm(tmPacket); if (result != returnvalue::OK) { @@ -422,7 +426,7 @@ ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { +ReturnValue_t PlocMpsocSpecialComHelper::fileCheck(std::string obcFile) { #ifdef XIPHOS_Q7S ReturnValue_t result = FilesystemHelper::checkPath(obcFile); if (result != returnvalue::OK) { @@ -438,8 +442,8 @@ ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, - std::string mpsocFile) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string obcFile, + std::string mpsocFile) { ReturnValue_t result = fileCheck(obcFile); if (result != returnvalue::OK) { return result; @@ -451,7 +455,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { +ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t result = reader.checkSize(); if (result != returnvalue::OK) { sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed" @@ -475,7 +479,8 @@ ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { 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; uint8_t* buffer = nullptr; result = uartComIF->requestReceiveMessage(comCookie, requestBytes); diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocSpecialComHelper.h similarity index 95% rename from linux/payload/PlocMpsocHelper.h rename to linux/payload/PlocMpsocSpecialComHelper.h index 2595c811..2a8e03dc 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocSpecialComHelper.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ #define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ -#include +#include #include #include @@ -23,7 +23,7 @@ * MPSoC and OBC. * @author J. Meier */ -class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { +class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF { public: 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 }; - PlocMPSoCHelper(object_id_t objectId); - virtual ~PlocMPSoCHelper(); + PlocMpsocSpecialComHelper(object_id_t objectId); + virtual ~PlocMpsocSpecialComHelper(); ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t operationCode = 0) override; @@ -175,7 +175,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { void resetHelper(); ReturnValue_t performFlashWrite(); ReturnValue_t performFlashRead(); - ReturnValue_t flashfopen(); + ReturnValue_t flashfopen(mpsoc::FileAccessMode mode); ReturnValue_t flashfclose(); ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc); @@ -186,8 +186,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t handleExe(); ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); ReturnValue_t fileCheck(std::string obcFile); - void handleAckApidFailure(uint16_t apid); - void handleExeApidFailure(uint16_t apid); + void handleAckApidFailure(const ploc::SpTmReader& reader); + void handleExeApidFailure(const ploc::SpTmReader& reader); ReturnValue_t handleTmReception(size_t remainingBytes); ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); }; diff --git a/linux/payload/plocMpsocHelpers.cpp b/linux/payload/plocMpsocHelpers.cpp new file mode 100644 index 00000000..ab6f0907 --- /dev/null +++ b/linux/payload/plocMpsocHelpers.cpp @@ -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 ""; +} diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpsocHelpers.h similarity index 92% rename from linux/payload/plocMpscoDefs.h rename to linux/payload/plocMpsocHelpers.h index 4bb19e4d..a7173d65 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpsocHelpers.h @@ -13,6 +13,16 @@ 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; 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 SPACE_PACKET_HEADER_SIZE = 6; +static const uint8_t STATUS_OFFSET = 10; + static constexpr size_t CRC_SIZE = 2; /** @@ -380,27 +392,24 @@ class FlashFopen : public ploc::SpTcBase { FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) : ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} - static const char APPEND = 'a'; - static const char WRITE = 'w'; - static const char READ = 'r'; - - ReturnValue_t createPacket(std::string filename, char accessMode_) { - accessMode = accessMode_; + ReturnValue_t createPacket(std::string filename, FileAccessMode mode) { + accessMode = mode; 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(); if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, filename.c_str(), nameSize); - *(spParams.buf + nameSize) = NULL_TERMINATOR; - std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode)); + payloadStart[nameSize] = NULL_TERMINATOR; + payloadStart[255] = NULL_TERMINATOR; + payloadStart[256] = static_cast(accessMode); updateSpFields(); return calcAndSetCrc(); } private: - char accessMode = APPEND; + FileAccessMode accessMode = FileAccessMode::OPEN_EXISTING; }; /** @@ -989,92 +998,8 @@ class HkReport : public StaticLocalDataSet<36> { lp_var_t(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); }; -const char* 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(); - break; - } - return ""; -} +uint16_t getStatusFromRawData(const uint8_t* data); +std::string getStatusString(uint16_t status); } // namespace mpsoc