MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_bits.c File Reference

MRTKLIB Bits Module — Implementation. More...

#include "mrtklib/mrtk_bits.h"
#include <stdint.h>
#include "mrtklib/mrtk_trace.h"
Include dependency graph for mrtk_bits.c:

Go to the source code of this file.

Macros

#define POLYCRC32   0xEDB88320u /* CRC32 polynomial */
#define POLYCRC24Q   0x1864CFBu /* CRC24Q polynomial */

Functions

uint32_t getbitu (const uint8_t *buff, int pos, int len)
 Extract unsigned bits from byte data.
int32_t getbits (const uint8_t *buff, int pos, int len)
 Extract signed bits from byte data.
void setbitu (uint8_t *buff, int pos, int len, uint32_t data)
 Set unsigned bits in byte data.
void setbits (uint8_t *buff, int pos, int len, int32_t data)
 Set signed bits in byte data.
uint32_t rtk_crc32 (const uint8_t *buff, int len)
 Compute CRC-32 parity for NovAtel raw data.
uint32_t rtk_crc24q (const uint8_t *buff, int len)
 Compute CRC-24Q parity for SBAS and RTCM3.
uint16_t rtk_crc16 (const uint8_t *buff, int len)
 Compute CRC-16 parity for BINEX and NVS.
int decode_word (uint32_t word, uint8_t *data)
 Check parity and decode GPS navigation data word.

Variables

static const uint16_t tbl_CRC16 []
static const uint32_t tbl_CRC24Q []

Detailed Description

MRTKLIB Bits Module — Implementation.

All functions and static data in this file are cut-and-paste extractions from the legacy rtkcmn.c with zero algorithmic changes.

Definition in file mrtk_bits.c.

Macro Definition Documentation

◆ POLYCRC24Q

#define POLYCRC24Q   0x1864CFBu /* CRC24Q polynomial */

Definition at line 39 of file mrtk_bits.c.

◆ POLYCRC32

#define POLYCRC32   0xEDB88320u /* CRC32 polynomial */

Definition at line 38 of file mrtk_bits.c.

Referenced by rtk_crc32().

Function Documentation

◆ decode_word()

int decode_word ( uint32_t word,
uint8_t * data )
extern

Check parity and decode GPS navigation data word.

Parameters
[in]wordNavigation data word (2+30 bit) (previous word D29*-30* + current word D1-30)
[out]dataDecoded navigation data without parity (8bit x 3)
Returns
Status (1:ok, 0:parity error)
Note
See reference [1] 20.3.5.2 user parity algorithm

Definition at line 224 of file mrtk_bits.c.

References trace().

Referenced by input_rtcm2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getbits()

int32_t getbits ( const uint8_t * buff,
int pos,
int len )
extern

Extract signed bits from byte data.

Parameters
[in]buffByte data
[in]posBit position from start of data (bits)
[in]lenBit length (bits) (len<=32)
Returns
Extracted signed bits

Definition at line 107 of file mrtk_bits.c.

References getbitu().

Referenced by decode_alm_sat(), decode_bds_d1_eph(), decode_bds_d1_ion(), decode_bds_d1_utc(), decode_bds_d2_eph(), decode_bds_d2_utc(), decode_bnx_7f_05(), decode_bnx_7f_05_obs(), decode_cssr_grid(), decode_frame_eph(), decode_frame_ion(), decode_frame_utc(), decode_gal_fnav_eph(), decode_gal_fnav_ion(), decode_gal_fnav_utc(), decode_gal_inav_eph(), decode_gal_inav_ion(), decode_gal_inav_utc(), decode_glostr_utc(), decode_has_clock(), decode_has_clock_subset(), decode_has_codebias(), decode_has_orbit(), decode_has_phasebias(), decode_irn_eph(), decode_irn_ion(), decode_irn_utc(), decode_longcorr0(), decode_longcorr1(), decode_mcssr_cb(), decode_mcssr_cc(), decode_mcssr_oc(), decode_mcssr_pb(), decode_measepoch(), decode_miono_correction(), decode_miono_coverage(), decode_msm4(), decode_msm5(), decode_msm6(), decode_msm7(), decode_sbstype2(), decode_sbstype24(), decode_sbstype9(), decode_ssr1(), decode_ssr2(), decode_ssr3(), decode_ssr4(), decode_ssr6(), decode_ssr7(), decode_sval(), decode_type1(), decode_type1002(), decode_type1004(), decode_type1010(), decode_type1012(), decode_type1019(), decode_type1041(), decode_type1042(), decode_type1044(), decode_type1045(), decode_type1046(), decode_type1230(), decode_type17(), decode_type18(), decode_type22(), decode_type3(), decode_type4050(), getbits2(), getbits3(), and getbits_38().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getbitu()

uint32_t getbitu ( const uint8_t * buff,
int pos,
int len )
extern

Extract unsigned bits from byte data.

