GNSS-SDR  0.0.13
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.com
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
10  *
11  * GNSS-SDR is a software defined Global Navigation
12  * Satellite Systems receiver
13  *
14  * This file is part of GNSS-SDR.
15  *
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 #ifndef GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
22 #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
23 
24 
25 #include "GLONASS_L1_L2_CA.h"
27 #include "gnss_satellite.h"
28 #include "gnss_synchro.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> // for ofstream
35 #include <string>
36 #if GNURADIO_USES_STD_POINTERS
37 #include <memory> // for std::shared_ptr
38 #else
39 #include <boost/shared_ptr.hpp>
40 #endif
41 
42 
44 
45 #if GNURADIO_USES_STD_POINTERS
46 using glonass_l1_ca_telemetry_decoder_gs_sptr = std::shared_ptr<glonass_l1_ca_telemetry_decoder_gs>;
47 #else
48 using glonass_l1_ca_telemetry_decoder_gs_sptr = boost::shared_ptr<glonass_l1_ca_telemetry_decoder_gs>;
49 #endif
50 
51 glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
52  const Gnss_Satellite &satellite,
53  bool dump);
54 
55 /*!
56  * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1
57  * \note Code added as part of GSoC 2017 program
58  * \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
59  *
60  */
61 class glonass_l1_ca_telemetry_decoder_gs : public gr::block
62 {
63 public:
64  ~glonass_l1_ca_telemetry_decoder_gs(); //!< Class destructor
65  void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
66  void set_channel(int32_t channel); //!< Set receiver's channel
67  inline void reset()
68  {
69  return;
70  }
71  /*!
72  * \brief This is where all signal processing takes place
73  */
74  int general_work(int noutput_items, gr_vector_int &ninput_items,
75  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
76 
77 private:
78  friend glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
79  const Gnss_Satellite &satellite,
80  bool dump);
81 
82  glonass_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
83 
84  const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
85 
86  const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
87 
88  void decode_string(const double *symbols, int32_t frame_length);
89 
90  // Help with coherent tracking
91 
92  // Preamble decoding
93  std::array<int32_t, GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS> d_preambles_symbols{};
94 
95  // Storage for incoming data
96  boost::circular_buffer<Gnss_Synchro> d_symbol_history;
97 
98  // Navigation Message variable
100 
101  Gnss_Satellite d_satellite;
102 
103  std::string d_dump_filename;
104  std::ofstream d_dump_file;
105 
106  double d_preamble_time_samples;
107  double d_TOW_at_current_symbol;
108  double delta_t; // GPS-GLONASS time offset
109 
110  // Variables for internal functionality
111  uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
112  uint64_t d_preamble_index; // Index of sample number where preamble was found
113 
114  uint32_t d_stat; // Status of decoder
115  int32_t d_CRC_error_counter; // Number of failed CRC operations
116  int32_t d_channel;
117 
118  bool d_flag_frame_sync; // Indicate when a frame sync is achieved
119  bool d_flag_parity; // Flag indicating when parity check was achieved (crc check)
120  bool d_flag_preamble; // Flag indicating when preamble was found
121  bool flag_TOW_set; // Indicates when time of week is set
122  bool Flag_valid_word;
123  bool d_dump;
124 };
125 
126 #endif // GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_GS_H
Defines system parameters for GLONASS L1 C/A signal and NAV data.
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.
void set_channel(int32_t channel)
Set receiver&#39;s channel.
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.
~glonass_l1_ca_telemetry_decoder_gs()
Class destructor.
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.
This class decodes a GLONASS GNAV Data message as described in GLONASS ICD (Edition 5...
Interface of the Gnss_Synchro class.