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

81 lines
2.9 KiB
C
Raw Normal View History

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-21 11:34:11 +02:00
#include "fsfw/tmtcpacket/pus/defs.h"
2022-07-18 18:36:41 +02:00
/**
2022-07-21 11:34:11 +02:00
* This class is the basic reader class to read ECSS PUS C Telecommand packets.
2022-07-18 18:36:41 +02:00
*
2022-07-21 11:34:11 +02:00
* 1. Implements the @SpacePacketIF to provide accessor methods for the contained space packet.
* 2. Implements the @PusTcIF to provide accessor methods for generic PUS C fields
*
* This is a zero-copy reader class. It does not contain the packet data itself but a pointer to
* the data. Calling any accessor methods without pointing the object to valid data first will
* cause undefined behaviour.
2022-07-18 18:36:41 +02:00
* @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-22 18:22:35 +02:00
~PusTcReader() override;
2022-07-18 18:36:41 +02:00
2022-07-22 18:22:35 +02:00
explicit operator bool() const;
2022-07-21 19:10:15 +02:00
[[nodiscard]] bool isNull() const;
2022-07-21 13:48:58 +02:00
ReturnValue_t parseDataWithCrcCheck();
ReturnValue_t parseDataWithoutCrcCheck();
2022-07-18 18:36:41 +02:00
/**
* 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;
2022-07-27 17:00:43 +02:00
const uint8_t* getFullData() const override;
2022-07-19 18:13:25 +02:00
2022-07-20 22:21:15 +02:00
ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size);
2022-07-21 11:34:11 +02:00
[[nodiscard]] const uint8_t* getUserData() const override;
2022-07-21 19:10:15 +02:00
[[nodiscard]] size_t getUserDataLen() const 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-21 13:48:58 +02:00
ReturnValue_t parseData(bool withCrc);
2022-07-19 18:13:25 +02:00
2022-07-18 18:36:41 +02:00
SpacePacketReader spReader;
2022-07-21 11:34:11 +02:00
ecss::PusPointers pointers{};
2022-07-19 18:13:25 +02:00
size_t appDataSize = 0;
2022-07-18 18:36:41 +02:00
};
#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */