add new HasReturnvaluesIF features

This commit is contained in:
Robin Müller 2022-07-26 10:21:16 +02:00
parent e48b6f1432
commit bdf71d4e66
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
9 changed files with 58 additions and 26 deletions

View File

@ -70,11 +70,12 @@ class ProvidesDataPoolSubscriptionIF {
virtual ReturnValue_t subscribeForDiagPeriodicPacket( virtual ReturnValue_t subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) = 0; subdp::DiagnosticsHkPeriodicParams params) = 0;
[[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] [[deprecated(
virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, "Please use the new API which takes all arguments as one wrapper "
float collectionInterval, bool isDiagnostics, "struct")]] virtual ReturnValue_t
object_id_t packetDestination) { subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval,
if(isDiagnostics) { bool isDiagnostics, object_id_t packetDestination) {
if (isDiagnostics) {
subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval);
return subscribeForDiagPeriodicPacket(params); return subscribeForDiagPeriodicPacket(params);
} else { } else {
@ -96,11 +97,12 @@ class ProvidesDataPoolSubscriptionIF {
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0;
virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0;
[[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] [[deprecated(
virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, "Please use the new API which takes all arguments as one wrapper "
bool isDiagnostics, "struct")]] virtual ReturnValue_t
object_id_t packetDestination) { subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics,
if(isDiagnostics) { object_id_t packetDestination) {
if (isDiagnostics) {
subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled);
return subscribeForDiagUpdatePacket(params); return subscribeForDiagUpdatePacket(params);
} else { } else {

View File

@ -128,7 +128,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool
LocalDataPoolManager &poolManager) { LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
localDataPoolMap.emplace(errorPoolIds::STORE_HITS,&storeHitsEntry); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams(
internalErrorSid, false, internalErrorSid, false,
static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0))); static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0)));

View File

@ -10,11 +10,21 @@
#define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number))
typedef uint16_t ReturnValue_t; 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<ReturnValue_t>(classId) << 8) + number;
}
} // namespace retval
class HasReturnvaluesIF { class HasReturnvaluesIF {
public: public:
static const ReturnValue_t RETURN_OK = 0; static const ReturnValue_t RETURN_OK = retval::OK;
static const ReturnValue_t RETURN_FAILED = 1; static const ReturnValue_t RETURN_FAILED = retval::FAILED;
virtual ~HasReturnvaluesIF() {}
virtual ~HasReturnvaluesIF() = default;
/** /**
* It is discouraged to use the input parameters 0,0 and 0,1 as this * It is discouraged to use the input parameters 0,0 and 0,1 as this
@ -23,8 +33,9 @@ class HasReturnvaluesIF {
* @param number * @param number
* @return * @return
*/ */
static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode(
return (static_cast<ReturnValue_t>(classId) << 8) + number; uint8_t classId, uint8_t number) {
return retval::makeCode(classId, number);
} }
}; };

View File

@ -9,5 +9,6 @@ target_sources(
SpacePacketParser.cpp SpacePacketParser.cpp
TmStoreHelper.cpp TmStoreHelper.cpp
TmSendHelper.cpp TmSendHelper.cpp
TmStoreAndSendHelper.cpp
tcHelpers.cpp tcHelpers.cpp
tmHelpers.cpp) tmHelpers.cpp)

View File

@ -0,0 +1,3 @@
#include "TmStoreAndSendHelper.h"
StoreAndSendWrapper::StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) {}

View File

@ -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

View File

@ -7,9 +7,6 @@
// I'd prefer to use tm, but there have been nameclashes with the tm struct // I'd prefer to use tm, but there have been nameclashes with the tm struct
namespace telemetry { namespace telemetry {
ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper,
bool delOnFailure = true);
class DataWithObjectIdPrefix : public SerializeIF { class DataWithObjectIdPrefix : public SerializeIF {
public: public:
DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) 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, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override { Endianness streamEndianness) override {
// TODO: Implement ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness);
return HasReturnvaluesIF::RETURN_FAILED; if (result != retval::OK) {
return result;
}
return retval::FAILED;
} }
private: private:

View File

@ -30,6 +30,4 @@ int customSetup() {
return 0; return 0;
} }
int customTeardown() { int customTeardown() { return 0; }
return 0;
}

View File

@ -7,11 +7,10 @@
#include <fsfw/datapoollocal/LocalPoolVariable.h> #include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/LocalPoolVector.h> #include <fsfw/datapoollocal/LocalPoolVector.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h> #include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include "fsfw/datapool/PoolEntry.h"
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
#include "fsfw/datapool/PoolEntry.h"
#include "mocks/MessageQueueMock.h" #include "mocks/MessageQueueMock.h"
#include "tests/TestsConfig.h" #include "tests/TestsConfig.h"