2022-09-14 19:29:43 +02:00
|
|
|
#ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H
|
|
|
|
#define FSFW_CFDP_CFDPSOURCEHANDLER_H
|
|
|
|
|
2023-06-30 11:59:22 +02:00
|
|
|
#include <cstdint>
|
2023-07-17 09:53:23 +02:00
|
|
|
#include <vector>
|
2023-06-30 11:59:22 +02:00
|
|
|
|
2023-07-17 09:53:23 +02:00
|
|
|
#include "UserBase.h"
|
2023-07-14 15:56:38 +02:00
|
|
|
#include "defs.h"
|
2023-07-17 09:53:23 +02:00
|
|
|
#include "fsfw/cfdp/FileSize.h"
|
|
|
|
#include "fsfw/cfdp/handler/mib.h"
|
2023-06-30 11:59:22 +02:00
|
|
|
#include "fsfw/events/EventReportingProxyIF.h"
|
|
|
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
|
|
|
|
2023-07-17 09:53:23 +02:00
|
|
|
namespace cfdp {
|
|
|
|
|
|
|
|
struct SourceHandlerParams {
|
|
|
|
SourceHandlerParams(LocalEntityCfg cfg, UserBase& user) : cfg(std::move(cfg)), user(user) {}
|
|
|
|
|
|
|
|
LocalEntityCfg cfg;
|
|
|
|
UserBase& user;
|
|
|
|
size_t maxFilePathSize = 256;
|
|
|
|
};
|
2023-06-30 11:36:19 +02:00
|
|
|
|
2023-06-30 11:59:22 +02:00
|
|
|
struct FsfwSourceParams {
|
|
|
|
FsfwSourceParams(EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore)
|
|
|
|
: tcStore(&tcStore){};
|
|
|
|
|
|
|
|
EventReportingProxyIF* eventReporter = nullptr;
|
|
|
|
StorageManagerIF* tcStore = nullptr;
|
|
|
|
};
|
|
|
|
|
2023-06-30 11:36:19 +02:00
|
|
|
class SourceHandler {
|
2023-06-30 11:48:25 +02:00
|
|
|
public:
|
2023-06-30 11:59:22 +02:00
|
|
|
SourceHandler(SourceHandlerParams params, FsfwSourceParams fsfwParams);
|
2023-06-30 11:48:25 +02:00
|
|
|
|
2023-07-14 15:56:38 +02:00
|
|
|
void stateMachine();
|
|
|
|
|
2023-06-30 11:48:25 +02:00
|
|
|
private:
|
|
|
|
enum class TransactionStep : uint8_t {
|
|
|
|
IDLE = 0,
|
|
|
|
TRANSACTION_START = 1,
|
|
|
|
CRC_PROCEDURE = 2,
|
|
|
|
SENDING_METADATA = 3,
|
|
|
|
SENDING_FILE_DATA = 4,
|
|
|
|
SENDING_EOF = 5,
|
|
|
|
WAIT_FOR_ACK = 6,
|
|
|
|
WAIT_FOR_FINISH = 7,
|
|
|
|
NOTICE_OF_COMPLETION = 8
|
|
|
|
};
|
2023-07-17 09:53:23 +02:00
|
|
|
struct TransactionParams {
|
|
|
|
// Initialize char vectors with length + 1 for 0 termination
|
|
|
|
explicit TransactionParams(size_t maxFileNameLen)
|
|
|
|
: sourceName(maxFileNameLen + 1), destName(maxFileNameLen + 1) {}
|
|
|
|
|
|
|
|
uint32_t crc{};
|
|
|
|
std::vector<char> sourceName;
|
|
|
|
std::vector<char> destName;
|
|
|
|
cfdp::FileSize fileSize;
|
|
|
|
} transactionParams;
|
|
|
|
cfdp::CfdpState state = cfdp::CfdpState::IDLE;
|
|
|
|
TransactionStep step = TransactionStep::IDLE;
|
|
|
|
SourceHandlerParams sourceParams;
|
2023-07-14 15:56:38 +02:00
|
|
|
|
|
|
|
void fsmNacked();
|
2023-07-17 09:53:23 +02:00
|
|
|
ReturnValue_t checksumGeneration();
|
2023-06-30 11:36:19 +02:00
|
|
|
};
|
2022-09-14 19:29:43 +02:00
|
|
|
|
2023-07-17 09:53:23 +02:00
|
|
|
} // namespace cfdp
|
|
|
|
|
2022-09-14 19:29:43 +02:00
|
|
|
#endif // FSFW_CFDP_CFDPSOURCEHANDLER_H
|