basic dest handler framework almost complete

This commit is contained in:
Robin Müller 2022-09-02 18:03:52 +02:00
parent 108e7737e2
commit 3147f67fbd
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 31 additions and 1 deletions

View File

@ -72,10 +72,14 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() {
} }
} }
if (step == TransactionStep::TRANSFER_COMPLETION) { if (step == TransactionStep::TRANSFER_COMPLETION) {
result = handleTransferCompletion();
if (result != OK) {
status = result;
}
} }
if (step == TransactionStep::SENDING_FINISHED_PDU) { if (step == TransactionStep::SENDING_FINISHED_PDU) {
} }
return OK; return status;
} }
if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) {
// TODO: Will be implemented at a later stage // TODO: Will be implemented at a later stage
@ -200,6 +204,13 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) {
} }
tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt);
} }
if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) {
step = TransactionStep::TRANSFER_COMPLETION;
} else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) {
step = TransactionStep::SENDING_ACK_PDU;
}
}
return returnvalue::OK; return returnvalue::OK;
} }
@ -287,3 +298,20 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met
} }
cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; } cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; }
ReturnValue_t cfdp::DestHandler::handleTransferCompletion() {
// TODO: Checksum verification and notice of completion
if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) {
if (tp.closureRequested) {
step = TransactionStep::SENDING_FINISHED_PDU;
} else {
finish();
}
} else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) {
step = TransactionStep::SENDING_FINISHED_PDU;
}
}
void cfdp::DestHandler::finish() {
// TODO: Clear PDU list, reset state to be ready for next transfer
}

View File

@ -123,6 +123,8 @@ class DestHandler {
ReturnValue_t handleFileDataPdu(const PacketInfo& info); ReturnValue_t handleFileDataPdu(const PacketInfo& info);
ReturnValue_t handleEofPdu(const PacketInfo& info); ReturnValue_t handleEofPdu(const PacketInfo& info);
ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize);
ReturnValue_t handleTransferCompletion();
void finish();
}; };
} // namespace cfdp } // namespace cfdp