20uint16_t
crc16(
const std::vector<uint8_t> &data,
21 uint16_t polynomial = 0x1021,
22 uint16_t initialValue = 0xFFFF,
23 uint16_t finalXorValue = 0x0000
63void printBufferData(
const std::vector<uint8_t> &buffer,
int limitBytes = 20);
138bool stringEndsWith(
const std::string& str,
const std::string& suffix);
147 using ConfigValue = std::variant<std::string, int, float, bool, std::vector<uint8_t>>;
160 bool isKey(
const std::string&
key)
const;
163 std::unordered_map<std::string, ConfigValue>
values;
166 static std::tuple<std::string, std::string, std::string>
parseLine(
const std::string&
line);
#define RET_IF_ERR_MSG(condition, errorCode, message)
Macro to return an error with an error message if a condition is met.
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.
std::string getBinaryString(uint32_t value, int bits)
Converts a given value to its binary representation as a string, with spaces every 4 bits.
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< uint8_t > &data, uint16_t polynomial=0x1021, uint16_t initialValue=0xFFFF, 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.
std::string getBitsSpaces(int num)
Generates a string of spaces for formatting binary outputs.
void printHeader(CCSDS::Header &header)
Prints the header fields and their binary or hexadecimal representations.
CCSDS::ResultBool writeBinaryFile(const std::vector< uint8_t > &data, const std::string &filename)
This function takes in a buffer of data and a file name.
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.
void printBufferData(const std::vector< uint8_t > &buffer, int limitBytes=20)
Prints to console the HEX data from the bytes vector.
Represents the data field of a CCSDS packet.
Manages CCSDS packets and their templates.
Represents a CCSDS (Consultative Committee for Space Data Systems) packet.
Encapsulates a result that can hold either a value or an Error.
Parses and stores config values from custom file format.
std::variant< std::string, int, float, bool, std::vector< uint8_t > > ConfigValue
bool isKey(const std::string &key) const
static CCSDS::ResultBuffer parseBytes(const std::string &valueStr)
Parse string "[1,2,3]" into vector<uint8_t>
std::unordered_map< std::string, ConfigValue > values
CCSDS::ResultBool load(const std::string &filename)
Load config file.
CCSDS::Result< T > get(const std::string &key) const
Get value by key and type.
static std::tuple< std::string, std::string, std::string > parseLine(const std::string &line)
Parse a single line from config.
@ NO_DATA
No data available.