F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PduHeader.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PduHeader.hpp
3 // \author Brian Campuzano
4 // \brief hpp file for CFDP PDU Header
5 // ======================================================================
6 
7 #ifndef Svc_Ccsds_Cfdp_PduHeader_HPP
8 #define Svc_Ccsds_Cfdp_PduHeader_HPP
9 
10 #include <Fw/Buffer/Buffer.hpp>
11 #include <Fw/FPrimeBasicTypes.hpp>
17 
18 namespace Svc {
19 namespace Ccsds {
20 namespace Cfdp {
21 
22 // CFDP PDU Type
23 enum class PduType : U8 {
24  PDU_TYPE_DIRECTIVE = 0, // File directive PDU
25  PDU_TYPE_FILE_DATA = 1 // File data PDU
26 };
27 
28 // CFDP PduDirection
29 enum class PduDirection : U8 {
30  DIRECTION_TOWARD_RECEIVER = 0, // Toward file receiver
31  DIRECTION_TOWARD_SENDER = 1 // Toward file sender
32 };
33 
34 // CFDP CRC Flag
35 enum class CrcFlag : U8 {
36  CRC_NOT_PRESENT = 0, // CRC not present
37  CRC_PRESENT = 1 // CRC present
38 };
39 
40 // CFDP Large File Flag
41 enum class LargeFileFlag : U8 {
42  LARGE_FILE_32_BIT = 0, // 32-bit file size
43  LARGE_FILE_64_BIT = 1 // 64-bit file size
44 };
45 
47 class PduHeader {
48  private:
50  PduTypeEnum::T m_type;
51 
53  U8 m_version;
54 
56  PduType m_pduType;
57 
59  PduDirection m_direction;
60 
62  Cfdp::Class::T m_class;
63 
65  CrcFlag m_crcFlag;
66 
68  LargeFileFlag m_largeFileFlag;
69 
71  U8 m_segmentationControl;
72 
74  U8 m_segmentMetadataFlag;
75 
77  U16 m_pduDataLength;
78 
80  EntityId m_sourceEid;
81 
83  TransactionSeq m_transactionSeq;
84 
86  EntityId m_destEid;
87 
88  public:
90  enum { MIN_HEADERSIZE = 7 }; // Minimum fixed portion
91 
93  void initialize(PduTypeEnum::T type,
94  PduDirection direction,
95  Cfdp::Class::T txmMode,
96  EntityId sourceEid,
97  TransactionSeq transactionSeq,
98  EntityId destEid);
99 
101  U32 getBufferSize() const;
102 
106  static U8 getValueEncodedSize(U64 value);
107 
110 
113 
115  PduTypeEnum::T getType() const { return this->m_type; }
116 
118  PduDirection getDirection() const { return this->m_direction; }
119 
121  Cfdp::Class::T getTxmMode() const { return this->m_class; }
122 
124  EntityId getSourceEid() const { return this->m_sourceEid; }
125 
127  TransactionSeq getTransactionSeq() const { return this->m_transactionSeq; }
128 
130  EntityId getDestEid() const { return this->m_destEid; }
131 
133  U16 getPduDataLength() const { return this->m_pduDataLength; }
134 
136  void setPduDataLength(U16 length) { this->m_pduDataLength = length; }
137 
139  LargeFileFlag getLargeFileFlag() const { return this->m_largeFileFlag; }
140 
142  bool hasSegmentMetadata() const { return this->m_segmentMetadataFlag != 0; }
143 
145  void setLargeFileFlag(LargeFileFlag flag) { this->m_largeFileFlag = flag; }
146 
148  friend class MetadataPdu;
149  friend class FileDataPdu;
150  friend class EofPdu;
151  friend class FinPdu;
152  friend class AckPdu;
153  friend class NakPdu;
154 };
155 
159 PduTypeEnum::T peekPduType(const Fw::Buffer& buffer);
160 
161 } // namespace Cfdp
162 } // namespace Ccsds
163 } // namespace Svc
164 
165 #endif // Svc_Ccsds_Cfdp_PduHeader_HPP
EntityId getDestEid() const
Get the destination entity ID.
Definition: PduHeader.hpp:130
U32 EntityId
Entity id size.
bool hasSegmentMetadata() const
Check if segment metadata is present.
Definition: PduHeader.hpp:142
U16 getPduDataLength() const
Get PDU data length.
Definition: PduHeader.hpp:133
void initialize(PduTypeEnum::T type, PduDirection direction, Cfdp::Class::T txmMode, EntityId sourceEid, TransactionSeq transactionSeq, EntityId destEid)
Initialize a PDU header.
Definition: PduHeader.cpp:16
LargeFileFlag getLargeFileFlag() const
Get the large file flag.
Definition: PduHeader.hpp:139
Fw::SerializeStatus fromSerialBuffer(Fw::SerialBufferBase &serialBuffer)
Initialize this Header from a SerialBufferBase.
Definition: PduHeader.cpp:163
SerializeStatus
forward declaration for string
Cfdp::Class::T getTxmMode() const
Get the transmission mode.
Definition: PduHeader.hpp:121
PduTypeEnum::T getType() const
Get the PDU type.
Definition: PduHeader.hpp:115
U32 TransactionSeq
transaction sequence number size
The type of a File Data PDU.
Definition: FileDataPdu.hpp:19
The type of a Metadata PDU.
Definition: MetadataPdu.hpp:20
U32 getBufferSize() const
Compute the buffer size needed to hold this Header.
Definition: PduHeader.cpp:80
The type of a Finished PDU.
Definition: FinPdu.hpp:19
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
void setPduDataLength(U16 length)
Set PDU data length (used during encoding)
Definition: PduHeader.hpp:136
The type of a PDU header (common to all PDUs)
Definition: PduHeader.hpp:47
PduTypeEnum::T peekPduType(const Fw::Buffer &buffer)
Definition: PduHeader.cpp:230
Fw::SerializeStatus toSerialBuffer(Fw::SerialBufferBase &serialBuffer) const
Write this Header to a SerialBufferBase.
Definition: PduHeader.cpp:95
TransactionSeq getTransactionSeq() const
Get the transaction sequence number.
Definition: PduHeader.hpp:127
RateGroupDivider component implementation.
EntityId getSourceEid() const
Get the source entity ID.
Definition: PduHeader.hpp:124
The type of an EOF PDU.
Definition: EofPdu.hpp:19
T
The raw enum type.
Definition: ClassEnumAc.hpp:42
PduDirection getDirection() const
Get the direction.
Definition: PduHeader.hpp:118
The type of a NAK PDU.
Definition: NakPdu.hpp:24
void setLargeFileFlag(LargeFileFlag flag)
Set the large file flag (used for testing and configuration)
Definition: PduHeader.hpp:145
The type of an ACK PDU.
Definition: AckPdu.hpp:18
static U8 getValueEncodedSize(U64 value)
Definition: PduHeader.cpp:38
#define U64(C)
Definition: sha.h:181