From 1f9c9e2407afb26ef3f50725039903e1dc8aac75 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 15:52:47 +0200 Subject: [PATCH] horrible --- linux/payload/PlocMpsocHandler.cpp | 27 ++++++++++++++++++--------- linux/payload/plocMpscoDefs.h | 4 +++- tmtc | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 481c6b09..325e8ed7 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -224,11 +225,11 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not normalCmdPending) { - *id = mpsoc::TC_GET_HK_REPORT; - normalCmdPending = true; - return buildCommandFromCommand(*id, nullptr, 0); - } + // if (not normalCmdPending) { + // *id = mpsoc::TC_GET_HK_REPORT; + // normalCmdPending = true; + // return buildCommandFromCommand(*id, nullptr, 0); + // } return NOTHING_TO_SEND; } @@ -352,13 +353,14 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 5, nullptr, mpsoc::SIZE_TM_HK_REPORT); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); - this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, 0); + this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; + sif::debug << "remainingSize: " << remainingSize << std::endl; SpacePacketReader spacePacket; spacePacket.setReadOnlyData(start, remainingSize); if (spacePacket.isNull()) { @@ -377,6 +379,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): + sif::debug << "got ack" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -408,7 +411,8 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::EXE_REPORT; break; default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid APID 0x" << std::hex + << std::setfill('0') << std::setw(2) << apid << std::dec << std::endl; *foundLen = remainingSize; return MPSoCReturnValuesIF::INVALID_APID; } @@ -445,6 +449,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const break; } case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): { + sif::debug << "received flash dir content packet" << std::endl; result = verifyPacket(packet, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl; @@ -1171,6 +1176,10 @@ void PlocMPSoCHandler::setNextReplyId() { case mpsoc::TC_MEM_READ: nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; break; + case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: { + nextReplyId = mpsoc::TM_FLASH_DIRECTORY_CONTENT; + break; + } case mpsoc::TC_GET_HK_REPORT: { nextReplyId = mpsoc::TM_GET_HK_REPORT; break; @@ -1403,12 +1412,12 @@ void PlocMPSoCHandler::disableExeReportReply() { } void PlocMPSoCHandler::printStatus(const uint8_t* data) { - uint16_t status = *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); + uint16_t status = (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); sif::info << "Verification report status: " << getStatusString(status) << std::endl; } uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { - return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); + return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); } void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index de123719..c5d53e6f 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -628,11 +628,13 @@ class TcGetDirContent : public TcBase { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; - spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); + // Yeah it needs to be 256.. even if the path is shorter. + spParams.setFullPayloadLen(256 + CRC_SIZE); if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, commandData, commandDataLen); + payloadStart[255] = '\0'; return result; } }; diff --git a/tmtc b/tmtc index 377e98b5..ef0adef0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 377e98b5c2da12f10cdd12b027548a8075fdcb58 +Subproject commit ef0adef04aebf8aa0d673e14403b484bd1200d9c