need to fix special com helper
EIVE/eive-obsw/pipeline/pr-main This commit looks good Details

This commit is contained in:
Robin Müller 2024-04-29 13:19:08 +02:00
parent 2431994180
commit c3dd2b55ee
Signed by: muellerr
GPG Key ID: A649FB78196E3849
9 changed files with 144 additions and 134 deletions

2
fsfw

@ -1 +1 @@
Subproject commit 0660457c92b4bc5a533e0821752b21c485e75fc7
Subproject commit 6381d9a83c439b1b092412dc4d59c1f515d236e7

View File

@ -38,7 +38,7 @@ void FreshMpsocHandler::performDeviceOperation(uint8_t opCode) {
if (opCode == OpCode::DEFAULT_OPERATION) {
performDefaultDeviceOperation();
} else if (opCode == OpCode::PARSE_TM) {
} else if (opCode == OpCode::PARSE_TM and not specialComHelperExecuting) {
// Just need to call this once, this should take care of processing the whole received
// Linux UART RX buffer.
comInterface.readSerialInterface();
@ -153,7 +153,6 @@ ReturnValue_t FreshMpsocHandler::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
specialComHelper.setSequenceCount(&commandSequenceCount);
result = commandActionHelper.initialize();
if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
@ -269,7 +268,7 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
if (result != returnvalue::OK) {
return result;
}
specialComHelperExecuting = true;
commonSpecialComInit();
return EXECUTION_FINISHED;
}
case mpsoc::TC_FLASH_READ_FULL_FILE: {
@ -284,7 +283,10 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
if (result != returnvalue::OK) {
return result;
}
specialComHelperExecuting = true;
sif::info << "PLOC MPSoC: Reading " << flashReadPusCmd.getMpsocFile() << " with size "
<< flashReadPusCmd.getReadSize() << " to " << flashReadPusCmd.getObcFile()
<< std::endl;
commonSpecialComInit();
return EXECUTION_FINISHED;
}
case (mpsoc::OBSW_RESET_SEQ_COUNT_LEGACY): {
@ -300,6 +302,11 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
return returnvalue::OK;
}
void FreshMpsocHandler::commonSpecialComInit() {
specialComHelperExecuting = true;
specialComHelper.setCommandSequenceCount(commandSequenceCount.get());
}
/**
* @overload
* @param submode
@ -556,6 +563,9 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
break;
}
case (mpsoc::TC_SIMPLEX_STREAM_FILE): {
if (submode != mpsoc::Submode::SNAPSHOT) {
return HasModesIF::INVALID_SUBMODE;
}
result = commandTcSimplexStreamFile(commandData, commandDataLen);
break;
}
@ -781,11 +791,7 @@ ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc:
// TODO: We should find a way so this works with the old implementation.
commandSequenceCount++;
if (MPSOC_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet. APID 0x" << std::hex << std::setw(3) << tcBase.getApid()
<< " Size " << std::dec << tcBase.getFullPacketLen() << " SSC "
<< tcBase.getSeqCount() << std::endl;
}
mpsoc::printTxPacket(tcBase);
activeCmdInfo.cmdCountdown.setTimeout(cmdCountdownMs);
activeCmdInfo.cmdCountdown.resetTimer();
activeCmdInfo.pending = true;
@ -795,11 +801,10 @@ ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc:
}
void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
// TODO: Shouldn't we check for specific events?
object_id_t objectId = eventMessage->getReporter();
switch (objectId) {
case objects::PLOC_MPSOC_HANDLER: {
specialComHelperExecuting = false;
case objects::PLOC_MPSOC_HELPER: {
commonSpecialComStop();
break;
}
default:
@ -807,6 +812,10 @@ void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
break;
}
}
void FreshMpsocHandler::commonSpecialComStop() {
specialComHelperExecuting = false;
commandSequenceCount.set(specialComHelper.getCommandSequenceCount());
}
void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
if (transitionState == TransitionState::SUBMODE) {
@ -829,15 +838,11 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
// SpacePacketReader spacePacket;
// spacePacket.setReadOnlyData(start, remainingSize);
auto& replyReader = comInterface.getSpReader();
const 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;
}
mpsoc::printRxPacket(replyReader);
uint16_t apid = replyReader.getApid();
switch (apid) {

View File

@ -11,9 +11,6 @@
#include "linux/payload/PlocMpsocSpecialComHelper.h"
#include "linux/payload/plocMpsocHelpers.h"
static constexpr bool MPSOC_TX_WIRETAPPING = true;
static constexpr bool MPSOC_RX_WIRETAPPING = true;
class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsIF {
public:
enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 };
@ -203,4 +200,6 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
void stopSpecialComHelper();
void commandSubmodeTransition();
void commonSpecialComInit();
void commonSpecialComStop();
};

View File

@ -13,6 +13,9 @@ MpsocCommunication::MpsocCommunication(object_id_t objectId, SerialConfig cfg)
ReturnValue_t MpsocCommunication::initialize() { return helper.initialize(); }
ReturnValue_t MpsocCommunication::send(const uint8_t* data, size_t dataLen) {
if (MPSOC_LOW_LEVEL_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet with size " << dataLen << std::endl;
}
return helper.send(data, dataLen);
}

View File

@ -9,6 +9,7 @@
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "linux/payload/SerialCommunicationHelper.h"
static constexpr bool MPSOC_LOW_LEVEL_TX_WIRETAPPING = true;
static constexpr bool MPSOC_LOW_LEVEL_RX_WIRETAPPING = true;
class MpsocCommunication : public SystemObject {

View File

@ -6,14 +6,14 @@
#include <filesystem>
#include <fstream>
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "linux/payload/MpsocCommunication.h"
#include "linux/payload/plocMpsocHelpers.h"
#ifdef XIPHOS_Q7S
#include "bsp_q7s/fs/FilesystemHelper.h"
#endif
#include "mission/utility/Timestamp.h"
using namespace ploc;
PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId,
@ -51,9 +51,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
case InternalState::FLASH_WRITE: {
result = performFlashWrite();
if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, sequenceCount->get());
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, txSequenceCount.get());
} else {
triggerEvent(MPSOC_FLASH_WRITE_FAILED, sequenceCount->get());
triggerEvent(MPSOC_FLASH_WRITE_FAILED, txSequenceCount.get());
}
internalState = InternalState::IDLE;
break;
@ -61,9 +61,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
case InternalState::FLASH_READ: {
result = performFlashRead();
if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, sequenceCount->get());
triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, txSequenceCount.get());
} else {
triggerEvent(MPSOC_FLASH_READ_FAILED, sequenceCount->get());
triggerEvent(MPSOC_FLASH_READ_FAILED, txSequenceCount.get());
}
internalState = InternalState::IDLE;
break;
@ -75,8 +75,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
}
}
void PlocMpsocSpecialComHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
sequenceCount = sequenceCount_;
void PlocMpsocSpecialComHelper::setCommandSequenceCount(uint16_t sequenceCount_) {
txSequenceCount.set(sequenceCount_);
}
uint16_t PlocMpsocSpecialComHelper::getCommandSequenceCount() const {
return txSequenceCount.get();
}
ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile,
@ -103,8 +107,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::startFlashRead(std::string obcFile, std
}
flashReadAndWrite.totalReadSize = readFileSize;
internalState = InternalState::FLASH_READ;
sif::info << "PLOC MPSoC: Reading " << mpsocFile << " with size " << readFileSize << " to "
<< obcFile << std::endl;
return semaphore.release();
}
@ -150,7 +152,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength);
bytesRead += dataLength;
remainingSize -= dataLength;
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
mpsoc::TcFlashWrite tc(spParams, txSequenceCount);
result = tc.setPayload(fileBuf.data(), dataLength);
if (result != returnvalue::OK) {
return result;
@ -159,7 +161,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
if (result != returnvalue::OK) {
return result;
}
(*sequenceCount)++;
txSequenceCount.increment();
result = handlePacketTransmissionNoReply(tc);
if (result != returnvalue::OK) {
return result;
@ -198,7 +200,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
std::filesystem::remove(flashReadAndWrite.obcFile, e);
return FILE_READ_ERROR;
}
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
mpsoc::TcFlashRead flashReadRequest(spParams, txSequenceCount);
result = flashReadRequest.setPayload(nextReadSize);
if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e);
@ -209,7 +211,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
std::filesystem::remove(flashReadAndWrite.obcFile, e);
return result;
}
(*sequenceCount)++;
txSequenceCount.increment();
result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize);
if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e);
@ -226,7 +228,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
spParams.buf = commandBuffer;
mpsoc::TcFlashFopen flashFopen(spParams, *sequenceCount);
mpsoc::TcFlashFopen flashFopen(spParams, txSequenceCount);
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
if (result != returnvalue::OK) {
return result;
@ -235,7 +237,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
if (result != returnvalue::OK) {
return result;
}
(*sequenceCount)++;
txSequenceCount.increment();
result = handlePacketTransmissionNoReply(flashFopen);
if (result != returnvalue::OK) {
return result;
@ -245,12 +247,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
spParams.buf = commandBuffer;
mpsoc::TcFlashFclose flashFclose(spParams, *sequenceCount);
mpsoc::TcFlashFclose flashFclose(spParams, txSequenceCount);
ReturnValue_t result = flashFclose.finishPacket();
if (result != returnvalue::OK) {
return result;
}
(*sequenceCount)++;
txSequenceCount.increment();
result = handlePacketTransmissionNoReply(flashFclose);
if (result != returnvalue::OK) {
return result;
@ -273,6 +275,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
if (result != returnvalue::OK) {
return result;
}
auto& spReader = comInterface.getSpReader();
// We have the nominal case where the flash read report appears first, or the case where we
// get an EXE failure immediately.
@ -283,7 +286,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
}
return handleExe();
} else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) {
handleExeFailure();
handleExeFailure(spReader);
} else {
triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast<uint32_t>(internalState));
sif::warning << "PLOC MPSoC: Expected execution report "
@ -307,6 +310,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S
ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t result = comInterface.send(tc.getFullPacket(), tc.getFullPacketLen());
mpsoc::printTxPacket(tc);
if (result != returnvalue::OK) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
triggerEvent(MPSOC_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
@ -325,6 +329,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
if (result != returnvalue::OK) {
return result;
}
const auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::ACK_SUCCESS) {
handleAckApidFailure(spReader);
@ -333,7 +339,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
return returnvalue::OK;
}
void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& reader) {
void PlocMpsocSpecialComHelper::handleAckApidFailure(const SpacePacketReader& reader) {
uint16_t apid = reader.getApid();
if (apid == mpsoc::apid::ACK_FAILURE) {
uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData());
@ -357,9 +363,10 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
if (result != returnvalue::OK) {
return result;
}
const auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid();
if (apid == mpsoc::apid::EXE_FAILURE) {
handleExeFailure();
handleExeFailure(spReader);
return returnvalue::FAILED;
} else if (apid != mpsoc::apid::EXE_SUCCESS) {
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
@ -369,7 +376,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
return returnvalue::OK;
}
void PlocMpsocSpecialComHelper::handleExeFailure() {
void PlocMpsocSpecialComHelper::handleExeFailure(const SpacePacketReader& spReader) {
uint16_t status = mpsoc::getStatusFromRawData(spReader.getFullData());
sif::warning << "PLOC MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
@ -378,23 +385,17 @@ void PlocMpsocSpecialComHelper::handleExeFailure() {
ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() {
ReturnValue_t result = returnvalue::OK;
tmCountdown.resetTimer();
size_t readBytes = 0;
size_t currentBytes = 0;
uint32_t usleepDelay = 5;
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) {
result = tryReceiveNextReply();
if (result != MpsocCommunication::PACKET_RECEIVED and result != returnvalue::OK) {
return result;
}
spReader.setReadOnlyData(tmBuf.data(), tmBuf.size());
fullPacketLen = spReader.getFullPacketLen();
readBytes += currentBytes;
if (readBytes == 6) {
if (result == MpsocCommunication::PACKET_RECEIVED) {
break;
}
usleep(usleepDelay);
@ -402,22 +403,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() {
usleepDelay *= 4;
}
}
while (true) {
if (tmCountdown.hasTimedOut()) {
triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs());
return returnvalue::FAILED;
}
result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, &currentBytes);
readBytes += currentBytes;
if (fullPacketLen == readBytes) {
break;
}
usleep(usleepDelay);
if (usleepDelay < 200000) {
usleepDelay *= 4;
}
}
// arrayprinter::print(tmBuf.data(), readBytes);
return result;
}
@ -427,6 +412,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofi
if (result != returnvalue::OK) {
return result;
}
auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) {
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR);
@ -492,25 +478,19 @@ ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string o
}
ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() {
const auto& spReader = comInterface.getSpReader();
ReturnValue_t result = spReader.checkSize();
if (result != returnvalue::OK) {
sif::error << "PLOC MPSoC: Size check on received TM failed" << std::endl;
triggerEvent(MPSOC_TM_SIZE_ERROR);
return result;
}
// No CRC check, this is already done by the communication interface..
uint16_t recvSeqCnt = spReader.getSequenceCount();
if (recvSeqCnt != *sequenceCount) {
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
*sequenceCount = recvSeqCnt;
}
// This sequence count ping pong does not make any sense but it is how the MPSoC expects it.
(*sequenceCount)++;
rxSequenceCount = spReader.getSequenceCount();
mpsoc::printRxPacket(spReader);
return returnvalue::OK;
}
ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t requestBytes,
size_t* readBytes) {
ReturnValue_t PlocMpsocSpecialComHelper::tryReceiveNextReply() {
ReturnValue_t result = returnvalue::OK;
result = comInterface.readSerialInterface();
if (result != returnvalue::OK) {
@ -518,11 +498,5 @@ ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t requestBy
static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
return returnvalue::FAILED;
}
result = comInterface.parseAndRetrieveNextPacket();
if (result == MpsocCommunication::PACKET_RECEIVED) {
auto& spReader = comInterface.getSpReader();
// Maybe unnecessary copy, but the easiest way to get this done for now..
std::memcpy(data, spReader.getFullData(), spReader.getFullPacketLen());
}
return result;
return comInterface.parseAndRetrieveNextPacket();
}

View File

@ -10,6 +10,7 @@
#include "fsfw/osal/linux/BinarySemaphore.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "linux/payload/MpsocCommunication.h"
#ifdef XIPHOS_Q7S
@ -113,7 +114,8 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
/**
* @brief Sets the sequence count object responsible for the sequence count handling
*/
void setSequenceCount(SourceSequenceCounter* sequenceCount_);
void setCommandSequenceCount(uint16_t sequenceCount_);
uint16_t getCommandSequenceCount() const;
private:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER;
@ -169,8 +171,9 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
// CookieIF* comCookie = nullptr;
MpsocCommunication& comInterface;
// Sequence count, must be set by Ploc MPSoC Handler
SourceSequenceCounter* sequenceCount = nullptr;
ploc::SpTmReader spReader;
// ploc::SpTmReader spReader;
uint16_t rxSequenceCount = 0;
SourceSequenceCounter txSequenceCount = 0;
void resetHelper();
ReturnValue_t performFlashWrite();
@ -182,13 +185,13 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
size_t expectedReadLen);
ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen);
ReturnValue_t sendCommand(ploc::SpTcBase& tc);
ReturnValue_t receive(uint8_t* data, size_t requestBytes, size_t* readBytes);
ReturnValue_t tryReceiveNextReply();
ReturnValue_t handleAck();
ReturnValue_t handleExe();
ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile);
ReturnValue_t fileCheck(std::string obcFile);
void handleAckApidFailure(const ploc::SpTmReader& reader);
void handleExeFailure();
void handleAckApidFailure(const SpacePacketReader& reader);
void handleExeFailure(const SpacePacketReader& reader);
ReturnValue_t handleTmReception();
ReturnValue_t checkReceivedTm();
};

