MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_has.c File Reference
#include "mrtklib/mrtk_has.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "mrtk_has_rs.h"
#include "mrtklib/mrtk_bits.h"
#include "mrtklib/mrtk_const.h"
#include "mrtklib/mrtk_time.h"
#include "mrtklib/mrtk_trace.h"
Include dependency graph for mrtk_has.c:

Go to the source code of this file.

Macros

#define HAS_DUMMY_HEADER   0xAF3BC3 /* 24-bit HAS header of a dummy page */
#define HAS_TIMEOUT   150.0 /* message collection timeout (s) [1] 6.4.1 */
#define HAS_MT1   1 /* HAS Message Type 1 (satellite corrections) */
#define HAS_GNSS_GPS   0 /* HAS GNSS ID: GPS ([1] Table 18) */
#define HAS_GNSS_GAL   2 /* HAS GNSS ID: Galileo ([1] Table 18) */
#define HAS_HASS_DONTUSE   3 /* HAS Status: don't use ([1] Table 9) */
#define HAS_SATM_BITS   40 /* satellite mask length ([1] 5.2.1.2) */
#define HAS_SIGM_BITS   16 /* signal mask length ([1] 5.2.1.3) */
#define HAS_DR_NA   (-4096) /* DR "data not available" (1000...0, 13-bit) */
#define HAS_DIT_NA   (-2048) /* DIT "data not available" (1000...0, 12-bit) */
#define HAS_DCT_NA   (-2048) /* DCT "data not available" (1000...0, 12-bit) */
#define HAS_DCC_NA   (-4096) /* DCC "data not available" (1000...0, 13-bit) */
#define HAS_DCC_NU   (4095) /* DCC "shall not be used" (0111...1, 13-bit) */
#define HAS_CB_NA   (-1024) /* CB "data not available" (1000...0, 11-bit) */
#define HAS_PB_NA   (-1024) /* PB "data not available" (1000...0, 11-bit) */
#define HAS_MAX_LATENCY   600.0

Functions

int satno (int sys, int prn)
void satno2id (int sat, char *id)
double time2gpst (gtime_t t, int *week)
char * time_str (gtime_t t, int n)
static int has_gnssid2sys (int gnssid)
static uint8_t has_sigcode (int gnssid, int sigidx)
static int has_iodref_bits (int gnssid)
static double has_code2lam (int sys, uint8_t code)
static int has_bits_ok (int i, int n, int nbit)
static int popcount_field (const uint8_t *buff, int pos, int len)
static gtime_t has_t_mt1 (gtime_t time, int toh)
static int decode_has_mask (has_t *has, const uint8_t *msg, int i, int nbit, int mid)
static int decode_has_orbit (has_t *has, const uint8_t *msg, int i, int nbit, int mid, int iodset, gtime_t t0)
static int decode_has_clock (has_t *has, const uint8_t *msg, int i, int nbit, int mid, int iodset, gtime_t t0)
static int decode_has_clock_subset (has_t *has, const uint8_t *msg, int i, int nbit, int mid, int iodset, gtime_t t0)
static int decode_has_codebias (has_t *has, const uint8_t *msg, int i, int nbit, gtime_t t0, const has_mask_t *m)
static int decode_has_phasebias (has_t *has, const uint8_t *msg, int i, int nbit, gtime_t t0, const has_mask_t *m)
static int decode_has_mt1 (has_t *has, const uint8_t *msg, int nbit, gtime_t time)
static int has_complete (has_t *has, has_collect_t *col, gtime_t time)
static has_collect_t * has_find_collect (has_t *has, int mid, int mt, gtime_t time)
static void has_flush (has_t *has)
has_t * has_new (void)
 Allocate and initialize a Galileo HAS decode context.
void has_free (has_t *has)
 Free a Galileo HAS decode context.
int has_input_page (has_t *has, int prn, const uint8_t *page56, gtime_t time)
 Input one received Galileo HAS page.
int has_input_file (has_t *has, FILE *fp, gtime_t tmax)
 Read .has records from a file and feed them to has_input_page().
int has_sel_biascode (int sys, uint8_t code)
 Select the HAS bias slot obs code for an observation code.

Variables

static const uint8_t has_sig_gal [HAS_MAX_SIG]
static const uint8_t has_sig_gps [HAS_MAX_SIG]

Macro Definition Documentation

◆ HAS_CB_NA

