Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
crc.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 *
9 * Based on work by flipflip (https://github.com/phkehl)
10 * \endverbatim
11 *
12 * @file
13 * @brief Fixposition SDK: Parser CRC routines
14 *
15 * @page FPSDK_COMMON_PARSER_CRC Parser CRC routines
16 *
17 * **API**: fpsdk_common/parser/crc.hpp and fpsdk::common::parser::crc
18 *
19 */
20#ifndef __FPSDK_COMMON_PARSER_CRC_HPP__
21#define __FPSDK_COMMON_PARSER_CRC_HPP__
22
23/* LIBC/STL */
24#include <cstdint>
25
26/* EXTERNAL */
27
28/* PACKAGE */
29
30namespace fpsdk {
31namespace common {
32namespace parser {
33/**
34 * @brief Parser NOV_B routines and types
35 */
36namespace crc {
37/* ****************************************************************************************************************** */
38
39/**
40 * @brief Calculate 32-bit CRC as used by FP_B
41 *
42 * @param[in] data Pointer to the data to calculate the CRC for
43 * @param[in] size Size of data
44 *
45 * @returns the CRC
46 */
47uint32_t Crc32fpb(const uint8_t* data, const std::size_t size);
48
49/**
50 * @brief Calculate 24-bit CRC as used by RTCM3 and SPARTN
51 *
52 * @param[in] data Pointer to the data to calculate the CRC for
53 * @param[in] size Size of data
54 *
55 * @returns the CRC (32-bit value masked with 0x00ffffff)
56 */
57uint32_t Crc24rtcm3(const uint8_t* data, const std::size_t size);
58
59/**
60 * @brief Calculate 32-bit CRC as used by NOV_B (and UNI_B)
61 *
62 * @param[in] data Pointer to the data to calculate the CRC for
63 * @param[in] size Size of data
64 *
65 * @returns the CRC
66 */
67uint32_t Crc32novb(const uint8_t* data, const std::size_t size);
68
69/**
70 * @brief Calculate 4-bit CRC as used by SPARTN
71 *
72 * @param[in] data Pointer to the data to calculate the CRC for
73 * @param[in] size Size of data
74
75 \returns CRC (8-bit value masked with 0x0f)
76*/
77uint8_t Crc4spartn(const uint8_t* data, const std::size_t size);
78
79/**
80 * @brief Calculate 8-bit CRC as used by SPARTN
81 *
82 * @param[in] data Pointer to the data to calculate the CRC for
83 * @param[in] size Size of data
84 *
85 * @returns the CRC
86 */
87uint8_t Crc8spartn(const uint8_t* data, const std::size_t size);
88
89/**
90 * @brief Calculate 16-bit CRC as used by SPARTN
91 *
92 * @param[in] data Pointer to the data to calculate the CRC for
93 * @param[in] size Size of data
94 *
95 * @returns the CRC (result undefined if size <= 0 or data == NULL)
96 */
97uint16_t Crc16spartn(const uint8_t* data, const std::size_t size);
98
99/**
100 * @brief Calculate 32-bit CRC as used by SPARTN
101 *
102 * @param[in] data Pointer to the data to calculate the CRC for
103 * @param[in] size Size of data
104 *
105 * @returns the CRC
106 */
107uint32_t Crc32spartn(const uint8_t* data, const std::size_t size);
108
109/**
110 * @brief Calculate 16-bit checksum as used by UBX
111 *
112 * @param[in] data Pointer to the data to calculate the CRC for
113 * @param[in] size Size of data
114 *
115 * @returns the checksum
116 */
117uint16_t ChecksumUbx(const uint8_t* data, const std::size_t size);
118
119/* ****************************************************************************************************************** */
120} // namespace crc
121} // namespace parser
122} // namespace common
123} // namespace fpsdk
124#endif // __FPSDK_COMMON_PARSER_CRC_HPP__
uint16_t ChecksumUbx(const uint8_t *data, const std::size_t size)
Calculate 16-bit checksum as used by UBX.
uint8_t Crc8spartn(const uint8_t *data, const std::size_t size)
Calculate 8-bit CRC as used by SPARTN.
uint32_t Crc24rtcm3(const uint8_t *data, const std::size_t size)
Calculate 24-bit CRC as used by RTCM3 and SPARTN.
uint32_t Crc32fpb(const uint8_t *data, const std::size_t size)
Calculate 32-bit CRC as used by FP_B.
uint8_t Crc4spartn(const uint8_t *data, const std::size_t size)
Calculate 4-bit CRC as used by SPARTN.
uint16_t Crc16spartn(const uint8_t *data, const std::size_t size)
Calculate 16-bit CRC as used by SPARTN.
uint32_t Crc32novb(const uint8_t *data, const std::size_t size)
Calculate 32-bit CRC as used by NOV_B (and UNI_B)
uint32_t Crc32spartn(const uint8_t *data, const std::size_t size)
Calculate 32-bit CRC as used by SPARTN.
Fixposition SDK.