F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
16namespace Fw {
17
18SerialBuffer ::SerialBuffer(U8* const data, const U32 capacity) : m_data(data), m_capacity(capacity) {}
19
20NATIVE_UINT_TYPE SerialBuffer ::getBuffCapacity() const {
21 return m_capacity;
22}
23
24U8* SerialBuffer ::getBuffAddr() {
25 return m_data;
26}
27
28const U8* SerialBuffer ::getBuffAddr() const {
29 return m_data;
30}
31
32void SerialBuffer ::fill() {
33 const SerializeStatus status = this->setBuffLen(this->m_capacity);
34 FW_ASSERT(status == FW_SERIALIZE_OK);
35}
36
37SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const NATIVE_UINT_TYPE n) {
38 // "true" means "just push the bytes"
39 return this->serialize(const_cast<U8*>(addr), n, true);
40}
41
42SerializeStatus SerialBuffer ::popBytes(U8* const addr, NATIVE_UINT_TYPE n) {
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
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.