LOOKING GOOOD
This commit is contained in:
parent
42c215ef70
commit
9c8434d856
@ -29,6 +29,8 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
|
|||||||
sif::error << "cfdp::SourceHandler: Seq count provider bit width "
|
sif::error << "cfdp::SourceHandler: Seq count provider bit width "
|
||||||
<< sourceParams.seqCountProvider.bitWidth() << " not allowed" << std::endl;
|
<< sourceParams.seqCountProvider.bitWidth() << " not allowed" << std::endl;
|
||||||
#else
|
#else
|
||||||
|
sif::printError("cfdp::SourceHandler: Seq count provider bit width %d not allowed\n",
|
||||||
|
sourceParams.seqCountProvider.bitWidth());
|
||||||
#endif
|
#endif
|
||||||
// Yeah, what am I supposed to do here? Can't throw an exception in the FSFW..
|
// Yeah, what am I supposed to do here? Can't throw an exception in the FSFW..
|
||||||
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE;
|
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE;
|
||||||
@ -70,7 +72,14 @@ cfdp::SourceHandler::FsmResult& cfdp::SourceHandler::fsmNacked() {
|
|||||||
if (result != OK) {
|
if (result != OK) {
|
||||||
// TODO: Error handling
|
// TODO: Error handling
|
||||||
}
|
}
|
||||||
return fsmResult;
|
if (sourceParams.cfg.indicCfg.eofSentIndicRequired) {
|
||||||
|
sourceParams.user.eofSentIndication(transactionParams.id);
|
||||||
|
}
|
||||||
|
if (transactionParams.closureRequested) {
|
||||||
|
step = TransactionStep::WAIT_FOR_FINISH;
|
||||||
|
return fsmResult;
|
||||||
|
}
|
||||||
|
step = TransactionStep::NOTICE_OF_COMPLETION;
|
||||||
}
|
}
|
||||||
if (step == TransactionStep::WAIT_FOR_FINISH) {
|
if (step == TransactionStep::WAIT_FOR_FINISH) {
|
||||||
// TODO: In case this is a request with closure, wait for finish.
|
// TODO: In case this is a request with closure, wait for finish.
|
||||||
@ -78,11 +87,8 @@ cfdp::SourceHandler::FsmResult& cfdp::SourceHandler::fsmNacked() {
|
|||||||
step = TransactionStep::NOTICE_OF_COMPLETION;
|
step = TransactionStep::NOTICE_OF_COMPLETION;
|
||||||
}
|
}
|
||||||
if (step == TransactionStep::NOTICE_OF_COMPLETION) {
|
if (step == TransactionStep::NOTICE_OF_COMPLETION) {
|
||||||
// TODO: Notice of completion
|
noticeOfCompletion();
|
||||||
// We are done, go back to idle state.
|
reset();
|
||||||
// TODO: Possible reset state?
|
|
||||||
step = TransactionStep::IDLE;
|
|
||||||
state = CfdpState::IDLE;
|
|
||||||
}
|
}
|
||||||
return fsmResult;
|
return fsmResult;
|
||||||
}
|
}
|
||||||
@ -98,6 +104,11 @@ cfdp::SourceHandler::FsmResult& cfdp::SourceHandler::stateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t cfdp::SourceHandler::checksumGeneration() {
|
ReturnValue_t cfdp::SourceHandler::checksumGeneration() {
|
||||||
|
if (transactionParams.fileSize.value() == 0) {
|
||||||
|
// NULL checksum for empty file.
|
||||||
|
transactionParams.crc = 0;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
std::array<uint8_t, 1024> buf{};
|
std::array<uint8_t, 1024> buf{};
|
||||||
etl::crc32 crcCalc;
|
etl::crc32 crcCalc;
|
||||||
uint64_t currentOffset = 0;
|
uint64_t currentOffset = 0;
|
||||||
@ -227,14 +238,13 @@ ReturnValue_t cfdp::SourceHandler::prepareAndSendNextFileDataPdu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t cfdp::SourceHandler::prepareAndSendEofPdu() {
|
ReturnValue_t cfdp::SourceHandler::prepareAndSendEofPdu() {
|
||||||
// TODO: Checksum
|
auto eofInfo =
|
||||||
auto eofInfo = EofInfo(ConditionCode::NO_ERROR, 0, transactionParams.fileSize);
|
EofInfo(ConditionCode::NO_ERROR, transactionParams.crc, transactionParams.fileSize);
|
||||||
auto eofPdu = EofPduCreator(transactionParams.pduConf, eofInfo);
|
auto eofPdu = EofPduCreator(transactionParams.pduConf, eofInfo);
|
||||||
ReturnValue_t result = sendGenericPdu(eofPdu);
|
ReturnValue_t result = sendGenericPdu(eofPdu);
|
||||||
if (result != OK) {
|
if (result != OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
step = TransactionStep::WAIT_FOR_FINISH;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,3 +286,20 @@ ReturnValue_t cfdp::SourceHandler::sendGenericPdu(const SerializeIF& pdu) const
|
|||||||
TmTcMessage tcMsg(storeId);
|
TmTcMessage tcMsg(storeId);
|
||||||
return fsfwParams.msgQueue->sendMessage(fsfwParams.packetDest.getReportReceptionQueue(), &tcMsg);
|
return fsfwParams.msgQueue->sendMessage(fsfwParams.packetDest.getReportReceptionQueue(), &tcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t cfdp::SourceHandler::noticeOfCompletion() {
|
||||||
|
if (sourceParams.cfg.indicCfg.transactionFinishedIndicRequired) {
|
||||||
|
cfdp::TransactionFinishedParams params(transactionParams.id, ConditionCode::NO_ERROR,
|
||||||
|
FileDeliveryCode::DATA_COMPLETE,
|
||||||
|
FileDeliveryStatus::RETAINED_IN_FILESTORE);
|
||||||
|
sourceParams.user.transactionFinishedIndication(params);
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t cfdp::SourceHandler::reset() {
|
||||||
|
step = TransactionStep::IDLE;
|
||||||
|
state = cfdp::CfdpState::IDLE;
|
||||||
|
transactionParams.reset();
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
@ -73,8 +73,16 @@ class SourceHandler {
|
|||||||
PduConfig pduConf;
|
PduConfig pduConf;
|
||||||
cfdp::TransactionId id{};
|
cfdp::TransactionId id{};
|
||||||
cfdp::WidthInBytes seqCountWidth;
|
cfdp::WidthInBytes seqCountWidth;
|
||||||
uint32_t seqNum = 0;
|
|
||||||
|
void reset() {
|
||||||
|
sourceNameSize = 0;
|
||||||
|
destNameSize = 0;
|
||||||
|
fileSize.setFileSize(0, false);
|
||||||
|
progress = 0;
|
||||||
|
closureRequested = false;
|
||||||
|
}
|
||||||
} transactionParams;
|
} transactionParams;
|
||||||
|
|
||||||
cfdp::CfdpState state = cfdp::CfdpState::IDLE;
|
cfdp::CfdpState state = cfdp::CfdpState::IDLE;
|
||||||
TransactionStep step = TransactionStep::IDLE;
|
TransactionStep step = TransactionStep::IDLE;
|
||||||
std::array<uint8_t, 4096> fileBuf{};
|
std::array<uint8_t, 4096> fileBuf{};
|
||||||
@ -87,8 +95,10 @@ class SourceHandler {
|
|||||||
ReturnValue_t prepareAndSendMetadataPdu();
|
ReturnValue_t prepareAndSendMetadataPdu();
|
||||||
ReturnValue_t prepareAndSendNextFileDataPdu();
|
ReturnValue_t prepareAndSendNextFileDataPdu();
|
||||||
ReturnValue_t prepareAndSendEofPdu();
|
ReturnValue_t prepareAndSendEofPdu();
|
||||||
|
ReturnValue_t noticeOfCompletion();
|
||||||
|
ReturnValue_t reset();
|
||||||
|
|
||||||
ReturnValue_t sendGenericPdu(const SerializeIF& pdu) const;
|
[[nodiscard]] ReturnValue_t sendGenericPdu(const SerializeIF& pdu) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
Loading…
Reference in New Issue
Block a user