fsfw/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h

93 lines
2.9 KiB
C
Raw Normal View History

#ifndef FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_
#define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_
2022-07-19 18:13:25 +02:00
#include "PusTmIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
2022-07-20 11:43:16 +02:00
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
2022-07-20 22:21:15 +02:00
#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h"
struct timeval;
2022-07-20 11:43:16 +02:00
class PacketTimestampInterpreterIF;
2022-07-20 11:43:16 +02:00
namespace mintm {
// NOTE: Only PUS C compatible!
2022-07-20 22:21:15 +02:00
struct PusTmMinimalSecHeaderPacked {
2022-07-20 11:43:16 +02:00
uint8_t versionAndScTimeRefStatus;
uint8_t service;
uint8_t subservice;
uint8_t messageTypeH;
uint8_t messageTypeL;
};
/**
* This struct defines the data structure of a PUS Telecommand Packet when
* accessed via a pointer.
* @ingroup tmtcpackets
*/
struct MinimalPusTm {
ccsds::PrimaryHeader primary;
2022-07-20 22:21:15 +02:00
PusTmMinimalSecHeaderPacked secHeader;
2022-07-20 11:43:16 +02:00
uint8_t rest;
};
// Must include a checksum and is therefore at least one larger than the above struct.
static const uint16_t MINIMUM_SIZE = sizeof(MinimalPusTm) + 1;
} // namespace mintm
/**
* This is a minimal version of a PUS TmPacket without any variable field, or,
* in other words with Service Type, Subtype and subcounter only.
* This is required for handling TM packets with different APIDs with different
* secondary headers.
*/
2022-07-20 22:21:15 +02:00
class PusTmMinimal : public PusTmIF, public RawUserDataReaderIF, public RedirectableDataPointerIF {
2022-02-02 10:29:30 +01:00
public:
2022-07-20 11:43:16 +02:00
explicit PusTmMinimal(mintm::MinimalPusTm* data);
2022-02-02 10:29:30 +01:00
/**
* This is the default constructor.
* It sets its internal data pointer to the address passed and also
* forwards the data pointer to the parent SpacePacketBase class.
* @param set_address The position where the packet data lies.
*/
2022-07-19 18:13:25 +02:00
explicit PusTmMinimal(uint8_t* data);
2022-02-02 10:29:30 +01:00
/**
* This is the empty default destructor.
*/
2022-07-19 18:13:25 +02:00
~PusTmMinimal() override;
2022-07-19 18:13:25 +02:00
void setApid(uint16_t apid);
2022-07-19 18:13:25 +02:00
ReturnValue_t getPacketTime(timeval* timestamp);
2022-02-02 10:29:30 +01:00
static void setInterpretTimestampObject(PacketTimestampInterpreterIF* interpreter);
2022-07-19 18:13:25 +02:00
ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override;
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 getService() const override;
[[nodiscard]] uint8_t getSubService() const override;
uint8_t getScTimeRefStatus() override;
uint16_t getMessageTypeCounter() override;
uint16_t getDestId() override;
2022-07-21 11:34:11 +02:00
const uint8_t* getUserData() const override;
size_t getUserDataLen() const override;
2022-07-19 18:13:25 +02:00
2022-02-02 10:29:30 +01:00
protected:
/**
* A pointer to a structure which defines the data structure of
* the packet's data.
*
* To be hardware-safe, all elements are of byte size.
*/
2022-07-20 22:21:15 +02:00
size_t userDataLen = 0;
2022-07-20 11:43:16 +02:00
mintm::MinimalPusTm* tmData;
2022-02-02 10:29:30 +01:00
static PacketTimestampInterpreterIF* timestampInterpreter;
};
#endif /* FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ */