diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 9914c0f28..76cd1a7ce 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -186,6 +186,21 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, boost::bind(&rtklib_pvt_gs::msg_handler_telemetry, this, _1)); #endif #endif + + //Galileo E6 HAS messages + this->message_port_register_in(pmt::mp("E6_HAS_to_PVT")); + //TODO: bind the Galileo E6 HAS message input with the desired function + // this->set_msg_handler(pmt::mp("E6_HAS_to_PVT"), + //#if HAS_GENERIC_LAMBDA + // [this](auto&& PH1) { msg_handler_telemetry(PH1); }); + //#else + //#if USE_BOOST_BIND_PLACEHOLDERS + // boost::bind(&rtklib_pvt_gs::msg_handler_telemetry, this, boost::placeholders::_1)); + //#else + // boost::bind(&rtklib_pvt_gs::msg_handler_telemetry, this, _1)); + //#endif + //#endif + // initialize kml_printer const std::string kml_dump_filename = d_dump_filename; d_kml_output_enabled = conf_.kml_output_enabled; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index 5070a02b6..3a4c9f1e1 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -65,6 +65,9 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( this->message_port_register_out(pmt::mp("telemetry")); // Control messages to tracking block this->message_port_register_out(pmt::mp("telemetry_to_trk")); + //register Gal E6 messages HAS out + this->message_port_register_out(pmt::mp("E6_HAS_from_TLM")); + d_last_valid_preamble = 0; d_sent_tlm_failed_msg = false; d_band = '1'; @@ -537,9 +540,12 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(float *page_symbols, int32_t } else { + //TODO: do not send HAS data over telemetry msg port const std::shared_ptr tmp_obj = std::make_shared(d_cnav_nav.get_HAS_data()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); std::cout << TEXT_MAGENTA << "New Galileo E6 HAS message received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << '\n'; + //Send HAS data to HAS processing class + this->message_port_pub(pmt::mp("E6_HAS_from_TLM"), pmt::make_any(tmp_obj)); } } } diff --git a/src/core/libs/CMakeLists.txt b/src/core/libs/CMakeLists.txt index a525f87c4..ba6e96932 100644 --- a/src/core/libs/CMakeLists.txt +++ b/src/core/libs/CMakeLists.txt @@ -15,6 +15,7 @@ set(CORE_LIBS_SOURCES channel_status_msg_receiver.cc channel_event.cc command_event.cc + galileo_e6_has_msg_receiver.cc ) set(CORE_LIBS_HEADERS diff --git a/src/core/libs/galileo_e6_has_msg_receiver.cc b/src/core/libs/galileo_e6_has_msg_receiver.cc new file mode 100644 index 000000000..e3c03e5c2 --- /dev/null +++ b/src/core/libs/galileo_e6_has_msg_receiver.cc @@ -0,0 +1,96 @@ +/*! + * \file galileo_e6_has_msg_receiver.cc + * \brief GNU Radio block that receives asynchronous Galileo E6 HAS message sections from Galileo E6 telemetry blocks + * \author Javier Arribas, 2021. jarribas(at)cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + + +#include "galileo_e6_has_msg_receiver.h" +#include "galileo_has_data.h" // For Galileo HAS messages +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + + +galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make() +{ + return galileo_e6_has_msg_receiver_sptr(new galileo_e6_has_msg_receiver()); +} + + +galileo_e6_has_msg_receiver::galileo_e6_has_msg_receiver() : gr::block("galileo_e6_has_msg_receiver", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + //register Gal E6 HAS input message port + this->message_port_register_in(pmt::mp("E6_HAS_from_TLM")); + this->set_msg_handler(pmt::mp("E6_HAS_from_TLM"), +#if HAS_GENERIC_LAMBDA + [this](auto&& PH1) { msg_handler_galileo_e6_has(PH1); }); +#else +#if USE_BOOST_BIND_PLACEHOLDERS + boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, boost::placeholders::_1)); +#else + boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, _1)); +#endif +#endif + + //register Gal E6 processed HAS out + this->message_port_register_out(pmt::mp("E6_HAS_to_PVT")); +} + + +void galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has(const pmt::pmt_t& msg) +{ + gr::thread::scoped_lock lock(d_setlock); // require mutex with msg_handler_galileo_e6_has function called by the scheduler + //1. receive the PMT message and reconstruct the object... + try + { + const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code(); + + //TODO: change example + // ****************** Gnss_Synchro received ************************ + if (msg_type_hash_code == typeid(std::shared_ptr).hash_code()) + { + const auto HAS_data_obj_obj = boost::any_cast>(pmt::any_ref(msg)); + + // store/ do things with the data + } + else + { + LOG(WARNING) << "channel_status_msg_receiver unknown object type!"; + } + } + catch (const boost::bad_any_cast& e) + { + LOG(WARNING) << "channel_status_msg_receiver Bad any_cast: " << e.what(); + } + + //2. Trigger the HAS processing function if required + //TODO + + //3. Send the resulting decoded HAS data (if available) to PVT + + //TODO: change example + Gnss_Synchro dummy; + this->message_port_pub(pmt::mp("E6_HAS_to_PVT"), pmt::make_any(dummy)); + //TODO +} diff --git a/src/core/libs/galileo_e6_has_msg_receiver.h b/src/core/libs/galileo_e6_has_msg_receiver.h new file mode 100644 index 000000000..317e94ce6 --- /dev/null +++ b/src/core/libs/galileo_e6_has_msg_receiver.h @@ -0,0 +1,57 @@ +/*! + * \file GALILEO_E6_HAS_msg_receiver.h + * \brief GNU Radio block that receives asynchronous Galileo E6 HAS message sections from Galileo E6 telemetry blocks + * \author Javier Arribas, 2021. jarribas(at)cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_CC_H +#define GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_CC_H + +#include "gnss_block_interface.h" +#include "gnss_synchro.h" +#include "monitor_pvt.h" +#include +#include +#include +#include + +/** \addtogroup Core + * \{ */ +/** \addtogroup Core_Receiver_Library + * \{ */ + + +class galileo_e6_has_msg_receiver; + +using galileo_e6_has_msg_receiver_sptr = gnss_shared_ptr; + +galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make(); + +/*! + * \brief GNU Radio block that receives asynchronous galileo e6 has messages from tlm blocks + */ +class galileo_e6_has_msg_receiver : public gr::block +{ +public: + ~galileo_e6_has_msg_receiver() = default; //!< Default destructor + +private: + friend galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make(); + galileo_e6_has_msg_receiver(); + void msg_handler_galileo_e6_has(const pmt::pmt_t& msg); +}; + + +/** \} */ +/** \} */ +#endif // GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_CC_H diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index fdb2d43a1..c6c09013e 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -99,6 +99,8 @@ void GNSSFlowgraph::init() channels_status_ = channel_status_msg_receiver_make(); + gal_e6_has_rx_ = galileo_e6_has_msg_receiver_make(); + // 1. read the number of RF front-ends available (one file_source per RF front-end) int sources_count_deprecated = configuration_->property("Receiver.sources_count", 1); sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated); @@ -443,6 +445,11 @@ int GNSSFlowgraph::connect_desktop_flowgraph() return 1; } + if (connect_gal_e6_has() != 0) + { + return 1; + } + // Activate acquisition in enabled channels for (int i = 0; i < channels_count_; i++) { @@ -1529,6 +1536,42 @@ int GNSSFlowgraph::connect_monitors() return 0; } +int GNSSFlowgraph::connect_gal_e6_has() +{ + try + { + bool gal_e6_channels = false; + for (int i = 0; i < channels_count_; i++) + { + const std::string gnss_signal = channels_.at(i)->get_signal().get_signal_str(); + std::string gnss_system; + Gnss_Signal signal_value; + switch (mapStringValues_[gnss_signal]) + { + case evGAL_E6: + top_block_->msg_connect(channels_.at(i)->get_right_block(), pmt::mp("E6_HAS_from_TLM"), gal_e6_has_rx_, pmt::mp("E6_HAS_from_TLM")); + gal_e6_channels = true; + break; + + default: + break; + } + } + + if (gal_e6_channels == true) + { + top_block_->msg_connect(gal_e6_has_rx_, pmt::mp("E6_HAS_to_PVT"), pvt_->get_left_block(), pmt::mp("E6_HAS_to_PVT")); + } + } + catch (const std::exception& e) + { + LOG(ERROR) << "Can't connect Galileo E6 HAS msg ports: " << e.what(); + top_block_->disconnect_all(); + return 1; + } + DLOG(INFO) << "Galileo E6 HAS message ports connected"; + return 0; +} int GNSSFlowgraph::disconnect_monitors() { diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index aea6c94e0..457bb5722 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -26,6 +26,7 @@ #include "channel_status_msg_receiver.h" #include "concurrent_queue.h" +#include "galileo_e6_has_msg_receiver.h" #include "gnss_sdr_sample_counter.h" #include "gnss_signal.h" #include "pvt_interface.h" @@ -176,6 +177,7 @@ private: int connect_channels_to_observables(); int connect_observables_to_pvt(); int connect_monitors(); + int connect_gal_e6_has(); int connect_gnss_synchro_monitor(); int connect_acquisition_monitor(); int connect_tracking_monitor(); @@ -244,6 +246,8 @@ private: gr::basic_block_sptr GnssSynchroAcquisitionMonitor_; gr::basic_block_sptr GnssSynchroTrackingMonitor_; channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels + galileo_e6_has_msg_receiver_sptr gal_e6_has_rx_; + gnss_sdr_sample_counter_sptr ch_out_sample_counter_; #if ENABLE_FPGA gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter_;