GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
cnav_msg.h
Go to the documentation of this file.
1 /*!
2  * \file cnav_msg.h
3  * \brief Utilities for CNAV message manipulation of the libswiftnav library
4  * \author Valeri Atamaniouk <valeri@swift-nav.com>
5  *
6  * -----------------------------------------------------------------------------
7  * This file was originally borrowed from libswiftnav
8  * <https://github.com/swift-nav/libswiftnav>,
9  * a portable C library implementing GNSS related functions and algorithms,
10  * and then modified by J. Arribas and C. Fernandez
11  *
12  * Copyright (C) 2016 Swift Navigation Inc.
13  * Contact: Valeri Atamaniouk <valeri@swift-nav.com>
14  *
15  * GNSS-SDR is a software defined Global Navigation
16  * Satellite Systems receiver
17  *
18  * This file is part of GNSS-SDR.
19  *
20  * SPDX-License-Identifier: LGPL-3.0-only
21  *.
22  */
23 
24 
25 #ifndef GNSS_SDR_CNAV_MSG_H
26 #define GNSS_SDR_CNAV_MSG_H
27 
28 #include "fec.h"
29 #include "swift_common.h"
30 #include <limits.h>
31 #include <stdbool.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 
35 /** \addtogroup GPS_L2
36  * \{ */
37 /** \addtogroup gps_cnav_decoder
38  * \{ */
39 
40 /** Size of the Viterbi decoder history. */
41 #define GPS_L2_V27_HISTORY_LENGTH_BITS 64
42 /** Bits to accumulate before decoding starts. */
43 #define GPS_L2C_V27_INIT_BITS (32)
44 /** Bits to decode at a time. */
45 #define GPS_L2C_V27_DECODE_BITS (32)
46 /** Bits in decoder tail. We ignore them. */
47 #define GPS_L2C_V27_DELAY_BITS (32)
48 /**
49  * GPS CNAV message container.
50  *
51  * @sa cnav_msg_decoder_add_symbol
52  */
53 typedef struct
54 {
55  uint8_t prn; /**< SV PRN. 0..31 */
56  uint8_t msg_id; /**< Message id. 0..31 */
57  uint32_t tow; /**< GPS ToW in 6-second units. Multiply to 6 to get seconds. */
58  bool alert; /**< CNAV message alert flag */
59  uint8_t raw_msg[GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS]; /**< RAW MSG for GNSS-SDR */
60 } cnav_msg_t;
61 
62 /**
63  * GPS CNAV decoder component.
64  * This component controls symbol decoding string.
65  *
66  * @sa cnav_msg_decoder_t
67  */
68 typedef struct
69 {
70  v27_t dec; /**< Viterbi block decoder object */
72  /**< Decision graph */
73  unsigned char symbols[(GPS_L2C_V27_INIT_BITS + GPS_L2C_V27_DECODE_BITS) * 2];
74  /**< Symbol buffer */
75  size_t n_symbols; /**< Count of symbols in the symbol buffer */
77  /**< Decode buffer */
78  size_t n_decoded; /**< Number of bits in the decode buffer */
79  bool preamble_seen; /**< When true, the decode buffer is aligned on
80  * preamble. */
81  bool invert; /**< When true, indicates the bits are inverted */
82  bool message_lock; /**< When true, indicates the message boundary
83  * is found. */
84  bool crc_ok; /**< Flag that the last message had good CRC */
85  size_t n_crc_fail; /**< Counter for CRC failures */
86  bool init; /**< Initial state flag. When true, initial bits
87  * do not produce output. */
89 
90 /**
91  * GPS CNAV message lock and decoder object.
92  *
93  * Decoder uses two Viterbi decoder objects to ensure the lock is acquired when
94  * the input symbol phase is not known.
95  */
96 typedef struct
97 {
98  cnav_v27_part_t part1; /**< Decoder for odd symbol pairs */
99  cnav_v27_part_t part2; /**< Decoder for even symbol pairs */
101 
102 const v27_poly_t *cnav_msg_decoder_get_poly(void);
103 void cnav_msg_decoder_init(cnav_msg_decoder_t *dec);
104 bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec,
105  unsigned char symbol,
106  cnav_msg_t *msg,
107  uint32_t *delay);
108 
109 /** \} */
110 /** \} */
111 
112 #endif /* GNSS_SDR_CNAV_MSG_H_ */
uint8_t prn
Definition: cnav_msg.h:55
cnav_v27_part_t part1
Definition: cnav_msg.h:98
size_t n_decoded
Definition: cnav_msg.h:78
#define GPS_L2C_V27_DELAY_BITS
Definition: cnav_msg.h:47
bool alert
Definition: cnav_msg.h:58
size_t n_symbols
Definition: cnav_msg.h:75
bool preamble_seen
Definition: cnav_msg.h:79
bool message_lock
Definition: cnav_msg.h:82
Definition: fec.h:47
uint8_t msg_id
Definition: cnav_msg.h:56
#define GPS_L2C_V27_DECODE_BITS
Definition: cnav_msg.h:45
#define GPS_L2C_V27_INIT_BITS
Definition: cnav_msg.h:43
Utilities for the convolutional encoder of the libswiftnav library.
size_t n_crc_fail
Definition: cnav_msg.h:85
Definition: fec.h:34
cnav_v27_part_t part2
Definition: cnav_msg.h:99
Common definitions used throughout the libswiftnav library.
uint32_t tow
Definition: cnav_msg.h:57
#define GPS_L2_V27_HISTORY_LENGTH_BITS
Definition: cnav_msg.h:41