update helper wip

This commit is contained in:
Jakob Meier 2022-04-07 11:00:07 +02:00
parent f058cf5e31
commit c0fd9aee6f
3 changed files with 39 additions and 75 deletions

View File

@ -30,6 +30,7 @@ enum commonClassIds: uint8_t {
NVM_PARAM_BASE, //NVMB
FILE_SYSTEM_HELPER, //FSHLP
PLOC_MPSOC_HELPER, // PLMPHLP
PLOC_SUPV_HELPER, // PLSPVHLP
SA_DEPL_HANDLER, //SADPL
MPSOC_RETURN_VALUES_IF, //MPSOCRTVIF
COMMON_CLASS_ID_END // [EXPORT] : [END]

View File

@ -34,12 +34,12 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
semaphore.acquire();
break;
}
case InternalState::FLASH_WRITE: {
case InternalState::UPDATE: {
result = performUpdate();
if (result == RETURN_OK) {
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL);
triggerEvent(SUPV_UPDATE_SUCCESSFUL);
} else {
triggerEvent(MPSOC_FLASH_WRITE_FAILED);
triggerEvent(SUPV_UPDATE_FAILED);
}
internalState = InternalState::IDLE;
break;
@ -62,45 +62,20 @@ ReturnValue_t PlocSupvHelper::setComIF(DeviceCommunicationIF* communicationInter
void PlocSupvHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
void PlocSupvHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
sequenceCount = sequenceCount_;
}
ReturnValue_t PlocSupvHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
uint32_t startAddress) {
ReturnValue_t result = RETURN_OK;
#ifdef XIPHOS_Q7S
result = FilesystemHelper::checkPath(obcFile);
if (result != RETURN_OK) {
return result;
}
result = FilesystemHelper::fileExists(mpsocFile);
result = FilesystemHelper::checkPath(file);
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::startUpdate: File " << file << " does not exists" << std::endl;
return result;
}
#endif
#ifdef TE0720_1CFA
if (not std::filesystem::exists(obcFile)) {
sif::warning << "PlocSupvHelper::startFlashWrite: File " << obcFile << "does not exist"
<< std::endl;
return RETURN_FAILED;
}
#endif
flashWrite.obcFile = obcFile;
flashWrite.mpsocFile = mpsocFile;
internalState = InternalState::FLASH_WRITE;
result = resetHelper();
if (result != RETURN_OK) {
return result;
}
return result;
}
ReturnValue_t PlocSupvHelper::resetHelper() {
ReturnValue_t result = RETURN_OK;
semaphore.release();
terminate = false;
result = uartComIF->flushUartRxBuffer(comCookie);
update.file = file;
update.memoryId = memoryId;
update.startAddress = startAddress;
internalState = InternalState::UPDATE;
return result;
}
@ -244,11 +219,11 @@ ReturnValue_t PlocSupvHelper::handleExe() {
void PlocSupvHelper::handleExeApidFailure(uint16_t apid) {
if (apid == supv::apid::EXE_FAILURE) {
triggerEvent(EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
triggerEvent(SUPV_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleExeApidFailure: Received execution failure "
<< "report" << std::endl;
} else {
triggerEvent(EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
triggerEvent(SUPV_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleExeApidFailure: Expected execution report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}

View File

@ -8,7 +8,6 @@
#include "fsfw/osal/linux/BinarySemaphore.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#ifdef XIPHOS_Q7S
@ -44,29 +43,25 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
//! [EXPORT] : [COMMENT] Did not receive acknowledgement report
//! P1: Number of bytes missing
//! P2: Internal state of MPSoC helper
static const Event MISSING_ACK = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Did not receive execution report
static const Event SUPV_MISSING_ACK = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor did not receive execution report
//! P1: Number of bytes missing
//! P2: Internal state of MPSoC helper
static const Event MISSING_EXE = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Received acknowledgement failure report
//! P1: Internal state of MPSoC
static const Event ACK_FAILURE_REPORT = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Received execution failure report
//! P1: Internal state of MPSoC
static const Event EXE_FAILURE_REPORT = MAKE_EVENT(8, severity::LOW);
//! [EXPORT] : [COMMENT] Expected acknowledgement report but received space packet with other apid
//! P2: Internal state of supervisor helper
static const Event SUPV_MISSING_EXE = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report
//! P1: Internal state of supervisor helper
static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received execution failure report
//! P1: Internal state of supervisor
static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(8, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with other apid
//! P1: Apid of received space packet
//! P2: Internal state of MPSoC
static const Event ACK_INVALID_APID = MAKE_EVENT(9, severity::LOW);
//! [EXPORT] : [COMMENT] Expected execution report but received space packet with other apid
//! P2: Internal state of supervisor helper
static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(9, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor helper expected execution report but received space packet with other apid
//! P1: Apid of received space packet
//! P2: Internal state of MPSoC
static const Event EXE_INVALID_APID = MAKE_EVENT(10, severity::LOW);
//! [EXPORT] : [COMMENT] Received sequence count does not match expected sequence count
//! P1: Expected sequence count
//! P2: Received sequence count
static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW);
//! P2: Internal state of supervisor helper
static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(10, severity::LOW);
PlocSupvHelper(object_id_t objectId);
virtual ~PlocSupvHelper();
@ -78,27 +73,23 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
void setComCookie(CookieIF* comCookie_);
/**
* @brief Starts flash write sequence
* @brief Starts update procedure
*
* @param obcFile File where to read from the data
* @param mpsocFile The file of the MPSoC where should be written to
* @param file File containing the update data
* @param memoryId ID of the memory where to write to
* @param startAddress Address where to write data
*
* @return RETURN_OK if successful, otherwise error return value
*/
ReturnValue_t startUpdate(std::string file, std::string mpsocFile);
ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress);
/**
* @brief Can be used to interrupt a running data transfer.
*/
void stopProcess();
/**
* @brief Sets the sequence count object responsible for the sequence count handling
*/
void setSequenceCount(SourceSequenceCounter* sequenceCount_);
private:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER;
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPV_HELPER;
//! [EXPORT] : [COMMENT] File accidentally close
static const ReturnValue_t FILE_CLOSED_ACCIDENTALLY = MAKE_RETURN_CODE(0xA0);
@ -110,7 +101,6 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
struct Update {
uint8_t memoryId;
uint32_t startAddress;
uint32_t length;
// Absolute name of file containing update data
std::string file;
};
@ -130,14 +120,11 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
bool terminate = false;
/**
* Communication interface of MPSoC responsible for low level access. Must be set by the
* MPSoC Handler.
* Communication interface responsible for data transactions between OBC and Supervisor.
*/
UartComIF* uartComIF = nullptr;
// Communication cookie. Must be set by the MPSoC Handler
// Communication cookie. Must be set by the supervisor Handler
CookieIF* comCookie = nullptr;
// Sequence count, must be set by Ploc MPSoC Handler
SourceSequenceCounter* sequenceCount;
ReturnValue_t performUpdate();
ReturnValue_t handlePacketTransmission(SpacePacket& tc);
@ -148,6 +135,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
void handleAckApidFailure(uint16_t apid);
void handleExeApidFailure(uint16_t apid);
ReturnValue_t handleTmReception(SpacePacket* tmPacket, size_t remainingBytes);
ReturnValue_t eraseMemory();
};
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */