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;
}
// 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
if (type == PduTypes::FILE_DATA) {
if (type == PduType::FILE_DATA) {
// Disable auto-deletion of packet
accessorPair.second.release();
PacketInfo info(type, msg.getStorageId());
@ -96,7 +96,7 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
if (not FileDirectiveReader::checkFileDirective(pduDataField[0])) {
return INVALID_DIRECTIVE_FIELD;
}
auto directive = static_cast<FileDirectives>(pduDataField[0]);
auto directive = static_cast<FileDirective>(pduDataField[0]);
auto passToDestHandler = [&]() {
accessorPair.second.release();
@ -106,27 +106,27 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
auto passToSourceHandler = [&]() {
};
if (directive == FileDirectives::METADATA or directive == FileDirectives::EOF_DIRECTIVE or
directive == FileDirectives::PROMPT) {
if (directive == FileDirective::METADATA or directive == FileDirective::EOF_DIRECTIVE or
directive == FileDirective::PROMPT) {
// Section b) of 4.5.3: These PDUs should always be targeted towards the file receiver a.k.a.
// the destination handler
passToDestHandler();
} else if (directive == FileDirectives::FINISH or directive == FileDirectives::NAK or
directive == FileDirectives::KEEP_ALIVE) {
} else if (directive == FileDirective::FINISH or directive == FileDirective::NAK or
directive == FileDirective::KEEP_ALIVE) {
// Section c) of 4.5.3: These PDUs should always be targeted towards the file sender a.k.a.
// the source handler
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
// 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.
FileDirectives ackedDirective;
FileDirective ackedDirective;
if (not AckPduReader::checkAckedDirectiveField(pduDataField[1], ackedDirective)) {
return INVALID_ACK_DIRECTIVE_FIELDS;
}
if (ackedDirective == FileDirectives::EOF_DIRECTIVE) {
if (ackedDirective == FileDirective::EOF_DIRECTIVE) {
passToSourceHandler();
} else if (ackedDirective == FileDirectives::FINISH) {
} else if (ackedDirective == FileDirective::FINISH) {
passToDestHandler();
}
}

View File

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

View File

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

View File

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