From d45108e3c210c1687718a1db61c486e8d3eab2a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 18:51:44 +0200 Subject: [PATCH] add remote config table provider class --- src/fsfw/cfdp/CMakeLists.txt | 3 +- .../{pdu/VarLenField.cpp => VarLenFields.cpp} | 12 ++++++-- .../{pdu/VarLenField.h => VarLenFields.h} | 29 +++++++++++++++++++ src/fsfw/cfdp/definitions.h | 6 +++- src/fsfw/cfdp/handler/DestHandler.cpp | 5 ++-- src/fsfw/cfdp/handler/DestHandler.h | 4 ++- src/fsfw/cfdp/handler/RemoteConfigTableIF.h | 15 ++++++++++ src/fsfw/cfdp/handler/UserBase.h | 15 ++++++++++ src/fsfw/cfdp/handler/mib.h | 10 +++++++ src/fsfw/cfdp/pdu/CMakeLists.txt | 1 - src/fsfw/cfdp/pdu/PduConfig.h | 22 +------------- 11 files changed, 92 insertions(+), 30 deletions(-) rename src/fsfw/cfdp/{pdu/VarLenField.cpp => VarLenFields.cpp} (93%) rename src/fsfw/cfdp/{pdu/VarLenField.h => VarLenFields.h} (64%) create mode 100644 src/fsfw/cfdp/handler/RemoteConfigTableIF.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 72324a535..30a7c7008 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,5 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp + VarLenFields.cpp) add_subdirectory(pdu) add_subdirectory(tlv) diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/VarLenFields.cpp similarity index 93% rename from src/fsfw/cfdp/pdu/VarLenField.cpp rename to src/fsfw/cfdp/VarLenFields.cpp index 1f4d24299..c70d90ec3 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/VarLenFields.cpp @@ -1,4 +1,4 @@ -#include "VarLenField.h" +#include "VarLenFields.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" @@ -119,9 +119,15 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz } bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const { - return getValue() < other.getValue(); + if (getWidth() < other.getWidth()) { + return true; + } else if (getWidth() == other.getWidth()) { + return getValue() < other.getValue(); + } else { + return false; + } } bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const { - return getValue() == other.getValue(); + return getWidth() == other.getWidth() and getValue() == other.getValue(); } diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/VarLenFields.h similarity index 64% rename from src/fsfw/cfdp/pdu/VarLenField.h rename to src/fsfw/cfdp/VarLenFields.h index 819e8ccd0..2b862d666 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -3,6 +3,7 @@ #include #include +#include #include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" @@ -56,6 +57,34 @@ cfdp::VarLenField::VarLenField(UnsignedByteField byteField) setValue(width, byteField.getValue()); } +struct EntityId : public VarLenField { + public: + EntityId() : VarLenField() {} + template + explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {} + EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {} +}; + +struct TransactionSeqNum : public VarLenField { + public: + TransactionSeqNum() : VarLenField() {} + template + explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {} + TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} +}; + +struct TransactionId { + TransactionId(EntityId entityId, TransactionSeqNum seqNum) + : entityId(std::move(entityId)), seqNum(std::move(seqNum)) {} + + bool operator==(const TransactionId &other) { + return entityId == other.entityId and seqNum == other.seqNum; + } + + EntityId entityId; + TransactionSeqNum seqNum; +}; + } // namespace cfdp #endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */ diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index b97b9b271..4bd149e2f 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -11,7 +11,11 @@ namespace cfdp { -static constexpr uint8_t VERSION_BITS = 0b00100000; +static constexpr char CFDP_VERSION_2_NAME[] = "CCSDS 727.0-B-5"; + +// Second version of the protocol, only this one is supported here +static constexpr uint8_t CFDP_VERSION_2 = 0b001; +static constexpr uint8_t VERSION_BITS = CFDP_VERSION_2 << 5; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index cd1886f3b..d2b672c99 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,5 +2,6 @@ #include -cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user) - : cfg(std::move(cfg)), user(user) {} +cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user, + RemoteConfigTableIF& remoteCfgTable) + : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 3b56e2c75..0032c7b88 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -1,6 +1,7 @@ #ifndef FSFW_CFDP_CFDPDESTHANDLER_H #define FSFW_CFDP_CFDPDESTHANDLER_H +#include "RemoteConfigTableIF.h" #include "UserBase.h" #include "fsfw/cfdp/handler/mib.h" #include "fsfw/cfdp/pdu/PduConfig.h" @@ -9,11 +10,12 @@ namespace cfdp { class DestHandler { public: - DestHandler(LocalEntityCfg cfg, UserBase& user /*, RemoteConfigTableIF& remoteConfigTable*/); + DestHandler(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable); private: LocalEntityCfg cfg; UserBase& user; + RemoteConfigTableIF& remoteCfgTable; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h new file mode 100644 index 000000000..c757fe7ea --- /dev/null +++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h @@ -0,0 +1,15 @@ +#ifndef FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H +#define FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H + +#include "fsfw/cfdp/handler/mib.h" + +namespace cfdp { + +class RemoteConfigTableIF { + virtual ~RemoteConfigTableIF() = default; + virtual bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg* cfg) = 0; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 07d281b05..dd3c7424a 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -1,6 +1,7 @@ #ifndef FSFW_CFDP_USERBASE_H #define FSFW_CFDP_USERBASE_H +#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/filesystem/HasFileSystemIF.h" namespace cfdp { @@ -22,6 +23,20 @@ class UserBase { */ explicit UserBase(HasFileSystemIF& vfs); + virtual void transactionIndication(TransactionId id) = 0; + virtual void eofSentIndication(TransactionId id) = 0; + + virtual void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) = 0; + virtual void eofRecvIndication(TransactionId id) = 0; + + // TODO: Parameters + virtual void transactionFinishedIndication() = 0; + virtual void metadataRecvdIndication() = 0; + virtual void fileSegmentRecvdIndication() = 0; + virtual void reportIndication() = 0; + virtual void suspendedIndication() = 0; + virtual void resumedIndication() = 0; + private: HasFileSystemIF& vfs; }; diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 79e6d8957..7ba15cd3d 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -26,6 +26,16 @@ struct LocalEntityCfg { FaultHandlerBase& fhBase; }; +struct RemoteEntityCfg { + EntityId remoteId; + size_t maxFileSegmentLen; + bool closureRequested; + bool crcOnTransmission; + TransmissionModes defaultTransmissionMode; + ChecksumType defaultChecksum; + const uint8_t version = CFDP_VERSION_2; +}; + } // namespace cfdp #endif // FSFW_CFDP_MIB_H diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 33b05eecb..91b5ad2e8 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE PduConfig.cpp - VarLenField.cpp HeaderCreator.cpp HeaderReader.cpp FileDirectiveReader.cpp diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index 48f3993bf..2e5131592 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -1,29 +1,9 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ -#include "VarLenField.h" +#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/cfdp/definitions.h" -namespace cfdp { - -struct EntityId : public VarLenField { - public: - EntityId() : VarLenField() {} - template - explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {} - EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {} -}; - -struct TransactionSeqNum : public VarLenField { - public: - TransactionSeqNum() : VarLenField() {} - template - explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {} - TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} -}; - -} // namespace cfdp - class PduConfig { public: PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode,