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
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
16namespace Fw {
17
18 SerialBuffer ::
19 SerialBuffer(
20 U8 *const data,
21 const U32 capacity
22 ) :
23 m_data(data),
24 m_capacity(capacity)
25 {
26
27 }
28
29 NATIVE_UINT_TYPE SerialBuffer ::
30 getBuffCapacity() const
31 {
32 return m_capacity;
33 }
34
35 U8* SerialBuffer ::
36 getBuffAddr()
37 {
38 return m_data;
39 }
40
41 const U8* SerialBuffer ::
42 getBuffAddr() const
43 {
44 return m_data;
45 }
46
47 void SerialBuffer ::
48 fill()
49 {
50 const SerializeStatus status = this->setBuffLen(this->m_capacity);
51 FW_ASSERT(status == FW_SERIALIZE_OK);
52 }
53
54 SerializeStatus SerialBuffer ::
55 pushBytes(const U8 *const addr, const NATIVE_UINT_TYPE n)
56 {
57 // "true" means "just push the bytes"
58 return this->serialize(const_cast<U8*>(addr), n, true);
59 }
60
61 SerializeStatus SerialBuffer ::
62 popBytes(U8 *const addr, NATIVE_UINT_TYPE n)
63 {
64 // "true" means "just pop the bytes"
65 return this->deserialize(addr, n, true);
66 }
67
68}
#define FW_ASSERT(...)
Definition Assert.hpp:14
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.