Parameters
[in]buffByte data
[in]posBit position from start of data (bits)
[in]lenBit length (bits) (len<=32)
Returns
Extracted unsigned bits

Definition at line 99 of file mrtk_bits.c.

Referenced by check_bit_width_atmos(), check_bit_width_bias(), check_bit_width_combo(), check_bit_width_grid(), check_bit_width_mask(), check_bit_width_si(), check_bit_width_stec(), decode_alm_gps(), decode_alm_qzs(), decode_alm_sat(), decode_bds_d1_eph(), decode_bds_d1_ion(), decode_bds_d1_utc(), decode_bds_d2_eph(), decode_bds_d2_utc(), decode_bdsraw(), decode_bnx_7f_05(), decode_bnx_7f_05_obs(), decode_cnav(), decode_cresgloeph(), decode_cssr_atmos(), decode_cssr_bias(), decode_cssr_combo(), decode_cssr_grid(), decode_cssr_head(), decode_cssr_mask(), decode_cssr_oc(), decode_cssr_pb(), decode_cssr_si(), decode_cssr_stec(), decode_cssr_ura(), decode_enav(), decode_frame_alm(), decode_frame_eph(), decode_frame_ion(), decode_frame_utc(), decode_gal_fnav_eph(), decode_gal_fnav_ion(), decode_gal_fnav_utc(), decode_gal_inav_eph(), decode_gal_inav_ion(), decode_gal_inav_utc(), decode_galrawfnav(), decode_galrawinav(), decode_glorawca(), decode_glostr_eph(), decode_glostr_utc(), decode_gnav(), decode_has_clock(), decode_has_clock_subset(), decode_has_mask(), decode_has_mt1(), decode_has_orbit(), decode_has_phasebias(), decode_head1001(), decode_head1009(), decode_irn_eph(), decode_irn_ion(), decode_irn_utc(), decode_L1nav(), decode_L2nav(), decode_L5nav(), decode_lclhead(), decode_lcliono(), decode_lcltrop(), decode_longcorr0(), decode_longcorr1(), decode_longcorrh(), decode_mcssr_head(), decode_mcssr_mask(), decode_mcssr_oc(), decode_mcssr_pb(), decode_mcssr_ura(), decode_miono_correction(), decode_miono_coverage(), decode_msm4(), decode_msm5(), decode_msm6(), decode_msm7(), decode_msm_head(), decode_nav(), decode_navicraw(), decode_qzs_msg(), decode_qzss_l6dmsg(), decode_qzss_l6emsg(), decode_rawca(), decode_rtcm2(), decode_rtcm3(), decode_rxmsfrb(), decode_sbstype1(), decode_sbstype18(), decode_sbstype2(), decode_sbstype24(), decode_sbstype26(), decode_sbstype6(), decode_sbstype7(), decode_sbstype9(), decode_ssr1(), decode_ssr1_head(), decode_ssr2(), decode_ssr2_head(), decode_ssr3(), decode_ssr4(), decode_ssr5(), decode_ssr6(), decode_ssr7(), decode_ssr7_head(), decode_ssr_epoch(), decode_stqbds(), decode_type1(), decode_type1002(), decode_type1004(), decode_type1005(), decode_type1006(), decode_type1007(), decode_type1008(), decode_type1010(), decode_type1012(), decode_type1019(), decode_type1020(), decode_type1029(), decode_type1033(), decode_type1041(), decode_type1042(), decode_type1044(), decode_type1045(), decode_type1046(), decode_type1230(), decode_type14(), decode_type16(), decode_type17(), decode_type18(), decode_type19(), decode_type22(), decode_type4050(), decode_type4073(), decode_type4076(), detslp_ll(), getbitg(), getbitg(), getbits(), getbits2(), getbits3(), getbits_38(), getbitu2(), getbitu3(), has_input_page(), input_rtcm3(), inputobs(), popcount_field(), save_msm_obs(), sbsupdatecorr(), and test_staid().

◆ rtk_crc16()

uint16_t rtk_crc16 ( const uint8_t * buff,
int len )
extern

Compute CRC-16 parity for BINEX and NVS.

Parameters
[in]buffData buffer
[in]lenData length (bytes)
Returns
CRC-16 parity

Definition at line 199 of file mrtk_bits.c.

References tbl_CRC16, and trace().

Referenced by decode_bnx(), and decode_sbf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtk_crc24q()

uint32_t rtk_crc24q ( const uint8_t * buff,
int len )
extern

Compute CRC-24Q parity for SBAS and RTCM3.

Parameters
[in]buffData buffer
[in]lenData length (bytes)
Returns
CRC-24Q parity

Definition at line 181 of file mrtk_bits.c.

References tbl_CRC24Q, and trace().

Referenced by decode_enav(), decode_galrawfnav(), decode_galrawinav(), gen_rtcm3(), input_rtcm3(), and sbsdecodemsg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtk_crc32()

uint32_t rtk_crc32 ( const uint8_t * buff,
int len )
extern

