cleaning up message queue mock and subscription API

This commit is contained in:
2022-07-25 19:36:56 +02:00
parent 5fd5d488ff
commit 6d0fa36f8a
39 changed files with 916 additions and 725 deletions

View File

@ -79,8 +79,7 @@ class HasLocalDataPoolIF {
* @param clearMessage If this is set to true, the pool manager will take care of
* clearing the store automatically
*/
virtual void handleChangedDataset(sid_t sid,
store_address_t storeId = store_address_t::invalid(),
virtual void handleChangedDataset(sid_t sid, store_address_t storeId = store_address_t::invalid(),
bool* clearMessage = nullptr) {
if (clearMessage != nullptr) {
*clearMessage = true;

View File

@ -1,6 +1,5 @@
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include <array>
#include <cmath>
#include "fsfw/datapoollocal.h"
@ -15,6 +14,7 @@
#include "internal/HasLocalDpIFManagerAttorney.h"
#include "internal/LocalPoolDataSetAttorney.h"
// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way
object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
@ -57,7 +57,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
}
if (defaultHkDestination != objects::NO_OBJECT) {
AcceptsHkPacketsIF* hkPacketReceiver =
auto* hkPacketReceiver =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(defaultHkDestination);
if (hkPacketReceiver != nullptr) {
hkDestinationId = hkPacketReceiver->getHkQueue();
@ -335,29 +335,32 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() {
}
}
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
float collectionInterval,
bool isDiagnostics,
object_id_t packetDestination) {
AcceptsHkPacketsIF* hkReceiverObject =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
if (hkReceiverObject == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams params) {
return subscribeForPeriodicPacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) {
return subscribeForPeriodicPacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = sid;
hkReceiver.dataId.sid = params.sid;
hkReceiver.reportingType = ReportingType::PERIODIC;
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
if (params.receiver == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = params.receiver;
}
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid);
if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics());
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval,
owner->getPeriodicOperationFrequency());
}
@ -365,27 +368,30 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isDiagnostics,
bool reportingEnabled,
object_id_t packetDestination) {
AcceptsHkPacketsIF* hkReceiverObject =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
if (hkReceiverObject == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket(
subdp::RegularHkUpdateParams params) {
return subscribeForUpdatePacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket(
subdp::DiagnosticsHkUpdateParams params) {
return subscribeForUpdatePacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = sid;
hkReceiver.dataId.sid = params.sid;
hkReceiver.reportingType = ReportingType::UPDATE_HK;
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
if (params.receiver == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = params.receiver;
}
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid);
if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics());
}
hkReceivers.push_back(hkReceiver);
@ -639,6 +645,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
/* Error, all destinations invalid */
printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
destination = hkDestinationId;
}
@ -879,3 +886,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
}
LocalDataPoolManager* LocalDataPoolManager::getPoolManagerHandle() { return this; }
void LocalDataPoolManager::setHkDestinationId(MessageQueueId_t hkDestId) {
hkDestinationId = hkDestId;
}

View File

