This commit is contained in:
2020-12-03 13:00:04 +01:00
parent 0cf65af506
commit 464988ca61
18 changed files with 1346 additions and 577 deletions

View File

@@ -1,5 +1,6 @@
#ifndef FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#define FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#include "../ipc/MessageQueueMessageIF.h"
class AcceptsHkPacketsIF {

View File

@@ -1,5 +1,6 @@
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include "HousekeepingMessage.h"
#include "../objectmanager/ObjectManagerIF.h"
#include <cstring>
HousekeepingMessage::~HousekeepingMessage() {}
@@ -148,7 +149,7 @@ void HousekeepingMessage::clear(CommandMessage* message) {
case(DIAGNOSTICS_REPORT):
case(HK_DEFINITIONS_REPORT):
case(DIAGNOSTICS_DEFINITION_REPORT):
case(UPDATE_SNAPSHOT): {
case(UPDATE_SNAPSHOT_SET): {
store_address_t storeId;
getHkDataReply(message, &storeId);
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
@@ -160,3 +161,55 @@ void HousekeepingMessage::clear(CommandMessage* message) {
}
message->setCommand(CommandMessage::CMD_NONE);
}
void HousekeepingMessage::setUpdateNotificationSetCommand(
CommandMessage *command, sid_t sid) {
command->setCommand(UPDATE_NOTIFICATION_SET);
setSid(command, sid);
}
void HousekeepingMessage::setUpdateNotificationVariableCommand(
CommandMessage *command, lp_id_t localPoolId) {
command->setCommand(UPDATE_NOTIFICATION_VARIABLE);
command->setParameter(localPoolId);
}
void HousekeepingMessage::setUpdateSnapshotSetCommand(CommandMessage *command,
sid_t sid, store_address_t storeId) {
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
setSid(command, sid);
command->setParameter3(storeId.raw);
}
void HousekeepingMessage::setUpdateSnapshotVariableCommand(
CommandMessage *command, lp_id_t localPoolId, store_address_t storeId) {
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
command->setParameter(localPoolId);
command->setParameter3(storeId.raw);
}
sid_t HousekeepingMessage::getUpdateNotificationSetCommand(
const CommandMessage *command) {
return getSid(command);
}
lp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(
const CommandMessage *command) {
return command->getParameter();
}
sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(
const CommandMessage *command, store_address_t *storeId) {
if(storeId != nullptr) {
*storeId = command->getParameter3();
}
return getSid(command);
}
lp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(
const CommandMessage *command, store_address_t *storeId) {
if(storeId != nullptr) {
*storeId = command->getParameter3();
}
return command->getParameter();
}

View File

@@ -1,49 +1,12 @@
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_
#include "../datapoollocal/locPoolDefinitions.h"
#include "../ipc/CommandMessage.h"
#include "../ipc/FwMessageTypes.h"
#include "../objectmanager/frameworkObjects.h"
#include "../objectmanager/SystemObjectIF.h"
#include "../storagemanager/StorageManagerIF.h"
union sid_t {
static constexpr uint64_t INVALID_SID = -1;
static constexpr uint32_t INVALID_SET_ID = -1;
static constexpr uint32_t INVALID_OBJECT_ID = objects::NO_OBJECT;
sid_t(): raw(INVALID_SID) {}
sid_t(object_id_t objectId, uint32_t setId):
objectId(objectId),
ownerSetId(setId) {}
struct {
object_id_t objectId ;
/**
* A generic 32 bit ID to identify unique HK packets for a single
* object. For example, the DeviceCommandId_t is used for
* DeviceHandlers
*/
uint32_t ownerSetId;
};
/**
* Alternative access to the raw value. This is also the size of the type.
*/
uint64_t raw;
bool notSet() const {
return raw == INVALID_SID;
}
bool operator==(const sid_t& other) const {
return raw == other.raw;
}
bool operator!=(const sid_t& other) const {
return not (raw == other.raw);
}
};
/**
* @brief Special command message type for housekeeping messages
@@ -101,14 +64,20 @@ public:
static constexpr Command_t HK_REQUEST_FAILURE =
MAKE_COMMAND_ID(129);
static constexpr Command_t UPDATE_NOTIFICATION = MAKE_COMMAND_ID(130);
static constexpr Command_t UPDATE_SNAPSHOT = MAKE_COMMAND_ID(131);
static constexpr Command_t UPDATE_NOTIFICATION_SET =
MAKE_COMMAND_ID(130);
static constexpr Command_t UPDATE_NOTIFICATION_VARIABLE =
MAKE_COMMAND_ID(131);
static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(132);
static constexpr Command_t UPDATE_SNAPSHOT_SET = MAKE_COMMAND_ID(132);
static constexpr Command_t UPDATE_SNAPSHOT_VARIABLE = MAKE_COMMAND_ID(133);
//static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(134);
static sid_t getSid(const CommandMessage* message);
/** Setter functions */
/* Housekeeping Interface Messages */
static void setToggleReportingCommand(CommandMessage* command, sid_t sid,
bool enableReporting, bool isDiagnostics);
static void setStructureReportingCommand(CommandMessage* command, sid_t sid,
@@ -148,6 +117,29 @@ public:
static sid_t getCollectionIntervalModificationCommand(
const CommandMessage* command, float* newCollectionInterval);
/* Update Notification Messages */
static void setUpdateNotificationSetCommand(CommandMessage* command,
sid_t sid);
static void setUpdateNotificationVariableCommand(CommandMessage* command,
lp_id_t localPoolId);
static void setUpdateSnapshotSetCommand(CommandMessage* command, sid_t sid,
store_address_t storeId);
static void setUpdateSnapshotVariableCommand(CommandMessage* command,
lp_id_t localPoolId, store_address_t storeId);
static sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
static lp_id_t getUpdateNotificationVariableCommand(
const CommandMessage* command);
static sid_t getUpdateSnapshotSetCommand(const CommandMessage* command,
store_address_t* storeId);
static lp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
store_address_t* storeId);
/** Utility */
static void clear(CommandMessage* message);
private:
static void setSid(CommandMessage* message, sid_t sid);

View File

@@ -1,5 +1,5 @@
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#include "../serialize/SerialBufferAdapter.h"
#include "../serialize/SerialLinkedListAdapter.h"
@@ -12,6 +12,7 @@
class HousekeepingPacketUpdate: public SerializeIF {
public:
/**
* Update packet constructor for datasets
* @param timeStamp
* @param timeStampSize
* @param hkData
@@ -19,8 +20,19 @@ public:
*/
HousekeepingPacketUpdate(uint8_t* timeStamp, size_t timeStampSize,
LocalPoolDataSetBase* dataSetPtr):
timeStamp(timeStamp), timeStampSize(timeStampSize),
dataSetPtr(dataSetPtr) {};
timeStamp(timeStamp), timeStampSize(timeStampSize),
updateData(dataSetPtr) {};
/**
* Update packet constructor for pool variables.
* @param timeStamp
* @param timeStampSize
* @param dataSetPtr
*/
HousekeepingPacketUpdate(uint8_t* timeStamp, size_t timeStampSize,
LocalPoolObjectBase* dataSetPtr):
timeStamp(timeStamp), timeStampSize(timeStampSize),
updateData(dataSetPtr) {};
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
size_t maxSize, Endianness streamEndianness) const {
@@ -31,43 +43,50 @@ public:
*size += timeStampSize;
*buffer += timeStampSize;
}
if(dataSetPtr == nullptr) {
if(updateData == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return dataSetPtr->serialize(buffer, size, maxSize, streamEndianness);
return updateData->serialize(buffer, size, maxSize, streamEndianness);
}
virtual size_t getSerializedSize() const {
if(dataSetPtr == nullptr) {
if(updateData == nullptr) {
return 0;
}
return timeStampSize + dataSetPtr->getSerializedSize();
return timeStampSize + updateData->getSerializedSize();
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override {
if(*size < timeStampSize) {
return SerializeIF::STREAM_TOO_SHORT;
}
if(timeStamp != nullptr) {
/* Endianness will always be MACHINE, so we can simply use memcpy
here. */
std::memcpy(timeStamp, *buffer, timeStampSize);
*size += timeStampSize;
*size -= timeStampSize;
*buffer += timeStampSize;
}
if(dataSetPtr == nullptr) {
if(updateData == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return dataSetPtr->deSerialize(buffer, size, streamEndianness);
if(*size < updateData->getSerializedSize()) {
return SerializeIF::STREAM_TOO_SHORT;
}
return updateData->deSerialize(buffer, size, streamEndianness);
}
private:
uint8_t* timeStamp;
size_t timeStampSize;
uint8_t* timeStamp = nullptr;
size_t timeStampSize = 0;
LocalPoolDataSetBase* dataSetPtr = nullptr;
SerializeIF* updateData = nullptr;
};
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */

View File

@@ -1,5 +1,6 @@
#include "../datapoollocal/LocalPoolDataSetBase.h"
#include "PeriodicHousekeepingHelper.h"
#include "../datapoollocal/LocalPoolDataSetBase.h"
#include <cmath>
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(