F´ Flight Software - C/C++ Documentation  NASA-v1.5.0
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  reinterpret_cast<U8*>(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 
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:26
Fw::Buffer::getsize
U32 getsize(void)
get member size
Definition: BufferSerializableAc.cpp:61
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::SerializeBufferBase::serialize
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Serializable.cpp:67
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Fw::FilePacket::Header
The type of a packet header.
Definition: FilePacket.hpp:83
Fw::Buffer
Definition: BufferSerializableAc.hpp:24
Fw::FilePacket::StartPacket::toSerialBuffer
SerializeStatus toSerialBuffer(SerialBuffer &serialBuffer) const
Write this StartPacket to a SerialBuffer.
Definition: StartPacket.cpp:83
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw::Buffer::getdata
U64 getdata(void)
get member data
Definition: BufferSerializableAc.cpp:57
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
FilePacket.hpp
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:292
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
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: BufferGetPortAc.cpp:6