@ -8,6 +8,7 @@
#include "ProvidesDataPoolSubscriptionIF.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/housekeeping/HousekeepingMessage.h"
#include "fsfw/housekeeping/HousekeepingPacketDownlink.h"
#include "fsfw/housekeeping/PeriodicHousekeepingHelper.h"
@ -80,7 +81,9 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
bool appendValidityBuffer = true);
virtual ~LocalDataPoolManager();
~LocalDataPoolManager() override;
void setHkDestinationId(MessageQueueId_t hkDestId);
/**
* Assigns the queue to use. Make sure to call this in the #initialize
@ -112,31 +115,6 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
virtual ReturnValue_t performHkOperation();
/**
* @brief Subscribe for the generation of periodic packets.
* @details
* This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly.
* @return
*/
ReturnValue_t subscribeForPeriodicPacket(
sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override;
/**
* @brief Subscribe for the generation of packets if the dataset
* is marked as changed.
* @details
* This subscription mechanism will generally be used by the data creator.
* @param sid
* @param isDiagnostics
* @param packetDestination
* @return
*/
ReturnValue_t subscribeForUpdatePacket(
sid_t sid, bool reportingEnabled, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override;
/**
* @brief Subscribe for a notification message which will be sent
* if a dataset has changed.
@ -151,7 +129,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
* Otherwise, only an notification message is sent.
* @return
*/
ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, object_id_t destinationObject,
ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
@ -169,7 +147,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
* Otherwise, only an notification message is sent.
* @return
*/
ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
@ -252,7 +230,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
void clearReceiversList();
object_id_t getCreatorObjectId() const;
[[nodiscard]] object_id_t getCreatorObjectId() const;
/**
* Get the pointer to the mutex. Can be used to lock the data pool
@ -262,7 +240,14 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
MutexIF* getMutexHandle();
virtual LocalDataPoolManager* getPoolManagerHandle() override;
LocalDataPoolManager* getPoolManagerHandle() override;
ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override;
ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override;
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params);
ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override;
ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override;
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params);
protected:
/** Core data structure for the actual pool data */

View File

@ -1,14 +1,56 @@
#ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#include "../ipc/messageQueueDefinitions.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "localPoolDefinitions.h"
namespace subdp {
struct ParamsBase {
ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics)
: sid(sid),
enableReporting(enableReporting),
collectionInterval(collectionInterval),
diagnostics(diagnostics) {}
[[nodiscard]] bool isDiagnostics() const { return diagnostics; }
sid_t sid;
bool enableReporting;
float collectionInterval;
MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE;
protected:
bool diagnostics;
};
struct RegularHkPeriodicParams : public ParamsBase {
RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, false) {}
};
struct DiagnosticsHkPeriodicParams : public ParamsBase {
DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, true) {}
};
struct RegularHkUpdateParams : public ParamsBase {
RegularHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, false) {}
};
struct DiagnosticsHkUpdateParams : public ParamsBase {
DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, true) {}
};
} // namespace subdp
class ProvidesDataPoolSubscriptionIF {
public:
virtual ~ProvidesDataPoolSubscriptionIF(){};
virtual ~ProvidesDataPoolSubscriptionIF() = default;
/**
* @brief Subscribe for the generation of periodic packets.
* @details
@ -16,9 +58,11 @@ class ProvidesDataPoolSubscriptionIF {
* to generate housekeeping packets which are downlinked directly.
* @return
*/
virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
float collectionInterval, bool isDiagnostics,
object_id_t packetDestination) = 0;
virtual ReturnValue_t subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams params) = 0;
virtual ReturnValue_t subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) = 0;
/**
* @brief Subscribe for the generation of packets if the dataset
* is marked as changed.
@ -29,9 +73,9 @@ class ProvidesDataPoolSubscriptionIF {
* @param packetDestination
* @return
*/
virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
bool isDiagnostics,
object_id_t packetDestination) = 0;
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0;
virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0;
/**
* @brief Subscribe for a notification message which will be sent
* if a dataset has changed.
@ -46,8 +90,7 @@ class ProvidesDataPoolSubscriptionIF {
* Otherwise, only an notification message is sent.
* @return
*/
virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId,
object_id_t destinationObject,
virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0;
/**
@ -64,7 +107,7 @@ class ProvidesDataPoolSubscriptionIF {
* only an notification message is sent.
* @return
*/
virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0;

View File

@ -1,12 +1,12 @@
#ifndef FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#define FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#include "../ipc/MessageQueueMessageIF.h"
#include "fsfw/ipc/MessageQueueMessageIF.h"
class AcceptsHkPacketsIF {
public:
virtual ~AcceptsHkPacketsIF(){};
virtual MessageQueueId_t getHkQueue() const = 0;
virtual ~AcceptsHkPacketsIF() = default;
[[nodiscard]] virtual MessageQueueId_t getHkQueue() const = 0;
};
#endif /* FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ */

View File

@ -129,8 +129,9 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(errorPoolIds::TM_HITS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry<uint32_t>());
poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(),
true);
poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams(
internalErrorSid, false,
static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0)));
internalErrorDataset.setValidity(true, true);
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -17,18 +17,18 @@ class MessageQueueBase : public MessageQueueIF {
[[nodiscard]] MessageQueueId_t getDefaultDestination() const override;
[[nodiscard]] bool isDefaultDestinationSet() const override;
ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
bool ignoreFault) override;
bool ignoreFault) override;
ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override;
ReturnValue_t reply(MessageQueueMessageIF* message) override;
ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
MessageQueueId_t* receivedFrom) override;
MessageQueueId_t* receivedFrom) override;
ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
bool ignoreFault = false) override;
bool ignoreFault = false) override;
// OSAL specific, forward the abstract function
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override = 0;
ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0;
MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0;
protected:
MessageQueueId_t id = MessageQueueIF::NO_QUEUE;

View File

