chonky #670

Merged
muellerr merged 278 commits from v3.0.0-dev into main 2023-06-11 14:25:21 +02:00
4 changed files with 136 additions and 81 deletions
Showing only changes of commit 90b7f069dc - Show all commits

View File

@ -136,7 +136,6 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
specialComHelper->setSequenceCount(&sequenceCount);
result = specialComHelper->startFlashWrite(flashWritePusCmd.getObcFile(), result = specialComHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMPSoCFile()); flashWritePusCmd.getMPSoCFile());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -151,7 +150,6 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
specialComHelper->setSequenceCount(&sequenceCount);
result = specialComHelper->startFlashRead(flashReadPusCmd.getObcFile(), result = specialComHelper->startFlashRead(flashReadPusCmd.getObcFile(),
flashReadPusCmd.getMPSoCFile(), flashReadPusCmd.getMPSoCFile(),
flashReadPusCmd.getReadSize()); flashReadPusCmd.getReadSize());
@ -226,9 +224,8 @@ void PlocMpsocHandler::doShutDown() {
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
powerState = PowerState::SHUTDOWN; powerState = PowerState::SHUTDOWN;
break; return;
case PowerState::OFF: case PowerState::OFF:
sequenceCount = 0;
hkReport.setReportingEnabled(false); hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
break; break;
@ -236,13 +233,19 @@ void PlocMpsocHandler::doShutDown() {
break; break;
} }
#else #else
sequenceCount = 0;
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN);
powerState = PowerState::OFF; powerState = PowerState::OFF;
#endif #endif
#endif #endif
Review

How do we ever get to PowerState::OFF, if we return here? Is that not needed for this configuration?

How do we ever get to PowerState::OFF, if we return here? Is that not needed for this configuration?
Review

This is done by the supervisor, so when the action reply arrive, the power state will go to OFF. Some sort of timeout is missing though..

This is done by the supervisor, so when the action reply arrive, the power state will go to OFF. Some sort of timeout is missing though..
if (specialComHelper != nullptr) {
specialComHelper->stopProcess();
}
hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN);
commandIsPending = false;
sequenceCount = 0;
plocMPSoCHelperExecuting = false;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
} }

View File

