From 91fdd7e7acdba4dd6944556213c1695747409414 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Apr 2024 12:12:01 +0200 Subject: [PATCH] almost at the goal --- fsfw | 2 +- linux/payload/CMakeLists.txt | 2 -- linux/payload/FreshMpsocHandler.cpp | 36 ++++++++++++++++------------- linux/payload/FreshMpsocHandler.h | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fsfw b/fsfw index 3b0ee7ca..0660457c 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3b0ee7ca3121a8d9e3e4d10a0c301ef5d1755102 +Subproject commit 0660457c92b4bc5a533e0821752b21c485e75fc7 diff --git a/linux/payload/CMakeLists.txt b/linux/payload/CMakeLists.txt index fc51cd6d..f0212c2e 100644 --- a/linux/payload/CMakeLists.txt +++ b/linux/payload/CMakeLists.txt @@ -1,12 +1,10 @@ target_sources( ${OBSW_NAME} PUBLIC PlocMemoryDumper.cpp - PlocMpsocHandler.cpp MpsocCommunication.cpp SerialCommunicationHelper.cpp FreshMpsocHandler.cpp FreshSupvHandler.cpp - PlocMpsocSpecialComHelperLegacy.cpp PlocMpsocSpecialComHelper.cpp plocMpsocHelpers.cpp PlocSupvUartMan.cpp diff --git a/linux/payload/FreshMpsocHandler.cpp b/linux/payload/FreshMpsocHandler.cpp index 7f90228e..c9a6f2ab 100644 --- a/linux/payload/FreshMpsocHandler.cpp +++ b/linux/payload/FreshMpsocHandler.cpp @@ -4,6 +4,7 @@ #include "eive/objects.h" #include "fsfw/action/CommandActionHelper.h" #include "fsfw/datapool/PoolReadGuard.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/QueueFactory.h" @@ -43,9 +44,11 @@ void FreshMpsocHandler::performDeviceOperation(uint8_t opCode) { // Handle all received packets. while (true) { ReturnValue_t result = comInterface.parseAndRetrieveNextPacket(); - if (result == returnvalue::OK) { - break; + if (result == MpsocCommunication::PACKET_RECEIVED) { + handleDeviceReply(); + continue; } + break; } } } @@ -229,6 +232,11 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue return mpsoc::MPSOC_HELPER_EXECUTING; } + // We do not accept the rest of the commands if we are not on. + if (mode != MODE_ON && mode != MODE_NORMAL) { + return HasModesIF::INVALID_MODE; + } + switch (actionId) { case mpsoc::TC_FLASH_WRITE_FULL_FILE: { mpsoc::FlashBasePusCmd flashWritePusCmd; @@ -707,18 +715,14 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() { // SpacePacketReader spacePacket; // spacePacket.setReadOnlyData(start, remainingSize); auto& replyReader = comInterface.getSpReader(); + if (replyReader.isNull()) { + return returnvalue::FAILED; + } if (MPSOC_RX_WIRETAPPING) { sif::debug << "RECV MPSOC packet. APID 0x" << std::hex << std::setw(3) << replyReader.getApid() << std::dec << " Size " << replyReader.getFullPacketLen() << " SSC " << replyReader.getSequenceCount() << std::endl; } - if (replyReader.isNull()) { - return returnvalue::FAILED; - } - auto res = replyReader.checkSize(); - if (res != returnvalue::OK) { - return res; - } uint16_t apid = replyReader.getApid(); switch (apid) { @@ -728,22 +732,24 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() { case (mpsoc::apid::ACK_FAILURE): break; case (mpsoc::apid::TM_MEMORY_READ_REPORT): - result = reportReplyData(); + result = reportReplyData(mpsoc::TM_MEMORY_READ_REPORT); break; case (mpsoc::apid::TM_CAM_CMD_RPT): - result = reportReplyData(); + result = reportReplyData(mpsoc::TM_CAM_CMD_RPT); break; case (mpsoc::apid::TM_HK_GET_REPORT): { result = handleGetHkReport(); break; } case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): { - result = reportReplyData(); + result = reportReplyData(mpsoc::TM_FLASH_DIRECTORY_CONTENT); break; } case (mpsoc::apid::EXE_SUCCESS): + case (mpsoc::apid::EXE_FAILURE): { result = handleExecutionReport(); break; + } default: { sif::debug << "FreshMpsocHandler:: Reply has invalid APID 0x" << std::hex << std::setfill('0') << std::setw(2) << apid << std::dec << std::endl; @@ -779,7 +785,6 @@ ReturnValue_t FreshMpsocHandler::handleExecutionReport() { uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData()); sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(mpsoc::EXE_FAILURE, commandId, status); - sendFailureReport(mpsoc::EXE_REPORT, mpsoc::RECEIVED_EXE_FAILURE); cmdDoneHandler(false, mpsoc::RECEIVED_EXE_FAILURE); break; } @@ -835,12 +840,11 @@ ReturnValue_t FreshMpsocHandler::getParameter(uint8_t domainId, uint8_t uniqueId startAtIndex); } -ReturnValue_t FreshMpsocHandler::reportReplyData() { +ReturnValue_t FreshMpsocHandler::reportReplyData(DeviceCommandId_t tmId) { auto& replyReader = comInterface.getSpReader(); if (activeCmdInfo.commandedBy != MessageQueueIF::NO_QUEUE) { return actionHelper.reportData( - activeCmdInfo.commandedBy, activeCmdInfo.pendingCmd, - replyReader.getFullData() + mpsoc::DATA_FIELD_OFFSET, + activeCmdInfo.commandedBy, tmId, replyReader.getFullData() + mpsoc::DATA_FIELD_OFFSET, replyReader.getFullPacketLen() - mpsoc::DATA_FIELD_OFFSET - mpsoc::CRC_SIZE); } return returnvalue::OK; diff --git a/linux/payload/FreshMpsocHandler.h b/linux/payload/FreshMpsocHandler.h index 7395d918..b930f1ad 100644 --- a/linux/payload/FreshMpsocHandler.h +++ b/linux/payload/FreshMpsocHandler.h @@ -193,7 +193,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI ReturnValue_t handleAckReport(); ReturnValue_t handleExecutionReport(); void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - ReturnValue_t reportReplyData(); + ReturnValue_t reportReplyData(DeviceCommandId_t tmId); ReturnValue_t handleGetHkReport(); bool handleHwStartup(); bool handleHwShutdown();