GNSS-SDR  0.0.21
An Open Source GNSS Software Defined Receiver
galileo_e6_has_msg_receiver.h
Go to the documentation of this file.
1 /*!
2  * \file galileo_e6_has_msg_receiver.h
3  * \brief GNU Radio block that processes Galileo HAS message pages received from
4  * Galileo E6B telemetry blocks. After successful decoding, sends the content to
5  * the PVT block.
6  * \author Carles Fernandez-Prades, 2021. cfernandez(at)cttc.es
7  * \author Javier Arribas, 2021. jarribas(at)cttc.es
8  *
9  * -----------------------------------------------------------------------------
10  *
11  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
12  * This file is part of GNSS-SDR.
13  *
14  * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 #ifndef GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_H
21 #define GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_H
22 
23 #include "Galileo_CNAV.h" // for GALILEO_CNAV_* constants
24 #include "galileo_has_data.h" // for Galileo_HAS_data
25 #include "gnss_block_interface.h" // for gnss_shared_ptr
26 #include "nav_message_packet.h" // for Nav_Message_Packet
27 #include <gnuradio/block.h> // for gr::block
28 #include <pmt/pmt.h> // for pmt::pmt_t
29 #include <bitset>
30 #include <cstdint>
31 #include <map>
32 #include <memory> // for std::unique_ptr
33 #include <string>
34 #include <utility> // std::pair
35 #include <vector>
36 
37 /** \addtogroup Core
38  * \{ */
39 /** \addtogroup Core_Receiver_Library
40  * \{ */
41 
42 class Galileo_HAS_page;
43 class ReedSolomon;
45 
46 using galileo_e6_has_msg_receiver_sptr = gnss_shared_ptr<galileo_e6_has_msg_receiver>;
47 
48 galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make();
49 
50 /*!
51  * \brief GNU Radio block that receives asynchronous Galileo HAS message pages
52  * from the telemetry blocks, stores them in memory, and decodes HAS messages
53  * when enough data have been received.
54  * The decoded HAS message is sent to the PVT block.
55  */
56 class galileo_e6_has_msg_receiver : public gr::block
57 {
58 public:
59  ~galileo_e6_has_msg_receiver() = default; //!< Default destructor
60  void set_enable_navdata_monitor(bool enable);
61  std::shared_ptr<Galileo_HAS_data> process_test_page(const pmt::pmt_t& msg); //!< For testing purposes only
62 
63 private:
64  friend galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make();
66 
67  void msg_handler_galileo_e6_has(const pmt::pmt_t& msg);
68  void process_HAS_page(const Galileo_HAS_page& has_page);
69  void read_MT1_header(const std::string& message_header);
70  void read_MT1_body(const std::string& message_body);
71  void delete_outdated_data(const Galileo_HAS_page& has_page);
72 
73  int decode_message_type1(uint8_t message_id, uint8_t message_size);
74 
75  uint16_t read_has_message_header_parameter_uint16(const std::bitset<GALILEO_CNAV_MT1_HEADER_BITS>& bits, const std::pair<int32_t, int32_t>& parameter) const;
76  uint8_t read_has_message_header_parameter_uint8(const std::bitset<GALILEO_CNAV_MT1_HEADER_BITS>& bits, const std::pair<int32_t, int32_t>& parameter) const;
77  bool read_has_message_header_parameter_bool(const std::bitset<GALILEO_CNAV_MT1_HEADER_BITS>& bits, const std::pair<int32_t, int32_t>& parameter) const;
78 
79  uint64_t read_has_message_body_uint64(const std::string& bits) const;
80  uint16_t read_has_message_body_uint16(const std::string& bits) const;
81  int16_t read_has_message_body_int16(const std::string& bits) const;
82  uint8_t read_has_message_body_uint8(const std::string& bits) const;
83 
84  template <class T>
85  std::string debug_print_vector(const std::string& title, const std::vector<T>& vec) const; // only for debug purposes
86 
87  template <class T>
88  std::string debug_print_matrix(const std::string& title, const std::vector<std::vector<T>>& mat) const; // only for debug purposes
89 
90  std::unique_ptr<ReedSolomon> d_rs;
91  Galileo_HAS_data d_HAS_data{};
92  Nav_Message_Packet d_nav_msg_packet;
93 
94  // Store decoding matrices and received PIDs
95  std::vector<std::vector<uint64_t>> d_received_timestamps;
96  std::vector<std::vector<std::vector<uint8_t>>> d_C_matrix;
97  std::vector<std::vector<uint8_t>> d_M_matrix;
98  std::vector<std::vector<uint8_t>> d_received_pids;
99  std::vector<uint64_t> d_printed_timestamps;
100  std::vector<bool> d_printed_mids;
101 
102  // Store masks
103  std::vector<int> d_nsat_in_mask_id;
104  std::vector<std::vector<uint8_t>> d_gnss_id_in_mask;
105  std::vector<std::vector<uint64_t>> d_satellite_mask;
106  std::vector<std::vector<uint16_t>> d_signal_mask;
107  std::vector<std::vector<bool>> d_cell_mask_availability_flag;
108  std::vector<std::vector<std::vector<std::vector<bool>>>> d_cell_mask;
109  std::vector<uint8_t> d_nsys_in_mask;
110  std::vector<std::vector<uint8_t>> d_nav_message_mask;
111 
112  std::map<std::pair<uint8_t, uint8_t>, std::vector<uint16_t>> d_iod_ref_map;
113 
114  uint8_t d_current_has_status{};
115  uint8_t d_current_message_id{};
116  bool d_new_message{};
117  bool d_enable_navdata_monitor{};
118 };
119 
120 
121 /** \} */
122 /** \} */
123 #endif // GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_H
std::shared_ptr< Galileo_HAS_data > process_test_page(const pmt::pmt_t &msg)
For testing purposes only.
Class implementing a Reed-Solomon encoder and decoder RS(255,K,d) where k=255-nroots is the informati...
Definition: reed_solomon.h:40
This class is a storage for Galileo HAS message type 1, as defined in Galileo High Accuracy Service S...
This interface represents a GNSS block.
Galileo CNAV message constants. Data from: Galileo High Accuracy Service Signal-In-Space Interface Co...
GNU Radio block that receives asynchronous Galileo HAS message pages from the telemetry blocks...
This class is a storage for Galileo HAS message page, as defined in Galileo High Accuracy Service Sig...
Class for Galileo HAS message type 1 data storage.
~galileo_e6_has_msg_receiver()=default
Default destructor.