#define HAS_CB_NA   (-1024) /* CB "data not available" (1000...0, 11-bit) */

Definition at line 50 of file mrtk_has.c.

Referenced by decode_has_codebias().

◆ HAS_DCC_NA

#define HAS_DCC_NA   (-4096) /* DCC "data not available" (1000...0, 13-bit) */

Definition at line 48 of file mrtk_has.c.

Referenced by decode_has_clock(), and decode_has_clock_subset().

◆ HAS_DCC_NU

#define HAS_DCC_NU   (4095) /* DCC "shall not be used" (0111...1, 13-bit) */

Definition at line 49 of file mrtk_has.c.

Referenced by decode_has_clock(), and decode_has_clock_subset().

◆ HAS_DCT_NA

#define HAS_DCT_NA   (-2048) /* DCT "data not available" (1000...0, 12-bit) */

Definition at line 47 of file mrtk_has.c.

Referenced by decode_has_orbit().

◆ HAS_DIT_NA

#define HAS_DIT_NA   (-2048) /* DIT "data not available" (1000...0, 12-bit) */

Definition at line 46 of file mrtk_has.c.

Referenced by decode_has_orbit().

◆ HAS_DR_NA

#define HAS_DR_NA   (-4096) /* DR "data not available" (1000...0, 13-bit) */

Definition at line 45 of file mrtk_has.c.

Referenced by decode_has_orbit().

◆ HAS_DUMMY_HEADER

#define HAS_DUMMY_HEADER   0xAF3BC3 /* 24-bit HAS header of a dummy page */

Definition at line 32 of file mrtk_has.c.

Referenced by has_input_page().

◆ HAS_GNSS_GAL

#define HAS_GNSS_GAL   2 /* HAS GNSS ID: Galileo ([1] Table 18) */

Definition at line 38 of file mrtk_has.c.

Referenced by has_gnssid2sys(), has_iodref_bits(), and has_sigcode().

◆ HAS_GNSS_GPS

#define HAS_GNSS_GPS   0 /* HAS GNSS ID: GPS ([1] Table 18) */

Definition at line 37 of file mrtk_has.c.

Referenced by has_gnssid2sys(), has_iodref_bits(), and has_sigcode().

◆ HAS_HASS_DONTUSE

#define HAS_HASS_DONTUSE   3 /* HAS Status: don't use ([1] Table 9) */

Definition at line 40 of file mrtk_has.c.

Referenced by has_input_page().

◆ HAS_MAX_LATENCY

#define HAS_MAX_LATENCY   600.0

Definition at line 165 of file mrtk_has.c.

Referenced by decode_has_mt1().

◆ HAS_MT1

#define HAS_MT1   1 /* HAS Message Type 1 (satellite corrections) */

Definition at line 35 of file mrtk_has.c.

Referenced by has_complete(), and has_input_page().

◆ HAS_PB_NA

#define HAS_PB_NA   (-1024) /* PB "data not available" (1000...0, 11-bit) */

Definition at line 51 of file mrtk_has.c.

Referenced by decode_has_phasebias().

◆ HAS_SATM_BITS

#define HAS_SATM_BITS   40 /* satellite mask length ([1] 5.2.1.2) */

Definition at line 42 of file mrtk_has.c.

Referenced by decode_has_mask().

◆ HAS_SIGM_BITS

#define HAS_SIGM_BITS   16 /* signal mask length ([1] 5.2.1.3) */

Definition at line 43 of file mrtk_has.c.

Referenced by decode_has_mask().

◆ HAS_TIMEOUT

#define HAS_TIMEOUT   150.0 /* message collection timeout (s) [1] 6.4.1 */

Definition at line 33 of file mrtk_has.c.

Referenced by has_find_collect().

Function Documentation

◆ decode_has_clock()

int decode_has_clock ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
int mid,
int iodset,
gtime_t t0 )
static

Definition at line 377 of file mrtk_has.c.

References ssr_t::dclk, getbits(), getbitu(), has_mask_t::gnssid, has_bits_ok(), HAS_DCC_NA, HAS_DCC_NU, HAS_MAX_SIG, ssr_t::hrclk, ssr_t::iod, has_t::mask, has_mask_t::nsat, has_mask_t::nsys, has_mask_t::sat, gtime_t::sec, has_t::ssr, ssr_t::t0, gtime_t::time, ssr_t::udi, and ssr_t::update.

