F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 <cstdio>
11 
12 namespace Fw {
13 
14 CmdPacket::CmdPacket() : m_opcode(0) {
15  this->m_type = ComPacketType::FW_PACKET_COMMAND;
16 }
17 
19 
20 // New serialization interface methods
22  // Shouldn't be called, no use case for serializing CmdPackets in FSW (currently)
23  FW_ASSERT(0);
24  return FW_SERIALIZE_OK; // for compiler
25 }
26 
29  if (stat != FW_SERIALIZE_OK) {
30  return stat;
31  }
32 
33  // double check packet type
34  if (this->m_type != ComPacketType::FW_PACKET_COMMAND) {
36  }
37 
38  stat = buffer.deserializeTo(this->m_opcode);
39  if (stat != FW_SERIALIZE_OK) {
40  return stat;
41  }
42 
43  // if non-empty, copy data
44  if (buffer.getBuffLeft()) {
45  // copy the serialized arguments to the buffer
46  stat = buffer.copyRaw(this->m_argBuffer, buffer.getBuffLeft());
47  }
48 
49  return stat;
50 }
51 
53  return this->m_opcode;
54 }
55 
57  return this->m_argBuffer;
58 }
59 
60 } /* namespace Fw */
Serialization/Deserialization operation was successful.
FwIdType FwOpcodeType
The type of a command opcode.
virtual ~CmdPacket()
Definition: CmdPacket.cpp:18
SerializeStatus copyRaw(SerializeBufferBase &dest, Serializable::SizeType size)
directly copies buffer without looking for a size in the stream.
ComPacketType m_type
Definition: ComPacket.hpp:28
SerializeStatus
forward declaration for string
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
FwOpcodeType m_opcode
Definition: CmdPacket.hpp:29
SerializeStatus serializeTo(SerializeBufferBase &buffer) const
serialize contents to buffer
Definition: CmdPacket.cpp:21
Deserialized type ID didn&#39;t match.
FwOpcodeType getOpCode() const
Definition: CmdPacket.cpp:52
CmdArgBuffer m_argBuffer
Definition: CmdPacket.hpp:30
SerializeStatus deserializeFrom(SerializeBufferBase &buffer)
deserialize contents from buffer
Definition: CmdPacket.cpp:27
SerializeStatus deserializeBase(SerializeBufferBase &buffer)
Definition: ComPacket.cpp:20
CmdArgBuffer & getArgBuffer()
Definition: CmdPacket.cpp:56
#define FW_ASSERT(...)
Definition: Assert.hpp:14
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int