| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title NakPdu.hpp | ||
| 3 | // \author Brian Campuzano | ||
| 4 | // \brief hpp file for CFDP NAK PDU | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #ifndef Svc_Ccsds_Cfdp_NakPdu_HPP | ||
| 8 | #define Svc_Ccsds_Cfdp_NakPdu_HPP | ||
| 9 | |||
| 10 | #include <Svc/Ccsds/CfdpManager/Types/PduBase.hpp> | ||
| 11 | #include <Svc/Ccsds/CfdpManager/Types/Types.hpp> | ||
| 12 | |||
| 13 | namespace Svc { | ||
| 14 | namespace Ccsds { | ||
| 15 | namespace Cfdp { | ||
| 16 | |||
| 17 | //! Segment request structure for NAK PDU | ||
| 18 | struct SegmentRequest { | ||
| 19 | FileSize offsetStart; //!< Start offset of missing data | ||
| 20 | FileSize offsetEnd; //!< End offset of missing data | ||
| 21 | }; | ||
| 22 | |||
| 23 | //! The type of a NAK PDU | ||
| 24 | class NakPdu : public PduBase { | ||
| 25 | private: | ||
| 26 | //! Scope start offset | ||
| 27 | FileSize m_scopeStart; | ||
| 28 | |||
| 29 | //! Scope end offset | ||
| 30 | FileSize m_scopeEnd; | ||
| 31 | |||
| 32 | //! Number of segment requests | ||
| 33 | U8 m_numSegments; | ||
| 34 | |||
| 35 | //! Segment requests array (max NakMaxSegments = 58) | ||
| 36 | SegmentRequest m_segments[58]; | ||
| 37 | |||
| 38 | public: | ||
| 39 | //! Constructor | ||
| 40 | 27 | NakPdu() : m_scopeStart(0), m_scopeEnd(0), m_numSegments(0) {} | |
| 41 | |||
| 42 | //! Initialize a NAK PDU | ||
| 43 | void initialize(PduDirection direction, | ||
| 44 | Cfdp::Class::T txmMode, | ||
| 45 | EntityId sourceEid, | ||
| 46 | TransactionSeq transactionSeq, | ||
| 47 | EntityId destEid, | ||
| 48 | FileSize scopeStart, | ||
| 49 | FileSize scopeEnd); | ||
| 50 | |||
| 51 | //! Compute the buffer size needed | ||
| 52 | U32 getBufferSize() const override; | ||
| 53 | |||
| 54 | //! Fw::Serializable interface - serialize to buffer | ||
| 55 | Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, | ||
| 56 | Fw::Endianness mode = Fw::Endianness::BIG) const override; | ||
| 57 | |||
| 58 | //! Fw::Serializable interface - deserialize from buffer | ||
| 59 | Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, | ||
| 60 | Fw::Endianness mode = Fw::Endianness::BIG) override; | ||
| 61 | |||
| 62 | //! Get this as a Header | ||
| 63 | 2 | const PduHeader& asHeader() const { return this->m_header; } | |
| 64 | |||
| 65 | //! Get scope start | ||
| 66 | 12 | FileSize getScopeStart() const { return this->m_scopeStart; } | |
| 67 | |||
| 68 | //! Get scope end | ||
| 69 | 12 | FileSize getScopeEnd() const { return this->m_scopeEnd; } | |
| 70 | |||
| 71 | //! Get number of segments | ||
| 72 | 10 | U8 getNumSegments() const { return this->m_numSegments; } | |
| 73 | |||
| 74 | //! Get segment at index (no bounds checking - caller must verify index < getNumSegments()) | ||
| 75 | 18 | const SegmentRequest& getSegment(U8 index) const { return this->m_segments[index]; } | |
| 76 | |||
| 77 | //! Add a segment request | ||
| 78 | //! @return True if segment was added, false if segment array is full | ||
| 79 | bool addSegment(FileSize offsetStart, FileSize offsetEnd); | ||
| 80 | |||
| 81 | //! Clear all segment requests | ||
| 82 | void clearSegments(); | ||
| 83 | |||
| 84 | //! Get directive code | ||
| 85 | FileDirective getDirectiveCode() const { return FileDirective::FILE_DIRECTIVE_NAK; } | ||
| 86 | |||
| 87 | private: | ||
| 88 | //! Initialize this NakPdu from a SerialBuffer | ||
| 89 | Fw::SerializeStatus fromSerialBuffer(Fw::SerialBufferBase& serialBuffer); | ||
| 90 | |||
| 91 | //! Write this NakPdu to a SerialBuffer | ||
| 92 | Fw::SerializeStatus toSerialBuffer(Fw::SerialBufferBase& serialBuffer) const; | ||
| 93 | }; | ||
| 94 | |||
| 95 | } // namespace Cfdp | ||
| 96 | } // namespace Ccsds | ||
| 97 | } // namespace Svc | ||
| 98 | |||
| 99 | #endif // Svc_Ccsds_Cfdp_NakPdu_HPP | ||
| 100 |