Referenced by decode_has_mt1().

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

◆ decode_has_clock_subset()

int decode_has_clock_subset ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
int mid,
int iodset,
gtime_t t0 )
static

Definition at line 436 of file mrtk_has.c.

References ssr_t::dclk, getbits(), getbitu(), has_mask_t::gnssid, has_bits_ok(), HAS_DCC_NA, HAS_DCC_NU, ssr_t::hrclk, ssr_t::iod, has_t::mask, has_mask_t::nsat, has_mask_t::sat, gtime_t::sec, has_t::ssr, ssr_t::t0, gtime_t::time, trace(), ssr_t::udi, and ssr_t::update.

Referenced by decode_has_mt1().

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

◆ decode_has_codebias()

int decode_has_codebias ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
gtime_t t0,
const has_mask_t * m )
static

Definition at line 516 of file mrtk_has.c.

References ssr_t::cbias, has_mask_t::cellmask, has_mask_t::code, CODE_NONE, getbits(), has_bits_ok(), HAS_CB_NA, has_mask_t::nsat, has_mask_t::nsig, has_mask_t::sat, has_t::ssr, ssr_t::t0, ssr_t::udi, ssr_t::update, and ssr_t::vcbias.

Referenced by decode_has_mt1().

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

◆ decode_has_mask()

int decode_has_mask ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
int mid )
static

Definition at line 195 of file mrtk_has.c.

References has_mask_t::cellmask, has_mask_t::code, getbitu(), has_mask_t::gnssid, has_bits_ok(), has_gnssid2sys(), HAS_MAX_SIG, HAS_SATM_BITS, has_sigcode(), HAS_SIGM_BITS, has_t::mask, MAXSAT, has_mask_t::navmsg, has_mask_t::nsat, has_mask_t::nsig, has_mask_t::nsys, popcount_field(), has_mask_t::sat, satno(), satno2id(), SYS_NONE, trace(), and has_mask_t::valid.

Referenced by decode_has_mt1().

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

◆ decode_has_mt1()

int decode_has_mt1 ( has_t * has,
const uint8_t * msg,
int nbit,
gtime_t time )
static

Definition at line 629 of file mrtk_has.c.

References decode_has_clock(), decode_has_clock_subset(), decode_has_codebias(), decode_has_mask(), decode_has_orbit(), decode_has_phasebias(), getbitu(), HAS_MAX_LATENCY, has_t_mt1(), has_t::iodset, has_t::mask, time2gpst(), time_str(), trace(), has_iodset_t::valid, and has_mask_t::valid.

Referenced by has_complete().

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

◆ decode_has_orbit()

int decode_has_orbit ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
int mid,
int iodset,
gtime_t t0 )
static

Definition at line 318 of file mrtk_has.c.

References ssr_t::ddeph, ssr_t::deph, getbits(), getbitu(), has_mask_t::gnssid, has_bits_ok(), HAS_DCT_NA, HAS_DIT_NA, HAS_DR_NA, has_iodref_bits(), ssr_t::iod, ssr_t::iode, has_iodset_t::iodref, has_t::iodset, has_t::mask, has_mask_t::nsat, has_mask_t::sat, has_t::ssr, ssr_t::t0, ssr_t::udi, ssr_t::update, and has_iodset_t::valid.

Referenced by decode_has_mt1().

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

◆ decode_has_phasebias()

int decode_has_phasebias ( has_t * has,
const uint8_t * msg,
int i,
int nbit,
gtime_t t0,
const has_mask_t * m )
static

Definition at line 568 of file mrtk_has.c.

References has_mask_t::cellmask, has_mask_t::code, CODE_NONE, ssr_t::discnt, getbits(), getbitu(), has_mask_t::gnssid, has_bits_ok(), has_code2lam(), has_gnssid2sys(), HAS_PB_NA, has_mask_t::nsat, has_mask_t::nsig, ssr_t::pbias, has_mask_t::sat, has_t::ssr, SYS_NONE, ssr_t::t0, ssr_t::udi, ssr_t::update, and ssr_t::vpbias.

Referenced by decode_has_mt1().

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

◆ has_bits_ok()

int has_bits_ok ( int i,
int n,
int nbit )
static

Definition at line 160 of file mrtk_has.c.

Referenced by decode_has_clock(), decode_has_clock_subset(), decode_has_codebias(), decode_has_mask(), decode_has_orbit(), and decode_has_phasebias().

