24#ifndef INCLUDED_SATNOGS_CRC_H
25#define INCLUDED_SATNOGS_CRC_H
27#define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS 1
28#define CRCPP_USE_CPP11 1
76 case type::CRC16_XMODEM:
78 case type::CRC16_HDLC:
79 case type::CRC16_AUG_CCITT:
80 case type::CRC16_AUG_CCITT_XOR:
81 case type::CRC16_KERMIT:
82 return sizeof(uint16_t);
84 return sizeof(uint32_t);
86 throw std::invalid_argument(
"crc: Invalid CRC method");
90 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
93 static_assert(CRCWidth % 8 == 0,
"Expected a CRC size with byte boundaries");
97 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
104 static_assert(CRCWidth % 8 == 0,
"Expected a CRC size with byte boundaries");
107 for (
int i =
sizeof(calc) - 1;
i >= 0;
i--) {
108 *out++ = calc >> (
i * 8);
111 for (
size_t i = 0;
i <
sizeof(calc);
i++) {
112 *out++ = calc >> (
i * 8);
119 append(
type t, uint8_t* out,
const uint8_t* data,
size_t len,
bool msb =
true);
121 static bool check(
type t,
const uint8_t* data,
size_t len,
bool msb =
true);
123 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
129 const size_t payload_len = len -
crc::size(
t);
133 for (
size_t i = 0;
i <
sizeof(recv);
i++) {
135 recv |= data[payload_len +
i];
138 for (
int i =
sizeof(recv) - 1;
i >= 0;
i--) {
140 recv |= data[payload_len +
i];
#define SATNOGS_API
Definition: api.h:19
static CRCType Calculate(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition: CRC.h:463
type
Predefined CRC types.
Definition: crc.h:51
static constexpr size_t size(type t)
Definition: crc.h:71
static constexpr size_t size(const CRC::Parameters< CRCType, CRCWidth > &t)
Definition: crc.h:91
static bool check(type t, const uint8_t *data, size_t len, bool msb=true)
static bool check(const CRC::Parameters< CRCType, CRCWidth > &t, const uint8_t *data, size_t len, bool msb=true)
Definition: crc.h:124
static size_t append(type t, uint8_t *out, const uint8_t *data, size_t len, bool msb=true)
static size_t append(const CRC::Parameters< CRCType, CRCWidth > &t, uint8_t *out, const uint8_t *data, size_t len, bool msb=true)
Definition: crc.h:98
data_t t[NROOTS+1]
Definition: decode_rs.h:77
int i
Definition: decode_rs.h:73
Definition: amsat_duv_decoder.h:29
CRC parameters.
Definition: CRC.h:160