GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
beidou_b3i_telemetry_decoder_gs.h
Go to the documentation of this file.
1 /*!
2  * \file beidou_b3i_telemetry_decoder_gs.h
3  * \brief Implementation of a BEIDOU B3I DNAV data decoder block
4  * \author Damian Miralles, 2019. dmiralles2009(at)gmail.com
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_BEIDOU_B3I_TELEMETRY_DECODER_GS_H
21 #define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_GS_H
22 
24 #include "gnss_satellite.h"
25 #include <boost/circular_buffer.hpp>
26 #include <gnuradio/block.h> // for block
27 #include <gnuradio/types.h> // for gr_vector_const_void_star
28 #include <array>
29 #include <cstdint>
30 #include <fstream>
31 #include <string>
32 #if GNURADIO_USES_STD_POINTERS
33 #include <memory>
34 #else
35 #include <boost/shared_ptr.hpp>
36 #endif
37 
39 
40 #if GNURADIO_USES_STD_POINTERS
41 using beidou_b3i_telemetry_decoder_gs_sptr =
42  std::shared_ptr<beidou_b3i_telemetry_decoder_gs>;
43 #else
44 using beidou_b3i_telemetry_decoder_gs_sptr =
45  boost::shared_ptr<beidou_b3i_telemetry_decoder_gs>;
46 #endif
47 
48 beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
49  const Gnss_Satellite &satellite,
50  bool dump);
51 
52 /*!
53  * \brief This class implements a block that decodes the BeiDou DNAV data.
54  */
55 class beidou_b3i_telemetry_decoder_gs : public gr::block
56 {
57 public:
58  ~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor
59  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
60  void set_channel(int channel); //!< Set receiver's channel
61  void reset();
62 
63  /*!
64  * \brief This is where all signal processing takes place
65  */
66  int general_work(int noutput_items, gr_vector_int &ninput_items,
67  gr_vector_const_void_star &input_items,
68  gr_vector_void_star &output_items);
69 
70 private:
71  friend beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
72  const Gnss_Satellite &satellite,
73  bool dump);
74 
75  beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
76 
77  void decode_subframe(float *symbols);
78  void decode_word(int32_t word_counter, const float *enc_word_symbols,
79  int32_t *dec_word_symbols);
80  void decode_bch15_11_01(const int32_t *bits, std::array<int32_t, 15> &decbits);
81 
82  // Preamble decoding
83  std::array<int32_t, BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
84  std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
85 
86  // Storage for incoming data
87  boost::circular_buffer<float> d_symbol_history;
88 
89  // Navigation Message variable
91 
92  Gnss_Satellite d_satellite;
93 
94  std::string d_dump_filename;
95  std::ofstream d_dump_file;
96 
97  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
98  uint64_t d_preamble_index; // Index of sample number where preamble was found
99  uint32_t d_required_symbols;
100  uint32_t d_stat; // Status of decoder
101 
102  int32_t d_channel;
103  int32_t d_CRC_error_counter; // Number of failed CRC operations
104  int32_t d_symbols_per_preamble;
105  int32_t d_samples_per_preamble;
106  int32_t d_preamble_period_samples;
107 
108  // Values to populate gnss synchronization structure
109  uint64_t d_last_valid_preamble;
110  uint32_t d_symbol_duration_ms;
111  uint32_t d_TOW_at_Preamble_ms;
112  uint32_t d_TOW_at_current_symbol_ms;
113 
114  bool flag_SOW_set; // Indicates when time of week is set
115  bool d_flag_frame_sync; // Indicate when a frame sync is achieved
116  bool d_flag_preamble; // Flag indicating when preamble was found
117  bool d_flag_valid_word;
118  bool d_sent_tlm_failed_msg;
119  bool Flag_valid_word;
120  bool d_dump;
121 };
122 
123 #endif // GNSS_SDR_BEIDOU_B3I_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.
Interface of a BeiDou DNAV Data message decoder.
This class implements a block that decodes the BeiDou DNAV data.
Interface of the Gnss_Satellite class.
This class represents a GNSS satellite.
void set_channel(int channel)
Set receiver&#39;s channel.
void set_satellite(const Gnss_Satellite &satellite)
Set satellite PRN.
This class decodes a BeiDou D1 NAV Data message.
~beidou_b3i_telemetry_decoder_gs()
Class destructor.