View File

@ -1,5 +1,8 @@
#include "plocMpsocHelpers.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "mission/payload/plocSpBase.h"
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
}
@ -97,3 +100,19 @@ std::string mpsoc::getStatusString(uint16_t status) {
}
return "";
}
void mpsoc::printRxPacket(const SpacePacketReader& spReader) {
if (mpsoc::MPSOC_RX_WIRETAPPING) {
sif::debug << "RECV MPSOC packet. APID 0x" << std::hex << std::setw(3) << spReader.getApid()
<< std::dec << " Size " << spReader.getFullPacketLen() << " SSC "
<< spReader.getSequenceCount() << std::endl;
}
}
void mpsoc::printTxPacket(const ploc::SpTcBase& tcBase) {
if (mpsoc::MPSOC_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet. APID 0x" << std::hex << std::setw(3) << tcBase.getApid()
<< " Size " << std::dec << tcBase.getFullPacketLen() << " SSC "
<< tcBase.getSeqCount() << std::endl;
}
}

View File

@ -14,6 +14,51 @@
namespace mpsoc {
static constexpr size_t CRC_SIZE = 2;
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public ploc::SpTcBase {
public:
virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = CRC_SIZE;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
spParams.setFullPayloadLen(INIT_LENGTH);
}
/**
* @brief Function to finsh and write the space packet. It is expected that the user has
* set the payload fields in the child class*
* @return returnvalue::OK if packet creation was successful, otherwise error return value
*/
ReturnValue_t finishPacket() {
updateSpFields();
ReturnValue_t res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
}
};
void printRxPacket(const SpacePacketReader& spReader);
void printTxPacket(const ploc::SpTcBase& tcBase);
static constexpr bool MPSOC_TX_WIRETAPPING = true;
static constexpr bool MPSOC_RX_WIRETAPPING = true;
static constexpr uint32_t DEFAULT_CMD_TIMEOUT_MS = 5000;
static constexpr uint32_t CMD_TIMEOUT_MKFS = 15000;
@ -236,8 +281,6 @@ static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
static const uint8_t STATUS_OFFSET = 10;
static constexpr size_t CRC_SIZE = 2;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
@ -310,47 +353,10 @@ static const uint16_t RESERVED_3 = 0x5F3;
static const uint16_t RESERVED_4 = 0x5F4;
} // namespace statusCode
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public ploc::SpTcBase {
public:
virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = CRC_SIZE;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
spParams.setFullPayloadLen(INIT_LENGTH);
}
/**
* @brief Function to finsh and write the space packet. It is expected that the user has
* set the payload fields in the child class*
* @return returnvalue::OK if packet creation was successful, otherwise error return value
*/
ReturnValue_t finishPacket() {
updateSpFields();
ReturnValue_t res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
}
};
/**
* @brief This class helps to build the memory read command for the PLOC.
*/
class TcMemRead : public TcBase {
class TcMemRead : public mpsoc::TcBase {
public:
/**
* @brief Constructor
@ -400,7 +406,7 @@ class TcMemRead : public TcBase {
* @brief This class helps to generate the space packet to write data to a memory address within
* the PLOC.
*/
class TcMemWrite : public TcBase {
class TcMemWrite : public mpsoc::TcBase {
public:
/**
* @brief Constructor
@ -450,7 +456,7 @@ class TcMemWrite : public TcBase {
/**
* @brief Class to help creation of flash fopen command.
*/
class TcFlashFopen : public TcBase {
class TcFlashFopen : public mpsoc::TcBase {
public:
TcFlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}