GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
glonass_l1_ca_telemetry_decoder_gs.h
Go to the documentation of this file.
1 /*!
2  * \file glonass_l1_ca_telemetry_decoder_gs.h
3  * \brief Implementation of a GLONASS L1 C/A NAV data decoder block
4  * \note Code added as part of GSoC 2017 program
5  * \author Damian Miralles, 2017. dmiralles2009(at)gmail.comK
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 #ifndef GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
19 #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
20 
21 
22 #include "GLONASS_L1_L2_CA.h"
24 #include "gnss_block_interface.h"
25 #include "gnss_satellite.h"
26 #include "gnss_synchro.h"
27 #include "nav_message_packet.h"
28 #include "tlm_conf.h"
29 #include "tlm_crc_stats.h"
30 #include <boost/circular_buffer.hpp>
31 #include <gnuradio/block.h> // for block
32 #include <gnuradio/types.h> // for gr_vector_const_void_star
33 #include <array>
34 #include <cstdint>
35 #include <fstream> // for ofstream
36 #include <memory> // for std::unique_ptr
37 #include <string>
38 
39 /** \addtogroup Telemetry_Decoder
40  * \{ */
41 /** \addtogroup Telemetry_Decoder_gnuradio_blocks
42  * \{ */
43 
44 
46 
47 using glonass_l1_ca_telemetry_decoder_gs_sptr = gnss_shared_ptr<glonass_l1_ca_telemetry_decoder_gs>;
48 
49 glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
50  const Gnss_Satellite &satellite,
51  const Tlm_Conf &conf);
52 
53 /*!
54  * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1
55  * \note Code added as part of GSoC 2017 program
56  * \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
57  *
58  */
59 class glonass_l1_ca_telemetry_decoder_gs : public gr::block
60 {
61 public:
62  ~glonass_l1_ca_telemetry_decoder_gs() override; //!< Class destructor
63  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
64  void set_channel(int32_t channel); //!< Set receiver's channel
65  inline 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) override;
72 
73 private:
74  friend glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
75  const Gnss_Satellite &satellite,
76  const Tlm_Conf &conf);
77 
78  glonass_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
79 
80  const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
81 
82  const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
83 
84  void decode_string(const double *symbols, int32_t frame_length, double cn0);
85 
86  // Help with coherent tracking
87 
88  // Preamble decoding
89  std::array<int32_t, GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS> d_preambles_symbols{};
90 
91  // Storage for incoming data
92  boost::circular_buffer<Gnss_Synchro> d_symbol_history;
93 
94  // Navigation Message variable
96 
97  Gnss_Satellite d_satellite;
98 
99  Nav_Message_Packet d_nav_msg_packet;
100  std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
101 
102  std::string d_dump_filename;
103  std::ofstream d_dump_file;
104 
105  double d_preamble_time_samples;
106  double d_TOW_at_current_symbol;
107 
108  // Variables for internal functionality
109  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
110  uint64_t d_preamble_index; // Index of sample number where preamble was found
111 
112  uint32_t d_stat; // Status of decoder
113  int32_t d_CRC_error_counter; // Number of failed CRC operations
114  int32_t d_channel;
115 
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_dump;
119  bool d_dump_mat;
120  bool d_remove_dat;
121  bool d_enable_navdata_monitor;
122  bool d_dump_crc_stats;
123 };
124 
125 
126 /** \} */
127 /** \} */
128 #endif // GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
Defines system parameters for GLONASS L1 C/A signal and NAV data.
Class that contains all the configuration parameters for generic telemetry decoder block...
Class that computes the telemetry CRC statistics.
void set_channel(int32_t channel)
Set receiver&#39;s channel.
This interface represents a GNSS block.
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.
Interface of the Gnss_Satellite class.
This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1.
This class represents a GNSS satellite.
Interface of a GLONASS GNAV Data message decoder as described in GLONASS ICD (Edition 5...
void set_satellite(const Gnss_Satellite &satellite)
Set satellite PRN.
~glonass_l1_ca_telemetry_decoder_gs() override
Class destructor.
This class decodes a GLONASS GNAV Data message as described in GLONASS ICD (Edition 5...
Interface of the Gnss_Synchro class.