GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
sbas_l1_telemetry_decoder_gs.h
Go to the documentation of this file.
1 /*!
2  * \file sbas_l1_telemetry_decoder_gs.h
3  * \brief Interface of a SBAS telemetry data decoder block
4  * \author Daniel Fehr 2013. daniel.co(at)bluewin.ch
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
9  *
10  * GNSS-SDR is a software defined Global Navigation
11  * Satellite Systems receiver
12  *
13  * This file is part of GNSS-SDR.
14  *
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 #ifndef GNSS_SDR_SBAS_L1_TELEMETRY_DECODER_GS_H
21 #define GNSS_SDR_SBAS_L1_TELEMETRY_DECODER_GS_H
22 
23 #include "gnss_satellite.h"
24 #include <boost/crc.hpp> // for crc_optimal
25 #include <gnuradio/block.h>
26 #include <gnuradio/types.h> // for gr_vector_const_void_star
27 #include <cstddef> // for size_t
28 #include <cstdint>
29 #include <deque>
30 #include <fstream>
31 #include <memory> // for std::shared_ptr
32 #include <string>
33 #include <utility> // for pair
34 #include <vector>
35 #if GNURADIO_USES_STD_POINTERS
36 #include <memory> // for std::shared_ptr
37 #else
38 #include <boost/shared_ptr.hpp>
39 #endif
40 
41 class Viterbi_Decoder;
42 
44 
45 #if GNURADIO_USES_STD_POINTERS
46 using sbas_l1_telemetry_decoder_gs_sptr = std::shared_ptr<sbas_l1_telemetry_decoder_gs>;
47 #else
48 using sbas_l1_telemetry_decoder_gs_sptr = boost::shared_ptr<sbas_l1_telemetry_decoder_gs>;
49 #endif
50 
51 sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs(
52  const Gnss_Satellite &satellite,
53  bool dump);
54 
55 /*!
56  * \brief This class implements a block that decodes the SBAS integrity and
57  * corrections data defined in RTCA MOPS DO-229
58  */
59 class sbas_l1_telemetry_decoder_gs : public gr::block
60 {
61 public:
63  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
64  void set_channel(int32_t channel); //!< Set receiver's channel
65  inline void reset()
66  {
67  return;
68  }
69 
70  /*!
71  * \brief This is where all signal processing takes place
72  */
73  int general_work(int noutput_items, gr_vector_int &ninput_items,
74  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
75 
76 private:
77  friend sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs(
78  const Gnss_Satellite &satellite,
79  bool dump);
80 
81  sbas_l1_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
82 
83  void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
84  void align_samples();
85 
86  static const int32_t D_SAMPLES_PER_SYMBOL = 2;
87  static const int32_t D_SYMBOLS_PER_BIT = 2;
88  static const int32_t D_BLOCK_SIZE_IN_BITS = 30;
89 
90  bool d_dump;
91  Gnss_Satellite d_satellite;
92  int32_t d_channel;
93 
94  std::string d_dump_filename;
95  std::ofstream d_dump_file;
96 
97  size_t d_block_size; //!< number of samples which are processed during one invocation of the algorithms
98  std::vector<double> d_sample_buf; //!< input buffer holding the samples to be processed in one block
99 
100  typedef std::pair<int32_t, std::vector<int32_t>> msg_candiate_int_t;
101  typedef std::pair<int32_t, std::vector<uint8_t>> msg_candiate_char_t;
102 
103  // helper class for sample alignment
104  class Sample_Aligner
105  {
106  public:
107  Sample_Aligner();
108  ~Sample_Aligner() = default;
109  void reset();
110  /*
111  * samples length must be a multiple of two
112  * for block operation
113  */
114  bool get_symbols(const std::vector<double> &samples, std::vector<double> &symbols);
115 
116  private:
117  int32_t d_n_smpls_in_history;
118  double d_iir_par;
119  double d_corr_paired{};
120  double d_corr_shifted{};
121  bool d_aligned{};
122  double d_past_sample{};
123  } d_sample_aligner;
124 
125  // helper class for symbol alignment and Viterbi decoding
126  class Symbol_Aligner_And_Decoder
127  {
128  public:
129  Symbol_Aligner_And_Decoder();
130  ~Symbol_Aligner_And_Decoder() = default;
131  void reset();
132  bool get_bits(const std::vector<double> &symbols, std::vector<int32_t> &bits);
133 
134  private:
135  int32_t d_KK;
136  std::shared_ptr<Viterbi_Decoder> d_vd1;
137  std::shared_ptr<Viterbi_Decoder> d_vd2;
138  double d_past_symbol;
139  } d_symbol_aligner_and_decoder;
140 
141 
142  // helper class for detecting the preamble and collect the corresponding message candidates
143  class Frame_Detector
144  {
145  public:
146  void reset();
147  void get_frame_candidates(const std::vector<int32_t> &bits, std::vector<std::pair<int32_t, std::vector<int32_t>>> &msg_candidates);
148 
149  private:
150  std::deque<int32_t> d_buffer;
151  } d_frame_detector;
152 
153 
154  // helper class for checking the CRC of the message candidates
155  class Crc_Verifier
156  {
157  public:
158  void reset();
159  void get_valid_frames(const std::vector<msg_candiate_int_t> &msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs);
160 
161  private:
162  typedef boost::crc_optimal<24, 0x1864CFBU, 0x0, 0x0, false, false> crc_24_q_type;
163  crc_24_q_type d_checksum_agent;
164  void zerropad_front_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes);
165  void zerropad_back_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes);
166  } d_crc_verifier;
167 };
168 
169 #endif // GNSS_SDR_SBAS_L1_TELEMETRY_DECODER_GS_H
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
This is where all signal processing takes place.
void set_satellite(const Gnss_Satellite &satellite)
Set satellite PRN.
Interface of the Gnss_Satellite class.
This class represents a GNSS satellite.
This class implements a block that decodes the SBAS integrity and corrections data defined in RTCA MO...
Class that implements a Viterbi decoder.
void set_channel(int32_t channel)
Set receiver&#39;s channel.