GCC Code Coverage Report


Directory: ./
File: Fw/Cmd/CmdPacket.cpp
Date: 2026-09-23 22:11:34
Exec Total Coverage
Lines: 18 24 75.0%
Functions: 5 6 83.3%
Branches: 6 9 66.7%

Line Branch Exec Source
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
1/1
✓ Branch 2 taken 150 times.
150 CmdPacket::CmdPacket() : m_opcode(0) {
15 150 this->m_type = ComPacketType::FW_PACKET_COMMAND;
16 150 }
17
18 300 CmdPacket::~CmdPacket() {}
19
20 // New serialization interface methods
21 ✗ SerializeStatus CmdPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const {
22 // Shouldn't be called, no use case for serializing CmdPackets in FSW (currently)
23 ✗ FW_ASSERT(false);
24 ✗ return FW_SERIALIZE_OK; // for compiler
25 }
26
27 150 SerializeStatus CmdPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) {
28 150 SerializeStatus stat = ComPacket::deserializeBase(buffer);
29
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if (stat != FW_SERIALIZE_OK) {
30 ✗ return stat;
31 }
32
33 // double check packet type
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if (this->m_type != ComPacketType::FW_PACKET_COMMAND) {
35 ✗ return FW_DESERIALIZE_TYPE_MISMATCH;
36 }
37
38 150 stat = buffer.deserializeTo(this->m_opcode, mode);
39
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if (stat != FW_SERIALIZE_OK) {
40 ✗ return stat;
41 }
42
43 // if non-empty, copy data
44
2/2
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 115 times.
150 if (buffer.getDeserializeSizeLeft()) {
45 // copy the serialized arguments to the buffer
46 35 stat = buffer.copyRaw(this->m_argBuffer, buffer.getDeserializeSizeLeft());
47 } else {
48 // copyRaw overwrites the argument buffer, so an argument-bearing command
49 // needs no clearing here, but a command without arguments would otherwise
50 // inherit whatever this packet held before.
51 115 this->m_argBuffer.resetSer();
52 }
53
54 150 return stat;
55 }
56
57 600 FwOpcodeType CmdPacket::getOpCode() const {
58 600 return this->m_opcode;
59 }
60
61 150 CmdArgBuffer& CmdPacket::getArgBuffer() {
62 150 return this->m_argBuffer;
63 }
64
65 } /* namespace Fw */
66