Here is the caller graph for this function:

◆ has_code2lam()

double has_code2lam ( int sys,
uint8_t code )
static

Definition at line 100 of file mrtk_has.c.

References CLIGHT, CODE_L1B, CODE_L1C, CODE_L1L, CODE_L1S, CODE_L1X, CODE_L2L, CODE_L2S, CODE_L2W, CODE_L2X, CODE_L5I, CODE_L5Q, CODE_L5X, CODE_L6B, CODE_L6C, CODE_L6X, CODE_L7I, CODE_L7Q, CODE_L7X, CODE_L8I, CODE_L8Q, CODE_L8X, FREQ1, FREQ2, FREQ5, FREQ6, FREQ7, FREQ8, SYS_GAL, and SYS_GPS.

Referenced by decode_has_phasebias().

Here is the caller graph for this function:

◆ has_complete()

int has_complete ( has_t * has,
has_collect_t * col,
gtime_t time )
static

Definition at line 725 of file mrtk_has.c.

References has_collect_t::active, calloc, decode_has_mt1(), free, HAS_MT1, HAS_PAGE_BYTES, has_rs_decode(), has_collect_t::mid, has_collect_t::ms, has_collect_t::mt, has_collect_t::page, has_collect_t::pid, and trace().

Referenced by has_input_page().

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

◆ has_find_collect()

has_collect_t * has_find_collect ( has_t * has,
int mid,
int mt,
gtime_t time )
static

Definition at line 749 of file mrtk_has.c.

References has_collect_t::active, has_t::collect, HAS_MAX_INFLIGHT, HAS_TIMEOUT, has_collect_t::mid, has_collect_t::mt, has_collect_t::t0, and timediff().

Referenced by has_input_page().

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

◆ has_flush()

void has_flush ( has_t * has)
static

Definition at line 777 of file mrtk_has.c.

References has_collect_t::active, has_t::collect, HAS_MAX_INFLIGHT, HAS_MAX_MID, has_t::mask, trace(), and has_mask_t::valid.

Referenced by has_input_page().

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

◆ has_free()

void has_free ( has_t * has)
extern

Free a Galileo HAS decode context.

Parameters
[in,out]hasContext allocated by has_new() (NULL: no-op)

Definition at line 801 of file mrtk_has.c.

References free.

Referenced by freepreceph(), and rtksvrfree().

Here is the caller graph for this function:

◆ has_gnssid2sys()

int has_gnssid2sys ( int gnssid)
static

Definition at line 64 of file mrtk_has.c.

References HAS_GNSS_GAL, HAS_GNSS_GPS, SYS_GAL, SYS_GPS, and SYS_NONE.

Referenced by decode_has_mask(), and decode_has_phasebias().

Here is the caller graph for this function:

◆ has_input_file()

int has_input_file ( has_t * has,
FILE * fp,
gtime_t tmax )
extern

Read .has records from a file and feed them to has_input_page().

Parameters
[in,out]hasHAS decode context
[in]fpOpen .has file pointer (64-byte little-endian records)
[in]tmaxStop after reading records past this time (GPST)
Returns
10 if any message completed during the call, 0 otherwise (including at end of file).

Definition at line 872 of file mrtk_has.c.

References gpst2time(), has_input_page(), gtime_t::time, timediff(), and trace().

Referenced by update_gal_has().

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

◆ has_input_page()

int has_input_page ( has_t * has,
int prn,
const uint8_t * page56,
gtime_t time )
extern

Input one received Galileo HAS page.

Parameters
[in,out]hasHAS decode context
[in]prnGalileo PRN of the transmitting satellite (1-40)
[in]page5656-byte HAS page (24-bit header + 424-bit encoded page)
[in]timePage reception time (GPST)
Returns
10 when a complete MT1 was decoded and ssr[] updated, 0 when no message completed, <0 on error.

Definition at line 804 of file mrtk_has.c.

References has_collect_t::active, getbitu(), has_complete(), HAS_DUMMY_HEADER, has_find_collect(), has_flush(), HAS_HASS_DONTUSE, HAS_MAX_PAGES, HAS_MT1, HAS_PAGE_BYTES, has_collect_t::mid, has_collect_t::ms, has_collect_t::mt, has_collect_t::npid, has_collect_t::page, has_collect_t::pid, has_collect_t::t0, and trace().

