2022-07-18 18:36:41 +02:00
|
|
|
#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_
|
|
|
|
#define TMTCPACKET_PUS_TCPACKETBASE_H_
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
#include "PusTcIF.h"
|
|
|
|
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.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"
|
2022-07-18 18:36:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is the basic data handler for any ECSS PUS Telecommand packet.
|
|
|
|
*
|
|
|
|
* In addition to #SpacePacketBase, the class provides methods to handle
|
|
|
|
* the standardized entries of the PUS TC Packet Data Field Header.
|
|
|
|
* It does not contain the packet data itself but a pointer to the
|
|
|
|
* data must be set on instantiation. An invalid pointer may cause
|
|
|
|
* damage, as no getter method checks data validity. Anyway, a NULL
|
|
|
|
* check can be performed by making use of the getWholeData method.
|
|
|
|
* @ingroup tmtcpackets
|
|
|
|
*/
|
2022-07-20 22:21:15 +02:00
|
|
|
class PusTcReader : public PusTcIF,
|
|
|
|
public RawUserDataReaderIF,
|
|
|
|
public ReadablePacketIF,
|
|
|
|
public RedirectableDataPointerIF {
|
2022-07-18 18:36:41 +02:00
|
|
|
public:
|
2022-07-19 18:13:25 +02:00
|
|
|
PusTcReader() = default;
|
2022-07-18 18:36:41 +02: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 setData The position where the packet data lies.
|
|
|
|
*/
|
2022-07-19 18:13:25 +02:00
|
|
|
PusTcReader(const uint8_t* setData, size_t size);
|
2022-07-18 18:36:41 +02:00
|
|
|
|
|
|
|
ReturnValue_t parseData();
|
|
|
|
/**
|
|
|
|
* This is the empty default destructor.
|
|
|
|
*/
|
|
|
|
~PusTcReader() override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a debugging helper method that prints the whole packet content
|
|
|
|
* to the screen.
|
|
|
|
*/
|
2022-07-19 18:13:25 +02:00
|
|
|
// void print();
|
2022-07-20 11:43:16 +02:00
|
|
|
[[nodiscard]] uint16_t getPacketIdRaw() const override;
|
|
|
|
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
|
2022-07-18 18:36:41 +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-19 18:13:25 +02:00
|
|
|
[[nodiscard]] uint16_t getErrorControl() const;
|
|
|
|
const uint8_t* getFullData() override;
|
|
|
|
|
2022-07-20 22:21:15 +02:00
|
|
|
ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size);
|
|
|
|
const uint8_t* getUserData(size_t& userDataLen) override;
|
2022-07-18 18:36:41 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* With this method, the packet data pointer can be redirected to another
|
|
|
|
* location.
|
|
|
|
* This call overwrites the parent's setData method to set both its
|
|
|
|
* @c tc_data pointer and the parent's @c data pointer.
|
|
|
|
*
|
|
|
|
* @param p_data A pointer to another PUS Telecommand Packet.
|
|
|
|
*/
|
2022-07-19 18:13:25 +02:00
|
|
|
ReturnValue_t setData(uint8_t* pData, size_t size, void* args) override;
|
|
|
|
|
2022-07-18 18:36:41 +02:00
|
|
|
SpacePacketReader spReader;
|
|
|
|
/**
|
|
|
|
* This struct defines the data structure of a Space Packet when accessed
|
|
|
|
* via a pointer.
|
|
|
|
* @ingroup tmtcpackets
|
|
|
|
*/
|
|
|
|
struct PusTcPointers {
|
|
|
|
const uint8_t* spHeaderStart;
|
|
|
|
const uint8_t* secHeaderStart;
|
|
|
|
const uint8_t* userDataStart;
|
2022-07-19 18:13:25 +02:00
|
|
|
const uint8_t* crcStart;
|
2022-07-18 18:36:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
PusTcPointers pointers{};
|
2022-07-19 18:13:25 +02:00
|
|
|
size_t size = 0;
|
|
|
|
size_t appDataSize = 0;
|
2022-07-18 18:36:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */
|