1
0
forked from fsfw/fsfw

taken over some changes

This commit is contained in:
2020-10-28 19:27:00 +01:00
parent e7210a34f9
commit 90bdb844e7
8 changed files with 243 additions and 252 deletions

View File

@ -1,8 +1,8 @@
#ifndef TMPACKETBASE_H_
#define TMPACKETBASE_H_
#ifndef TMTCPACKET_PUS_TMPACKETBASE_H_
#define TMTCPACKET_PUS_TMPACKETBASE_H_
#include "../SpacePacketBase.h"
#include "../../timemanager/TimeStamperIF.h"
#include "../../tmtcpacket/SpacePacketBase.h"
#include "../../timemanager/Clock.h"
#include "../../objectmanager/SystemObjectIF.h"
@ -14,7 +14,7 @@ void setStaticFrameworkObjectIds();
* This struct defines a byte-wise structured PUS TM Data Field Header.
* Any optional fields in the header must be added or removed here.
* Currently, no Destination field is present, but an eigth-byte representation
* for a time tag [TBD].
* for a time tag.
* @ingroup tmtcpackets
*/
struct PUSTmDataFieldHeader {
@ -40,7 +40,7 @@ struct TmPacketPointer {
/**
* This class is the basic data handler for any ECSS PUS Telemetry packet.
*
* In addition to \SpacePacketBase, the class provides methods to handle
* In addition to #SpacePacketBase, the class provides methods to handle
* the standardized entries of the PUS TM 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
@ -54,29 +54,27 @@ public:
/**
* This constant defines the minimum size of a valid PUS Telemetry Packet.
*/
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) + sizeof(PUSTmDataFieldHeader) + 2); //!< Minimum size of a valid PUS Telemetry Packet.
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048; //!< Maximum size of a TM Packet in this mission.
static const uint8_t VERSION_NUMBER_BYTE_PUS_A = 0b00010000; //!< First byte of secondary header for PUS-A packets.
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
sizeof(PUSTmDataFieldHeader) + 2);
//! Maximum size of a TM Packet in this mission.
//! TODO: Make this dependant on a config variable.
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
//! First byte of secondary header for PUS-A packets.
//! TODO: Maybe also support PUS-C via config?
static const uint8_t VERSION_NUMBER_BYTE_PUS_A = 0b00010000;
/**
* 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 set_address The position where the packet data lies.
*/
TmPacketBase( uint8_t* set_data );
TmPacketBase( uint8_t* setData );
/**
* This is the empty default destructor.
*/
virtual ~TmPacketBase();
/**
* Initializes the Tm Packet header.
* Does set the timestamp (to now), but not the error control field.
* @param apid APID used.
* @param service PUS Service
* @param subservice PUS Subservice
* @param packetSubcounter Additional subcounter used.
*/
void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packetSubcounter);
/**
* This is a getter for the packet's PUS Service ID, which is the second
* byte of the Data Field Header.
@ -106,11 +104,14 @@ public:
*/
uint16_t getSourceDataSize();
/**
* In case data was filled manually (almost never the case).
* @param size Size of source data (without CRC and data filed header!).
*/
void setSourceDataSize(uint16_t size);
/**
* With this method, the Error Control Field is updated to match the
* current content of the packet. This method is not protected because
* a recalculation by the user might be necessary when manipulating fields
* like the sequence count.
*/
void setErrorControl();
/**
* This getter returns the Error Control Field of the packet.
*
@ -120,35 +121,15 @@ public:
* @return The PUS Error Control
*/
uint16_t getErrorControl();
/**
* With this method, the Error Control Field is updated to match the
* current content of the packet.
*/
void setErrorControl();
/**
* This sets the source data. It copies the provided data to
* the internal TmPacketPointer source data location.
* @param sourceData
* @param sourceSize
*/
void setSourceData(uint8_t* sourceData, size_t sourceSize);
/**
* 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 Telemetry Packet.
*/
void setData( const uint8_t* p_Data );
/**
* This is a debugging helper method that prints the whole packet content
* to the screen.
*/
void print();
/**
* Interprets the "time"-field in the secondary header and returns it in timeval format.
* Interprets the "time"-field in the secondary header and returns it in
* timeval format.
* @return Converted timestamp of packet.
*/
ReturnValue_t getPacketTime(timeval* timestamp) const;
@ -158,7 +139,7 @@ public:
*/
uint8_t* getPacketTimeRaw() const;
uint32_t getTimestampSize() const;
size_t getTimestampSize() const;
protected:
/**
@ -167,20 +148,49 @@ protected:
*
* To be hardware-safe, all elements are of byte size.
*/
TmPacketPointer* tm_data;
TmPacketPointer* tmData;
/**
* The timeStamper is responsible for adding a timestamp to the packet.
* It is initialized lazy.
*/
static TimeStamperIF* timeStamper;
//! The ID to use when looking for a time stamper.
static object_id_t timeStamperId;
static object_id_t timeStamperId; //!< The ID to use when looking for a time stamper.
/**
* Checks if a time stamper is available and tries to set it if not.
* @return Returns false if setting failed.
*/
bool checkAndSetStamper();
/**
* Initializes the Tm Packet header.
* Does set the timestamp (to now), but not the error control field.
* @param apid APID used.
* @param service PUS Service
* @param subservice PUS Subservice
* @param packetSubcounter Additional subcounter used.
*/
void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
uint8_t packetSubcounter);
/**
* 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 Telemetry Packet.
*/
void setData( const uint8_t* pData );
/**
* In case data was filled manually (almost never the case).
* @param size Size of source data (without CRC and data filed header!).
*/
void setSourceDataSize(uint16_t size);
/**
* Checks if a time stamper is available and tries to set it if not.
* @return Returns false if setting failed.
*/
bool checkAndSetStamper();
};
#endif /* TMPACKETBASE_H_ */
#endif /* TMTCPACKET_PUS_TMPACKETBASE_H_ */