GNSS-SDR  0.0.14
An Open Source GNSS Software Defined Receiver
beidou_b1i_telemetry_decoder_gs.h
Go to the documentation of this file.
1 /*!
2  * \file beidou_b1i_telemetry_decoder_gs.h
3  * \brief Implementation of a BEIDOU BI1 DNAV data decoder block
4  * \details Code added as part of GSoC 2018 program.
5  * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com
6  * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.es
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
14  * SPDX-License-Identifier: GPL-3.0-or-later
15  *
16  * -----------------------------------------------------------------------------
17  */
18 
19 #ifndef GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_GS_H
20 #define GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_GS_H
21 
22 
24 #include "gnss_block_interface.h"
25 #include "gnss_satellite.h"
26 #include "tlm_conf.h"
27 #include <boost/circular_buffer.hpp>
28 #include <gnuradio/block.h> // for block
29 #include <gnuradio/types.h> // for gr_vector_const_void_star
30 #include <array>
31 #include <cstdint>
32 #include <fstream>
33 #include <string>
34 
35 /** \addtogroup Telemetry_Decoder
36  * \{ */
37 /** \addtogroup Telemetry_Decoder_gnuradio_blocks
38  * \{ */
39 
40 
42 
43 using beidou_b1i_telemetry_decoder_gs_sptr = gnss_shared_ptr<beidou_b1i_telemetry_decoder_gs>;
44 
45 beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
46  const Gnss_Satellite &satellite,
47  const Tlm_Conf &conf);
48 
49 
50 /*!
51  * \brief This class implements a block that decodes the BeiDou DNAV data.
52  * \note Code added as part of GSoC 2018 program
53  */
54 class beidou_b1i_telemetry_decoder_gs : public gr::block
55 {
56 public:
57  ~beidou_b1i_telemetry_decoder_gs(); //!< Class destructor
58  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
59  void set_channel(int channel); //!< Set receiver's channel
60  void reset();
61 
62  /*!
63  * \brief This is where all signal processing takes place
64  */
65  int general_work(int noutput_items, gr_vector_int &ninput_items,
66  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
67 
68 private:
69  friend beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
70  const Gnss_Satellite &satellite,
71  const Tlm_Conf &conf);
72 
73  beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
74 
75  void decode_subframe(float *symbols);
76  void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols);
77  void decode_bch15_11_01(const int32_t *bits, std::array<int32_t, 15> &decbits);
78 
79  // Preamble decoding
80  std::array<int32_t, BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
81 
82  std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
83 
84  // Storage for incoming data
85  boost::circular_buffer<float> d_symbol_history;
86 
87  // Navigation Message variable
89 
90  // Satellite Information and logging capacity
91  Gnss_Satellite d_satellite;
92  std::string d_dump_filename;
93  std::ofstream d_dump_file;
94 
95  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
96  uint64_t d_preamble_index; // Index of sample number where preamble was found
97 
98  int32_t d_channel;
99  int32_t d_symbols_per_preamble;
100  int32_t d_samples_per_preamble;
101  int32_t d_preamble_period_samples;
102  int32_t d_CRC_error_counter; // Number of failed CRC operations
103  uint32_t d_required_symbols;
104  uint32_t d_stat; // Status of decoder
105 
106  // Values to populate gnss synchronization structure
107  uint64_t d_last_valid_preamble;
108  uint32_t d_symbol_duration_ms;
109  uint32_t d_TOW_at_Preamble_ms;
110  uint32_t d_TOW_at_current_symbol_ms;
111 
112  bool flag_SOW_set; // Indicates when time of week is set
113  bool d_flag_frame_sync; // Indicate when a frame sync is achieved
114  bool d_flag_preamble; // Flag indicating when preamble was found
115 
116  bool d_flag_valid_word;
117  bool d_sent_tlm_failed_msg;
118  bool Flag_valid_word;
119  bool d_dump;
120  bool d_dump_mat;
121  bool d_remove_dat;
122 };
123 
124 
125 /** \} */
126 /** \} */
127 #endif // GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_GS_H
void set_satellite(const Gnss_Satellite &satellite)
Set satellite PRN.
void set_channel(int channel)
Set receiver&#39;s channel.
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.
~beidou_b1i_telemetry_decoder_gs()
Class destructor.
Interface of a BeiDou DNAV Data message decoder.
Class that contains all the configuration parameters for generic telemetry decoder block...
This interface represents a GNSS block.
Interface of the Gnss_Satellite class.
This class represents a GNSS satellite.
This class decodes a BeiDou D1 NAV Data message.
This class implements a block that decodes the BeiDou DNAV data.