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

84 lines
3.0 KiB
C
Raw Normal View History

2022-07-19 18:13:25 +02:00
#ifndef FSFW_TMTCPACKET_PUSTMREADER_H
#define FSFW_TMTCPACKET_PUSTMREADER_H
2022-07-21 11:34:11 +02:00
#include "fsfw/timemanager/TimeReaderIF.h"
#include "fsfw/tmtcpacket/ReadablePacketIF.h"
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h"
2022-07-19 18:13:25 +02:00
#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h"
2022-07-28 13:24:50 +02:00
/**
* This object can be used to read existing PUS TM packets in raw byte format.
* It is a zero-copy object, so reading a TM packet with will not copy anything.
*
* Please note that a parser function must be called after the constructor. This will also check
* the packet for validity.
*
* There are two parser function, where one does not perform the CRC check. This is useful
* if the CRC calculation will is performed in a separate step.
* This object also requires an explicit time stamp reader to allow flexibility in the used
* timestamp.
*/
2022-07-21 11:34:11 +02:00
class PusTmReader : public PusTmIF,
public RawUserDataReaderIF,
public ReadablePacketIF,
public RedirectableDataPointerIF {
public:
explicit PusTmReader(TimeReaderIF* timeReader);
PusTmReader(const uint8_t* data, size_t size);
PusTmReader(TimeReaderIF* timeReader, const uint8_t* data, size_t size);
2022-07-28 13:24:50 +02:00
/**
* No CRC check will be performed
* @return
*/
2022-07-21 13:48:58 +02:00
ReturnValue_t parseDataWithoutCrcCheck();
2022-07-28 13:24:50 +02:00
/**
* Performs a CRC check on the data as well
* @return
* - HasReturnvaluesIF::RETURN_OK: Successfully parsed the packet
* - SerializeIF::STREAM_TOO_SHORT: Stream too short for detected packet size
* - PusIF::INVALID_CRC_16 on invalid CRC
*/
2022-07-21 13:48:58 +02:00
ReturnValue_t parseDataWithCrcCheck();
2022-07-27 17:33:39 +02:00
[[nodiscard]] const uint8_t* getFullData() const override;
2022-07-21 11:34:11 +02:00
2022-07-28 13:24:50 +02:00
/**
* Returns @isNull
* @return
*/
2022-07-22 18:22:35 +02:00
explicit operator bool() const;
2022-07-28 13:24:50 +02:00
/**
* No (valid) data was set yet or the parse function was not called yet.
* @return
*/
2022-07-22 18:22:35 +02:00
[[nodiscard]] bool isNull() const;
2022-07-21 11:34:11 +02:00
void setTimeReader(TimeReaderIF* timeReader);
TimeReaderIF* getTimeReader();
ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size);
[[nodiscard]] uint16_t getPacketIdRaw() const override;
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
[[nodiscard]] uint16_t getPacketDataLen() const override;
[[nodiscard]] uint8_t getPusVersion() const override;
[[nodiscard]] uint8_t getService() const override;
[[nodiscard]] uint8_t getSubService() const override;
2022-07-22 18:22:35 +02:00
[[nodiscard]] const uint8_t* getUserData() const override;
[[nodiscard]] size_t getUserDataLen() const override;
2022-07-21 11:34:11 +02:00
uint8_t getScTimeRefStatus() override;
uint16_t getMessageTypeCounter() override;
uint16_t getDestId() override;
2022-07-27 11:26:47 +02:00
protected:
ecss::PusPointers pointers{};
2022-07-21 11:34:11 +02:00
SpacePacketReader spReader{};
size_t sourceDataLen = 0;
TimeReaderIF* timeReader{};
2022-07-27 11:26:47 +02:00
ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override;
ReturnValue_t parseData(bool crcCheck);
private:
2022-07-21 11:34:11 +02:00
};
2022-07-19 18:13:25 +02:00
#endif // FSFW_TMTCPACKET_PUSTMREADER_H