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