F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
IdlePacket.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title IdlePacket.cpp
3 // \brief Space Packet Protocol idle packet helpers shared by CCSDS framers
4 // ======================================================================
5 
7 #include "Fw/Types/Assert.hpp"
9 #include "config/ApidEnumAc.hpp"
10 
11 namespace Svc {
12 namespace Ccsds {
13 namespace Utils {
14 namespace IdlePacket {
15 
17  FW_ASSERT(size >= MIN_SIZE, static_cast<FwAssertArgType>(size));
18  FW_ASSERT(size <= MAX_SIZE, static_cast<FwAssertArgType>(size));
19  // Length token is defined as the number of bytes of payload data minus 1
20  const FwSizeType lengthToken = size - SpacePacketHeader::SERIALIZED_SIZE - 1;
21 
22  SpacePacketHeader header;
24  // Sequence Flags = 0b11 (unsegmented) & unused sequence count
25  header.set_packetSequenceControl(static_cast<U16>(0x3 << SpacePacketSubfields::SeqFlagsOffset));
26  header.set_packetDataLength(static_cast<U16>(lengthToken));
27 
28  Fw::SerializeStatus status = serializer.serializeFrom(header);
29  for (FwSizeType i = SpacePacketHeader::SERIALIZED_SIZE; (status == Fw::FW_SERIALIZE_OK) && (i < size); i++) {
30  status = serializer.serializeFrom(DATA_PATTERN);
31  }
32  return status;
33 }
34 
35 } // namespace IdlePacket
36 } // namespace Utils
37 } // namespace Ccsds
38 } // namespace Svc
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
Fw::SerializeStatus serialize(Fw::SerialBufferBase &serializer, FwSizeType size)
Serialize an idle packet of exactly size bytes (header and idle data) into serializer ...
Definition: IdlePacket.cpp:16
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
constexpr U8 DATA_PATTERN
Fill pattern for idle packet data.
Definition: IdlePacket.hpp:21
Describes the frame header format for the SpacePacket communications protocol.
constexpr FwSizeType MIN_SIZE
Minimum idle packet size: header plus one byte of idle data.
Definition: IdlePacket.hpp:24
void set_packetDataLength(U16 packetDataLength)
Set member packetDataLength.
void set_packetIdentification(U16 packetIdentification)
Set member packetIdentification.
void set_packetSequenceControl(U16 packetSequenceControl)
Set member packetSequenceControl.
RateGroupDivider component implementation.
constexpr FwSizeType MAX_SIZE
Maximum idle packet size: header plus the largest data length the SPP length field can express...
Definition: IdlePacket.hpp:27
Per Space Packet Standard, all 1s (11bits) is reserved for Idle Packets.
Definition: ApidEnumAc.hpp:54
#define FW_ASSERT(...)
Definition: Assert.hpp:14