From 3098ca1a48bd879866ae079f25a84b61337d22c9 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 27 Mar 2019 16:59:04 +0100 Subject: [PATCH] added the reception of messages from the telemetry module to the FPGA tracking modules. --- .../dll_pll_veml_tracking_fpga.cc | 47 +++++++++++++++---- .../dll_pll_veml_tracking_fpga.h | 4 +- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 4af42d09f..a7b68aeb4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -80,7 +80,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & this->message_port_register_in(pmt::mp("preamble_samplestamp")); // Telemetry message port input this->message_port_register_in(pmt::mp("telemetry_to_trk")); - //todo: Implement the telemetry_to_trk handler in the same way the software version of tracking + this->set_msg_handler(pmt::mp("telemetry_to_trk"), boost::bind(&dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk, this, _1)); // initialize internal vars d_veml = false; @@ -88,7 +88,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = 0.0; d_secondary_code_length = 0U; d_secondary_code_string = nullptr; - d_gps_l1ca_preambles_symbols = nullptr; + d_preambles_symbols = nullptr; signal_type = std::string(trk_parameters.signal); std::map map_signal_pretty_name; @@ -124,7 +124,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; // preamble bits to sampled symbols - d_gps_l1ca_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); int32_t n = 0; for (uint16_t preambles_bit : preambles_bits) { @@ -132,11 +132,11 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & { if (preambles_bit == 1) { - d_gps_l1ca_preambles_symbols[n] = 1; + d_preambles_symbols[n] = 1; } else { - d_gps_l1ca_preambles_symbols[n] = -1; + d_preambles_symbols[n] = -1; } n++; } @@ -426,6 +426,37 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_sample_counter_next = 0ULL; } +void dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) +{ + try + { + if (pmt::any_ref(msg).type() == typeid(int)) + { + int tlm_event; + tlm_event = boost::any_cast(pmt::any_ref(msg)); + + switch (tlm_event) + { + case 1: //tlm fault in current channel + { + DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel; + gr::thread::scoped_lock lock(d_setlock); + d_carrier_lock_fail_counter = 10000; //force loss-of-lock condition + break; + } + default: + { + break; + } + } + } + } + catch (boost::bad_any_cast &e) + { + LOG(WARNING) << "msg_handler_telemetry_to_trk Bad any cast!"; + } +} + void dll_pll_veml_tracking_fpga::start_tracking() { @@ -512,7 +543,7 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { if (signal_type == "1C") { - volk_gnsssdr_free(d_gps_l1ca_preambles_symbols); + volk_gnsssdr_free(d_preambles_symbols); } if (d_dump_file.is_open()) @@ -1617,11 +1648,11 @@ void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) { if (d_symbol_history.at(i) < 0) // symbols clipping { - corr_value -= d_gps_l1ca_preambles_symbols[i]; + corr_value -= d_preambles_symbols[i]; } else { - corr_value += d_gps_l1ca_preambles_symbols[i]; + corr_value += d_preambles_symbols[i]; } } } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 681573639..4d619f50e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -77,7 +77,7 @@ public: private: friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); - + void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg); dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); void msg_handler_preamble_index(pmt::pmt_t msg); @@ -115,7 +115,7 @@ private: std::string *d_secondary_code_string; std::string signal_pretty_name; - int32_t *d_gps_l1ca_preambles_symbols; + int32_t *d_preambles_symbols; boost::circular_buffer d_symbol_history; //tracking state machine