F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
Header.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title Header.cpp
3// \author bocchino
4// \brief cpp file for FilePacket::Header
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
14#include <Fw/Types/Assert.hpp>
15
16namespace Fw {
17
18 void FilePacket::Header ::
19 initialize(
20 const Type type,
21 const U32 sequenceIndex
22 )
23 {
24 this->type = type;
25 this->sequenceIndex = sequenceIndex;
26 }
27
28 U32 FilePacket::Header ::
29 bufferSize() const
30 {
31 return sizeof(U8) + sizeof(this->sequenceIndex);
32 }
33
34 SerializeStatus FilePacket::Header ::
35 fromSerialBuffer(SerialBuffer& serialBuffer)
36 {
37
38 U8 type;
39 SerializeStatus status;
40
41 status = serialBuffer.deserialize(type);
42 if (status != FW_SERIALIZE_OK) {
43 return status;
44 }
45 this->type = static_cast<Type>(type);
46
47 status = serialBuffer.deserialize(this->sequenceIndex);
48
49 return status;
50
51 }
52
53 SerializeStatus FilePacket::Header ::
54 toSerialBuffer(SerialBuffer& serialBuffer) const
55 {
56
57 const U8 type = static_cast<U8>(this->type);
58 SerializeStatus status;
59
60 status = serialBuffer.serialize(type);
61 if (status != FW_SERIALIZE_OK)
62 return status;
63
64 status = serialBuffer.serialize(this->sequenceIndex);
65 if (status != FW_SERIALIZE_OK)
66 return status;
67
68 return FW_SERIALIZE_OK;
69
70 }
71
72}
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
Definition Buffer.cpp:21
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.