F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StartPacket.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title StartPacket.cpp
3// \author bocchino
4// \brief cpp file for FilePacket::StartPacket
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::StartPacket ::
19 initialize(
20 const U32 fileSize,
21 const char *const sourcePath,
22 const char *const destinationPath
23 )
24 {
25 this->m_header.initialize(FilePacket::T_START, 0);
26 this->m_fileSize = fileSize;
27 this->m_sourcePath.initialize(sourcePath);
28 this->m_destinationPath.initialize(destinationPath);
29 }
30
31 U32 FilePacket::StartPacket ::
32 bufferSize() const
33 {
34 return this->m_header.bufferSize() +
35 sizeof(this->m_fileSize) +
36 this->m_sourcePath.bufferSize() +
37 this->m_destinationPath.bufferSize();
38 }
39
40 SerializeStatus FilePacket::StartPacket ::
41 toBuffer(Buffer& buffer) const
42 {
43 SerialBuffer serialBuffer(
44 buffer.getData(),
45 buffer.getSize()
46 );
47 return this->toSerialBuffer(serialBuffer);
48 }
49
50 SerializeStatus FilePacket::StartPacket ::
51 fromSerialBuffer(SerialBuffer& serialBuffer)
52 {
53
54 FW_ASSERT(this->m_header.m_type == T_START);
55
56 {
57 const SerializeStatus status =
58 serialBuffer.deserialize(this->m_fileSize);
59 if (status != FW_SERIALIZE_OK)
60 return status;
61 }
62
63 {
64 const SerializeStatus status =
65 this->m_sourcePath.fromSerialBuffer(serialBuffer);
66 if (status != FW_SERIALIZE_OK)
67 return status;
68 }
69
70 {
71 const SerializeStatus status =
72 this->m_destinationPath.fromSerialBuffer(serialBuffer);
73 if (status != FW_SERIALIZE_OK)
74 return status;
75 }
76
77 return FW_SERIALIZE_OK;
78
79 }
80
81 SerializeStatus FilePacket::StartPacket ::
82 toSerialBuffer(SerialBuffer& serialBuffer) const
83 {
84
85 FW_ASSERT(this->m_header.m_type == T_START);
86
87 {
88 const SerializeStatus status =
89 this->m_header.toSerialBuffer(serialBuffer);
90 if (status != FW_SERIALIZE_OK)
91 return status;
92 }
93
94 {
95 const SerializeStatus status =
96 serialBuffer.serialize(this->m_fileSize);
97 if (status != FW_SERIALIZE_OK)
98 return status;
99 }
100
101 {
102 const SerializeStatus status =
103 this->m_sourcePath.toSerialBuffer(serialBuffer);
104 if (status != FW_SERIALIZE_OK)
105 return status;
106 }
107
108 {
109 const SerializeStatus status =
110 this->m_destinationPath.toSerialBuffer(serialBuffer);
111 if (status != FW_SERIALIZE_OK)
112 return status;
113 }
114
115 return FW_SERIALIZE_OK;
116
117 }
118
119}
#define FW_ASSERT(...)
Definition Assert.hpp:14
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
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.