| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title FileDataPdu.hpp | ||
| 3 | // \author Brian Campuzano | ||
| 4 | // \brief hpp file for CFDP File Data PDU | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #ifndef Svc_Ccsds_Cfdp_FileDataPdu_HPP | ||
| 8 | #define Svc_Ccsds_Cfdp_FileDataPdu_HPP | ||
| 9 | |||
| 10 | #include <Fw/Types/SerialBuffer.hpp> | ||
| 11 | #include <Svc/Ccsds/CfdpManager/Types/PduBase.hpp> | ||
| 12 | #include <config/FileSizeAliasAc.hpp> | ||
| 13 | |||
| 14 | namespace Svc { | ||
| 15 | namespace Ccsds { | ||
| 16 | namespace Cfdp { | ||
| 17 | |||
| 18 | //! The type of a File Data PDU | ||
| 19 | class FileDataPdu : public PduBase { | ||
| 20 | private: | ||
| 21 | //! File offset | ||
| 22 | FileSize m_offset; | ||
| 23 | |||
| 24 | //! Data size | ||
| 25 | U16 m_dataSize; | ||
| 26 | |||
| 27 | //! Pointer to file data | ||
| 28 | const U8* m_data; | ||
| 29 | |||
| 30 | public: | ||
| 31 | //! Constructor | ||
| 32 | 181 | FileDataPdu() : m_offset(0), m_dataSize(0), m_data(nullptr) {} | |
| 33 | |||
| 34 | //! Initialize a File Data PDU | ||
| 35 | void initialize(PduDirection direction, | ||
| 36 | Cfdp::Class::T txmMode, | ||
| 37 | EntityId sourceEid, | ||
| 38 | TransactionSeq transactionSeq, | ||
| 39 | EntityId destEid, | ||
| 40 | FileSize offset, | ||
| 41 | U16 dataSize, | ||
| 42 | const U8* data); | ||
| 43 | |||
| 44 | //! Compute the buffer size needed | ||
| 45 | U32 getBufferSize() const override; | ||
| 46 | |||
| 47 | //! Convert this FileDataPdu to a Buffer | ||
| 48 | Fw::SerializeStatus toBuffer(Fw::Buffer& buffer) const; | ||
| 49 | |||
| 50 | //! Initialize this FileDataPdu from a Buffer | ||
| 51 | Fw::SerializeStatus fromBuffer(const Fw::Buffer& buffer); | ||
| 52 | |||
| 53 | //! Fw::Serializable interface - serialize to buffer | ||
| 54 | Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer, | ||
| 55 | Fw::Endianness mode = Fw::Endianness::BIG) const override; | ||
| 56 | |||
| 57 | //! Fw::Serializable interface - deserialize from buffer | ||
| 58 | Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer, | ||
| 59 | Fw::Endianness mode = Fw::Endianness::BIG) override; | ||
| 60 | |||
| 61 | //! Get this as a Header | ||
| 62 | 63 | const PduHeader& asHeader() const { return this->m_header; } | |
| 63 | |||
| 64 | //! Get the file offset | ||
| 65 | 87 | FileSize getOffset() const { return this->m_offset; } | |
| 66 | |||
| 67 | //! Get the data size | ||
| 68 | 125 | U16 getDataSize() const { return this->m_dataSize; } | |
| 69 | |||
| 70 | //! Get the data pointer | ||
| 71 | 65 | const U8* getData() const { return this->m_data; } | |
| 72 | |||
| 73 | //! Calculate maximum file data payload size | ||
| 74 | //! @return Maximum number of data bytes that can fit in a File Data PDU | ||
| 75 | U32 getMaxFileDataSize(); | ||
| 76 | |||
| 77 | private: | ||
| 78 | //! Initialize this FileDataPdu from a SerialBuffer | ||
| 79 | Fw::SerializeStatus fromSerialBuffer(Fw::SerialBuffer& serialBuffer); | ||
| 80 | |||
| 81 | //! Write this FileDataPdu to a SerialBuffer | ||
| 82 | Fw::SerializeStatus toSerialBuffer(Fw::SerialBuffer& serialBuffer) const; | ||
| 83 | }; | ||
| 84 | |||
| 85 | } // namespace Cfdp | ||
| 86 | } // namespace Ccsds | ||
| 87 | } // namespace Svc | ||
| 88 | |||
| 89 | #endif // Svc_Ccsds_Cfdp_FileDataPdu_HPP | ||
| 90 |