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// Copyright 2025-2026 ExoSpaceLabs
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef CCSDS_UTILS_H
5#define CCSDS_UTILS_H
6
7#include <CCSDSPacket.h>
8#include <CCSDSManager.h>
9#include <string>
10#include <vector>
11
12// free functions
22uint16_t crc16(const std::vector<std::uint8_t> &data,
23 std::uint16_t polynomial = 0x1021,
24 std::uint16_t initialValue = 0xFFFF,
25 std::uint16_t finalXorValue = 0x0000
26);
27
28
37bool stringEndsWith(const std::string& str, const std::string& suffix);
38
44void printPacket(CCSDS::Packet &packet);
45
51void printPackets(CCSDS::Manager & manager);
52
60std::string getBinaryString(std::uint32_t value, std::int32_t bits);
61
68std::string getBitsSpaces(std::int32_t num);
69
76void printBufferData(const std::vector<std::uint8_t> &buffer, std::int32_t limitBytes = 20);
77
86void printData(CCSDS::DataField dataField);
87
97void printHeader(CCSDS::Header &header);
98
106
115void printDataField(CCSDS::Packet &packet);
116
125CCSDS::ResultBool writeBinaryFile(const std::vector<std::uint8_t>& data, const std::string& filename);
126
133CCSDS::ResultBuffer readBinaryFile(const std::string& filename);
134
141bool fileExists(const std::string &fileName);
142
143
144#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:83
Manages CCSDS packets and their templates.
Represents a CCSDS (Consultative Committee for Space Data Systems) packet.
Definition CCSDSPacket.h:62
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:85