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
CmdPacket.cpp
Go to the documentation of this file.
1 /*
2  * CmdPacket.cpp
3  *
4  * Created on: May 24, 2014
5  * Author: Timothy Canham
6  */
7 
8 #include <Fw/Cmd/CmdPacket.hpp>
9 #include <Fw/Types/Assert.hpp>
10 #include <stdio.h>
11 
12 namespace Fw {
13 
14  CmdPacket::CmdPacket() : m_opcode(0) {
15  this->m_type = FW_PACKET_COMMAND;
16  }
17 
19  }
20 
22 
23  // Shouldn't be called
24  FW_ASSERT(0);
25  return FW_SERIALIZE_OK; // for compiler
26 
27  }
28 
30 
32  if (stat != FW_SERIALIZE_OK) {
33  return stat;
34  }
35 
36  // double check packet type
37  if (this->m_type != FW_PACKET_COMMAND) {
39  }
40 
41  stat = buffer.deserialize(this->m_opcode);
42  if (stat != FW_SERIALIZE_OK) {
43  return stat;
44  }
45 
46  // if non-empty, copy data
47  if (buffer.getBuffLeft()) {
48  // copy the serialized arguments to the buffer
49  stat = buffer.copyRaw(this->m_argBuffer,buffer.getBuffLeft());
50  }
51 
52  return stat;
53  }
54 
56  return this->m_opcode;
57  }
58 
60  return this->m_argBuffer;
61  }
62 
63 
64 
65 } /* namespace Fw */
Fw::ComPacket::deserializeBase
SerializeStatus deserializeBase(SerializeBufferBase &buffer)
Definition: ComPacket.cpp:22
Fw::CmdPacket::m_argBuffer
CmdArgBuffer m_argBuffer
Definition: CmdPacket.hpp:29
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::SerializeBufferBase::copyRaw
SerializeStatus copyRaw(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
Definition: Serializable.cpp:623
CmdPacket.hpp
Fw::ComPacket::FW_PACKET_COMMAND
@ FW_PACKET_COMMAND
Definition: ComPacket.hpp:22
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw::SerializeBufferBase::getBuffLeft
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
Definition: Serializable.cpp:619
Fw::CmdPacket::~CmdPacket
virtual ~CmdPacket()
Definition: CmdPacket.cpp:18
FwOpcodeType
#define FwOpcodeType
Type representation for a command opcode.
Definition: FpConfig.hpp:62
Fw::CmdPacket::deserialize
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
Definition: CmdPacket.cpp:29
Fw::CmdPacket::getArgBuffer
CmdArgBuffer & getArgBuffer(void)
Definition: CmdPacket.cpp:59
Fw::CmdArgBuffer
Definition: CmdArgBuffer.hpp:22
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::ComPacket::m_type
ComPacketType m_type
Definition: ComPacket.hpp:35
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:292
Fw::FW_DESERIALIZE_TYPE_MISMATCH
@ FW_DESERIALIZE_TYPE_MISMATCH
Deserialized type ID didn't match.
Definition: Serializable.hpp:21
Fw::CmdPacket::getOpCode
FwOpcodeType getOpCode(void) const
Definition: CmdPacket.cpp:55
Fw::CmdPacket::CmdPacket
CmdPacket()
Definition: CmdPacket.cpp:14
Fw::CmdPacket::serialize
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
Definition: CmdPacket.cpp:21
Fw::CmdPacket::m_opcode
FwOpcodeType m_opcode
Definition: CmdPacket.hpp:28
Fw
Definition: BufferGetPortAc.cpp:6