v1.10.0 #220

Merged
meierj merged 592 commits from develop into main 2022-04-22 07:42:20 +02:00
7 changed files with 73 additions and 34 deletions
Showing only changes of commit 45c7f9555d - Show all commits

View File

@ -58,6 +58,22 @@ EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
return result;
}
void PlocMPSoCHandler::performOperationHook() {
EventMessage event;
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
result == RETURN_OK; result = eventQueue->receiveMessage(&event)) {
switch (event.getMessageId()) {
case EventMessage::EVENT_MESSAGE:
handleEvent(&event);
break;
default:
sif::debug << "PlocMPSoCHandler::performOperationHook: Did not subscribe to this event"
<< " message" << std::endl;
break;
}
}
}
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
ReturnValue_t result = RETURN_OK;
@ -234,6 +250,20 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc
return HasReturnvaluesIF::RETURN_OK;
}
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
object_id_t objectId = eventMessage->getReporter();
switch(objectId){
case objects::PLOC_MPSOC_HELPER: {
plocMPSoCHelperExecuting = false;
break;
}
default:
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event"
<< std::endl;
break;
}
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
@ -553,21 +583,16 @@ void PlocMPSoCHandler::disableAllReplies() {
}
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
return;
}
DeviceCommandInfo* info = &(iter->second.command->second);
if (info == nullptr) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl;
return;
}
if (info->sendReplyTo != NO_COMMANDER) {
actionHelper.finish(false, info->sendReplyTo, iter->first, status);
}
@ -592,6 +617,6 @@ ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) {
<< expectedSeqCnt << std::endl;
triggerEvent(SEQ_CNT_MISMATCH, expectedSeqCnt, receivedSeqCnt);
}
sequenceCount.set(receivedSeqCnt);
sequenceCount.reset(receivedSeqCnt);
return RETURN_OK;
}

View File

@ -2,9 +2,9 @@
#define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "devicedefinitions/PlocMPSoCDefinitions.h"
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "MPSoCSequenceCount.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "PlocMPSoCHelper.h"
#include <cstring>
@ -47,6 +47,7 @@ public:
virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
void performOperationHook() override;
protected:
void doStartUp() override;
@ -88,7 +89,7 @@ private:
static const uint16_t APID_MASK = 0x7FF;
MPSoCSequenceCount sequenceCount;
SourceSequenceCounter sequenceCount;
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
@ -106,6 +107,11 @@ private:
// Used to block incoming commands when MPSoC helper class is currently executing a command
bool plocMPSoCHelperExecuting = false;
/**
* @brief Handles events received from the PLOC MPSoC helper
*/
void handleEvent(EventMessage* eventMessage);
ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen);
ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen);
ReturnValue_t prepareFlashFopenCmd(const uint8_t * commandData, size_t commandDataLen);

View File

