| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title IdlePacket.cpp | ||
| 3 | // \brief Space Packet Protocol idle packet helpers shared by CCSDS framers | ||
| 4 | // ====================================================================== | ||
| 5 | |||
| 6 | #include "Svc/Ccsds/Utils/IdlePacket.hpp" | ||
| 7 | #include <limits> | ||
| 8 | #include "Fw/Types/Assert.hpp" | ||
| 9 | #include "Svc/Ccsds/Types/FppConstantsAc.hpp" | ||
| 10 | #include "config/ApidEnumAc.hpp" | ||
| 11 | |||
| 12 | namespace Svc { | ||
| 13 | namespace Ccsds { | ||
| 14 | namespace Utils { | ||
| 15 | namespace IdlePacket { | ||
| 16 | |||
| 17 | 239 | Fw::SerializeStatus serialize(Fw::SerialBufferBase& serializer, FwSizeType size) { | |
| 18 | 239 | FW_ASSERT(size >= MIN_SIZE, static_cast<FwAssertArgType>(size)); | |
| 19 | // Length token is defined as the number of bytes of payload data minus 1 | ||
| 20 | 239 | const FwSizeType lengthToken = size - SpacePacketHeader::SERIALIZED_SIZE - 1; | |
| 21 | 239 | FW_ASSERT(lengthToken <= std::numeric_limits<U16>::max(), static_cast<FwAssertArgType>(lengthToken)); | |
| 22 | |||
| 23 |
1/1✓ Branch 1 taken 239 times.
|
239 | SpacePacketHeader header; |
| 24 |
1/1✓ Branch 1 taken 239 times.
|
239 | header.set_packetIdentification(static_cast<U16>(ComCfg::Apid::SPP_IDLE_PACKET)); |
| 25 | // Sequence Flags = 0b11 (unsegmented) & unused sequence count | ||
| 26 |
1/1✓ Branch 1 taken 239 times.
|
239 | header.set_packetSequenceControl(static_cast<U16>(0x3 << SpacePacketSubfields::SeqFlagsOffset)); |
| 27 |
1/1✓ Branch 1 taken 239 times.
|
239 | header.set_packetDataLength(static_cast<U16>(lengthToken)); |
| 28 | |||
| 29 |
1/1✓ Branch 1 taken 239 times.
|
239 | Fw::SerializeStatus status = serializer.serializeFrom(header); |
| 30 |
3/4✓ Branch 0 taken 163580 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163341 times.
✓ Branch 3 taken 239 times.
|
163580 | for (FwSizeType i = SpacePacketHeader::SERIALIZED_SIZE; (status == Fw::FW_SERIALIZE_OK) && (i < size); i++) { |
| 31 |
1/1✓ Branch 1 taken 163341 times.
|
163341 | status = serializer.serializeFrom(DATA_PATTERN); |
| 32 | } | ||
| 33 | 239 | return status; | |
| 34 | 239 | } | |
| 35 | |||
| 36 | } // namespace IdlePacket | ||
| 37 | } // namespace Utils | ||
| 38 | } // namespace Ccsds | ||
| 39 | } // namespace Svc | ||
| 40 |