@ -1,5 +1,7 @@
#include <fsfw/globalfunctions/arrayprinter.h> #include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/tasks/TaskFactory.h>
#include <linux/payload/PlocMpsocSpecialComHelper.h> #include <linux/payload/PlocMpsocSpecialComHelper.h>
#include <unistd.h>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@ -40,16 +42,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
#endif #endif
switch (internalState) { switch (internalState) {
case InternalState::IDLE: { case InternalState::IDLE: {
sif::debug << "ploc mpsoc helper idle" << std::endl;
semaphore.acquire(); semaphore.acquire();
break; break;
} }
case InternalState::FLASH_WRITE: { case InternalState::FLASH_WRITE: {
result = performFlashWrite(); result = performFlashWrite();
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL); triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, sequenceCount->get());
} else { } else {
triggerEvent(MPSOC_FLASH_WRITE_FAILED); triggerEvent(MPSOC_FLASH_WRITE_FAILED, sequenceCount->get());
} }
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
@ -57,9 +58,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
case InternalState::FLASH_READ: { case InternalState::FLASH_READ: {
result = performFlashRead(); result = performFlashRead();
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL); triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, sequenceCount->get());
} else { } else {
triggerEvent(MPSOC_FLASH_READ_FAILED); triggerEvent(MPSOC_FLASH_READ_FAILED, sequenceCount->get());
} }
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
@ -155,13 +156,18 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength); file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength);
bytesRead += dataLength; bytesRead += dataLength;
remainingSize -= dataLength; remainingSize -= dataLength;
(*sequenceCount)++;
mpsoc::TcFlashWrite tc(spParams, *sequenceCount); mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
result = tc.buildPacket(fileBuf.data(), dataLength); result = tc.setPayload(fileBuf.data(), dataLength);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
flashfclose(); flashfclose();
return result; return result;
} }
result = tc.finishPacket();
if (result != returnvalue::OK) {
flashfclose();
return result;
}
(*sequenceCount)++;
result = handlePacketTransmissionNoReply(tc); result = handlePacketTransmissionNoReply(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
flashfclose(); flashfclose();
@ -205,7 +211,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
flashfclose(); flashfclose();
return FILE_READ_ERROR; return FILE_READ_ERROR;
} }
(*sequenceCount)++;
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
result = flashReadRequest.setPayload(nextReadSize); result = flashReadRequest.setPayload(nextReadSize);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -219,15 +224,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
flashfclose(); flashfclose();
return result; return result;
} }
result = handlePacketTransmissionFlashRead(flashReadRequest); (*sequenceCount)++;
if (result != returnvalue::OK) { result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize);
std::filesystem::remove(flashReadAndWrite.obcFile, e);
flashfclose();
return result;
}
result = handleFlashReadReply(ofile, nextReadSize);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
sif::debug << "flash close" << std::endl;
flashfclose(); flashfclose();
return result; return result;
} }
@ -239,7 +240,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) { ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
(*sequenceCount)++;
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode); ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -249,6 +249,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode)
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
(*sequenceCount)++;
result = handlePacketTransmissionNoReply(flashFopen); result = handlePacketTransmissionNoReply(flashFopen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -258,12 +259,22 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode)
ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
(*sequenceCount)++;
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
return handlePacketTransmissionNoReply(flashFclose); ReturnValue_t result = flashFclose.finishPacket();
if (result != returnvalue::OK) {
return result;
}
(*sequenceCount)++;
result = handlePacketTransmissionNoReply(flashFclose);
if (result != returnvalue::OK) {
return result;
}
return result;
} }
ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc,
std::ofstream& ofile,
size_t expectedReadLen) {
ReturnValue_t result = sendCommand(tc); ReturnValue_t result = sendCommand(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -272,12 +283,29 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = handleTmReception(ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + // ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + mpsoc::CRC_SIZE
mpsoc::CRC_SIZE); result = handleTmReception();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
return handleExe();
// We have the nominal case where the flash read report appears first, or the case where we
// get an EXE failure immediately.
if (spReader.getApid() == mpsoc::apid::TM_FLASH_READ_REPORT) {
result = handleFlashReadReply(ofile, expectedReadLen);
if (result != returnvalue::OK) {
return result;
}
return handleExe();
} else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) {
handleExeFailure();
} else {
triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast<uint32_t>(internalState));
sif::warning << "PLOC MPSoC: Expected execution report "
<< "but received space packet with apid " << std::hex << spReader.getApid()
<< std::endl;
}
return returnvalue::FAILED;
} }
ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) {
@ -294,7 +322,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S
ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen());
result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
@ -306,12 +333,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t PlocMpsocSpecialComHelper::handleAck() { ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = handleTmReception(mpsoc::SIZE_ACK_REPORT); result = handleTmReception();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
result = checkReceivedTm(tmPacket); result = checkReceivedTm();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -327,7 +354,7 @@ void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& rea
uint16_t apid = reader.getApid(); uint16_t apid = reader.getApid();
if (apid == mpsoc::apid::ACK_FAILURE) { if (apid == mpsoc::apid::ACK_FAILURE) {
uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData());
sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; sif::warning << "PLOC MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState), status); 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));
@ -339,74 +366,93 @@ void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& rea
ReturnValue_t PlocMpsocSpecialComHelper::handleExe() { ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = handleTmReception(mpsoc::SIZE_EXE_REPORT); result = handleTmReception();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
ploc::SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); result = checkReceivedTm();
result = checkReceivedTm(tmPacket);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
uint16_t apid = tmPacket.getApid(); uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::EXE_SUCCESS) { if (apid == mpsoc::apid::EXE_FAILURE) {
handleExeApidFailure(tmPacket); handleExeFailure();
return returnvalue::FAILED; return returnvalue::FAILED;
} else if (apid != mpsoc::apid::EXE_SUCCESS) {
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PLOC MPSoC: Expected execution report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
} }
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMpsocSpecialComHelper::handleExeApidFailure(const ploc::SpTmReader& reader) { void PlocMpsocSpecialComHelper::handleExeFailure() {
uint16_t apid = reader.getApid(); uint16_t status = mpsoc::getStatusFromRawData(spReader.getFullData());
if (apid == mpsoc::apid::EXE_FAILURE) { sif::warning << "PLOC MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
} else {
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}
} }
ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception(size_t remainingBytes) { ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
tmCountdown.resetTimer();
size_t readBytes = 0; size_t readBytes = 0;
size_t currentBytes = 0; size_t currentBytes = 0;
for (int retries = 0; retries < RETRIES; retries++) { uint32_t usleepDelay = 5;
result = receive(tmBuf.data() + readBytes, &currentBytes, remainingBytes); size_t fullPacketLen = 0;
while (true) {
if (tmCountdown.hasTimedOut()) {
triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs());
return returnvalue::FAILED;
}
result = receive(tmBuf.data() + readBytes, 6, &currentBytes);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
spReader.setReadOnlyData(tmBuf.data(), tmBuf.size());
fullPacketLen = spReader.getFullPacketLen();
readBytes += currentBytes; readBytes += currentBytes;
remainingBytes = remainingBytes - currentBytes; if (readBytes == 6) {
if (remainingBytes == 0) {
break; break;
} }
usleep(usleepDelay);
if (usleepDelay < 200000) {
usleepDelay *= 4;
}
} }
if (remainingBytes != 0) { sif::debug << "recvd first 6 bytes" << std::endl;
sif::warning << "PlocMPSoCHelper::handleTmReception: Failed to receive reply" << std::endl; while (true) {
triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState)); if (tmCountdown.hasTimedOut()) {
return returnvalue::FAILED; triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs());
return returnvalue::FAILED;
}
result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, &currentBytes);
readBytes += currentBytes;
if (fullPacketLen == readBytes) {
sif::debug << "recvd full " << fullPacketLen << std::endl;
break;
}
usleep(usleepDelay);
if (usleepDelay < 200000) {
usleepDelay *= 4;
}
} }
return result; return result;
} }
ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile, ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile,
size_t expectedReadLen) { size_t expectedReadLen) {
SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); ReturnValue_t result = checkReceivedTm();
ReturnValue_t result = checkReceivedTm(tmPacket);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
uint16_t apid = tmPacket.getApid(); uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) { if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) {
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR); triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR);
sif::warning << "PLOC MPSoC Flash Read: Unexpected APID" << std::endl; sif::warning << "PLOC MPSoC Flash Read: Unexpected APID" << std::endl;
return result; return result;
} }
const uint8_t* packetData = tmPacket.getPacketData(); const uint8_t* packetData = spReader.getPacketData();
size_t deserDummy = tmPacket.getPacketDataLen() - mpsoc::CRC_SIZE; size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE;
uint32_t receivedReadLen = 0; uint32_t receivedReadLen = 0;
std::string receivedShortName = std::string(reinterpret_cast<const char*>(packetData), 12); std::string receivedShortName = std::string(reinterpret_cast<const char*>(packetData), 12);
if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) { if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) {
@ -462,21 +508,20 @@ ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string o
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() {
ReturnValue_t result = reader.checkSize(); ReturnValue_t result = spReader.checkSize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed" sif::error << "PLOC MPSoC: Size check on received TM failed" << std::endl;
<< std::endl;
triggerEvent(MPSOC_TM_SIZE_ERROR); triggerEvent(MPSOC_TM_SIZE_ERROR);
return result; return result;
} }
reader.checkCrc(); spReader.checkCrc();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl; sif::warning << "PLOC MPSoC: CRC check failed" << std::endl;
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount); triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);
return result; return result;
} }
uint16_t recvSeqCnt = reader.getSequenceCount(); uint16_t recvSeqCnt = spReader.getSequenceCount();
if (recvSeqCnt != *sequenceCount) { if (recvSeqCnt != *sequenceCount) {
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt); triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
*sequenceCount = recvSeqCnt; *sequenceCount = recvSeqCnt;
@ -486,8 +531,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t* readBytes, ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t requestBytes,
size_t requestBytes) { size_t* readBytes) {
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

@ -75,6 +75,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
static const Event MPSOC_FLASH_READ_PACKET_ERROR = MAKE_EVENT(14, severity::LOW); static const Event MPSOC_FLASH_READ_PACKET_ERROR = MAKE_EVENT(14, severity::LOW);
static const Event MPSOC_FLASH_READ_FAILED = MAKE_EVENT(15, severity::LOW); static const Event MPSOC_FLASH_READ_FAILED = MAKE_EVENT(15, severity::LOW);
static const Event MPSOC_FLASH_READ_SUCCESSFUL = MAKE_EVENT(16, severity::INFO); static const Event MPSOC_FLASH_READ_SUCCESSFUL = MAKE_EVENT(16, severity::INFO);
static const Event MPSOC_READ_TIMEOUT = MAKE_EVENT(17, severity::LOW);
enum FlashReadErrorType : uint32_t { enum FlashReadErrorType : uint32_t {
FLASH_READ_APID_ERROR = 0, FLASH_READ_APID_ERROR = 0,
@ -157,6 +158,8 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
SpacePacketCreator creator; SpacePacketCreator creator;
ploc::SpTcParams spParams = ploc::SpTcParams(creator); ploc::SpTcParams spParams = ploc::SpTcParams(creator);
Countdown tmCountdown = Countdown(5000);
std::array<uint8_t, mpsoc::SP_MAX_DATA_SIZE> fileBuf{}; std::array<uint8_t, mpsoc::SP_MAX_DATA_SIZE> fileBuf{};
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf{}; std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf{};
@ -171,6 +174,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
CookieIF* comCookie = nullptr; CookieIF* comCookie = nullptr;
// Sequence count, must be set by Ploc MPSoC Handler // Sequence count, must be set by Ploc MPSoC Handler
SourceSequenceCounter* sequenceCount = nullptr; SourceSequenceCounter* sequenceCount = nullptr;
ploc::SpTmReader spReader;
void resetHelper(); void resetHelper();
ReturnValue_t performFlashWrite(); ReturnValue_t performFlashWrite();
@ -178,18 +182,19 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
ReturnValue_t flashfopen(mpsoc::FileAccessMode mode); 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, std::ofstream& ofile,
size_t expectedReadLen);
ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen); ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen);
ReturnValue_t sendCommand(ploc::SpTcBase& tc); ReturnValue_t sendCommand(ploc::SpTcBase& tc);
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); ReturnValue_t receive(uint8_t* data, size_t requestBytes, size_t* readBytes);
ReturnValue_t handleAck(); ReturnValue_t handleAck();
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(const ploc::SpTmReader& reader); void handleAckApidFailure(const ploc::SpTmReader& reader);
void handleExeApidFailure(const ploc::SpTmReader& reader); void handleExeFailure();
ReturnValue_t handleTmReception(size_t remainingBytes); ReturnValue_t handleTmReception();
ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); ReturnValue_t checkReceivedTm();
}; };
#endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */ #endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */

View File

@ -229,7 +229,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
virtual ~TcBase() = default; virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created. // Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 2; static const uint16_t INIT_LENGTH = CRC_SIZE;
/** /**
* @brief Constructor * @brief Constructor
@ -391,7 +391,9 @@ class FlashFopen : public TcBase {
class FlashFclose : public TcBase { class FlashFclose : public TcBase {
public: public:
FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount) FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {
spParams.setFullPayloadLen(CRC_SIZE);
}
}; };
/** /**
@ -402,7 +404,7 @@ class TcFlashWrite : public TcBase {
TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount) TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) { ReturnValue_t setPayload(const uint8_t* writeData, uint32_t writeLen_) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
writeLen = writeLen_; writeLen = writeLen_;
if (writeLen > SP_MAX_DATA_SIZE) { if (writeLen > SP_MAX_DATA_SIZE) {