F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
EndPacket.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title EndPacket.cpp
3// \author bocchino
4// \brief cpp file for FilePacket::EndPacket
5//
6// \copyright
7// Copyright 2009-2016, by the California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12
13#include <cstring>
14
16#include <Fw/Types/Assert.hpp>
17
18namespace Fw {
19
20 void FilePacket::EndPacket ::
21 initialize(
22 const U32 sequenceIndex,
23 const CFDP::Checksum& checksum
24 )
25 {
26 this->m_header.initialize(FilePacket::T_END, sequenceIndex);
27 this->setChecksum(checksum);
28 }
29
30 U32 FilePacket::EndPacket ::
31 bufferSize() const
32 {
33 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_checksumValue));
34 }
35
36 SerializeStatus FilePacket::EndPacket ::
37 toBuffer(Buffer& buffer) const
38 {
39 SerialBuffer serialBuffer(
40 buffer.getData(),
41 buffer.getSize()
42 );
43 return this->toSerialBuffer(serialBuffer);
44 }
45
46 void FilePacket::EndPacket ::
47 setChecksum(const CFDP::Checksum& checksum)
48 {
49 this->m_checksumValue = checksum.getValue();
50 }
51
52
53 void FilePacket::EndPacket ::
54 getChecksum(CFDP::Checksum& checksum) const
55 {
56 CFDP::Checksum c(this->m_checksumValue);
57 checksum = c;
58 }
59
60 SerializeStatus FilePacket::EndPacket ::
61 fromSerialBuffer(SerialBuffer& serialBuffer)
62 {
63
64 FW_ASSERT(this->m_header.m_type == T_END);
65
66 const SerializeStatus status =
67 serialBuffer.deserialize(this->m_checksumValue);
68
69 return status;
70
71 }
72
73 SerializeStatus FilePacket::EndPacket ::
74 toSerialBuffer(SerialBuffer& serialBuffer) const
75 {
76
77 FW_ASSERT(this->m_header.m_type == T_END);
78
79 SerializeStatus status;
80
81 status = this->m_header.toSerialBuffer(serialBuffer);
82 if (status != FW_SERIALIZE_OK) {
83 return status;
84 }
85
86 status = serialBuffer.serialize(this->m_checksumValue);
87 if (status != FW_SERIALIZE_OK) {
88 return status;
89 }
90
91 return FW_SERIALIZE_OK;
92
93 }
94
95}
#define FW_ASSERT(...)
Definition Assert.hpp:14
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol.
Definition Checksum.hpp:53
U32 getValue() const
Get the checksum value.
Definition Checksum.cpp:66
U8 * getData() const
Definition Buffer.cpp:68
U32 getSize() const
Definition Buffer.cpp:72
A variable-length serializable buffer.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.