F´ Flight Software - C/C++ Documentation
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->m_type = type;
25 this->m_sequenceIndex = sequenceIndex;
26 }
27
28 U32 FilePacket::Header ::
29 bufferSize() const
30 {
31 return sizeof(U8) + sizeof(this->m_sequenceIndex);
32 }
33
34 SerializeStatus FilePacket::Header ::
35 fromSerialBuffer(SerialBuffer& serialBuffer)
36 {
37
38 U8 new_type;
39 SerializeStatus status;
40
41 status = serialBuffer.deserialize(new_type);
42 if (status != FW_SERIALIZE_OK) {
43 return status;
44 }
45 this->m_type = static_cast<Type>(new_type);
46
47 status = serialBuffer.deserialize(this->m_sequenceIndex);
48
49 return status;
50
51 }
52
53 SerializeStatus FilePacket::Header ::
54 toSerialBuffer(SerialBuffer& serialBuffer) const
55 {
56
57 const U8 type_casted = static_cast<U8>(this->m_type);
58 SerializeStatus status;
59
60 status = serialBuffer.serialize(type_casted);
61 if (status != FW_SERIALIZE_OK) {
62 return status;
63 }
64
65 status = serialBuffer.serialize(this->m_sequenceIndex);
66 if (status != FW_SERIALIZE_OK) {
67 return status;
68 }
69
70 return FW_SERIALIZE_OK;
71
72 }
73
74}
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.