fsfw/tmtcpacket/pus/tc/TcPacketPus.h

91 lines
2.6 KiB
C
Raw Normal View History

2021-06-13 12:34:06 +02:00
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
2021-06-14 10:19:01 +02:00
#include "../../../FSFW.h"
#include "../../ccsds_header.h"
2021-06-13 12:34:06 +02:00
#include "TcPacketBase.h"
#include <cstdint>
/**
* This struct defines a byte-wise structured PUS TC A Data Field Header.
* Any optional fields in the header must be added or removed here.
* Currently, the Source Id field is present with one byte.
* @ingroup tmtcpackets
*/
struct PUSTcDataFieldHeader {
2021-06-14 10:19:01 +02:00
uint8_t versionTypeAck;
uint8_t serviceType;
uint8_t serviceSubtype;
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
2021-06-14 11:16:56 +02:00
uint8_t sourceIdH;
uint8_t sourceIdL;
2021-06-14 10:19:01 +02:00
#else
uint8_t sourceId;
#endif
2021-06-13 12:34:06 +02:00
};
/**
* This struct defines the data structure of a PUS Telecommand A packet when
* accessed via a pointer.
* @ingroup tmtcpackets
*/
struct TcPacketPointer {
CCSDSPrimaryHeader primary;
PUSTcDataFieldHeader dataField;
uint8_t appData;
};
2021-06-14 10:19:01 +02:00
class TcPacketPus: public TcPacketBase {
2021-06-13 12:34:06 +02:00
public:
2021-06-13 16:29:13 +02:00
static const uint16_t TC_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
sizeof(PUSTcDataFieldHeader) + 2);
/**
* Initialize a PUS A telecommand packet which already exists. You can also
* create an empty (invalid) object by passing nullptr as the data pointer
* @param setData
*/
2021-06-14 10:19:01 +02:00
TcPacketPus(const uint8_t* setData);
2021-06-13 16:29:13 +02:00
// Base class overrides
2021-06-14 11:16:56 +02:00
uint8_t getSecondaryHeaderFlag() const override;
uint8_t getPusVersionNumber() const override;
uint8_t getAcknowledgeFlags() const override;
uint8_t getService() const override;
uint8_t getSubService() const override;
uint16_t getSourceId() const override;
2021-06-13 16:29:13 +02:00
const uint8_t* getApplicationData() const override;
2021-06-14 11:16:56 +02:00
uint16_t getApplicationDataSize() const override;
uint16_t getErrorControl() const override;
2021-06-13 16:29:13 +02:00
void setErrorControl() override;
2021-06-14 11:16:56 +02:00
size_t calculateFullPacketLength(size_t appDataLen) const override;
2021-06-13 16:29:13 +02:00
protected:
void setData(const uint8_t* pData) override;
/**
* Initializes the Tc Packet header.
* @param apid APID used.
* @param sequenceCount Sequence Count in the primary header.
* @param ack Which acknowledeges are expected from the receiver.
* @param service PUS Service
* @param subservice PUS Subservice
*/
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
uint8_t service, uint8_t subservice);
/**
* 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.
*/
TcPacketPointer* tcData = nullptr;
2021-06-13 12:34:06 +02:00
};
#endif /* FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ */