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