F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 
16 namespace Fw {
17 
18 void FilePacket::Header ::initialize(const Type type, const U32 sequenceIndex) {
19  this->m_type = type;
20  this->m_sequenceIndex = sequenceIndex;
21 }
22 
23 U32 FilePacket::Header ::bufferSize() const {
24  return sizeof(U8) + sizeof(this->m_sequenceIndex);
25 }
26 
27 SerializeStatus FilePacket::Header ::fromSerialBuffer(SerialBuffer& serialBuffer) {
28  U8 new_type;
29  SerializeStatus status;
30 
31  status = serialBuffer.deserialize(new_type);
32  if (status != FW_SERIALIZE_OK) {
33  return status;
34  }
35  this->m_type = static_cast<Type>(new_type);
36 
37  status = serialBuffer.deserialize(this->m_sequenceIndex);
38 
39  return status;
40 }
41 
42 SerializeStatus FilePacket::Header ::toSerialBuffer(SerialBuffer& serialBuffer) const {
43  const U8 type_casted = static_cast<U8>(this->m_type);
44  SerializeStatus status;
45 
46  status = serialBuffer.serialize(type_casted);
47  if (status != FW_SERIALIZE_OK) {
48  return status;
49  }
50 
51  status = serialBuffer.serialize(this->m_sequenceIndex);
52  if (status != FW_SERIALIZE_OK) {
53  return status;
54  }
55 
56  return FW_SERIALIZE_OK;
57 }
58 
59 } // namespace Fw
Serialization/Deserialization operation was successful.
Type
Packet type.
Definition: FilePacket.hpp:40
SerializeStatus
forward declaration for string
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53