Referenced by decoderaw(), and has_input_file().

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

◆ has_iodref_bits()

int has_iodref_bits ( int gnssid)
static

Definition at line 89 of file mrtk_has.c.

References HAS_GNSS_GAL, and HAS_GNSS_GPS.

Referenced by decode_has_orbit().

Here is the caller graph for this function:

◆ has_new()

has_t * has_new ( void )
extern

Allocate and initialize a Galileo HAS decode context.

Returns
Pointer to a heap-allocated has_t (NULL on allocation failure or RS init failure). Free with has_free().
Note
Calls has_rs_init() to build the RS(255,32) erasure-decoder tables.

Definition at line 790 of file mrtk_has.c.

References calloc, and has_rs_init().

Referenced by readpreceph(), and rtksvrstart().

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

◆ has_sel_biascode()

int has_sel_biascode ( int sys,
uint8_t code )
extern

Select the HAS bias slot obs code for an observation code.

Parameters
[in]sysSatellite system (SYS_GPS or SYS_GAL)
[in]codeObservation code (CODE_???)
Returns
Obs code under which the HAS bias is stored, with same-frequency fallback (component <-> combined on the same carrier per HAS SIS ICD Table 20); 0 (CODE_NONE) if no mapping exists.

Definition at line 902 of file mrtk_has.c.

References CODE_L1B, CODE_L1C, CODE_L1L, CODE_L1S, CODE_L1X, CODE_L2L, CODE_L2S, CODE_L2W, CODE_L2X, CODE_L5I, CODE_L5Q, CODE_L5X, CODE_L6B, CODE_L6C, CODE_L6X, CODE_L7I, CODE_L7Q, CODE_L7X, CODE_L8I, CODE_L8Q, CODE_L8X, CODE_NONE, SYS_GAL, and SYS_GPS.

Referenced by corr_meas().

Here is the caller graph for this function:

◆ has_sigcode()

uint8_t has_sigcode ( int gnssid,
int sigidx )
static

Definition at line 75 of file mrtk_has.c.

References CODE_NONE, HAS_GNSS_GAL, HAS_GNSS_GPS, HAS_MAX_SIG, has_sig_gal, and has_sig_gps.

Referenced by decode_has_mask().

Here is the caller graph for this function:

◆ has_t_mt1()

gtime_t has_t_mt1 ( gtime_t time,
int toh )
static

Definition at line 180 of file mrtk_has.c.

References gpst2time(), and time2gpst().

Referenced by decode_has_mt1().

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

◆ popcount_field()

int popcount_field ( const uint8_t * buff,
int pos,
int len )
static

Definition at line 168 of file mrtk_has.c.

References getbitu().

Referenced by decode_has_mask().

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

◆ satno()

int satno ( int sys,
int prn )
extern

Definition at line 58 of file mrtk_nav.c.

Referenced by decode_has_mask().

Here is the caller graph for this function:

◆ satno2id()

void satno2id ( int sat,
char * id )
extern

Definition at line 817 of file mrtk_nav.c.

Referenced by decode_has_mask().

Here is the caller graph for this function:

◆ time2gpst()

double time2gpst ( gtime_t t,
int * week )
extern

Definition at line 181 of file mrtk_time.c.

Referenced by decode_has_mt1(), and has_t_mt1().

Here is the caller graph for this function:

◆ time_str()

char * time_str ( gtime_t t,
int n )
extern

Definition at line 530 of file mrtk_time.c.

Referenced by decode_has_mt1().

Here is the caller graph for this function:

Variable Documentation

◆ has_sig_gal

const uint8_t has_sig_gal[HAS_MAX_SIG]
static
Initial value:
#define CODE_L5Q
#define CODE_L6C
#define CODE_L5I
#define CODE_L5X
#define CODE_L7X
#define CODE_L1C
#define CODE_L7I
#define CODE_L6X
#define CODE_NONE
#define CODE_L8Q
#define CODE_L1B
#define CODE_L7Q
#define CODE_L6B
#define CODE_L8X
#define CODE_L8I
#define CODE_L1X

Definition at line 54 of file mrtk_has.c.

Referenced by has_sigcode().

◆ has_sig_gps

const uint8_t has_sig_gps[HAS_MAX_SIG]
static
Initial value:

Definition at line 59 of file mrtk_has.c.

Referenced by has_sigcode().