@ -1,5 +1,6 @@
#include "PlocMPSoCHelper.h"
#include "mission/utility/Timestamp.h"
#include "bsp_q7s/memory/FileSystemHelper.h"
#include <fstream>
#include <filesystem>
@ -59,7 +60,7 @@ void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) {
comCookie = comCookie_;
}
void PlocMPSoCHelper::setSequenceCount(MPSoCSequenceCount* sequenceCount_) {
void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
sequenceCount = sequenceCount_;
}
@ -89,11 +90,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
// Set position of next character to end of file input stream
file.seekg(0, file.end);
// tellg returns position of character in input stream
imageSize = file.tellg();
size_t imageSize = file.tellg();
sequenceCount->increment();
mpsoc::FlashWrite tc(sequenceCount->get());
result = sendCommand(tc);
if (result != REUTRN_OK) {
result = sendCommand(&tc);
if (result != RETURN_OK) {
return result;
}
result = handleAck();
@ -107,12 +108,12 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
return result;
}
ReturnValue_t PlocMPSoCHelper::sendCommand(TcBase* tc) {
ReturnValue_t PlocMPSoCHelper::sendCommand(mpsoc::TcBase* tc) {
ReturnValue_t result = RETURN_OK;
result = uartComIF->sendMessage(comCookie, tc->getWholeData(), tc->getFullSize());
if (result != RETURN_OK) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
triggerEvent(SENDING_COMMAND_FAILED, result, internalState);
triggerEvent(SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
return result;
}
return result;
@ -121,7 +122,7 @@ ReturnValue_t PlocMPSoCHelper::sendCommand(TcBase* tc) {
ReturnValue_t PlocMPSoCHelper::handleAck() {
ReturnValue_t result = RETURN_OK;
mpsoc::TmPacket tmPacket;
result = handleTmReception(tmPacket, mpsoc::SIZE_ACK_REPORT);
result = handleTmReception(&tmPacket, mpsoc::SIZE_ACK_REPORT);
if (result != RETURN_OK) {
return result;
}
@ -135,12 +136,12 @@ ReturnValue_t PlocMPSoCHelper::handleAck() {
void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
if (apid == mpsoc::apid::ACK_FAILURE) {
triggerEvent(ACK_FAILURE_REPORT, internalState);
triggerEvent(ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure "
<< "report" << std::endl;
}
else {
triggerEvent(ACK_INVALID_APID, apid, internalState);
triggerEvent(ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}
@ -149,7 +150,7 @@ void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
ReturnValue_t PlocMPSoCHelper::handleExe() {
ReturnValue_t result = RETURN_OK;
mpsoc::TmPacket tmPacket;
result = handleTmReception(tmPacket, mpsoc::SIZE_EXE_REPORT);
result = handleTmReception(&tmPacket, mpsoc::SIZE_EXE_REPORT);
if (result != RETURN_OK) {
return result;
}
@ -163,21 +164,22 @@ ReturnValue_t PlocMPSoCHelper::handleExe() {
void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) {
if (apid == mpsoc::apid::EXE_FAILURE) {
triggerEvent(EXE_FAILURE_REPORT, internalState);
triggerEvent(EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure "
<< "report" << std::endl;
}
else {
triggerEvent(EXE_INVALID_APID, apid, internalState);
triggerEvent(EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected execution report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}
}
ReturnValue_t PlocMPSoCHelper::handleTmReception(TmPacket* tmPacket, size_t remainingBytes) {
ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes) {
ReturnValue_t result = RETURN_OK;
size_t readBytes = 0;
for(int retries = 0; retries < RETRIES; retries++) {
result = receive(tmPacket->getWholeData(), readBytes, remainingBytes);
result = receive(tmPacket->getWholeData(), &readBytes, remainingBytes);
if (result != RETURN_OK) {
return result;
}
@ -188,7 +190,7 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(TmPacket* tmPacket, size_t rema
}
if (remainingBytes != 0) {
sif::warning << "PlocMPSoCHelper::handleTmReception: Failed to receive reply" << std::endl;
triggerEvent(MISSING_EXE, remainingBytes, internalState);
triggerEvent(MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
return RETURN_FAILED;
}
result = tmPacket->checkCrc();
@ -196,6 +198,7 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(TmPacket* tmPacket, size_t rema
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl;
return result;
}
return result;
}
ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) {
@ -203,13 +206,16 @@ ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t
result = uartComIF->requestReceiveMessage(comCookie, requestBytes);
if (result != RETURN_OK) {
sif::warning << "PlocMPSoCHelper::receive: Failed to request reply" << std::endl;
triggerEvent(MPSOC_HELPER_REQUESTING_REPLY_FAILED, result, internalState);
triggerEvent(MPSOC_HELPER_REQUESTING_REPLY_FAILED, result,
static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
return RETURN_FAILED;
}
result = uartComIF->readReceivedMessage(comCookie, &data, readBytes);
if (result != RETURN_OK) {
sif::warning << "PlocMPSoCHelper::receive: Failed to read received message" << std::endl;
triggerEvent(MPSOC_HELPER_READING_REPLY_FAILED, result, internalState);
triggerEvent(MPSOC_HELPER_READING_REPLY_FAILED, result,
static_cast<uint32_t>(internalState));
return RETURN_FAILED;
}
return result;
}

View File

@ -10,7 +10,7 @@
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw/devicehandlers/CookieIF.h"
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "MPSoCSequenceCount.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
/**
* @brief Helper class for MPSoC of PLOC intended to accelerate large data transfers between
@ -37,7 +37,7 @@ public:
//! [EXPORT] : [COMMENT] Reading receive message of communication interface failed
//!P1: Return value returned by the communication interface readingReceivedMessage function
//!P2: Internal state of MPSoC helper
static const Event MPSOC_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW);
static const Event MPSOC_HELPER_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Did not receive acknowledgement report
//!P1: Number of bytes missing
//!P2: Internal state of MPSoC helper
@ -87,7 +87,7 @@ public:
/**
* @brief Sets the sequence count object responsible for the sequence count handling
*/
void setSequenceCount(MPSoCSequenceCount* sequenceCount_);
void setSequenceCount(SourceSequenceCounter* sequenceCount_);
private:
@ -128,16 +128,16 @@ private:
// Communication cookie. Must be set by the MPSoC Handler
CookieIF* comCookie = nullptr;
// Sequence count, must be set by Ploc MPSoC Handler
MPSoCSequenceCount* sequenceCount;
SourceSequenceCounter* sequenceCount;
ReturnValue_t performFlashWrite();
ReturnValue_t sendCommand(TcBase* tc);
ReturnValue_t sendCommand(mpsoc::TcBase* tc);
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
ReturnValue_t handleAck();
ReturnValue_t handleExe();
void handleAckApidFailure(uint16_t apid);
void handleExeApidFailure(uint16_t apid);
ReturnValue_t handleTmReception(TmPacket* tmPacket, size_t remainingBytes);
ReturnValue_t handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes);
};
#endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */

View File

@ -227,7 +227,7 @@ void StarTrackerHandler::performOperationHook() {
handleEvent(&event);
break;
default:
sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message"
sif::debug << "StarTrackerHandler::checkEvents: Did not subscribe to this event message"
<< std::endl;
break;
}

View File

@ -2,4 +2,5 @@ target_sources(${TARGET_NAME} PRIVATE
FileSystemHandler.cpp
SdCardManager.cpp
scratchApi.cpp
FilesystemHelper.cpp
)

View File

@ -91,7 +91,8 @@ enum commonObjects: uint32_t {
PLOC_UPDATER = 0x44330000,
PLOC_MEMORY_DUMPER = 0x44330001,
STR_HELPER = 0x44330002
STR_HELPER = 0x44330002,
PLOC_MPSOC_HELPER = 0x44330003
};
}