fsfw/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h

80 lines
2.7 KiB
C
Raw Normal View History

2020-10-28 02:20:12 +01:00
#ifndef FSFW_TMTCPACKET_SPACEPACKETBASE_H_
#define FSFW_TMTCPACKET_SPACEPACKETBASE_H_
2020-05-15 19:51:39 +02:00
#include <cstddef>
2022-02-02 10:29:30 +01:00
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
2022-07-20 11:43:16 +02:00
#include "fsfw/tmtcpacket/ReadablePacketIF.h"
#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h"
#include "fsfw/tmtcpacket/ccsds/defs.h"
2022-02-02 10:29:30 +01:00
/**
2020-05-15 19:51:39 +02:00
* @defgroup tmtcpackets Space Packets
* This is the group, where all classes associated with Telecommand and
* Telemetry packets belong to.
* The class hierarchy resembles the dependency between the different standards
* applied, namely the CCSDS Space Packet standard and the ECCSS Packet
* Utilization Standard. Most field and structure names are taken from these
* standards.
*/
/**
* This class is the basic data handler for any CCSDS Space Packet
* compatible Telecommand and Telemetry packet.
* 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.
* Remark: All bit numbers in this documentation are counted from
* the most significant bit (from left).
* @ingroup tmtcpackets
*/
2022-07-19 18:13:25 +02:00
class SpacePacketReader : public SpacePacketIF,
public ReadablePacketIF,
public RedirectableDataPointerIF {
2022-02-02 10:29:30 +01:00
public:
2022-07-19 18:13:25 +02:00
SpacePacketReader() = default;
2022-02-02 10:29:30 +01:00
/**
* This is the default constructor.
* It sets its internal data pointer to the address passed.
* @param set_address The position where the packet data lies.
*/
2022-07-19 18:13:25 +02:00
explicit SpacePacketReader(const uint8_t* setAddress, size_t maxSize);
2022-02-02 10:29:30 +01:00
/**
* No data is allocated, so the destructor is empty.
*/
2022-07-18 10:42:56 +02:00
~SpacePacketReader() override;
2022-02-02 10:29:30 +01:00
2022-07-20 11:43:16 +02:00
[[nodiscard]] uint16_t getPacketIdRaw() const override;
[[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override;
2022-07-18 10:20:26 +02:00
[[nodiscard]] uint16_t getPacketDataLen() const override;
2022-07-19 18:13:25 +02:00
const uint8_t* getFullData() override;
2022-02-02 10:29:30 +01:00
// Helper methods:
2022-07-19 18:13:25 +02:00
[[nodiscard]] ReturnValue_t checkLength() const;
2022-02-02 10:29:30 +01:00
2022-07-19 18:13:25 +02:00
const uint8_t* getPacketData();
2022-02-02 10:29:30 +01:00
/**
* With this method, the packet data pointer can be redirected to another
* location.
* @param p_Data A pointer to another raw Space Packet.
*/
2022-07-18 10:20:26 +02:00
ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args) override;
2022-07-19 18:13:25 +02:00
protected:
2022-02-02 10:29:30 +01:00
/**
2022-07-19 18:13:25 +02:00
* A pointer to a structure which defines the data structure of
* the packet header.
* To be hardware-safe, all elements are of byte size.
2022-02-02 10:29:30 +01:00
*/
2022-07-20 11:43:16 +02:00
const ccsds::PrimaryHeader* spHeader{};
2022-07-19 18:13:25 +02:00
const uint8_t* packetDataField{};
size_t maxSize = 0;
void setInternalFields(const uint8_t* data, size_t maxSize);
};
2020-10-28 02:20:12 +01:00
#endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */