GNSS-SDR  0.0.21
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 
21 #include <boost/crc.hpp> // for crc_optimal
22 #include <gnuradio/types.h> // for gr_vector_const_void_star
23 #include <cstddef> // for size_t
24 #include <deque>
25 #include <vector>
26 
27 /** \addtogroup Telemetry_Decoder
28  * \{ */
29 /** \addtogroup Telemetry_Decoder_gnuradio_blocks
30  * \{ */
31 
32 
34 
36 
37 using sbas_l1_telemetry_decoder_gs_sptr = gnss_shared_ptr<sbas_l1_telemetry_decoder_gs>;
38 
39 sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs(
40  const Gnss_Satellite &satellite,
41  bool dump);
42 
43 /*!
44  * \brief This class implements a block that decodes the SBAS integrity and
45  * corrections data defined in RTCA MOPS DO-229
46  */
48 {
49 public:
50  ~sbas_l1_telemetry_decoder_gs() override;
51  void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN
52  void set_channel(int32_t channel) override; //!< Set receiver's channel
53  inline void reset() override {};
54 
55  /*!
56  * \brief This is where all signal processing takes place
57  */
58  int general_work(int noutput_items, gr_vector_int &ninput_items,
59  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override;
60 
61 private:
62  friend sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs(
63  const Gnss_Satellite &satellite,
64  bool dump);
65 
66  sbas_l1_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
67 
68  void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
69  void align_samples();
70 
71  static const int32_t D_SAMPLES_PER_SYMBOL = 2;
72  static const int32_t D_SYMBOLS_PER_BIT = 2;
73  static const int32_t D_BLOCK_SIZE_IN_BITS = 30;
74 
75  bool d_dump;
76  Gnss_Satellite d_satellite;
77  int32_t d_channel;
78 
79  std::string d_dump_filename;
80  std::ofstream d_dump_file;
81 
82  size_t d_block_size; //!< number of samples which are processed during one invocation of the algorithms
83  std::vector<double> d_sample_buf; //!< input buffer holding the samples to be processed in one block
84 
85  typedef std::pair<int32_t, std::vector<int32_t>> msg_candiate_int_t;
86  typedef std::pair<int32_t, std::vector<uint8_t>> msg_candiate_char_t;
87 
88  // helper class for sample alignment
89  class Sample_Aligner
90  {
91  public:
92  Sample_Aligner();
93  void reset();
94  /*
95  * samples length must be a multiple of two
96  * for block operation
97  */
98  bool get_symbols(const std::vector<double> &samples, std::vector<double> &symbols);
99 
100  private:
101  int32_t d_n_smpls_in_history{3};
102  double d_iir_par{0.05};
103  double d_corr_paired{};
104  double d_corr_shifted{};
105  bool d_aligned{};
106  double d_past_sample{};
107  } d_sample_aligner;
108 
109  // helper class for symbol alignment and Viterbi decoding
110  class Symbol_Aligner_And_Decoder
111  {
112  public:
113  Symbol_Aligner_And_Decoder();
114  void reset();
115  bool get_bits(const std::vector<double> &symbols, std::vector<int32_t> &bits);
116 
117  private:
118  int32_t d_KK{7};
119  std::shared_ptr<Viterbi_Decoder_Sbas> d_vd1;
120  std::shared_ptr<Viterbi_Decoder_Sbas> d_vd2;
121  double d_past_symbol{0};
122  } d_symbol_aligner_and_decoder;
123 
124 
125  // helper class for detecting the preamble and collect the corresponding message candidates
126  class Frame_Detector
127  {
128  public:
129  void reset();
130  void get_frame_candidates(const std::vector<int32_t> &bits, std::vector<std::pair<int32_t, std::vector<int32_t>>> &msg_candidates);
131 
132  private:
133  std::deque<int32_t> d_buffer;
134  } d_frame_detector;
135 
136 
137  // helper class for checking the CRC of the message candidates
138  class Crc_Verifier
139  {
140  public:
141  void reset();
142  void get_valid_frames(const std::vector<msg_candiate_int_t> &msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs);
143 
144  private:
145  typedef boost::crc_optimal<24, 0x1864CFBU, 0x0, 0x0, false, false> crc_24_q_type;
146  crc_24_q_type d_checksum_agent;
147  void zerropad_front_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes);
148  void zerropad_back_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes);
149  } d_crc_verifier;
150 };
151 
152 
153 /** \} */
154 /** \} */
155 #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) override
This is where all signal processing takes place.
Class that implements a Viterbi decoder.
void set_channel(int32_t channel) override
Set receiver&#39;s channel.
Common base class for telemetry decoder GNU Radio implementations.
This class represents a GNSS satellite.
Base class for telemetry decoder GNU Radio blocks.
This class implements a block that decodes the SBAS integrity and corrections data defined in RTCA MO...
void set_satellite(const Gnss_Satellite &satellite) override
Set satellite PRN.