F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
SerialBuffer.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SerialBuffer.cpp
3 // \author bocchino
4 // \brief cpp file for SerialBuffer type
5 //
6 // \copyright
7 // Copyright (C) 2016 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #include "Fw/Types/Assert.hpp"
15 
16 namespace Fw {
17 
18 SerialBuffer ::SerialBuffer(U8* const data, const U32 capacity) : m_data(data), m_capacity(capacity) {}
19 
21  return m_capacity;
22 }
23 
25  return m_data;
26 }
27 
29  return m_data;
30 }
31 
33  const SerializeStatus status = this->setBuffLen(this->m_capacity);
34  FW_ASSERT(status == FW_SERIALIZE_OK);
35 }
36 
38  // "true" means "just push the bytes"
39  return this->serialize(const_cast<U8*>(addr), n, true);
40 }
41 
43  // "true" means "just pop the bytes"
44  return this->deserialize(addr, n, true);
45 }
46 
47 } // namespace Fw
#define FW_ASSERT(...)
Definition: Assert.hpp:14
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:56
NATIVE_UINT_TYPE getBuffCapacity() const
returns capacity, not current size, of buffer
SerializeStatus popBytes(U8 *const addr, NATIVE_UINT_TYPE n)
Pop n bytes off the buffer.
SerializeStatus pushBytes(const U8 *const addr, const NATIVE_UINT_TYPE n)
Push n bytes onto the buffer.
void fill()
Fill the buffer to capacity with preexisting data.
SerialBuffer(U8 *const data, const U32 capacity)
U8 * getBuffAddr()
gets buffer address for data filling
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.