Compute CRC-32 parity for NovAtel raw data.

Parameters
[in]buffData buffer
[in]lenData length (bytes)
Returns
CRC-32 parity
Note
See NovAtel OEMV firmware manual 1.7 32-bit CRC

Definition at line 156 of file mrtk_bits.c.

References POLYCRC32, and trace().

Referenced by decode_oem4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setbits()

void setbits ( uint8_t * buff,
int pos,
int len,
int32_t data )
extern

Set signed bits in byte data.

Parameters
[in,out]buffByte data
[in]posBit position from start of data (bits)
[in]lenBit length (bits) (len<=32)
[in]dataSigned data to set

Definition at line 136 of file mrtk_bits.c.

References setbitu().

Referenced by encode_msm_phrng(), encode_msm_phrng_ex(), encode_msm_psrng(), encode_msm_psrng_ex(), encode_msm_rrate(), encode_ssr1(), encode_ssr2(), encode_ssr3(), encode_ssr4(), encode_ssr6(), encode_ssr7(), encode_type1001(), encode_type1002(), encode_type1003(), encode_type1004(), encode_type1009(), encode_type1010(), encode_type1011(), encode_type1012(), encode_type1019(), encode_type1041(), encode_type1042(), encode_type1044(), encode_type1045(), encode_type1046(), encode_type1230(), encode_type63(), and set38bits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setbitu()

void setbitu ( uint8_t * buff,
int pos,
int len,
uint32_t data )
extern

Set unsigned bits in byte data.

Parameters
[in,out]buffByte data
[in]posBit position from start of data (bits)
[in]lenBit length (bits) (len<=32)
[in]dataUnsigned data to set

Definition at line 122 of file mrtk_bits.c.

Referenced by clas_input_cssr(), decode_bdsraw(), decode_cnav(), decode_enav(), decode_galrawfnav(), decode_galrawinav(), decode_georawl1(), decode_glorawca(), decode_L1nav(), decode_lD(), decode_nav(), decode_navicraw(), decode_rawca(), decode_rxmsfrb(), decode_snav(), decode_stqbds(), decode_stqglo(), detslp_ll(), encode_head(), encode_lclhead(), encode_lcliono(), encode_lcltrop(), encode_msm_cnr(), encode_msm_cnr_ex(), encode_msm_half_amb(), encode_msm_head(), encode_msm_info(), encode_msm_int_rrng(), encode_msm_lock(), encode_msm_lock_ex(), encode_msm_mod_rrng(), encode_msm_rate(), encode_ssr1(), encode_ssr2(), encode_ssr3(), encode_ssr4(), encode_ssr5(), encode_ssr6(), encode_ssr7(), encode_ssr_head(), encode_type1001(), encode_type1002(), encode_type1003(), encode_type1004(), encode_type1005(), encode_type1006(), encode_type1007(), encode_type1008(), encode_type1009(), encode_type1010(), encode_type1011(), encode_type1012(), encode_type1019(), encode_type1020(), encode_type1033(), encode_type1041(), encode_type1042(), encode_type1044(), encode_type1045(), encode_type1046(), encode_type1230(), encode_type63(), gen_rtcm3(), set38bits(), setbitg(), and setbits().

Here is the caller graph for this function:

Variable Documentation

◆ tbl_CRC16

const uint16_t tbl_CRC16[]
static
Initial value:
= {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD,
0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A,
0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B,
0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861,
0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96,
0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87,
0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A,
0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3,
0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290,
0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E,
0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F,
0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C,
0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83,
0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74,
0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}

Definition at line 42 of file mrtk_bits.c.

Referenced by rtk_crc16().

◆ tbl_CRC24Q

const uint32_t tbl_CRC24Q[]
static
Initial value:
= {
0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, 0xA18139, 0x27CDC2, 0x2B5434,
0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493,
0xDC7D65, 0x5A319E, 0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, 0x0CD1E9,
0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926,
0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7, 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C,
0x56E077, 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E, 0x19A3D2, 0x9FEF29,
0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5, 0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A,
0xAD88F1, 0xA11107, 0x275DFC, 0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C,
0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, 0x15723B, 0x933EC0, 0x9FA736,
0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918,
0xADC0EE, 0x2B8C15, 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5, 0x71BD8B,
0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C, 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52,
0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3, 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571,
0x0DB98A, 0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, 0x578814, 0xD1C4EF,
0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, 0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC,
0x2A3C57, 0x26A5A1, 0xA0E95A, 0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863,
0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, 0x5B59FD, 0xDD1506, 0xD18CF0,
0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA, 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C,
0x33D79A, 0xB59B61, 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58, 0xEFAAFF,
0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8, 0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230,
0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, 0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673,
0xB94A88, 0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, 0xE37B16, 0x6537ED,
0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE,
0x575035, 0x5BC9C3, 0xDD8538}

Definition at line 62 of file mrtk_bits.c.

Referenced by rtk_crc24q().