diff --git a/src/fsfw/cfdp.h b/src/fsfw/cfdp.h new file mode 100644 index 00000000..421a7fe1 --- /dev/null +++ b/src/fsfw/cfdp.h @@ -0,0 +1,8 @@ +#ifndef FSFW_CFDP_H +#define FSFW_CFDP_H + +#include "cfdp/definitions.h" +#include "cfdp/handler/DestHandler.h" +#include "cfdp/handler/FaultHandlerBase.h" + +#endif // FSFW_CFDP_H diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index df83bd7f..72324a53 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,8 +1,5 @@ -target_sources( - ${LIB_FSFW_NAME} - PRIVATE CfdpMessage.cpp CfdpDistributor.cpp CfdpSourceHandler.cpp - CfdpDestHandler.cpp FaultHandlerBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) -# CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) add_subdirectory(tlv) +add_subdirectory(handler) diff --git a/src/fsfw/cfdp/CfdpDestHandler.cpp b/src/fsfw/cfdp/CfdpDestHandler.cpp deleted file mode 100644 index f3eb657a..00000000 --- a/src/fsfw/cfdp/CfdpDestHandler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "CfdpDestHandler.h" diff --git a/src/fsfw/cfdp/CfdpDestHandler.h b/src/fsfw/cfdp/CfdpDestHandler.h deleted file mode 100644 index e317cc4f..00000000 --- a/src/fsfw/cfdp/CfdpDestHandler.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef FSFW_CFDP_CFDPDESTHANDLER_H -#define FSFW_CFDP_CFDPDESTHANDLER_H - -#include - -#include "fsfw/cfdp/pdu/PduConfig.h" - -class CfdpDestHandler { - public: - CfdpDestHandler(); - - private: -}; - -#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/CfdpSourceHandler.cpp b/src/fsfw/cfdp/CfdpSourceHandler.cpp deleted file mode 100644 index c4b42d55..00000000 --- a/src/fsfw/cfdp/CfdpSourceHandler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "CfdpSourceHandler.h" diff --git a/src/fsfw/cfdp/handler/CMakeLists.txt b/src/fsfw/cfdp/handler/CMakeLists.txt new file mode 100644 index 00000000..7ad995c0 --- /dev/null +++ b/src/fsfw/cfdp/handler/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp + FaultHandlerBase.cpp UserBase.cpp) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp new file mode 100644 index 00000000..72f7951e --- /dev/null +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -0,0 +1,5 @@ +#include "DestHandler.h" + +#include + +cfdp::DestHandler::DestHandler(LocalEntityCfg cfg) : cfg(std::move(cfg)) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h new file mode 100644 index 00000000..e934fc9c --- /dev/null +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -0,0 +1,19 @@ +#ifndef FSFW_CFDP_CFDPDESTHANDLER_H +#define FSFW_CFDP_CFDPDESTHANDLER_H + +#include "fsfw/cfdp/handler/mib.h" +#include "fsfw/cfdp/pdu/PduConfig.h" + +namespace cfdp { + +class DestHandler { + public: + DestHandler(LocalEntityCfg cfg /*, CfdpUserBase& user, RemoteConfigTableIF& remoteConfigTable*/); + + private: + LocalEntityCfg cfg; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp similarity index 100% rename from src/fsfw/cfdp/FaultHandlerBase.cpp rename to src/fsfw/cfdp/handler/FaultHandlerBase.cpp diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h similarity index 98% rename from src/fsfw/cfdp/FaultHandlerBase.h rename to src/fsfw/cfdp/handler/FaultHandlerBase.h index ba816161..2383f849 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.h +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h @@ -3,7 +3,7 @@ #include -#include "definitions.h" +#include "fsfw/cfdp/definitions.h" namespace cfdp { diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp new file mode 100644 index 00000000..513b25f3 --- /dev/null +++ b/src/fsfw/cfdp/handler/SourceHandler.cpp @@ -0,0 +1 @@ +#include "SourceHandler.h" diff --git a/src/fsfw/cfdp/CfdpSourceHandler.h b/src/fsfw/cfdp/handler/SourceHandler.h similarity index 80% rename from src/fsfw/cfdp/CfdpSourceHandler.h rename to src/fsfw/cfdp/handler/SourceHandler.h index b343a6ed..319cf258 100644 --- a/src/fsfw/cfdp/CfdpSourceHandler.h +++ b/src/fsfw/cfdp/handler/SourceHandler.h @@ -1,6 +1,6 @@ #ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H #define FSFW_CFDP_CFDPSOURCEHANDLER_H -class CfdpSourceHandler {}; +class SourceHandler {}; #endif // FSFW_CFDP_CFDPSOURCEHANDLER_H diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp new file mode 100644 index 00000000..212396fb --- /dev/null +++ b/src/fsfw/cfdp/handler/UserBase.cpp @@ -0,0 +1,3 @@ +#include "UserBase.h" + +cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {} diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h new file mode 100644 index 00000000..c928789c --- /dev/null +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -0,0 +1,18 @@ +#ifndef FSFW_CFDP_USERBASE_H +#define FSFW_CFDP_USERBASE_H + +#include "fsfw/memory/HasFileSystemIF.h" + +namespace cfdp { + +class UserBase { + public: + explicit UserBase(HasFileSystemIF& vfs); + + private: + HasFileSystemIF& vfs; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_USERBASE_H diff --git a/src/fsfw/cfdp/mib.h b/src/fsfw/cfdp/handler/mib.h similarity index 56% rename from src/fsfw/cfdp/mib.h rename to src/fsfw/cfdp/handler/mib.h index c40034d4..e78b0f4f 100644 --- a/src/fsfw/cfdp/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -1,6 +1,12 @@ #ifndef FSFW_CFDP_MIB_H #define FSFW_CFDP_MIB_H +#include + +#include "FaultHandlerBase.h" + +namespace cfdp { + struct IndicationCfg { bool eofSentIndicRequired = true; bool eofRecvIndicRequired = true; @@ -11,8 +17,14 @@ struct IndicationCfg { }; struct LocalEntityCfg { - cfdp::EntityId localId; + LocalEntityCfg(EntityId localId, IndicationCfg indicationCfg, FaultHandlerBase& fhBase) + : localId(std::move(localId)), indicCfg(indicationCfg), fhBase(fhBase) {} + + EntityId localId; IndicationCfg indicCfg; + FaultHandlerBase& fhBase; }; +} // namespace cfdp + #endif // FSFW_CFDP_MIB_H diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index bb2a5ac4..e2f95388 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,3 +1,11 @@ #include -TEST_CASE("CFDP Dest Handler", "[cfdp]") {} \ No newline at end of file +#include "fsfw/cfdp.h" + +TEST_CASE("CFDP Dest Handler", "[cfdp]") { + using namespace cfdp; + // auto localEntityCfg = LocalEntityCfg(); + // auto destHandler = DestHandler(); + + SECTION("State") {} +} \ No newline at end of file diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index e6fb4547..945e09b8 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -43,12 +43,13 @@ TEST_CASE("CFDP Fault Handler", "[cfdp]") { SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(ConditionCode::NO_ERROR)); } - SECTION("Invalid FH code"){ - CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, FaultHandlerCodes::RESERVED)); - CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); - CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); - CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); + SECTION("Invalid FH code") { + CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + FaultHandlerCodes::RESERVED)); + CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); + CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); } SECTION("Set Other Fault Handler") { diff --git a/unittests/mocks/CfdpFaultHandlerMock.h b/unittests/mocks/CfdpFaultHandlerMock.h index ae7b251e..721cf7e0 100644 --- a/unittests/mocks/CfdpFaultHandlerMock.h +++ b/unittests/mocks/CfdpFaultHandlerMock.h @@ -4,7 +4,7 @@ #include #include -#include "fsfw/cfdp/FaultHandlerBase.h" +#include "fsfw/cfdp/handler/FaultHandlerBase.h" class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { public: