fsfw/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h

80 lines
3.1 KiB
C
Raw Normal View History

2022-07-18 10:29:39 +02:00
#ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H
#define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
2022-07-20 11:43:16 +02:00
#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h"
2022-07-22 17:09:44 +02:00
#include "fsfw/tmtcpacket/pus/CustomUserDataIF.h"
2022-07-21 11:34:11 +02:00
#include "fsfw/tmtcpacket/pus/defs.h"
2022-07-19 18:13:25 +02:00
#include "fsfw/tmtcpacket/pus/tc/PusTcIF.h"
2022-07-18 10:29:39 +02:00
2022-07-19 18:13:25 +02:00
struct PusTcParams {
PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {}
2022-09-05 16:02:32 +02:00
void setRawAppData(const uint8_t *data, size_t len) {
bufAdapter.setConstBuffer(data, len);
appData = &bufAdapter;
}
void setSerializableAppData(const SerializeIF &serializable) { appData = &serializable; }
2022-07-19 18:13:25 +02:00
uint8_t service;
uint8_t subservice;
uint8_t ackFlags = ecss::ACK_ALL;
uint16_t sourceId = 0;
2022-09-05 16:02:32 +02:00
SerialBufferAdapter<uint8_t> bufAdapter;
const SerializeIF *appData = nullptr;
2022-07-19 18:13:25 +02:00
uint8_t pusVersion = ecss::PusVersion::PUS_C;
};
2022-07-28 13:24:50 +02:00
/**
* This class provides a high-level interface to create PUS TC packets and then @serialize
* them into a raw byte format. It implements @SerializeIF for that purpose.
* A custom time stamper can be set, with the implementation of @TimeStamperIF as the only
* requirement.
*/
2022-07-22 17:09:44 +02:00
class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF {
2022-07-18 10:29:39 +02:00
public:
2022-07-21 17:48:11 +02:00
PusTcCreator(SpacePacketParams initSpParams, PusTcParams initPusParams);
2022-07-19 18:13:25 +02:00
2022-07-21 17:48:11 +02:00
/**
* If the parameter structure is changed in a way which changes the resulting serialized packet
* size, this function should be called to set the data length field in the space packet
* header. This fields is the primary source of information for length information.
*
* The only case for a telecommand where this size changes would be if user data is set.
*/
2022-07-19 18:13:25 +02:00
void updateSpLengthField();
2022-07-21 11:34:11 +02:00
PusTcParams &getPusParams();
SpacePacketParams &getSpParams();
2022-07-21 19:10:15 +02:00
2022-07-19 18:13:25 +02:00
[[nodiscard]] size_t getSerializedSize() const override;
2022-07-27 21:11:12 +02:00
2022-07-20 11:43:16 +02:00
[[nodiscard]] uint16_t getPacketIdRaw() const override;
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
2022-07-19 18:13:25 +02:00
[[nodiscard]] uint16_t getPacketDataLen() const override;
[[nodiscard]] uint8_t getPusVersion() const override;
[[nodiscard]] uint8_t getAcknowledgeFlags() const override;
[[nodiscard]] uint8_t getService() const override;
[[nodiscard]] uint8_t getSubService() const override;
[[nodiscard]] uint16_t getSourceId() const override;
2022-07-22 17:09:44 +02:00
ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override;
2022-09-05 16:02:32 +02:00
ReturnValue_t setSerializableUserData(const SerializeIF &serializable) override;
2022-07-18 10:29:39 +02:00
2022-08-15 19:16:31 +02:00
// Load all big endian helpers into the class namespace
using SerializeIF::serializeBe;
2022-07-18 10:42:56 +02:00
private:
2022-08-15 19:16:31 +02:00
// Forbidden to use, enforce big endian serialization
2022-07-21 17:48:11 +02:00
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
2022-07-27 21:11:12 +02:00
// Forbidden to use
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
void setup();
2022-07-19 18:13:25 +02:00
SpacePacketCreator spCreator;
PusTcParams pusParams;
2022-07-18 10:29:39 +02:00
};
#endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H