GNSS-SDR  0.0.19
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 "nav_message_packet.h"
27 #include "tlm_conf.h"
28 #include "tlm_crc_stats.h"
29 #include <boost/circular_buffer.hpp>
30 #include <gnuradio/block.h> // for block
31 #include <gnuradio/types.h> // for gr_vector_const_void_star
32 #include <array>
33 #include <cstdint>
34 #include <fstream>
35 #include <memory> // for std::unique_ptr
36 #include <string>
37 
38 /** \addtogroup Telemetry_Decoder
39  * \{ */
40 /** \addtogroup Telemetry_Decoder_gnuradio_blocks
41  * \{ */
42 
43 
45 
46 using beidou_b1i_telemetry_decoder_gs_sptr = gnss_shared_ptr<beidou_b1i_telemetry_decoder_gs>;
47 
48 beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
49  const Gnss_Satellite &satellite,
50  const Tlm_Conf &conf);
51 
52 
53 /*!
54  * \brief This class implements a block that decodes the BeiDou DNAV data.
55  * \note Code added as part of GSoC 2018 program
56  */
57 class beidou_b1i_telemetry_decoder_gs : public gr::block
58 {
59 public:
60  ~beidou_b1i_telemetry_decoder_gs() override; //!< Class destructor
61  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
62  void set_channel(int channel); //!< Set receiver's channel
63  void reset();
64 
65  /*!
66  * \brief This is where all signal processing takes place
67  */
68  int general_work(int noutput_items, gr_vector_int &ninput_items,
69  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override;
70 
71 private:
72  friend beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
73  const Gnss_Satellite &satellite,
74  const Tlm_Conf &conf);
75 
76  beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
77 
78  void decode_subframe(float *symbols, double cn0);
79  void decode_word(int32_t word_counter, const float *enc_word_symbols, 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 
85  std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
86 
87  // Storage for incoming data
88  boost::circular_buffer<float> d_symbol_history;
89 
90  // Navigation Message variable
92 
93  Nav_Message_Packet d_nav_msg_packet;
94  std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
95 
96  // Satellite Information and logging capacity
97  Gnss_Satellite d_satellite;
98  std::string d_dump_filename;
99  std::ofstream d_dump_file;
100 
101  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
102  uint64_t d_preamble_index; // Index of sample number where preamble was found
103 
104  int32_t d_channel;
105  int32_t d_symbols_per_preamble;
106  int32_t d_samples_per_preamble;
107  int32_t d_preamble_period_samples;
108  int32_t d_CRC_error_counter; // Number of failed CRC operations
109  uint32_t d_required_symbols;
110  uint32_t d_stat; // Status of decoder
111 
112  // Values to populate gnss synchronization structure
113  uint64_t d_last_valid_preamble;
114  uint32_t d_symbol_duration_ms;
115  uint32_t d_TOW_at_Preamble_ms;
116  uint32_t d_TOW_at_current_symbol_ms;
117 
118  bool d_flag_SOW_set; // Indicates when time of week is set
119  bool d_flag_frame_sync; // Indicate when a frame sync is achieved
120  bool d_flag_preamble; // Flag indicating when preamble was found
121 
122  bool d_flag_valid_word;
123  bool d_sent_tlm_failed_msg;
124  bool d_dump;
125  bool d_dump_mat;
126  bool d_remove_dat;
127  bool d_enable_navdata_monitor;
128  bool d_dump_crc_stats;
129 };
130 
131 
132 /** \} */
133 /** \} */
134 #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.
Interface of a BeiDou DNAV Data message decoder.
~beidou_b1i_telemetry_decoder_gs() override
Class destructor.
Class that contains all the configuration parameters for generic telemetry decoder block...
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.
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.
This class decodes a BeiDou D1 NAV Data message.
This class implements a block that decodes the BeiDou DNAV data.