@ -10,10 +10,10 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize()
}
MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
: messageSize(this->HEADER_SIZE + size) {
if (size <= this->MAX_DATA_SIZE) {
memcpy(this->getData(), data, size);
this->messageSize = this->HEADER_SIZE + size;
: messageSize(MessageQueueMessage::HEADER_SIZE + size) {
if (size <= MessageQueueMessage::MAX_DATA_SIZE) {
std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size);
this->messageSize = MessageQueueMessage::HEADER_SIZE + size;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "MessageQueueMessage: Passed size larger than maximum"
@ -21,21 +21,23 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
<< std::endl;
#endif
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
this->messageSize = this->HEADER_SIZE;
this->messageSize = MessageQueueMessage::HEADER_SIZE;
}
}
MessageQueueMessage::~MessageQueueMessage() {}
MessageQueueMessage::~MessageQueueMessage() = default;
const uint8_t* MessageQueueMessage::getBuffer() const { return this->internalBuffer; }
uint8_t* MessageQueueMessage::getBuffer() { return this->internalBuffer; }
const uint8_t* MessageQueueMessage::getData() const {
return this->internalBuffer + this->HEADER_SIZE;
return this->internalBuffer + MessageQueueMessage::HEADER_SIZE;
}
uint8_t* MessageQueueMessage::getData() { return this->internalBuffer + this->HEADER_SIZE; }
uint8_t* MessageQueueMessage::getData() {
return this->internalBuffer + MessageQueueMessage::HEADER_SIZE;
}
MessageQueueId_t MessageQueueMessage::getSender() const {
MessageQueueId_t temp_id;
@ -58,14 +60,22 @@ void MessageQueueMessage::print(bool printWholeMessage) {
}
}
void MessageQueueMessage::clear() { memset(this->getBuffer(), 0, this->MAX_MESSAGE_SIZE); }
void MessageQueueMessage::clear() {
memset(this->getBuffer(), 0, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
size_t MessageQueueMessage::getMessageSize() const { return this->messageSize; }
void MessageQueueMessage::setMessageSize(size_t messageSize) { this->messageSize = messageSize; }
void MessageQueueMessage::setMessageSize(size_t messageSize_) { this->messageSize = messageSize_; }
size_t MessageQueueMessage::getMinimumMessageSize() const { return this->MIN_MESSAGE_SIZE; }
size_t MessageQueueMessage::getMinimumMessageSize() const {
return MessageQueueMessage::MIN_MESSAGE_SIZE;
}
size_t MessageQueueMessage::getMaximumMessageSize() const { return this->MAX_MESSAGE_SIZE; }
size_t MessageQueueMessage::getMaximumMessageSize() const {
return MessageQueueMessage::MAX_MESSAGE_SIZE;
}
size_t MessageQueueMessage::getMaximumDataSize() const { return this->MAX_DATA_SIZE; }
size_t MessageQueueMessage::getMaximumDataSize() const {
return MessageQueueMessage::MAX_DATA_SIZE;
}

View File

@ -25,6 +25,30 @@
*/
class MessageQueueMessage : public MessageQueueMessageIF {
public:
/**
* @brief This constant defines the maximum size of the data content,
* excluding the header.
* @details
* It may be changed if necessary, but in general should be kept
* as small as possible.
*/
static const size_t MAX_DATA_SIZE = 24;
/**
* @brief This constant defines the maximum total size in bytes
* of a sent message.
* @details
* It is the sum of the maximum data and the header size. Be aware that
* this constant is used to define the buffer sizes for every message
* queue in the system. So, a change here may have significant impact on
* the required resources.
*/
static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE;
/**
* @brief Defines the minimum size of a message where only the
* header is included
*/
static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE;
/**
* @brief The class is initialized empty with this constructor.
* @details
@ -50,59 +74,12 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @brief As no memory is allocated in this class,
* the destructor is empty.
*/
virtual ~MessageQueueMessage();
~MessageQueueMessage() override;
/**
* @brief The size information of each message is stored in
* this attribute.
* @details
* It is public to simplify usage and to allow for passing the size
* address as a pointer. Care must be taken when inheriting from this class,
* as every child class is responsible for managing the size information by
* itself. When using the class to receive a message, the size information
* is updated automatically.
*
* Please note that the minimum size is limited by the size of the header
* while the maximum size is limited by the maximum allowed message size.
*/
size_t messageSize;
/**
* @brief This constant defines the maximum size of the data content,
* excluding the header.
* @details
* It may be changed if necessary, but in general should be kept
* as small as possible.
*/
static const size_t MAX_DATA_SIZE = 24;
/**
* @brief This constant defines the maximum total size in bytes
* of a sent message.
* @details
* It is the sum of the maximum data and the header size. Be aware that
* this constant is used to define the buffer sizes for every message
* queue in the system. So, a change here may have significant impact on
* the required resources.
*/
static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE;
/**
* @brief Defines the minimum size of a message where only the
* header is included
*/
static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE;
private:
/**
* @brief This is the internal buffer that contains the
* actual message data.
*/
uint8_t internalBuffer[MAX_MESSAGE_SIZE];
public:
/**
* @brief This method is used to get the complete data of the message.
*/
const uint8_t* getBuffer() const override;
[[nodiscard]] const uint8_t* getBuffer() const override;
/**
* @brief This method is used to get the complete data of the message.
*/
@ -112,7 +89,7 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @details
* It shall be used by child classes to add data at the right position.
*/
const uint8_t* getData() const override;
[[nodiscard]] const uint8_t* getData() const override;
/**
* @brief This method is used to fetch the data content of the message.
* @details
@ -123,7 +100,7 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @brief This method is used to extract the sender's message
* queue id information from a received message.
*/
MessageQueueId_t getSender() const override;
[[nodiscard]] MessageQueueId_t getSender() const override;
/**
* @brief With this method, the whole content
* and the message size is set to zero.
@ -138,16 +115,40 @@ class MessageQueueMessage : public MessageQueueMessageIF {
*/
void setSender(MessageQueueId_t setId) override;
virtual size_t getMessageSize() const override;
virtual void setMessageSize(size_t messageSize) override;
virtual size_t getMinimumMessageSize() const override;
virtual size_t getMaximumMessageSize() const override;
virtual size_t getMaximumDataSize() const override;
[[nodiscard]] size_t getMessageSize() const override;
void setMessageSize(size_t messageSize) override;
[[nodiscard]] size_t getMinimumMessageSize() const override;
[[nodiscard]] size_t getMaximumMessageSize() const override;
[[nodiscard]] size_t getMaximumDataSize() const override;
/**
* @brief This is a debug method that prints the content.
*/
void print(bool printWholeMessage);
/**
* TODO: This really should not be public. If it should be possible to pass size address as a
* pointer, add a getter function returning a const reference to the size
* @brief The size information of each message is stored in
* this attribute.
* @details
* It is public to simplify usage and to allow for passing the size
* address as a pointer. Care must be taken when inheriting from this class,
* as every child class is responsible for managing the size information by
* itself. When using the class to receive a message, the size information
* is updated automatically.
*
* Please note that the minimum size is limited by the size of the header
* while the maximum size is limited by the maximum allowed message size.
*/
size_t messageSize;
private:
/**
* @brief This is the internal buffer that contains the
* actual message data.
*/
uint8_t internalBuffer[MAX_MESSAGE_SIZE] = {};
};
#endif /* FSFW_IPC_MESSAGEQUEUEMESSAGE_H_ */

View File

@ -14,7 +14,7 @@ class MessageQueueMessageIF {
*/
static const size_t HEADER_SIZE = sizeof(MessageQueueId_t);
virtual ~MessageQueueMessageIF(){};
virtual ~MessageQueueMessageIF() = default;
/**
* @brief With this method, the whole content and the message
@ -29,7 +29,7 @@ class MessageQueueMessageIF {
* @brief Get read-only pointer to the complete data of the message.
* @return
*/
virtual const uint8_t* getBuffer() const = 0;
[[nodiscard]] virtual const uint8_t* getBuffer() const = 0;
/**
* @brief This method is used to get the complete data of the message.
@ -48,14 +48,14 @@ class MessageQueueMessageIF {
* @brief This method is used to extract the sender's message queue id
* information from a received message.
*/
virtual MessageQueueId_t getSender() const = 0;
[[nodiscard]] virtual MessageQueueId_t getSender() const = 0;
/**
* @brief This method is used to fetch the data content of the message.
* @details
* It shall be used by child classes to add data at the right position.
*/
virtual const uint8_t* getData() const = 0;
[[nodiscard]] virtual const uint8_t* getData() const = 0;
/**
* @brief This method is used to fetch the data content of the message.
* @details
@ -67,12 +67,28 @@ class MessageQueueMessageIF {
* Get constant message size of current message implementation.
* @return
*/
virtual size_t getMessageSize() const = 0;
[[nodiscard]] virtual size_t getMessageSize() const = 0;
/**
* Sets the current message size of a given message
* @param messageSize
*/
virtual void setMessageSize(size_t messageSize) = 0;
virtual size_t getMinimumMessageSize() const = 0;
virtual size_t getMaximumMessageSize() const = 0;
virtual size_t getMaximumDataSize() const = 0;
/**
* Returns the smallest possible message size, including any headers
* @return
*/
[[nodiscard]] virtual size_t getMinimumMessageSize() const = 0;
/**
* Returns the largest possible message size, including any headers
* @return
*/
[[nodiscard]] virtual size_t getMaximumMessageSize() const = 0;
/**
* Returns the largest possible data size without any headers
* @return
*/
[[nodiscard]] virtual size_t getMaximumDataSize() const = 0;
};
#endif /* FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ */

View File

@ -2,9 +2,9 @@
#include <linux/sysinfo.h>
#include <sys/sysinfo.h>
#include <ctime>
#include <unistd.h>
#include <ctime>
#include <fstream>
#include "fsfw/ipc/MutexGuard.h"

View File

@ -64,7 +64,7 @@ class SerializeIF {
/**
* Forwards to regular @serialize call with big (network) endianness
*/
virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) {
virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) {
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
}
/**
@ -105,7 +105,7 @@ class SerializeIF {
/**
* Forwards to regular @deSerialize call with big (network) endianness
*/
virtual ReturnValue_t deSerializeBe(const uint8_t** buffer, size_t* size) {
virtual ReturnValue_t deSerializeBe(const uint8_t **buffer, size_t *size) {
return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK);
}
/**

View File

@ -6,9 +6,9 @@
#include <cstddef>
#include <cstdint>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "Clock.h"
#include "clockDefinitions.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
bool operator<(const timeval &lhs, const timeval &rhs);
bool operator<=(const timeval &lhs, const timeval &rhs);

View File

@ -3,8 +3,8 @@
#include <cstring>
#include "fsfw/ipc/MessageQueueMessage.h"
#include "Clock.h"
#include "fsfw/ipc/MessageQueueMessage.h"
class TimeMessage : public MessageQueueMessage {
protected:

View File

@ -101,7 +101,7 @@ ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF& serializable) {
ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) {
// TODO: Check length field?
pusParams.dataWrapper.setSerializable(serializable);
updateSpLengthField();

View File

@ -47,7 +47,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
[[nodiscard]] uint8_t getSubService() const override;
[[nodiscard]] uint16_t getSourceId() const override;
ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override;
ReturnValue_t setSerializableUserData(SerializeIF& serializable) override;
ReturnValue_t setSerializableUserData(SerializeIF &serializable) override;
private:
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,

View File

@ -2,16 +2,17 @@
#include "fsfw/ipc/MessageQueueSenderIF.h"
TmSendHelper::TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF *reporter, MessageQueueId_t tmtcMsgDest)
TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter,
MessageQueueId_t tmtcMsgDest)
: tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {}
TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter)
: queue(queue), errReporter(reporter) {}
: queue(queue), errReporter(reporter) {}
TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {}
ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) {
if(queue == nullptr) {
if (queue == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
TmTcMessage message(storeId);

View File

@ -9,11 +9,11 @@
class TmSendHelper {
public:
TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter, MessageQueueId_t tmtcMsgDest);
TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter,
MessageQueueId_t tmtcMsgDest);
TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter);
explicit TmSendHelper(InternalErrorReporterIF* reporter);
void setMsgQueue(MessageQueueIF* queue);
void setMsgDestination(MessageQueueId_t msgDest);
void setInternalErrorReporter(InternalErrorReporterIF* reporter);

View File

@ -2,7 +2,7 @@
#include "TmTcMessage.h"
TmStoreHelper::TmStoreHelper(uint16_t defaultApid): tmStore(nullptr) {
TmStoreHelper::TmStoreHelper(uint16_t defaultApid) : tmStore(nullptr) {
creator.setApid(defaultApid);
}
@ -17,7 +17,6 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore,
creator.setTimeStamper(timeStamper);
}
ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) {
PusTmParams& params = creator.getParams();
params.secHeader.service = service;
@ -33,8 +32,8 @@ void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; }
const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; }
ReturnValue_t TmStoreHelper::deletePacket() {
ReturnValue_t result = tmStore->deleteData(currentAddr);
if(result == HasReturnvaluesIF::RETURN_OK) {
ReturnValue_t result = tmStore->deleteData(currentAddr);
if (result == HasReturnvaluesIF::RETURN_OK) {
currentAddr = store_address_t::invalid();
}
return result;

View File

@ -30,7 +30,6 @@ class TmStoreHelper {
ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len);
ReturnValue_t setSourceDataSerializable(SerializeIF& serializable);
ReturnValue_t addPacketToStore();
ReturnValue_t deletePacket();