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