CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
CCSDSUtils.h
Go to the documentation of this file.
1#ifndef CCSDS_UTILS_H
2#define CCSDS_UTILS_H
3
4#include <CCSDSPacket.h>
5#include <CCSDSManager.h>
6#include <string>
7#include <vector>
8
9// free functions
19uint16_t crc16(const std::vector<std::uint8_t> &data,
20 std::uint16_t polynomial = 0x1021,
21 std::uint16_t initialValue = 0xFFFF,
22 std::uint16_t finalXorValue = 0x0000
23);
24
25
34bool stringEndsWith(const std::string& str, const std::string& suffix);
35
41void printPacket(CCSDS::Packet &packet);
42
48void printPackets(CCSDS::Manager & manager);
49
57std::string getBinaryString(std::uint32_t value, std::int32_t bits);
58
65std::string getBitsSpaces(std::int32_t num);
66
73void printBufferData(const std::vector<std::uint8_t> &buffer, std::int32_t limitBytes = 20);
74
83void printData(CCSDS::DataField dataField);
84
94void printHeader(CCSDS::Header &header);
95
103
112void printDataField(CCSDS::Packet &packet);
113
122CCSDS::ResultBool writeBinaryFile(const std::vector<std::uint8_t>& data, const std::string& filename);
123
130CCSDS::ResultBuffer readBinaryFile(const std::string& filename);
131
138bool fileExists(const std::string &fileName);
139
140
141#endif // CCSDS_UTILS_H
std::string getBinaryString(std::uint32_t value, std::int32_t bits)
Converts a given value to its binary representation as a string, with spaces every 4 bits.
void printBufferData(const std::vector< std::uint8_t > &buffer, std::int32_t limitBytes=20)
Prints to console the HEX data from the bytes vector.
bool fileExists(const std::string &fileName)
filesystem check fore file existence prepared for both windows and linux.
void printPacket(CCSDS::Packet &packet)
Prints to console a CCSDS Packets, breaking it down to Primary header and Data field.
bool stringEndsWith(const std::string &str, const std::string &suffix)
Tests if str ends with suffix.
CCSDS::ResultBool printPrimaryHeader(CCSDS::Packet &packet)
Prints to console the primary header of a provided CCSDS packet.
uint16_t crc16(const std::vector< std::uint8_t > &data, std::uint16_t polynomial=0x1021, std::uint16_t initialValue=0xFFFF, std::uint16_t finalXorValue=0x0000)
Computes the CRC-16 checksum for a given data vector with configurable parameters.
void printData(CCSDS::DataField dataField)
Prints the data field details, including the secondary header and application data.
CCSDS::ResultBuffer readBinaryFile(const std::string &filename)
Read a specified binary file and return its contents as a buffer.
void printHeader(CCSDS::Header &header)
Prints the header fields and their binary or hexadecimal representations.
CCSDS::ResultBool writeBinaryFile(const std::vector< std::uint8_t > &data, const std::string &filename)
This function takes in a buffer of data and a file name.
std::string getBitsSpaces(std::int32_t num)
Generates a string of spaces for formatting binary outputs.
void printPackets(CCSDS::Manager &manager)
Prints to console a series of CCSDS Packets contained in the manager.
void printDataField(CCSDS::Packet &packet)
Prints the data field and the CRC-16 checksum of the packet.
Represents the data field of a CCSDS packet.
Manages the decomposition and manipulation of CCSDS primary headers.
Definition CCSDSHeader.h:80
Manages CCSDS packets and their templates.
Represents a CCSDS (Consultative Committee for Space Data Systems) packet.
Definition CCSDSPacket.h:59
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:82