GNSS-SDR  0.0.19
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  * 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_BEIDOU_B3I_TELEMETRY_DECODER_GS_H
18 #define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_GS_H
19 
21 #include "gnss_block_interface.h"
22 #include "gnss_satellite.h"
23 #include "nav_message_packet.h"
24 #include "tlm_conf.h"
25 #include "tlm_crc_stats.h"
26 #include <boost/circular_buffer.hpp>
27 #include <gnuradio/block.h> // for block
28 #include <gnuradio/types.h> // for gr_vector_const_void_star
29 #include <array>
30 #include <cstdint>
31 #include <fstream>
32 #include <memory> // for std::unique_ptr
33 #include <string>
34 
35 
36 /** \addtogroup Telemetry_Decoder
37  * \{ */
38 /** \addtogroup Telemetry_Decoder_gnuradio_blocks
39  * \{ */
40 
41 
43 
44 using beidou_b3i_telemetry_decoder_gs_sptr =
45  gnss_shared_ptr<beidou_b3i_telemetry_decoder_gs>;
46 
47 beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
48  const Gnss_Satellite &satellite,
49  const Tlm_Conf &conf);
50 
51 /*!
52  * \brief This class implements a block that decodes the BeiDou DNAV data.
53  */
54 class beidou_b3i_telemetry_decoder_gs : public gr::block
55 {
56 public:
57  ~beidou_b3i_telemetry_decoder_gs() override; //!< 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,
67  gr_vector_void_star &output_items) override;
68 
69 private:
70  friend beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
71  const Gnss_Satellite &satellite,
72  const Tlm_Conf &conf);
73 
74  beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
75 
76  void decode_subframe(float *symbols, double cn0);
77  void decode_word(int32_t word_counter, const float *enc_word_symbols,
78  int32_t *dec_word_symbols);
79  void decode_bch15_11_01(const int32_t *bits, std::array<int32_t, 15> &decbits);
80 
81  // Preamble decoding
82  std::array<int32_t, BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
83  std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
84 
85  // Storage for incoming data
86  boost::circular_buffer<float> d_symbol_history;
87 
88  // Navigation Message variable
90  Gnss_Satellite d_satellite;
91 
92  Nav_Message_Packet d_nav_msg_packet;
93  std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
94 
95  std::string d_dump_filename;
96  std::ofstream d_dump_file;
97 
98  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
99  uint64_t d_preamble_index; // Index of sample number where preamble was found
100  uint32_t d_required_symbols;
101  uint32_t d_stat; // Status of decoder
102 
103  int32_t d_channel;
104  int32_t d_CRC_error_counter; // Number of failed CRC operations
105  int32_t d_symbols_per_preamble;
106  int32_t d_samples_per_preamble;
107  int32_t d_preamble_period_samples;
108 
109  // Values to populate gnss synchronization structure
110  uint64_t d_last_valid_preamble;
111  uint32_t d_symbol_duration_ms;
112  uint32_t d_TOW_at_Preamble_ms;
113  uint32_t d_TOW_at_current_symbol_ms;
114 
115  bool d_flag_SOW_set; // Indicates when time of week is set
116  bool d_flag_frame_sync; // Indicate when a frame sync is achieved
117  bool d_flag_preamble; // Flag indicating when preamble was found
118  bool d_flag_valid_word;
119  bool d_sent_tlm_failed_msg;
120  bool d_dump;
121  bool d_dump_mat;
122  bool d_remove_dat;
123  bool d_enable_navdata_monitor;
124  bool d_dump_crc_stats;
125 };
126 
127 
128 /** \} */
129 /** \} */
130 #endif // GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_GS_H
~beidou_b3i_telemetry_decoder_gs() override
Class destructor.
Interface of a BeiDou DNAV Data message decoder.
Class that contains all the configuration parameters for generic telemetry decoder block...
This class implements a block that decodes the BeiDou DNAV data.
Class that computes the telemetry CRC statistics.
This interface represents a GNSS block.
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.
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.