F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
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 
16 namespace Fw {
17 
20  const U32 fileSize,
21  const char *const sourcePath,
22  const char *const destinationPath
23  )
24  {
26  this->header = header;
27  this->fileSize = fileSize;
28  this->sourcePath.initialize(sourcePath);
29  this->destinationPath.initialize(destinationPath);
30  }
31 
33  bufferSize(void) const
34  {
35  return this->header.bufferSize() +
36  sizeof(this->fileSize) +
37  this->sourcePath.bufferSize() +
38  this->destinationPath.bufferSize();
39  }
40 
42  toBuffer(Buffer& buffer) const
43  {
44  SerialBuffer serialBuffer(
45  buffer.getData(),
46  buffer.getSize()
47  );
48  return this->toSerialBuffer(serialBuffer);
49  }
50 
51  SerializeStatus FilePacket::StartPacket ::
52  fromSerialBuffer(SerialBuffer& serialBuffer)
53  {
54 
55  FW_ASSERT(this->header.type == T_START);
56 
57  {
58  const SerializeStatus status =
59  serialBuffer.deserialize(this->fileSize);
60  if (status != FW_SERIALIZE_OK)
61  return status;
62  }
63 
64  {
65  const SerializeStatus status =
66  this->sourcePath.fromSerialBuffer(serialBuffer);
67  if (status != FW_SERIALIZE_OK)
68  return status;
69  }
70 
71  {
72  const SerializeStatus status =
73  this->destinationPath.fromSerialBuffer(serialBuffer);
74  if (status != FW_SERIALIZE_OK)
75  return status;
76  }
77 
78  return FW_SERIALIZE_OK;
79 
80  }
81 
82  SerializeStatus FilePacket::StartPacket ::
83  toSerialBuffer(SerialBuffer& serialBuffer) const
84  {
85 
86  FW_ASSERT(this->header.type == T_START);
87 
88  {
89  const SerializeStatus status =
90  this->header.toSerialBuffer(serialBuffer);
91  if (status != FW_SERIALIZE_OK)
92  return status;
93  }
94 
95  {
96  const SerializeStatus status =
97  serialBuffer.serialize(this->fileSize);
98  if (status != FW_SERIALIZE_OK)
99  return status;
100  }
101 
102  {
103  const SerializeStatus status =
104  this->sourcePath.toSerialBuffer(serialBuffer);
105  if (status != FW_SERIALIZE_OK)
106  return status;
107  }
108 
109  {
110  const SerializeStatus status =
111  this->destinationPath.toSerialBuffer(serialBuffer);
112  if (status != FW_SERIALIZE_OK)
113  return status;
114  }
115 
116  return FW_SERIALIZE_OK;
117 
118  }
119 
120 }
Fw::FilePacket::StartPacket::fileSize
U32 fileSize
The file size.
Definition: FilePacket.hpp:128
Fw::SerialBuffer
A variable-length serializable buffer.
Definition: SerialBuffer.hpp:24
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::Buffer::getData
U8 * getData() const
Definition: Buffer.cpp:56
Fw::FilePacket::Header
The type of a packet header.
Definition: FilePacket.hpp:83
Fw::Buffer
Definition: Buffer.hpp:43
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw::Buffer::getSize
U32 getSize() const
Definition: Buffer.cpp:60
Fw::FilePacket::StartPacket::sourcePath
PathName sourcePath
The source path.
Definition: FilePacket.hpp:131
Fw::FilePacket::T_START
@ T_START
Definition: FilePacket.hpp:37
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::FilePacket::StartPacket::header
Header header
The packet header.
Definition: FilePacket.hpp:125
Fw::FilePacket::StartPacket::bufferSize
U32 bufferSize(void) const
Compute the buffer size needed to hold this StartPacket.
Definition: StartPacket.cpp:33
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:290
Fw::FilePacket::StartPacket::toBuffer
SerializeStatus toBuffer(Buffer &buffer) const
Convert this StartPacket to a Buffer.
Definition: StartPacket.cpp:42
Fw::FilePacket::StartPacket::destinationPath
PathName destinationPath
The destination path.
Definition: FilePacket.hpp:134
FilePacket.hpp
Fw::FilePacket::Header::type
Type type
The packet type.
Definition: FilePacket.hpp:90
Fw::FilePacket::StartPacket::initialize
void initialize(const U32 fileSize, const char *const sourcePath, const char *const destinationPath)
Initialize a StartPacket with sequence number 0.
Definition: StartPacket.cpp:19
Fw
Definition: Buffer.cpp:21