This commit is contained in:
Ulrich Mohr 2023-07-12 14:19:58 +02:00
parent 3a433915f1
commit ae2823ba2d
7 changed files with 113 additions and 49 deletions

View File

@ -118,29 +118,12 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, size_t offset,
action->commandedBy = commandedBy;
result = owner->executeAction(action);
TmManager::protocolInformation information;
result = tmManager->getProtocolInformation(dataAddress, &information);
result =
tmManager->sendTmPacket(0xff, HasActionsIF::INTERFACE_ID, 0x13, action, dataAddress, offset);
if (result != returnvalue::OK) {
// HTF did we get here?
sif::error << "replying action failed " << std::hex << result << std::dec << std::endl;
}
store_address_t replyStoreId;
uint8_t* replyPointer;
result = ipcStore->getFreeElement(&replyStoreId, information.offset + 4, &replyPointer);
if (result != returnvalue::OK) {
return;
}
memset(replyPointer, 0xfd, 4);
CommandMessage message;
ipcStore->deleteData(dataAddress);
TmMessage::setCommand(&message, replyStoreId, store_address_t());
queueToUse->sendMessage(information.reportingQueue, &message);
// ipcStore->deleteData(dataAddress);
if (result == HasActionsIF::EXECUTION_FINISHED) {
CommandMessage reply;

View File

@ -8,7 +8,7 @@
#include "HousekeepingSet.h"
class HousekeepingHelper {
friend class HousekeepingHelper;
friend class HousekeepingSet;
public:
HousekeepingHelper();
@ -20,10 +20,10 @@ class HousekeepingHelper {
return &housekeepingSets;
}
protected:
void registerSet(HousekeepingSet* set);
protected:
ReturnValue_t reportHousekeeping(SerializeIF* data, const Action* action = nullptr);
ReturnValue_t reportHousekeeping(HousekeepingSet* set, const Action* action = nullptr);
private:
std::map<HousekeepingSetId_t, HousekeepingSet*> housekeepingSets;

View File

@ -4,7 +4,8 @@
#ifdef FSFW_INTROSPECTION
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id) {
owner->getHelper()->registerSet(this);
helper = owner->getHelper();
helper->registerSet(this);
}
void HousekeepingSet::setEnum(EnumIF* theEnum) {
@ -13,13 +14,17 @@ void HousekeepingSet::setEnum(EnumIF* theEnum) {
}
#else
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id) : id(id) {
owner->getHelper()->registerSet(this);
helper = owner->getHelper();
helper->registerSet(this);
}
#endif
void HousekeepingSet::report(const Action* action) {
helper->reportHousekeeping(this, action);
}
void HousekeepingSet::registerParameter(ParameterIF* parameter) {
parameterList.push_back(parameter);
}
std::vector<ParameterIF*> const* HousekeepingSet::getParameters() { return &parameterList; }

View File

@ -4,6 +4,7 @@
#include <fsfw/introspection/Enum.h>
#include <fsfw/introspection/HasTmTcParametersIF.h>
#include <fsfw/introspection/ParameterIF.h>
#include <fsfw/serialize/SerializeIF.h>
#include <cstdint>
@ -12,20 +13,21 @@ class GeneratesHousekeepingIF;
using HousekeepingSetId_t = uint32_t;
class HousekeepingSet : public HasTmTcParametersIF {
class HousekeepingSet : public HasTmTcParametersIF, public SerializeIF {
friend class ParameterIF;
public:
#ifdef FSFW_INTROSPECTION
HousekeepingSet(GeneratesHousekeepingIF* owner);
void setEnum(EnumIF* theEnum);
#else
HousekeepingSet(GeneratesHousekeepingIF *owner, HousekeepingSetId_t id);
HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id);
#endif
HousekeepingSetId_t getId() const { return id; }
void report(const Action* action = nullptr);
void registerParameter(ParameterIF* parameter) override;
std::vector<ParameterIF*> const* getParameters() override;
protected:
@ -35,4 +37,6 @@ class HousekeepingSet : public HasTmTcParametersIF {
const char* description;
#endif
std::vector<ParameterIF*> parameterList;
void registerParameter(ParameterIF* parameter) override;
};

View File

@ -5,10 +5,13 @@
class FsfwProtocolHeader : public SerializeIF {
public:
using InterfaceType_t = uint8_t;
using FunctionType_t = uint8_t;
static const size_t HEADER_SIZE = 6;
FsfwProtocolHeader();
FsfwProtocolHeader(object_id_t objectID, uint8_t interface, uint8_t function);
FsfwProtocolHeader(object_id_t objectID, InterfaceType_t interface, FunctionType_t function);
~FsfwProtocolHeader() override;
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
@ -20,11 +23,11 @@ class FsfwProtocolHeader : public SerializeIF {
Endianness streamEndianness) override;
object_id_t getObjectId() const;
uint8_t getInterface() const;
uint8_t getFunction() const;
InterfaceType_t getInterface() const;
FunctionType_t getFunction() const;
private:
object_id_t objectId;
uint8_t interface;
uint8_t function;
InterfaceType_t interface;
FunctionType_t function;
};

View File

@ -1,7 +1,10 @@
#include "TmManager.h"
#include <fsfw/ipc/MessageQueueSenderIF.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include "TmMessage.h"
TmManager::TmManager(object_id_t setObjectId) : SystemObject(setObjectId) {}
ReturnValue_t TmManager::initialize() {
@ -18,8 +21,62 @@ ReturnValue_t TmManager::initialize() {
return returnvalue::OK;
}
ReturnValue_t TmManager::sendTmPacket(object_id_t objectId,
FsfwProtocolHeader::InterfaceType_t interface,
FsfwProtocolHeader::FunctionType_t function,
SerializeIF* applicationData, store_address_t tc,
size_t tcOffset) {
ProtocolInformation information;
ReturnValue_t result = getProtocolInformation(tc, &information);
if (result != returnvalue::OK) {
return result;
}
const FsfwProtocolHeader tmHeader = FsfwProtocolHeader(objectId, interface, function);
const size_t storedTcSize =
information.offset + tmHeader.getSerializedSize() + applicationData->getSerializedSize();
store_address_t tm;
uint8_t* dataPointer;
result = IPCStore->getFreeElement(&tm, storedTcSize, &dataPointer);
if (result != returnvalue::OK) {
return result;
}
*dataPointer = information.protocol;
size_t serializedSize = information.offset;
dataPointer += information.offset;
result = tmHeader.serialize(&dataPointer, &serializedSize, storedTcSize,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
IPCStore->deleteData(tm);
return result;
}
result = applicationData->serialize(&dataPointer, &serializedSize, storedTcSize,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
IPCStore->deleteData(tm);
return result;
}
CommandMessage tmMessage;
TmMessage::setCommand(&tmMessage, tm, tc);
result = MessageQueueSenderIF::sendMessage(information.reportingQueue, &tmMessage);
if (result != returnvalue::OK) {
IPCStore->deleteData(tm);
return result;
}
return returnvalue::OK;
}
ReturnValue_t TmManager::getProtocolInformation(store_address_t tc,
protocolInformation* information) const {
ProtocolInformation* information) const {
const uint8_t* tcData;
size_t tcDataSize;
ReturnValue_t result = IPCStore->getData(tc, &tcData, &tcDataSize);
@ -47,12 +104,13 @@ ReturnValue_t TmManager::registerNetworkProtocolInterface(AcceptsTelemetryIF2* o
return returnvalue::FAILED;
}
protocolMap.emplace(protocol, ProtocolInformation({object->getReportReceptionQueue(), offset}));
protocolMap.emplace(protocol,
StoredProtocolInformation({object->getReportReceptionQueue(), offset}));
return returnvalue::OK;
}
ReturnValue_t TmManager::getDefaultProtocolInformation(protocolInformation* information) const {
ReturnValue_t TmManager::getDefaultProtocolInformation(ProtocolInformation* information) const {
if (protocolMap.empty()) {
return returnvalue::FAILED;
}

View File

@ -6,18 +6,19 @@
#include <map>
#include "AcceptsTelemetryIF.h"
#include "FsfwProtocolHeader.h"
#include "FsfwProtocols.h"
// TODO handle VCs and backpressure
// TODO trailing space?
class TmManager : public SystemObject {
public:
struct protocolInformation {
neither_type protocol;
size_t offset;
MessageQueueId_t reportingQueue;
};
struct ProtocolInformation {
neither_type protocol;
size_t offset;
MessageQueueId_t reportingQueue;
};
TmManager(object_id_t setObjectId);
@ -25,32 +26,42 @@ class TmManager : public SystemObject {
ReturnValue_t initialize() override;
/**
* send a tm packet
*
*
*/
ReturnValue_t sendTmPacket(object_id_t objectId, FsfwProtocolHeader::InterfaceType_t interface,
FsfwProtocolHeader::FunctionType_t function,
SerializeIF *applicationData,
store_address_t tc = store_address_t(), size_t tcOffset = 0);
/**
* returns the offset which the application data should start at, using the same network layer as
* the tc, as well as the protocol type which should be the first byte of the tm
*
*/
ReturnValue_t getProtocolInformation(store_address_t tc, protocolInformation *information) const;
ReturnValue_t getProtocolInformation(store_address_t tc, ProtocolInformation *information) const;
/**
* If tm is unrequested, get Default path
*/
ReturnValue_t getDefaultProtocolInformation(protocolInformation *information) const;
ReturnValue_t getDefaultProtocolInformation(ProtocolInformation *information) const;
/**
* Offset is where application data should start in a preset zero-copy packet. If no fixed value,
* report 0 and allocate and copy yourself
* Offset is where application data should start in a preallocated zero-copy packet. If no fixed
* value, report 0 and allocate and copy yourself
*/
ReturnValue_t registerNetworkProtocolInterface(AcceptsTelemetryIF2 *object, neither_type protocol,
size_t offset);
protected:
struct ProtocolInformation {
struct StoredProtocolInformation {
MessageQueueId_t queue;
size_t offset;
};
StorageManagerIF *IPCStore;
std::map<neither_type, ProtocolInformation> protocolMap;
std::map<neither_type, StoredProtocolInformation> protocolMap;
};