25#ifndef COMMUNICATION_SPACEPACKETUTILS_HPP
26#define COMMUNICATION_SPACEPACKETUTILS_HPP
39static const uint8 CCSDS_PACKET_VERSION_NUM = 0;
42static const uint32 CCSDS_PRI_HDR_LEN_BYTES = 6;
45static const uint32 CCSDS_SEC_HDR_LEN_BYTES = 8;
48static const uint32 CCSDS_FULL_HDR_LEN_BYTES = CCSDS_PRI_HDR_LEN_BYTES + CCSDS_SEC_HDR_LEN_BYTES;
51static const uint32 CRC16_LEN_BYTES = 2;
60int16
computeCRC16(uint32 &crc,
const uint8 *packet_ptr,
size_t length,
61 uint32 input_crc = 0);
70int16
validateCRC16(
const uint32 &crc,
const uint8 *packet_ptr,
size_t length,
71 uint32 input_crc = 0);
101int16
writeCCSDSHeader(uint8 *header,
bool is_tlm, uint16 apid, uint8 seq_flag,
102 uint16 seq_count, uint16 data_len, clockwerk::Time timestamp, uint8 instance);
116 uint8 &seq_flag, uint16 &seq_count, uint16 &data_len,
117 clockwerk::Time ×tamp, uint8 &instance);
125 char*
const p =
reinterpret_cast<char*
>(&in);
126 for (
size_t i = 0; i <
sizeof(T) / 2; ++i)
127 std::swap(p[i], p[
sizeof(T) - i - 1]);
132template <
class T, std::
size_t N>
134 std::array<T, N> out;
135 for (std::size_t i = 0; i < N; ++i)
unsigned long uint32
Fastest unsigned integer of (at least) 32 bits width.
Definition half.hpp:510
Definition DeadReckon.cpp:20
int16 computeFletcher8Checksum(const uint8 *packet_ptr, uint8 length, uint16 &checksum)
Function to calculate the fletcher 8 checksum.
Definition spacepacketutils.cpp:97
int16 validateCRC16(const uint32 &crc, const uint8 *packet_ptr, size_t length, uint32 input_crc)
Function to validate the CRC16 checksum for a packet.
Definition spacepacketutils.cpp:81
int16 readCCSDSHeader(uint8 *header, bool &is_tlm, uint16 &apid, uint8 &seq_flag, uint16 &seq_count, uint16 &data_len, clockwerk::Time ×tamp, uint8 &instance)
Function to read the CCSDS packet header and extract its contents.
Definition spacepacketutils.cpp:188
T changeEndian(T in)
Change the endianness of a number.
Definition spacepacketutils.hpp:123
int16 validateFletcher8Checksum(const uint8 *packet_ptr, uint8 length, const uint16 &checksum)
Function to validate the fletcher8 checksum for a packet.
Definition spacepacketutils.cpp:110
int16 writeCCSDSHeader(uint8 *header, bool is_tlm, uint16 apid, uint8 seq_flag, uint16 seq_count, uint16 data_len, clockwerk::Time timestamp, uint8 instance)
Function to write the CCSDS packet header.
Definition spacepacketutils.cpp:126
int16 computeCRC16(uint32 &crc, const uint8 *packet_ptr, size_t length, uint32 input_crc)
Function to compute the CRC16 checksum for a packet.
Definition spacepacketutils.cpp:50