From 0179c04472874f1ef4aa47c7abbb60cef3d43277 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 12:59:29 +0200 Subject: [PATCH] that did not help --- linux/payload/PlocMpsocSpecialComHelper.cpp | 18 ++++++++++++++---- linux/payload/plocMpsocHelpers.h | 7 ++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 7b3cf264..20e9acca 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -198,6 +198,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { while (readSoFar < flashReadAndWrite.totalReadSize) { if (terminate) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return returnvalue::OK; } @@ -208,6 +209,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl; if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return FILE_READ_ERROR; } @@ -215,12 +217,14 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { result = flashReadRequest.setPayload(nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return result; } result = flashReadRequest.finishPacket(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return result; } @@ -228,7 +232,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - sif::debug << "flash close" << std::endl; + // TODO: Might not be needed flashfclose(); return result; } @@ -283,7 +287,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } - // ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + mpsoc::CRC_SIZE result = handleTmReception(); if (result != returnvalue::OK) { return result; @@ -296,6 +299,10 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } + result = handleTmReception(); + if (result != returnvalue::OK) { + return result; + } return handleExe(); } else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) { handleExeFailure(); @@ -322,6 +329,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; + sif::debug << "sending TC" << std::endl; + arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; @@ -419,7 +428,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } - sif::debug << "recvd first 6 bytes" << std::endl; + // sif::debug << "recvd first 6 bytes" << std::endl; while (true) { if (tmCountdown.hasTimedOut()) { triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); @@ -428,7 +437,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, ¤tBytes); readBytes += currentBytes; if (fullPacketLen == readBytes) { - sif::debug << "recvd full " << fullPacketLen << std::endl; + // sif::debug << "recvd full " << fullPacketLen << std::endl; break; } usleep(usleepDelay); @@ -436,6 +445,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } + arrayprinter::print(tmBuf.data(), readBytes); return result; } diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 820b479a..4a6e6b5c 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -375,8 +375,9 @@ class FlashFopen : public TcBase { return result; } std::memcpy(payloadStart, filename.c_str(), nameSize); - payloadStart[nameSize] = NULL_TERMINATOR; - payloadStart[255] = NULL_TERMINATOR; + // payloadStart[nameSize] = NULL_TERMINATOR; + std::memset(payloadStart + nameSize, 0, 256 - nameSize); + // payloadStart[255] = NULL_TERMINATOR; payloadStart[256] = static_cast(accessMode); return returnvalue::OK; } @@ -445,7 +446,7 @@ class TcFlashRead : public TcBase { sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl; return returnvalue::FAILED; } - spParams.setFullPayloadLen(readLen + FLASH_READ_MIN_OVERHEAD + CRC_SIZE); + spParams.setFullPayloadLen(sizeof(uint32_t) + CRC_SIZE); ReturnValue_t result = checkPayloadLen(); if (result != returnvalue::OK) { return result;