CFDP SOURCE handler #157

Merged
muellerr merged 107 commits from cfdp-source-handler into develop 2023-10-19 10:59:55 +02:00
3 changed files with 6 additions and 4 deletions
Showing only changes of commit e4aae75747 - Show all commits

View File

@ -353,8 +353,8 @@ cfdp::CfdpState cfdp::SourceHandler::getState() const { return state; }
cfdp::SourceHandler::TransactionStep cfdp::SourceHandler::getStep() const { return step; } cfdp::SourceHandler::TransactionStep cfdp::SourceHandler::getStep() const { return step; }
void cfdp::SourceHandler::addError(ReturnValue_t error) { void cfdp::SourceHandler::addError(ReturnValue_t error) {
if (errorIndex < fsmResult.errorCodes.size()) { if (fsmResult.errors < fsmResult.errorCodes.size()) {
fsmResult.errorCodes[errorIndex] = error; fsmResult.errorCodes[fsmResult.errors] = error;
errorIndex++; fsmResult.errors++;
} }
} }

View File

@ -92,7 +92,6 @@ class SourceHandler {
std::array<uint8_t, 4096> fileBuf{}; std::array<uint8_t, 4096> fileBuf{};
SourceHandlerParams sourceParams; SourceHandlerParams sourceParams;
cfdp::FsfwParams fsfwParams; cfdp::FsfwParams fsfwParams;
uint8_t errorIndex = 0;
FsmResult fsmResult; FsmResult fsmResult;
FsmResult& fsmNacked(); FsmResult& fsmNacked();

View File

@ -66,6 +66,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
auto onePduSentCheck = [&](SourceHandler::FsmResult& fsmResult, TmTcMessage& tmtcMessage, auto onePduSentCheck = [&](SourceHandler::FsmResult& fsmResult, TmTcMessage& tmtcMessage,
const uint8_t** pduPtr) { const uint8_t** pduPtr) {
CHECK(fsmResult.errors == 0);
CHECK(fsmResult.packetsSent == 1); CHECK(fsmResult.packetsSent == 1);
CHECK(mqMock.numberOfSentMessages() == 1); CHECK(mqMock.numberOfSentMessages() == 1);
REQUIRE(mqMock.getNextSentMessage(destQueueId, tmtcMessage) == OK); REQUIRE(mqMock.getNextSentMessage(destQueueId, tmtcMessage) == OK);
@ -75,6 +76,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
return std::move(accessor); return std::move(accessor);
}; };
auto genericMetadataCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize) { auto genericMetadataCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize) {
CHECK(fsmResult.errors == 0);
TmTcMessage tmtcMessage; TmTcMessage tmtcMessage;
const uint8_t* pduPtr; const uint8_t* pduPtr;
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr); auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
@ -97,6 +99,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
}; };
auto genericEofCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize, auto genericEofCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize,
uint32_t expectedChecksum) { uint32_t expectedChecksum) {
CHECK(fsmResult.errors == 0);
TmTcMessage tmtcMessage; TmTcMessage tmtcMessage;
const uint8_t* pduPtr; const uint8_t* pduPtr;
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr); auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);