diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 6170e7ac5..e1aca321a 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -70,11 +70,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; - [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] - virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination) { - if(isDiagnostics) { + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, + bool isDiagnostics, object_id_t packetDestination) { + if (isDiagnostics) { subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); return subscribeForDiagPeriodicPacket(params); } else { @@ -96,11 +97,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] - virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination) { - if(isDiagnostics) { + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics, + object_id_t packetDestination) { + if (isDiagnostics) { subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); return subscribeForDiagUpdatePacket(params); } else { diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index 32038406c..0e404d22e 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -128,7 +128,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); - localDataPoolMap.emplace(errorPoolIds::STORE_HITS,&storeHitsEntry); + localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( internalErrorSid, false, static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index eec802281..4d59c26b1 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -10,11 +10,21 @@ #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) typedef uint16_t ReturnValue_t; +namespace retval { +static constexpr ReturnValue_t OK = 0; +static constexpr ReturnValue_t FAILED = 1; + +static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { + return (static_cast(classId) << 8) + number; +} +} // namespace retval + class HasReturnvaluesIF { public: - static const ReturnValue_t RETURN_OK = 0; - static const ReturnValue_t RETURN_FAILED = 1; - virtual ~HasReturnvaluesIF() {} + static const ReturnValue_t RETURN_OK = retval::OK; + static const ReturnValue_t RETURN_FAILED = retval::FAILED; + + virtual ~HasReturnvaluesIF() = default; /** * It is discouraged to use the input parameters 0,0 and 0,1 as this @@ -23,8 +33,9 @@ class HasReturnvaluesIF { * @param number * @return */ - static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { - return (static_cast(classId) << 8) + number; + [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( + uint8_t classId, uint8_t number) { + return retval::makeCode(classId, number); } }; diff --git a/src/fsfw/tmtcservices/CMakeLists.txt b/src/fsfw/tmtcservices/CMakeLists.txt index 42ac61282..ca3c887ef 100644 --- a/src/fsfw/tmtcservices/CMakeLists.txt +++ b/src/fsfw/tmtcservices/CMakeLists.txt @@ -9,5 +9,6 @@ target_sources( SpacePacketParser.cpp TmStoreHelper.cpp TmSendHelper.cpp + TmStoreAndSendHelper.cpp tcHelpers.cpp tmHelpers.cpp) diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp new file mode 100644 index 000000000..9e858ed63 --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -0,0 +1,3 @@ +#include "TmStoreAndSendHelper.h" + +StoreAndSendWrapper::StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) {} diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h new file mode 100644 index 000000000..d75d68396 --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -0,0 +1,18 @@ +#ifndef FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H +#define FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H + +#include "TmSendHelper.h" +#include "TmStoreHelper.h" + +class StoreAndSendWrapper { + public: + StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) + : storeHelper(storeHelper), sendHelper(sendHelper) {} + ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, + bool delOnFailure = true); + TmStoreHelper& storeHelper; + TmSendHelper& sendHelper; + bool delOnFailure = true; +}; + +#endif // FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index e49e11ae4..6a754bdfd 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -7,9 +7,6 @@ // I'd prefer to use tm, but there have been nameclashes with the tm struct namespace telemetry { -ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, - bool delOnFailure = true); - class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) @@ -34,8 +31,11 @@ class DataWithObjectIdPrefix : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - // TODO: Implement - return HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); + if (result != retval::OK) { + return result; + } + return retval::FAILED; } private: diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 1bdc20f4e..9206c2e18 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -30,6 +30,4 @@ int customSetup() { return 0; } -int customTeardown() { - return 0; -} +int customTeardown() { return 0; } diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 3233d5d49..f1d1225f8 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -7,11 +7,10 @@ #include #include #include -#include "fsfw/datapool/PoolEntry.h" - #include #include +#include "fsfw/datapool/PoolEntry.h" #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h"