Update FSFW from upstream #71

Closed
muellerr wants to merge 1112 commits from development into eive/develop
3 changed files with 18 additions and 20 deletions
Showing only changes of commit 67439b4285 - Show all commits

View File

@ -32,10 +32,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
if (infoIter->pduType == PduType::FILE_DIRECTIVE and if (infoIter->pduType == PduType::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::METADATA) { infoIter->directiveType == FileDirectives::METADATA) {
result = handleMetadataPdu(*infoIter); result = handleMetadataPdu(*infoIter);
if (result != OK and errorIdx < 3) { checkAndHandleError(result, errorIdx);
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
// Store data was deleted in PDU handler because a store guard is used // Store data was deleted in PDU handler because a store guard is used
dp.packetListRef.erase(infoIter++); dp.packetListRef.erase(infoIter++);
} }
@ -61,10 +58,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
if (infoIter->pduType == PduType::FILE_DATA) { if (infoIter->pduType == PduType::FILE_DATA) {
result = handleFileDataPdu(*infoIter); result = handleFileDataPdu(*infoIter);
if (result != OK and errorIdx < 3) { checkAndHandleError(result, errorIdx);
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
// Store data was deleted in PDU handler because a store guard is used // Store data was deleted in PDU handler because a store guard is used
dp.packetListRef.erase(infoIter++); dp.packetListRef.erase(infoIter++);
} }
@ -72,10 +66,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
if (infoIter->pduType == PduType::FILE_DIRECTIVE and if (infoIter->pduType == PduType::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) {
result = handleEofPdu(*infoIter); result = handleEofPdu(*infoIter);
if (result != OK and errorIdx < 3) { checkAndHandleError(result, errorIdx);
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
// Store data was deleted in PDU handler because a store guard is used // Store data was deleted in PDU handler because a store guard is used
dp.packetListRef.erase(infoIter++); dp.packetListRef.erase(infoIter++);
} }
@ -84,17 +75,11 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
} }
if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) { if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) {
result = handleTransferCompletion(); result = handleTransferCompletion();
if (result != OK and errorIdx < 3) { checkAndHandleError(result, errorIdx);
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
} }
if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) { if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) {
result = sendFinishedPdu(); result = sendFinishedPdu();
if (result != OK and errorIdx < 3) { checkAndHandleError(result, errorIdx);
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
finish(); finish();
} }
return updateFsmRes(errorIdx); return updateFsmRes(errorIdx);
@ -457,3 +442,10 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t erro
} }
const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; } const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; }
void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx) {
if (result != OK and errorIdx < 3) {
fsmRes.errorCodes[errorIdx] = result;
errorIdx++;
}
}

View File

@ -180,6 +180,7 @@ class DestHandler {
ReturnValue_t noticeOfCompletion(); ReturnValue_t noticeOfCompletion();
ReturnValue_t checksumVerification(); ReturnValue_t checksumVerification();
const FsmResult& updateFsmRes(uint8_t errors); const FsmResult& updateFsmRes(uint8_t errors);
void checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx);
void finish(); void finish();
}; };

View File

@ -168,6 +168,11 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt);
packetInfoList.push_back(packetInfo); packetInfoList.push_back(packetInfo);
destHandler.performStateMachine(); destHandler.performStateMachine();
REQUIRE(res.result == OK);
REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED);
REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS);
REQUIRE(not tcStore.hasDataAtId(storeId));
REQUIRE(packetInfoList.empty());
eofPreparation(cfdpFileSize, crc32); eofPreparation(cfdpFileSize, crc32);
// After EOF, operation is done because no closure was requested // After EOF, operation is done because no closure was requested
destHandler.performStateMachine(); destHandler.performStateMachine();