adaptions for enum renaming

This commit is contained in:
Robin Müller 2022-09-15 18:44:00 +02:00
parent 7eb63d6d79
commit c38088c64b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 36 additions and 36 deletions

View File

@ -74,9 +74,9 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
return INVALID_PDU_FORMAT; return INVALID_PDU_FORMAT;
} }
// The CFDP distributor should have taken care of ensuring the destination ID is correct // The CFDP distributor should have taken care of ensuring the destination ID is correct
PduTypes type = reader.getPduType(); PduType type = reader.getPduType();
// Only the destination handler can process these PDUs // Only the destination handler can process these PDUs
if (type == PduTypes::FILE_DATA) { if (type == PduType::FILE_DATA) {
// Disable auto-deletion of packet // Disable auto-deletion of packet
accessorPair.second.release(); accessorPair.second.release();
PacketInfo info(type, msg.getStorageId()); PacketInfo info(type, msg.getStorageId());
@ -96,7 +96,7 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
if (not FileDirectiveReader::checkFileDirective(pduDataField[0])) { if (not FileDirectiveReader::checkFileDirective(pduDataField[0])) {
return INVALID_DIRECTIVE_FIELD; return INVALID_DIRECTIVE_FIELD;
} }
auto directive = static_cast<FileDirectives>(pduDataField[0]); auto directive = static_cast<FileDirective>(pduDataField[0]);
auto passToDestHandler = [&]() { auto passToDestHandler = [&]() {
accessorPair.second.release(); accessorPair.second.release();
@ -106,27 +106,27 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
auto passToSourceHandler = [&]() { auto passToSourceHandler = [&]() {
}; };
if (directive == FileDirectives::METADATA or directive == FileDirectives::EOF_DIRECTIVE or if (directive == FileDirective::METADATA or directive == FileDirective::EOF_DIRECTIVE or
directive == FileDirectives::PROMPT) { directive == FileDirective::PROMPT) {
// Section b) of 4.5.3: These PDUs should always be targeted towards the file receiver a.k.a. // Section b) of 4.5.3: These PDUs should always be targeted towards the file receiver a.k.a.
// the destination handler // the destination handler
passToDestHandler(); passToDestHandler();
} else if (directive == FileDirectives::FINISH or directive == FileDirectives::NAK or } else if (directive == FileDirective::FINISH or directive == FileDirective::NAK or
directive == FileDirectives::KEEP_ALIVE) { directive == FileDirective::KEEP_ALIVE) {
// Section c) of 4.5.3: These PDUs should always be targeted towards the file sender a.k.a. // Section c) of 4.5.3: These PDUs should always be targeted towards the file sender a.k.a.
// the source handler // the source handler
passToSourceHandler(); passToSourceHandler();
} else if (directive == FileDirectives::ACK) { } else if (directive == FileDirective::ACK) {
// Section a): Recipient depends of the type of PDU that is being acknowledged. We can simply // Section a): Recipient depends of the type of PDU that is being acknowledged. We can simply
// extract the PDU type from the raw stream. If it is an EOF PDU, this packet is passed to // extract the PDU type from the raw stream. If it is an EOF PDU, this packet is passed to
// the source handler, for a Finished PDU, it is passed to the destination handler. // the source handler, for a Finished PDU, it is passed to the destination handler.
FileDirectives ackedDirective; FileDirective ackedDirective;
if (not AckPduReader::checkAckedDirectiveField(pduDataField[1], ackedDirective)) { if (not AckPduReader::checkAckedDirectiveField(pduDataField[1], ackedDirective)) {
return INVALID_ACK_DIRECTIVE_FIELDS; return INVALID_ACK_DIRECTIVE_FIELDS;
} }
if (ackedDirective == FileDirectives::EOF_DIRECTIVE) { if (ackedDirective == FileDirective::EOF_DIRECTIVE) {
passToSourceHandler(); passToSourceHandler();
} else if (ackedDirective == FileDirectives::FINISH) { } else if (ackedDirective == FileDirective::FINISH) {
passToDestHandler(); passToDestHandler();
} }
} }

View File

@ -29,8 +29,8 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
fsmRes.resetOfIteration(); fsmRes.resetOfIteration();
if (fsmRes.step == TransactionStep::IDLE) { if (fsmRes.step == TransactionStep::IDLE) {
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and if (infoIter->pduType == PduType::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::METADATA) { infoIter->directiveType == FileDirective::METADATA) {
result = handleMetadataPdu(*infoIter); result = handleMetadataPdu(*infoIter);
checkAndHandleError(result, errorIdx); checkAndHandleError(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
@ -57,13 +57,13 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
if (infoIter->pduType == PduTypes::FILE_DATA) { if (infoIter->pduType == PduType::FILE_DATA) {
result = handleFileDataPdu(*infoIter); result = handleFileDataPdu(*infoIter);
checkAndHandleError(result, errorIdx); checkAndHandleError(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++);
} else if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and } else if (infoIter->pduType == PduType::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { infoIter->directiveType == FileDirective::EOF_DIRECTIVE) {
// TODO: Support for check timer missing // TODO: Support for check timer missing
result = handleEofPdu(*infoIter); result = handleEofPdu(*infoIter);
checkAndHandleError(result, errorIdx); checkAndHandleError(result, errorIdx);
@ -206,7 +206,7 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) {
return result; return result;
} }
// TODO: Error handling // TODO: Error handling
if (eofInfo.getConditionCode() == ConditionCodes::NO_ERROR) { if (eofInfo.getConditionCode() == ConditionCode::NO_ERROR) {
tp.crc = eofInfo.getChecksum(); tp.crc = eofInfo.getChecksum();
uint64_t fileSizeFromEof = eofInfo.getFileSize().value(); uint64_t fileSizeFromEof = eofInfo.getFileSize().value();
// CFDP 4.6.1.2.9: Declare file size error if progress exceeds file size // CFDP 4.6.1.2.9: Declare file size error if progress exceeds file size
@ -272,9 +272,9 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met
} }
ReturnValue_t result = OK; ReturnValue_t result = OK;
fsmRes.step = TransactionStep::TRANSACTION_START; fsmRes.step = TransactionStep::TRANSACTION_START;
if (reader.getTransmissionMode() == TransmissionModes::UNACKNOWLEDGED) { if (reader.getTransmissionMode() == TransmissionMode::UNACKNOWLEDGED) {
fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED; fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED;
} else if (reader.getTransmissionMode() == TransmissionModes::ACKNOWLEDGED) { } else if (reader.getTransmissionMode() == TransmissionMode::ACKNOWLEDGED) {
fsmRes.state = CfdpStates::BUSY_CLASS_2_ACKED; fsmRes.state = CfdpStates::BUSY_CLASS_2_ACKED;
} }
tp.checksumType = info.getChecksumType(); tp.checksumType = info.getChecksumType();
@ -339,13 +339,13 @@ cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return fsmRes.state;
ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { ReturnValue_t cfdp::DestHandler::handleTransferCompletion() {
ReturnValue_t result; ReturnValue_t result;
if (tp.checksumType != ChecksumTypes::NULL_CHECKSUM) { if (tp.checksumType != ChecksumType::NULL_CHECKSUM) {
result = checksumVerification(); result = checksumVerification();
if (result != OK) { if (result != OK) {
// TODO: Warning / error handling? // TODO: Warning / error handling?
} }
} else { } else {
tp.conditionCode = ConditionCodes::NO_ERROR; tp.conditionCode = ConditionCode::NO_ERROR;
} }
result = noticeOfCompletion(); result = noticeOfCompletion();
if (result != OK) { if (result != OK) {
@ -398,14 +398,14 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() {
uint32_t value = crcCalc.value(); uint32_t value = crcCalc.value();
if (value == tp.crc) { if (value == tp.crc) {
tp.conditionCode = ConditionCodes::NO_ERROR; tp.conditionCode = ConditionCode::NO_ERROR;
tp.deliveryCode = FileDeliveryCode::DATA_COMPLETE; tp.deliveryCode = FileDeliveryCode::DATA_COMPLETE;
} else { } else {
// TODO: Proper error handling // TODO: Proper error handling
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CRC check for file " << tp.destName.data() << " failed" << std::endl; sif::warning << "CRC check for file " << tp.destName.data() << " failed" << std::endl;
#endif #endif
tp.conditionCode = ConditionCodes::FILE_CHECKSUM_FAILURE; tp.conditionCode = ConditionCode::FILE_CHECKSUM_FAILURE;
} }
return OK; return OK;
} }

View File

@ -21,12 +21,12 @@
namespace cfdp { namespace cfdp {
struct PacketInfo { struct PacketInfo {
PacketInfo(PduTypes type, store_address_t storeId, PacketInfo(PduType type, store_address_t storeId,
std::optional<FileDirectives> directive = std::nullopt) std::optional<FileDirective> directive = std::nullopt)
: pduType(type), directiveType(directive), storeId(storeId) {} : pduType(type), directiveType(directive), storeId(storeId) {}
PduTypes pduType = PduTypes::FILE_DATA; PduType pduType = PduType::FILE_DATA;
std::optional<FileDirectives> directiveType = FileDirectives::INVALID_DIRECTIVE; std::optional<FileDirective> directiveType = FileDirective::INVALID_DIRECTIVE;
store_address_t storeId = store_address_t::invalid(); store_address_t storeId = store_address_t::invalid();
PacketInfo() = default; PacketInfo() = default;
}; };
@ -150,24 +150,24 @@ class DestHandler {
std::fill(sourceName.begin(), sourceName.end(), '\0'); std::fill(sourceName.begin(), sourceName.end(), '\0');
std::fill(destName.begin(), destName.end(), '\0'); std::fill(destName.begin(), destName.end(), '\0');
fileSize.setFileSize(0, false); fileSize.setFileSize(0, false);
conditionCode = ConditionCodes::NO_ERROR; conditionCode = ConditionCode::NO_ERROR;
deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; deliveryCode = FileDeliveryCode::DATA_INCOMPLETE;
deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY;
crc = 0; crc = 0;
progress = 0; progress = 0;
remoteCfg = nullptr; remoteCfg = nullptr;
closureRequested = false; closureRequested = false;
checksumType = ChecksumTypes::NULL_CHECKSUM; checksumType = ChecksumType::NULL_CHECKSUM;
} }
ChecksumTypes checksumType = ChecksumTypes::NULL_CHECKSUM; ChecksumType checksumType = ChecksumType::NULL_CHECKSUM;
bool closureRequested = false; bool closureRequested = false;
std::vector<char> sourceName; std::vector<char> sourceName;
std::vector<char> destName; std::vector<char> destName;
cfdp::FileSize fileSize; cfdp::FileSize fileSize;
TransactionId transactionId; TransactionId transactionId;
PduConfig pduConf; PduConfig pduConf;
ConditionCodes conditionCode = ConditionCodes::NO_ERROR; ConditionCode conditionCode = ConditionCode::NO_ERROR;
FileDeliveryCode deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; FileDeliveryCode deliveryCode = FileDeliveryCode::DATA_INCOMPLETE;
FileDeliveryStatus deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; FileDeliveryStatus deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY;
uint32_t crc = 0; uint32_t crc = 0;

View File

@ -50,7 +50,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
auto destHandler = DestHandler(dp, fp); auto destHandler = DestHandler(dp, fp);
CHECK(destHandler.initialize() == OK); CHECK(destHandler.initialize() == OK);
auto metadataPreparation = [&](FileSize cfdpFileSize, ChecksumTypes checksumType) { auto metadataPreparation = [&](FileSize cfdpFileSize, ChecksumType checksumType) {
std::string srcNameString = "hello.txt"; std::string srcNameString = "hello.txt";
std::string destNameString = "hello-cpy.txt"; std::string destNameString = "hello-cpy.txt";
StringLv srcName(srcNameString); StringLv srcName(srcNameString);
@ -59,7 +59,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(1)); TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(1));
conf.sourceId = remoteId; conf.sourceId = remoteId;
conf.destId = localId; conf.destId = localId;
conf.mode = TransmissionModes::UNACKNOWLEDGED; conf.mode = TransmissionMode::UNACKNOWLEDGED;
conf.seqNum = seqNum; conf.seqNum = seqNum;
MetadataPduCreator metadataCreator(conf, info); MetadataPduCreator metadataCreator(conf, info);
REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &buf) == OK); REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &buf) == OK);
@ -146,7 +146,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
const DestHandler::FsmResult& res = destHandler.performStateMachine(); const DestHandler::FsmResult& res = destHandler.performStateMachine();
CHECK(res.result == OK); CHECK(res.result == OK);
FileSize cfdpFileSize(0); FileSize cfdpFileSize(0);
metadataPreparation(cfdpFileSize, ChecksumTypes::NULL_CHECKSUM); metadataPreparation(cfdpFileSize, ChecksumType::NULL_CHECKSUM);
destHandler.performStateMachine(); destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", 0); metadataCheck(res, "hello.txt", "hello-cpy.txt", 0);
destHandler.performStateMachine(); destHandler.performStateMachine();
@ -166,7 +166,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
crcCalc.add(fileData.begin(), fileData.end()); crcCalc.add(fileData.begin(), fileData.end());
uint32_t crc32 = crcCalc.value(); uint32_t crc32 = crcCalc.value();
FileSize cfdpFileSize(fileData.size()); FileSize cfdpFileSize(fileData.size());
metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); metadataPreparation(cfdpFileSize, ChecksumType::CRC_32);
destHandler.performStateMachine(); destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", fileData.size()); metadataCheck(res, "hello.txt", "hello-cpy.txt", fileData.size());
destHandler.performStateMachine(); destHandler.performStateMachine();
@ -202,7 +202,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
crcCalc.add(largerFileData.begin(), largerFileData.end()); crcCalc.add(largerFileData.begin(), largerFileData.end());
uint32_t crc32 = crcCalc.value(); uint32_t crc32 = crcCalc.value();
FileSize cfdpFileSize(largerFileData.size()); FileSize cfdpFileSize(largerFileData.size());
metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); metadataPreparation(cfdpFileSize, ChecksumType::CRC_32);
destHandler.performStateMachine(); destHandler.performStateMachine();
metadataCheck(res, "hello.txt", "hello-cpy.txt", largerFileData.size()); metadataCheck(res, "hello.txt", "hello-cpy.txt", largerFileData.size());
destHandler.performStateMachine(); destHandler.performStateMachine();