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

@ -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;
}