F´ Flight Software - C/C++ Documentation
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 
14 #include "Fw/Types/Assert.hpp"
15 
16 namespace Fw {
17 
18 SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {}
19 
21  return m_capacity;
22 }
23 
24 FwSizeType SerialBuffer ::getBuffCapacity() const {
25  return this->getCapacity();
26 }
27 
29  return m_data;
30 }
31 
33  return m_data;
34 }
35 
37  const SerializeStatus status = this->setBuffLen(this->m_capacity);
38  FW_ASSERT(status == FW_SERIALIZE_OK);
39 }
40 
42  return this->serializeFrom(const_cast<U8*>(addr), n, Fw::Serialization::OMIT_LENGTH);
43 }
44 
46  return this->deserializeTo(addr, n, Fw::Serialization::OMIT_LENGTH);
47 }
48 
49 } // namespace Fw
Serialization/Deserialization operation was successful.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
void fill()
Fill the buffer to capacity with preexisting data.
SerializeStatus
forward declaration for string
SerializeStatus popBytes(U8 *const addr, FwSizeType n)
Pop n bytes off the buffer.
Omit length from serialization.
SerializeStatus pushBytes(const U8 *const addr, const FwSizeType n)
Push n bytes onto the buffer.
FwSizeType getCapacity() const
Get buffer capacity.
SerialBuffer(U8 *const data, const FwSizeType capacity)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
Implementation of malloc based allocator.
#define FW_ASSERT(...)
Definition: Assert.hpp:14