From 795889e0c05909315b831388b1644a20fe102c90 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Jul 2023 13:51:25 +0200 Subject: [PATCH 001/142] Bump Benchmark to 1.8.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e562631..f2a91527b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,7 +344,7 @@ set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.0.0") -set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.8.1") +set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.8.2") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") # Downgrade versions if requirements are not met From 2568b8be8183d1e49780eb3628412ae63484b7cf Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 8 Jul 2023 19:18:08 +0200 Subject: [PATCH 002/142] Fix PVT Kalman filter for any PVT.output_rate_ms Remove averaging in Pvt_Solution, since it was broken, misleading, not used, and added unnecessary complexity in the interfaces. Uniformize names of public Pvt_Kf class memben functions --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 15 ++-- src/algorithms/PVT/libs/geojson_printer.cc | 21 +---- src/algorithms/PVT/libs/geojson_printer.h | 2 +- src/algorithms/PVT/libs/gpx_printer.cc | 21 +---- src/algorithms/PVT/libs/gpx_printer.h | 2 +- src/algorithms/PVT/libs/kml_printer.cc | 21 +---- src/algorithms/PVT/libs/kml_printer.h | 2 +- src/algorithms/PVT/libs/nmea_printer.cc | 5 +- src/algorithms/PVT/libs/nmea_printer.h | 4 +- src/algorithms/PVT/libs/pvt_kf.cc | 64 ++++++++++---- src/algorithms/PVT/libs/pvt_kf.h | 10 ++- src/algorithms/PVT/libs/pvt_solution.cc | 88 ------------------- src/algorithms/PVT/libs/pvt_solution.h | 47 +++------- src/algorithms/PVT/libs/rtklib_solver.cc | 16 ++-- src/algorithms/PVT/libs/rtklib_solver.h | 2 +- .../pvt/nmea_printer_test.cc | 4 +- 16 files changed, 98 insertions(+), 226 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index ab145aff4..83c6bb231 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -535,21 +535,18 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, // setup two PVT solvers: internal solver for rx clock and user solver // user PVT solver d_user_pvt_solver = std::make_shared(rtk, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat, conf_); - d_user_pvt_solver->set_averaging_depth(1); d_user_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); // internal PVT solver, mainly used to estimate the receiver clock rtk_t internal_rtk = rtk; internal_rtk.opt.mode = PMODE_SINGLE; // use single positioning mode in internal PVT solver d_internal_pvt_solver = std::make_shared(internal_rtk, dump_ls_pvt_filename, d_type_of_rx, false, false, conf_); - d_internal_pvt_solver->set_averaging_depth(1); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); } else { // only one solver, customized by the user options d_internal_pvt_solver = std::make_shared(rtk, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat, conf_); - d_internal_pvt_solver->set_averaging_depth(1); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); d_user_pvt_solver = d_internal_pvt_solver; } @@ -2109,7 +2106,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // old_time_debug = d_gnss_observables_map.cbegin()->second.RX_time * 1000.0; uint32_t current_RX_time_ms = 0; // #### solve PVT and store the corrected observable set - if (d_internal_pvt_solver->get_PVT(d_gnss_observables_map, false)) + if (d_internal_pvt_solver->get_PVT(d_gnss_observables_map, d_observable_interval_ms / 1000.0)) { d_pvt_errors_counter = 0; // Reset consecutive PVT error counter const double Rx_clock_offset_s = d_internal_pvt_solver->get_time_offset_s(); @@ -2223,7 +2220,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // compute on the fly PVT solution if (flag_compute_pvt_output == true) { - flag_pvt_valid = d_user_pvt_solver->get_PVT(d_gnss_observables_map, false); + flag_pvt_valid = d_user_pvt_solver->get_PVT(d_gnss_observables_map, d_output_rate_ms / 1000.0); } if (flag_pvt_valid == true) @@ -2335,28 +2332,28 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item { if (current_RX_time_ms % d_kml_rate_ms == 0) { - d_kml_dump->print_position(d_user_pvt_solver.get(), false); + d_kml_dump->print_position(d_user_pvt_solver.get()); } } if (d_gpx_output_enabled) { if (current_RX_time_ms % d_gpx_rate_ms == 0) { - d_gpx_dump->print_position(d_user_pvt_solver.get(), false); + d_gpx_dump->print_position(d_user_pvt_solver.get()); } } if (d_geojson_output_enabled) { if (current_RX_time_ms % d_geojson_rate_ms == 0) { - d_geojson_printer->print_position(d_user_pvt_solver.get(), false); + d_geojson_printer->print_position(d_user_pvt_solver.get()); } } if (d_nmea_output_file_enabled) { if (current_RX_time_ms % d_nmea_rate_ms == 0) { - d_nmea_printer->Print_Nmea_Line(d_user_pvt_solver.get(), false); + d_nmea_printer->Print_Nmea_Line(d_user_pvt_solver.get()); } } if (d_rinex_output_enabled) diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 85e9e62d7..f57e9d582 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -156,24 +156,11 @@ bool GeoJSON_Printer::set_headers(const std::string& filename, bool time_tag_nam } -bool GeoJSON_Printer::print_position(const Pvt_Solution* const position, bool print_average_values) +bool GeoJSON_Printer::print_position(const Pvt_Solution* const position) { - double latitude; - double longitude; - double height; - - if (print_average_values == false) - { - latitude = position->get_latitude(); - longitude = position->get_longitude(); - height = position->get_height(); - } - else - { - latitude = position->get_avg_latitude(); - longitude = position->get_avg_longitude(); - height = position->get_avg_height(); - } + const double latitude = position->get_latitude(); + const double longitude = position->get_longitude(); + const double height = position->get_height(); if (geojson_file.is_open()) { diff --git a/src/algorithms/PVT/libs/geojson_printer.h b/src/algorithms/PVT/libs/geojson_printer.h index 98651df22..cb7c00cdb 100644 --- a/src/algorithms/PVT/libs/geojson_printer.h +++ b/src/algorithms/PVT/libs/geojson_printer.h @@ -42,7 +42,7 @@ public: explicit GeoJSON_Printer(const std::string& base_path = "."); ~GeoJSON_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); - bool print_position(const Pvt_Solution* const position, bool print_average_values); + bool print_position(const Pvt_Solution* const position); bool close_file(); private: diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index ea33cdb1c..699f92db5 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -140,12 +140,8 @@ bool Gpx_Printer::set_headers(const std::string& filename, bool time_tag_name) } -bool Gpx_Printer::print_position(const Pvt_Solution* const position, bool print_average_values) +bool Gpx_Printer::print_position(const Pvt_Solution* const position) { - double latitude; - double longitude; - double height; - positions_printed = true; const double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s @@ -162,18 +158,9 @@ bool Gpx_Printer::print_position(const Pvt_Solution* const position, bool print_ utc_time.resize(23, '0'); // time up to ms utc_time.append("Z"); // UTC time zone - if (print_average_values == false) - { - latitude = position->get_latitude(); - longitude = position->get_longitude(); - height = position->get_height(); - } - else - { - latitude = position->get_avg_latitude(); - longitude = position->get_avg_longitude(); - height = position->get_avg_height(); - } + const double latitude = position->get_latitude(); + const double longitude = position->get_longitude(); + const double height = position->get_height(); if (gpx_file.is_open()) { diff --git a/src/algorithms/PVT/libs/gpx_printer.h b/src/algorithms/PVT/libs/gpx_printer.h index 0013beeba..697ac6523 100644 --- a/src/algorithms/PVT/libs/gpx_printer.h +++ b/src/algorithms/PVT/libs/gpx_printer.h @@ -42,7 +42,7 @@ public: explicit Gpx_Printer(const std::string& base_path = "."); ~Gpx_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); - bool print_position(const Pvt_Solution* const position, bool print_average_values); + bool print_position(const Pvt_Solution* const position); bool close_file(); private: diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index ad7ccb0e3..72ea272d9 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -210,12 +210,8 @@ bool Kml_Printer::set_headers(const std::string& filename, bool time_tag_name) } -bool Kml_Printer::print_position(const Pvt_Solution* const position, bool print_average_values) +bool Kml_Printer::print_position(const Pvt_Solution* const position) { - double latitude; - double longitude; - double height; - positions_printed = true; const double speed_over_ground = position->get_speed_over_ground(); // expressed in m/s @@ -232,18 +228,9 @@ bool Kml_Printer::print_position(const Pvt_Solution* const position, bool print_ utc_time.resize(23, '0'); // time up to ms utc_time.append("Z"); // UTC time zone - if (print_average_values == false) - { - latitude = position->get_latitude(); - longitude = position->get_longitude(); - height = position->get_height(); - } - else - { - latitude = position->get_avg_latitude(); - longitude = position->get_avg_longitude(); - height = position->get_avg_height(); - } + const double latitude = position->get_latitude(); + const double longitude = position->get_longitude(); + const double height = position->get_height(); if (kml_file.is_open() && tmp_file.is_open()) { diff --git a/src/algorithms/PVT/libs/kml_printer.h b/src/algorithms/PVT/libs/kml_printer.h index 9813cca8b..af3c535ad 100644 --- a/src/algorithms/PVT/libs/kml_printer.h +++ b/src/algorithms/PVT/libs/kml_printer.h @@ -41,7 +41,7 @@ public: explicit Kml_Printer(const std::string& base_path = std::string(".")); ~Kml_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); - bool print_position(const Pvt_Solution* const position, bool print_average_values); + bool print_position(const Pvt_Solution* const position); bool close_file(); private: diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 1939313ee..20c876059 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -100,7 +100,7 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, { nmea_dev_descriptor = -1; } - print_avg_pos = false; + d_PVT_data = nullptr; } @@ -190,11 +190,10 @@ void Nmea_Printer::close_serial() const } -bool Nmea_Printer::Print_Nmea_Line(const Rtklib_Solver* const pvt_data, bool print_average_values) +bool Nmea_Printer::Print_Nmea_Line(const Rtklib_Solver* const pvt_data) { // set the new PVT data d_PVT_data = pvt_data; - print_avg_pos = print_average_values; // generate the NMEA sentences diff --git a/src/algorithms/PVT/libs/nmea_printer.h b/src/algorithms/PVT/libs/nmea_printer.h index 42ec117d3..58b5f0912 100644 --- a/src/algorithms/PVT/libs/nmea_printer.h +++ b/src/algorithms/PVT/libs/nmea_printer.h @@ -57,7 +57,7 @@ public: /*! * \brief Print NMEA PVT and satellite info to the initialized device */ - bool Print_Nmea_Line(const Rtklib_Solver* const pvt_data, bool print_average_values); + bool Print_Nmea_Line(const Rtklib_Solver* const pvt_data); private: int init_serial(const std::string& serial_device); // serial port control @@ -80,8 +80,6 @@ private: std::string nmea_devname; int nmea_dev_descriptor; // NMEA serial device descriptor (i.e. COM port) - - bool print_avg_pos; bool d_flag_nmea_output_file; }; diff --git a/src/algorithms/PVT/libs/pvt_kf.cc b/src/algorithms/PVT/libs/pvt_kf.cc index 10083b221..805a53a57 100644 --- a/src/algorithms/PVT/libs/pvt_kf.cc +++ b/src/algorithms/PVT/libs/pvt_kf.cc @@ -19,16 +19,16 @@ #include -void Pvt_Kf::init_kf(const arma::vec& p, +void Pvt_Kf::init_Kf(const arma::vec& p, const arma::vec& v, - double solver_interval_s, + double update_interval_s, double measures_ecef_pos_sd_m, double measures_ecef_vel_sd_ms, double system_ecef_pos_sd_m, double system_ecef_vel_sd_ms) { // Kalman Filter class variables - const double Ti = solver_interval_s; + const double Ti = update_interval_s; d_F = {{1.0, 0.0, 0.0, Ti, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0, Ti, 0.0}, @@ -68,7 +68,7 @@ void Pvt_Kf::init_kf(const arma::vec& p, d_x_old_old.subvec(0, 2) = p; d_x_old_old.subvec(3, 5) = v; - initialized = true; + d_initialized = true; DLOG(INFO) << "Ti: " << Ti; DLOG(INFO) << "F: " << d_F; @@ -80,28 +80,54 @@ void Pvt_Kf::init_kf(const arma::vec& p, } +bool Pvt_Kf::is_initialized() const +{ + return d_initialized; +} + + +void Pvt_Kf::reset_Kf() +{ + d_initialized = false; +} + + void Pvt_Kf::run_Kf(const arma::vec& p, const arma::vec& v) { - // Kalman loop - // Prediction - d_x_new_old = d_F * d_x_old_old; - d_P_new_old = d_F * d_P_old_old * d_F.t() + d_Q; + if (d_initialized) + { + // Kalman loop + // Prediction + d_x_new_old = d_F * d_x_old_old; + d_P_new_old = d_F * d_P_old_old * d_F.t() + d_Q; - // Measurement update - arma::vec z = arma::join_cols(p, v); - arma::mat K = d_P_new_old * d_H.t() * arma::inv(d_H * d_P_new_old * d_H.t() + d_R); // Kalman gain + // Measurement update + try + { + arma::vec z = arma::join_cols(p, v); + arma::mat K = d_P_new_old * d_H.t() * arma::inv(d_H * d_P_new_old * d_H.t() + d_R); // Kalman gain - d_x_new_new = d_x_new_old + K * (z - d_H * d_x_new_old); - d_P_new_new = (arma::eye(6, 6) - K * d_H) * d_P_new_old; + d_x_new_new = d_x_new_old + K * (z - d_H * d_x_new_old); + d_P_new_new = (arma::eye(6, 6) - K * d_H) * d_P_new_old; - // prepare data for next KF epoch - d_x_old_old = d_x_new_new; - d_P_old_old = d_P_new_new; + // prepare data for next KF epoch + d_x_old_old = d_x_new_new; + d_P_old_old = d_P_new_new; + } + catch (...) + { + d_x_new_new = d_x_new_old; + this->reset_Kf(); + } + } } -void Pvt_Kf::get_pvt(arma::vec& p, arma::vec& v) +void Pvt_Kf::get_pv_Kf(arma::vec& p, arma::vec& v) const { - p = d_x_new_new.subvec(0, 2); - v = d_x_new_new.subvec(3, 5); + if (d_initialized) + { + p = d_x_new_new.subvec(0, 2); + v = d_x_new_new.subvec(3, 5); + } } diff --git a/src/algorithms/PVT/libs/pvt_kf.h b/src/algorithms/PVT/libs/pvt_kf.h index 26dc25a43..204035f21 100644 --- a/src/algorithms/PVT/libs/pvt_kf.h +++ b/src/algorithms/PVT/libs/pvt_kf.h @@ -35,16 +35,17 @@ class Pvt_Kf public: Pvt_Kf() = default; virtual ~Pvt_Kf() = default; - void init_kf(const arma::vec& p, + void init_Kf(const arma::vec& p, const arma::vec& v, - double solver_interval_s, + double update_interval_s, double measures_ecef_pos_sd_m, double measures_ecef_vel_sd_ms, double system_ecef_pos_sd_m, double system_ecef_vel_sd_ms); + bool is_initialized() const; void run_Kf(const arma::vec& p, const arma::vec& v); - void get_pvt(arma::vec& p, arma::vec& v); - bool initialized{false}; + void get_pv_Kf(arma::vec& p, arma::vec& v) const; + void reset_Kf(); private: // Kalman Filter class variables @@ -58,6 +59,7 @@ private: arma::vec d_x_old_old; arma::vec d_x_new_old; arma::vec d_x_new_new; + bool d_initialized{false}; }; diff --git a/src/algorithms/PVT/libs/pvt_solution.cc b/src/algorithms/PVT/libs/pvt_solution.cc index 7ebeb0324..c97a12d70 100644 --- a/src/algorithms/PVT/libs/pvt_solution.cc +++ b/src/algorithms/PVT/libs/pvt_solution.cc @@ -69,70 +69,6 @@ int Pvt_Solution::cart2geo(double X, double Y, double Z, int elipsoid_selection) } -void Pvt_Solution::set_averaging_depth(int depth) -{ - d_averaging_depth = depth; -} - - -void Pvt_Solution::set_averaging_flag(bool flag) -{ - d_flag_averaging = flag; -} - - -void Pvt_Solution::perform_pos_averaging() -{ - // MOVING AVERAGE PVT - bool avg = d_flag_averaging; - if (avg == true) - { - if (d_hist_longitude_d.size() == static_cast(d_averaging_depth)) - { - // Pop oldest value - d_hist_longitude_d.pop_back(); - d_hist_latitude_d.pop_back(); - d_hist_height_m.pop_back(); - // Push new values - d_hist_longitude_d.push_front(d_longitude_d); - d_hist_latitude_d.push_front(d_latitude_d); - d_hist_height_m.push_front(d_height_m); - - d_avg_latitude_d = 0.0; - d_avg_longitude_d = 0.0; - d_avg_height_m = 0.0; - for (size_t i = 0; i < d_hist_longitude_d.size(); i++) - { - d_avg_latitude_d = d_avg_latitude_d + d_hist_latitude_d.at(i); - d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i); - d_avg_height_m = d_avg_height_m + d_hist_height_m.at(i); - } - d_avg_latitude_d = d_avg_latitude_d / static_cast(d_averaging_depth); - d_avg_longitude_d = d_avg_longitude_d / static_cast(d_averaging_depth); - d_avg_height_m = d_avg_height_m / static_cast(d_averaging_depth); - d_valid_position = true; - } - else - { - // int current_depth=d_hist_longitude_d.size(); - // Push new values - d_hist_longitude_d.push_front(d_longitude_d); - d_hist_latitude_d.push_front(d_latitude_d); - d_hist_height_m.push_front(d_height_m); - - d_avg_latitude_d = d_latitude_d; - d_avg_longitude_d = d_longitude_d; - d_avg_height_m = d_height_m; - d_valid_position = false; - } - } - else - { - d_valid_position = true; - } -} - - double Pvt_Solution::get_time_offset_s() const { return d_rx_dt_s; @@ -199,30 +135,6 @@ double Pvt_Solution::get_course_over_ground() const } -double Pvt_Solution::get_avg_latitude() const -{ - return d_avg_latitude_d; -} - - -double Pvt_Solution::get_avg_longitude() const -{ - return d_avg_longitude_d; -} - - -double Pvt_Solution::get_avg_height() const -{ - return d_avg_height_m; -} - - -bool Pvt_Solution::is_averaging() const -{ - return d_flag_averaging; -} - - bool Pvt_Solution::is_valid_position() const { return d_valid_position; diff --git a/src/algorithms/PVT/libs/pvt_solution.h b/src/algorithms/PVT/libs/pvt_solution.h index 3d9764537..bd00208bf 100644 --- a/src/algorithms/PVT/libs/pvt_solution.h +++ b/src/algorithms/PVT/libs/pvt_solution.h @@ -20,7 +20,6 @@ #include #include -#include /** \addtogroup PVT * \{ */ @@ -38,20 +37,10 @@ public: Pvt_Solution() = default; virtual ~Pvt_Solution() = default; - void set_rx_pos(const std::array &pos); //!< Set position: X, Y, Z in Cartesian ECEF coordinates [m] - void set_rx_vel(const std::array &vel); //!< Set velocity: East [m/s], North [m/s], Up [m/s] - void set_position_UTC_time(const boost::posix_time::ptime &pt); - void set_time_offset_s(double offset); //!< Set RX time offset [s] - void set_clock_drift_ppm(double clock_drift_ppm); //!< Set the Rx clock drift [ppm] - void set_speed_over_ground(double speed_m_s); //!< Set RX speed over ground [m/s] - void set_course_over_ground(double cog_deg); //!< Set RX course over ground [deg] - void set_valid_position(bool is_valid); - void set_num_valid_observations(int num); //!< Set the number of valid pseudorange observations (valid satellites) - void set_pre_2009_file(bool pre_2009_file); //!< Flag for the week rollover computation in post processing mode for signals older than 2009 - // averaging - void set_averaging_depth(int depth); //!< Set length of averaging window - void set_averaging_flag(bool flag); - void perform_pos_averaging(); + virtual double get_hdop() const = 0; + virtual double get_vdop() const = 0; + virtual double get_pdop() const = 0; + virtual double get_gdop() const = 0; std::array get_rx_pos() const; std::array get_rx_vel() const; @@ -63,18 +52,20 @@ public: double get_clock_drift_ppm() const; //!< Get the Rx clock drift [ppm] double get_speed_over_ground() const; //!< Get RX speed over ground [m/s] double get_course_over_ground() const; //!< Get RX course over ground [deg] - double get_avg_latitude() const; //!< Get RX position averaged Latitude WGS84 [deg] - double get_avg_longitude() const; //!< Get RX position averaged Longitude WGS84 [deg] - double get_avg_height() const; //!< Get RX position averaged height WGS84 [m] int get_num_valid_observations() const; //!< Get the number of valid pseudorange observations (valid satellites) bool is_pre_2009() const; bool is_valid_position() const; - bool is_averaging() const; - virtual double get_hdop() const = 0; - virtual double get_vdop() const = 0; - virtual double get_pdop() const = 0; - virtual double get_gdop() const = 0; + void set_rx_pos(const std::array &pos); //!< Set position: X, Y, Z in Cartesian ECEF coordinates [m] + void set_rx_vel(const std::array &vel); //!< Set velocity: East [m/s], North [m/s], Up [m/s] + void set_position_UTC_time(const boost::posix_time::ptime &pt); + void set_time_offset_s(double offset); //!< Set RX time offset [s] + void set_clock_drift_ppm(double clock_drift_ppm); //!< Set the Rx clock drift [ppm] + void set_speed_over_ground(double speed_m_s); //!< Set RX speed over ground [m/s] + void set_course_over_ground(double cog_deg); //!< Set RX course over ground [deg] + void set_valid_position(bool is_valid); + void set_num_valid_observations(int num); //!< Set the number of valid pseudorange observations (valid satellites) + void set_pre_2009_file(bool pre_2009_file); //!< Flag for the week rollover computation in post processing mode for signals older than 2009 private: /* @@ -98,10 +89,6 @@ private: std::array d_rx_vel{}; boost::posix_time::ptime d_position_UTC_time; - std::deque d_hist_latitude_d; - std::deque d_hist_longitude_d; - std::deque d_hist_height_m; - double d_latitude_d{0.0}; // RX position Latitude WGS84 [deg] double d_longitude_d{0.0}; // RX position Longitude WGS84 [deg] double d_height_m{0.0}; // RX position height WGS84 [m] @@ -110,16 +97,10 @@ private: double d_speed_over_ground_m_s{0.0}; // RX speed over ground [m/s] double d_course_over_ground_d{0.0}; // RX course over ground [deg] - double d_avg_latitude_d{0.0}; // Averaged latitude in degrees - double d_avg_longitude_d{0.0}; // Averaged longitude in degrees - double d_avg_height_m{0.0}; // Averaged height [m] - - int d_averaging_depth{0}; // Length of averaging window int d_valid_observations{0}; // Number of valid observations in this epoch bool d_pre_2009_file{false}; // Flag to correct week rollover in post processing mode for signals older than 2009 bool d_valid_position{false}; - bool d_flag_averaging{false}; }; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index e17edfa14..8b9d5b8ee 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -56,8 +56,6 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, d_flag_dump_enabled(flag_dump_to_file), d_flag_dump_mat_enabled(flag_dump_to_mat) { - this->set_averaging_flag(false); - // see freq index at src/algorithms/libs/rtklib/rtklib_rtkcmn.cc // function: satwavelen d_rtklib_freq_index[0] = 0; @@ -900,7 +898,7 @@ void Rtklib_Solver::get_current_has_obs_correction(const std::string &signal, ui } -bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_map, bool flag_averaging) +bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_map, double kf_update_interval_s) { std::map::const_iterator gnss_observables_iter; std::map::const_iterator galileo_ephemeris_iter; @@ -911,8 +909,6 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ const Glonass_Gnav_Utc_Model &gnav_utc = this->glonass_gnav_utc_model; - this->set_averaging_flag(flag_averaging); - // ******************************************************************************** // ****** PREPARE THE DATA (SV EPHEMERIS AND OBSERVATIONS) ************************ // ******************************************************************************** @@ -1509,7 +1505,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ this->set_num_valid_observations(0); if (d_conf.enable_pvt_kf == true) { - d_pvt_kf.initialized = false; + d_pvt_kf.reset_Kf(); } } else @@ -1548,14 +1544,14 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ if (d_conf.enable_pvt_kf == true) { - if (d_pvt_kf.initialized == false) + if (d_pvt_kf.is_initialized() == false) { arma::vec p = {pvt_sol.rr[0], pvt_sol.rr[1], pvt_sol.rr[2]}; arma::vec v = {pvt_sol.rr[3], pvt_sol.rr[4], pvt_sol.rr[5]}; - d_pvt_kf.init_kf(p, + d_pvt_kf.init_Kf(p, v, - d_conf.observable_interval_ms / 1000.0, + kf_update_interval_s, d_conf.measures_ecef_pos_sd_m, d_conf.measures_ecef_vel_sd_ms, d_conf.system_ecef_pos_sd_m, @@ -1566,7 +1562,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ arma::vec p = {pvt_sol.rr[0], pvt_sol.rr[1], pvt_sol.rr[2]}; arma::vec v = {pvt_sol.rr[3], pvt_sol.rr[4], pvt_sol.rr[5]}; d_pvt_kf.run_Kf(p, v); - d_pvt_kf.get_pvt(p, v); + d_pvt_kf.get_pv_Kf(p, v); pvt_sol.rr[0] = p[0]; // [m] pvt_sol.rr[1] = p[1]; // [m] pvt_sol.rr[2] = p[2]; // [m] diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index 7bffa042d..f24a37b2a 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -89,7 +89,7 @@ public: Pvt_Conf conf); ~Rtklib_Solver(); - bool get_PVT(const std::map& gnss_observables_map, bool flag_averaging); + bool get_PVT(const std::map& gnss_observables_map, double kf_update_interval_s); double get_hdop() const override; double get_vdop() const override; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index fcc0920be..9032f878a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -15,8 +15,8 @@ */ -#include "gnss_sdr_filesystem.h" #include "nmea_printer.h" +#include "gnss_sdr_filesystem.h" #include "pvt_conf.h" #include "rtklib_rtkpos.h" #include "rtklib_solver.h" @@ -168,7 +168,7 @@ TEST_F(NmeaPrinterTest, PrintLine) bool flag_nmea_output_file = true; ASSERT_NO_THROW({ std::shared_ptr nmea_printer = std::make_shared(filename, flag_nmea_output_file, false, ""); - nmea_printer->Print_Nmea_Line(pvt_solution.get(), false); + nmea_printer->Print_Nmea_Line(pvt_solution.get()); }) << "Failure printing NMEA messages."; std::ifstream test_file(filename); From 6b45a92e6e0820a5d19889665d05462153b33ecf Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 9 Jul 2023 16:55:36 +0200 Subject: [PATCH 003/142] Make clang-format CI job happy --- .../unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 9032f878a..dd165b652 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -14,7 +14,6 @@ * ----------------------------------------------------------------------------- */ - #include "nmea_printer.h" #include "gnss_sdr_filesystem.h" #include "pvt_conf.h" From dd42c5c1b03e1a6829d06df185dc3a266eab0216 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 9 Jul 2023 16:57:56 +0200 Subject: [PATCH 004/142] Improve formatting --- .../signal_source/adapters/ad936x_custom_signal_source.cc | 5 +---- .../signal_source/adapters/ad936x_custom_signal_source.h | 1 - .../adapters/four_bit_cpx_file_signal_source.cc | 8 ++++++-- .../adapters/four_bit_cpx_file_signal_source.h | 7 +++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.cc b/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.cc index 067bf0e3d..796126e03 100644 --- a/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.cc @@ -65,8 +65,6 @@ Ad936xCustomSignalSource::Ad936xCustomSignalSource(const ConfigurationInterface* high_side_lo_(configuration->property(role + ".high_side_lo", false)), tx_lo_channel_(configuration->property(role + ".tx_lo_channel", 1)), rx0_to_rx1_delay_ns_(configuration->property(role + ".rx0_to_rx1_delay_ns", 0.0)) - - { if (item_type_ == "gr_complex") { @@ -186,7 +184,6 @@ Ad936xCustomSignalSource::Ad936xCustomSignalSource(const ConfigurationInterface* exit(1); } - if (dump_) { for (int n = 0; n < n_channels; n++) @@ -388,7 +385,6 @@ void Ad936xCustomSignalSource::connect(gr::top_block_sptr top_block) else { if (dump_) - { top_block->connect(gr_interleaved_short_to_complex_.at(n), 0, sink_.at(n), 0); DLOG(INFO) << "connected source to file sink"; @@ -520,6 +516,7 @@ gr::basic_block_sptr Ad936xCustomSignalSource::get_right_block() return gr_interleaved_short_to_complex_.at(0); } + gr::basic_block_sptr Ad936xCustomSignalSource::get_right_block(int RF_channel) { if (delay_enabled == true) diff --git a/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.h b/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.h index 4d4ae813c..bb9e98763 100644 --- a/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad936x_custom_signal_source.h @@ -83,7 +83,6 @@ private: std::vector unpack_byte_fourbits; std::vector unpack_byte_twobits; - std::string item_type_; size_t item_size_; int64_t samples_; diff --git a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc index 3ac128a05..fecf2d28f 100644 --- a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc @@ -30,10 +30,10 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource( unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue) : FileSourceBase(configuration, role, "Four_Bit_Cpx_File_Signal_Source"s, queue, "byte"s), + sample_type_(configuration->property(role + ".sample_type", "iq"s)), timestamp_file_(configuration->property(role + ".timestamp_filename"s, ""s)), timestamp_clock_offset_ms_(configuration->property(role + ".timestamp_clock_offset_ms"s, 0.0)) { - sample_type_ = configuration->property(role + ".sample_type", "iq"s); // the complex-ness of the input is inferred from the output type if (sample_type_ == "iq") { @@ -48,7 +48,6 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource( LOG(WARNING) << sample_type_ << " unrecognized sample type. Assuming: "; } - if (in_streams > 0) { LOG(ERROR) << "A signal source does not have an input stream"; @@ -83,8 +82,11 @@ std::tuple FourBitCpxFileSignalSource::itemTypeToSize() return std::make_tuple(item_size, is_complex); } + // 1 byte -> 1 complex samples double FourBitCpxFileSignalSource::packetsPerSample() const { return 1.0; } + + gnss_shared_ptr FourBitCpxFileSignalSource::source() const { if (timestamp_file_.size() > 1) @@ -114,6 +116,7 @@ void FourBitCpxFileSignalSource::create_file_source_hook() } } + void FourBitCpxFileSignalSource::pre_connect_hook(gr::top_block_sptr top_block) { top_block->connect(file_source(), 0, unpack_byte_, 0); @@ -126,6 +129,7 @@ void FourBitCpxFileSignalSource::pre_connect_hook(gr::top_block_sptr top_block) } } + void FourBitCpxFileSignalSource::pre_disconnect_hook(gr::top_block_sptr top_block) { if (timestamp_file_.size() > 1) diff --git a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.h b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.h index a36776afb..cedbb0741 100644 --- a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.h @@ -1,5 +1,5 @@ /*! - * \file FOUR_BIT_cpx_file_signal_source.h + * \file four_bit_cpx_file_signal_source.h * \brief Interface of a class that reads signals samples from a 2 bit complex sampler front-end file * and adapts it to a SignalSourceInterface. * \author Javier Arribas, 2015 jarribas(at)cttc.es @@ -62,12 +62,11 @@ protected: private: unpack_byte_4bit_samples_sptr unpack_byte_; gr::blocks::interleaved_short_to_complex::sptr inter_shorts_to_cpx_; - std::string sample_type_; - bool reverse_interleaving_; - gnss_shared_ptr timestamp_block_; + std::string sample_type_; std::string timestamp_file_; double timestamp_clock_offset_ms_; + bool reverse_interleaving_; }; From fd57c34d5d39a0d1978ea456a9ccac82c4a2a555 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 9 Jul 2023 23:57:59 +0200 Subject: [PATCH 005/142] Fix clang-format job --- .../signal-processing-blocks/pvt/nmea_printer_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index dd165b652..5c56c6f7f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -14,8 +14,9 @@ * ----------------------------------------------------------------------------- */ -#include "nmea_printer.h" + #include "gnss_sdr_filesystem.h" +#include "nmea_printer.h" #include "pvt_conf.h" #include "rtklib_rtkpos.h" #include "rtklib_solver.h" From 7e5bc88632f2d5ff83e69abc40e7218837e8fd9e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 13 Sep 2023 11:48:21 +0200 Subject: [PATCH 006/142] Since applying reduced CED parameters can break PVT continuity due to an increase in the residuals, we disable their usage by default. New conf parameter TelemetryDecoder_1B.use_reduced_ced --- .../adapters/galileo_e1b_telemetry_decoder.cc | 1 + .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/galileo_telemetry_decoder_gs.h | 1 + src/algorithms/telemetry_decoder/libs/tlm_conf.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc index 92e5e4071..cadc48503 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc @@ -33,6 +33,7 @@ GalileoE1BTelemetryDecoder::GalileoE1BTelemetryDecoder( DLOG(INFO) << "role " << role; tlm_parameters_.SetFromConfiguration(configuration, role); tlm_parameters_.enable_reed_solomon = configuration->property(role + ".enable_reed_solomon", false); + tlm_parameters_.use_ced = configuration->property(role + ".use_reduced_ced", false); // make telemetry decoder object telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 1); // unified galileo decoder set to INAV (frame_type=1) DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; 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 2c2693c44..ea99988d8 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 @@ -105,7 +105,8 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( d_enable_reed_solomon_inav(false), d_valid_timetag(false), d_E6_TOW_set(false), - d_there_are_e6_channels(conf.there_are_e6_channels) + d_there_are_e6_channels(conf.there_are_e6_channels), + d_use_ced(conf.use_ced) { // prevent telemetry symbols accumulation in output buffers this->set_max_noutput_items(1); @@ -442,7 +443,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in else { // If we still do not have ephemeris, check if we have a reduced CED - if ((d_band == '1') && !d_first_eph_sent && (d_inav_nav.have_new_reduced_ced() == true)) + if ((d_band == '1') && d_use_ced && !d_first_eph_sent && (d_inav_nav.have_new_reduced_ced() == true)) { const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_reduced_ced()); std::cout << "New Galileo E1 I/NAV reduced CED message received in channel " << d_channel << " from satellite " << d_satellite << '\n'; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h index dd6253829..39f2936c9 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h @@ -152,6 +152,7 @@ private: bool d_valid_timetag; bool d_E6_TOW_set; bool d_there_are_e6_channels; + bool d_use_ced; }; diff --git a/src/algorithms/telemetry_decoder/libs/tlm_conf.h b/src/algorithms/telemetry_decoder/libs/tlm_conf.h index abac3ac87..fccbb3f7b 100644 --- a/src/algorithms/telemetry_decoder/libs/tlm_conf.h +++ b/src/algorithms/telemetry_decoder/libs/tlm_conf.h @@ -43,6 +43,7 @@ public: bool dump_crc_stats{false}; // telemetry CRC statistics bool enable_navdata_monitor{false}; bool there_are_e6_channels{false}; + bool use_ced{false}; }; From e592d09971bbfa730d626273466f5df88a542743 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Wed, 13 Sep 2023 15:04:50 +0200 Subject: [PATCH 007/142] Disable Galileo E6 observables generation if the user sets PVT.use_e6_for_pvt=false --- src/algorithms/observables/adapters/hybrid_observables.cc | 1 + .../observables/gnuradio_blocks/hybrid_observables_gs.cc | 4 ++++ src/algorithms/observables/libs/obs_conf.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/algorithms/observables/adapters/hybrid_observables.cc b/src/algorithms/observables/adapters/hybrid_observables.cc index 6413d48a7..fbb6ba2a3 100644 --- a/src/algorithms/observables/adapters/hybrid_observables.cc +++ b/src/algorithms/observables/adapters/hybrid_observables.cc @@ -43,6 +43,7 @@ HybridObservables::HybridObservables(const ConfigurationInterface* configuration conf.observable_interval_ms = configuration->property("GNSS-SDR.observable_interval_ms", conf.observable_interval_ms); conf.enable_carrier_smoothing = configuration->property(role + ".enable_carrier_smoothing", conf.enable_carrier_smoothing); conf.always_output_gs = configuration->property("PVT.an_output_enabled", conf.always_output_gs) || configuration->property(role + ".always_output_gs", conf.always_output_gs); + conf.enable_E6 = configuration->property("PVT.use_e6_for_pvt", conf.enable_E6); if (FLAGS_carrier_smoothing_factor == DEFAULT_CARRIER_SMOOTHING_FACTOR) { diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 6fb36d92c..ddc32e2c0 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -720,6 +720,10 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) // Push the valid tracking Gnss_Synchros to their corresponding deque if (in[n][m].Flag_valid_word) { + if (std::string(in[n][m].Signal, 2) == std::string("E6")) + { + if (d_conf.enable_E6 == false) continue; + } if (d_gnss_synchro_history->size(n) > 0) { // Check if the last Gnss_Synchro comes from the same satellite as the previous ones diff --git a/src/algorithms/observables/libs/obs_conf.h b/src/algorithms/observables/libs/obs_conf.h index 22da24476..480a0d888 100644 --- a/src/algorithms/observables/libs/obs_conf.h +++ b/src/algorithms/observables/libs/obs_conf.h @@ -41,6 +41,7 @@ public: bool always_output_gs{false}; bool dump{false}; bool dump_mat{false}; + bool enable_E6{false}; }; /** \} */ From 5c0826b11e1b864d0f4be4624d83554a6e2ff9fb Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 13 Sep 2023 17:19:10 +0200 Subject: [PATCH 008/142] Optimize the use of the FPGA dynamic bit selection blocks. Reorder AD9361 FPGA signal source private members by size. use ssize_t write() return value. --- .../adapters/ad9361_fpga_signal_source.cc | 55 +++---- .../adapters/ad9361_fpga_signal_source.h | 22 +-- .../libs/fpga_dynamic_bit_selection.cc | 143 +++++++----------- .../libs/fpga_dynamic_bit_selection.h | 18 +-- src/core/libs/gnss_sdr_fpga_sample_counter.cc | 6 +- 5 files changed, 99 insertions(+), 145 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 065838450..0caa240f0 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -59,26 +59,26 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con filename0_(configuration->property(role + ".filename", empty_string)), rf_gain_rx1_(configuration->property(role + ".gain_rx1", default_manual_gain_rx1)), rf_gain_rx2_(configuration->property(role + ".gain_rx2", default_manual_gain_rx2)), + scale_dds_dbfs_(configuration->property(role + ".scale_dds_dbfs", -3.0)), + phase_dds_deg_(configuration->property(role + ".phase_dds_deg", 0.0)), + tx_attenuation_db_(configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db)), freq0_(configuration->property(role + ".freq", 0)), freq1_(configuration->property(role + ".freq1", static_cast(GPS_L5_FREQ_HZ))), sample_rate_(configuration->property(role + ".sampling_frequency", default_bandwidth)), bandwidth_(configuration->property(role + ".bandwidth", default_bandwidth)), samples_to_skip_(0), samples_(configuration->property(role + ".samples", static_cast(0))), + freq_dds_tx_hz_(configuration->property(role + ".freq_dds_tx_hz", uint64_t(10000))), + freq_rf_tx_hz_(configuration->property(role + ".freq_rf_tx_hz", static_cast(GPS_L1_FREQ_HZ - GPS_L5_FREQ_HZ - freq_dds_tx_hz_))), + tx_bandwidth_(configuration->property(role + ".tx_bandwidth", static_cast(500000))), Fpass_(configuration->property(role + ".Fpass", static_cast(0.0))), Fstop_(configuration->property(role + ".Fstop", static_cast(0.0))), num_freq_bands_(2), dma_buff_offset_pos_(0), - scale_dds_dbfs_(configuration->property(role + ".scale_dds_dbfs", -3.0)), - phase_dds_deg_(configuration->property(role + ".phase_dds_deg", 0.0)), - tx_attenuation_db_(configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db)), - freq_dds_tx_hz_(configuration->property(role + ".freq_dds_tx_hz", uint64_t(10000))), - freq_rf_tx_hz_(configuration->property(role + ".freq_rf_tx_hz", static_cast(GPS_L1_FREQ_HZ - GPS_L5_FREQ_HZ - freq_dds_tx_hz_))), - tx_bandwidth_(configuration->property(role + ".tx_bandwidth", static_cast(500000))), - item_size_(sizeof(int8_t)), in_stream_(in_stream), out_stream_(out_stream), switch_position_(configuration->property(role + ".switch_position", 0)), + item_size_(sizeof(int8_t)), enable_dds_lo_(configuration->property(role + ".enable_dds_lo", false)), filter_auto_(configuration->property(role + ".filter_auto", false)), quadrature_(configuration->property(role + ".quadrature", true)), @@ -93,11 +93,17 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con rf_shutdown_(configuration->property(role + ".rf_shutdown", FLAGS_rf_shutdown)), repeat_(configuration->property(role + ".repeat", false)) { - const int l1_band = configuration->property("Channels_1C.count", 0) + - configuration->property("Channels_1B.count", 0); - const double seconds_to_skip = configuration->property(role + ".seconds_to_skip", 0.0); const size_t header_size = configuration->property(role + ".header_size", 0); + const int num_ch_rx1 = configuration->property("Channels_1C.count", 0) + + configuration->property("Channels_1B.count", 0); + const int num_ch_rx2 = (configuration->property("Channels_L2.count", 0) > 0) ? configuration->property("Channels_L2.count", 0) : configuration->property("Channels_L5.count", 0) + configuration->property("Channels_5X.count", 0); + + // number of frequency bands + if (num_ch_rx2 == 0) + { + num_freq_bands_ = 1; + } if (freq0_ == 0) { @@ -135,8 +141,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con // if more than one input file are specified then the DMA transfer the samples to both the L1 and the L2/L5 frequency channels. if (filename1_.empty()) { - num_freq_bands_ = 1; - if (l1_band != 0) + if (num_ch_rx1 != 0) { dma_buff_offset_pos_ = 2; } @@ -160,7 +165,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con if (find_uio_dev_file_name(device_io_name, switch_device_name, 0) < 0) { std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << switch_device_name << '\n'; - item_size_ = 0; return; } @@ -196,7 +200,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con else { std::cerr << "SignalSource: Unable to open the samples file " << filename0_.c_str() << '\n'; - item_size_ = 0; return; } std::streamsize ss = std::cout.precision(); @@ -224,7 +227,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con else { std::cerr << "SignalSource: Unable to open the samples file " << filename1_.c_str() << '\n'; - item_size_ = 0; return; } std::streamsize ss = std::cout.precision(); @@ -372,7 +374,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con catch (const std::runtime_error &e) { std::cerr << "Exception cached when configuring the RX chain: " << e.what() << '\n'; - item_size_ = 0; return; } // LOCAL OSCILLATOR DDS GENERATOR FOR DUAL FREQUENCY OPERATION @@ -407,7 +408,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con catch (const std::runtime_error &e) { std::cerr << "Exception cached when configuring the TX carrier: " << e.what() << '\n'; - item_size_ = 0; return; } } @@ -424,7 +424,6 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con if (find_uio_dev_file_name(device_io_name_buffer_monitor, buffer_monitor_device_name, 0) < 0) { std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << buffer_monitor_device_name << '\n'; - item_size_ = 0; return; } @@ -435,25 +434,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con // dynamic bits selection if (enable_dynamic_bit_selection_) { - std::string device_io_name_dyn_bit_sel_0; - std::string device_io_name_dyn_bit_sel_1; - - // find the uio device file corresponding to the dynamic bit selector 0 module. - if (find_uio_dev_file_name(device_io_name_dyn_bit_sel_0, dyn_bit_sel_device_name, 0) < 0) - { - std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; - item_size_ = 0; - return; - } - - // find the uio device file corresponding to the dynamic bit selector 1 module. - if (find_uio_dev_file_name(device_io_name_dyn_bit_sel_1, dyn_bit_sel_device_name, 1) < 0) - { - std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; - item_size_ = 0; - return; - } - dynamic_bit_selection_fpga = std::make_shared(device_io_name_dyn_bit_sel_0, device_io_name_dyn_bit_sel_1); + dynamic_bit_selection_fpga = std::make_shared(num_freq_bands_); thread_dynamic_bit_selection = std::thread([&] { run_dynamic_bit_selection_process(); }); } diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h index f16f6f274..a78b1aa00 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h @@ -118,7 +118,6 @@ private: Concurrent_Queue *queue_; - // Front-end settings std::string gain_mode_rx1_; std::string gain_mode_rx2_; std::string rf_port_select_; @@ -130,30 +129,31 @@ private: double rf_gain_rx1_; double rf_gain_rx2_; + double scale_dds_dbfs_; + double phase_dds_deg_; + double tx_attenuation_db_; + uint64_t freq0_; // frequency of local oscillator for ADRV9361-A 0 uint64_t freq1_; // frequency of local oscillator for ADRV9361-B (if present) uint64_t sample_rate_; uint64_t bandwidth_; uint64_t samples_to_skip_; int64_t samples_; + uint64_t freq_dds_tx_hz_; + uint64_t freq_rf_tx_hz_; + uint64_t tx_bandwidth_; + float Fpass_; float Fstop_; uint32_t num_freq_bands_; uint32_t dma_buff_offset_pos_; - - // DDS configuration for LO generation for external mixer - double scale_dds_dbfs_; - double phase_dds_deg_; - double tx_attenuation_db_; - uint64_t freq_dds_tx_hz_; - uint64_t freq_rf_tx_hz_; - uint64_t tx_bandwidth_; - size_t item_size_; uint32_t in_stream_; uint32_t out_stream_; int32_t switch_position_; - bool enable_dds_lo_; + size_t item_size_; + + bool enable_dds_lo_; bool filter_auto_; bool quadrature_; bool rf_dc_; diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index 0e7a5afca..c897e40f5 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -2,7 +2,7 @@ * \file fpga_dynamic_bit_selection.cc * \brief Dynamic Bit Selection in the received signal. * \authors
    - *
  • Marc Majoral, 2020. mmajoral(at)cttc.es + *
  • Marc Majoral, 2023. mmajoral(at)cttc.es *
* * Class that controls the Dynamic Bit Selection in the FPGA. @@ -13,58 +13,52 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- */ #include "fpga_dynamic_bit_selection.h" +#include "uio_fpga.h" #include #include // for open, O_RDWR, O_SYNC #include // for cout #include // for mmap -Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(const std::string &device_name1, const std::string &device_name2) +Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(uint32_t num_freq_bands) + : d_num_freq_bands(num_freq_bands) { - // dynamic bits selection corresponding to frequency band 1 - if ((d_device_descriptor1 = open(device_name1.c_str(), O_RDWR | O_SYNC)) == -1) + d_map_base = std::vector(d_num_freq_bands); + d_device_descriptors = std::vector(d_num_freq_bands); + d_shift_out_bits = std::vector(d_num_freq_bands); + for (uint32_t k = 0; k < d_num_freq_bands; k++) { - LOG(WARNING) << "Cannot open deviceio" << device_name1; + // find the uio device file corresponding to the dynamic bit selector 0 module. + std::string device_name; + if (find_uio_dev_file_name(device_name, dyn_bit_sel_device_name, 0) < 0) + { + std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; + return; + } + // dynamic bits selection corresponding to frequency band 1 + if ((d_device_descriptors[k] = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << device_name; + } + d_map_base[k] = reinterpret_cast(mmap(nullptr, FPGA_PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptors[k], 0)); + + if (d_map_base[k] == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA dynamic bit selection module in frequency band 1 into tracking memory"; + std::cout << "Could not map dynamic bit selection memory corresponding to frequency band 1.\n"; + } + + // init bit selection corresopnding to frequency band 1 + d_shift_out_bits[k] = shift_out_bits_default; + d_map_base[k][0] = d_shift_out_bits[k]; } - d_map_base1 = reinterpret_cast(mmap(nullptr, FPGA_PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor1, 0)); - - if (d_map_base1 == reinterpret_cast(-1)) - { - LOG(WARNING) << "Cannot map the FPGA dynamic bit selection module in frequency band 1 into tracking memory"; - std::cout << "Could not map dynamic bit selection memory corresponding to frequency band 1.\n"; - } - - // dynamic bits selection corresponding to frequency band 2 - if ((d_device_descriptor2 = open(device_name2.c_str(), O_RDWR | O_SYNC)) == -1) - { - LOG(WARNING) << "Cannot open deviceio" << device_name2; - } - d_map_base2 = reinterpret_cast(mmap(nullptr, FPGA_PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor2, 0)); - - if (d_map_base2 == reinterpret_cast(-1)) - { - LOG(WARNING) << "Cannot map the FPGA dynamic bit selection module in frequency band 2 into tracking memory"; - std::cout << "Could not map dynamic bit selection memory corresponding to frequency band 2.\n"; - } - - // initialize default bit selection - shift_out_bits_band1 = shift_out_bits_default; - shift_out_bits_band2 = shift_out_bits_default; - - // init bit selection corresopnding to frequency band 1 - d_map_base1[0] = shift_out_bits_band1; - - // init bit selection corresponding to frequency band 2 - d_map_base2[0] = shift_out_bits_band2; - DLOG(INFO) << "Dynamic bit selection FPGA class created"; } @@ -77,65 +71,42 @@ Fpga_dynamic_bit_selection::~Fpga_dynamic_bit_selection() void Fpga_dynamic_bit_selection::bit_selection() { - // estimated signal power corresponding to frequency band 1 - uint32_t rx_signal_power1 = d_map_base1[1]; - // estimated signal power corresponding to frequency band 2 - uint32_t rx_signal_power2 = d_map_base2[1]; - - // dynamic bit selection corresponding to frequency band 1 - if (rx_signal_power1 > Power_Threshold_High) + for (uint32_t k = 0; k < d_num_freq_bands; k++) { - if (shift_out_bits_band1 < shift_out_bit_max) - { - shift_out_bits_band1 = shift_out_bits_band1 + 1; - } - } - else if (rx_signal_power1 < Power_Threshold_Low) - { - if (shift_out_bits_band1 > shift_out_bits_min) - { - shift_out_bits_band1 = shift_out_bits_band1 - 1; - } - } + // estimated signal power + uint32_t rx_signal_power = d_map_base[k][1]; - // dynamic bit selection corresponding to frequency band 2 - if (rx_signal_power2 > Power_Threshold_High) - { - if (shift_out_bits_band2 < shift_out_bit_max) + // dynamic bit selection + if (rx_signal_power > Power_Threshold_High) { - shift_out_bits_band2 = shift_out_bits_band2 + 1; + if (d_shift_out_bits[k] < shift_out_bit_max) + { + d_shift_out_bits[k] = d_shift_out_bits[k] + 1; + } } - } - else if (rx_signal_power2 < Power_Threshold_Low) - { - if (shift_out_bits_band2 > shift_out_bits_min) + else if (rx_signal_power < Power_Threshold_Low) { - shift_out_bits_band2 = shift_out_bits_band2 - 1; + if (d_shift_out_bits[k] > shift_out_bits_min) + { + d_shift_out_bits[k] = d_shift_out_bits[k] - 1; + } } + + // update bit selection corresopnding to frequency band 1 + d_map_base[k][0] = d_shift_out_bits[k]; } - - // update bit selection corresopnding to frequency band 1 - d_map_base1[0] = shift_out_bits_band1; - - // udpate bit selection corresponding to frequency band 2 - d_map_base2[0] = shift_out_bits_band2; } void Fpga_dynamic_bit_selection::close_devices() { - auto *aux = const_cast(d_map_base1); - if (munmap(static_cast(aux), FPGA_PAGE_SIZE) == -1) + for (uint32_t k = 0; k < d_num_freq_bands; k++) { - std::cout << "Failed to unmap memory uio\n"; + auto *aux = const_cast(d_map_base[k]); + if (munmap(static_cast(aux), FPGA_PAGE_SIZE) == -1) + { + std::cout << "Failed to unmap memory uio\n"; + } + close(d_device_descriptors[k]); } - - aux = const_cast(d_map_base2); - if (munmap(static_cast(aux), FPGA_PAGE_SIZE) == -1) - { - std::cout << "Failed to unmap memory uio\n"; - } - - close(d_device_descriptor1); - close(d_device_descriptor2); } diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h index 500bb182e..f5454e299 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h @@ -25,6 +25,7 @@ #include #include #include +#include /** \addtogroup Signal_Source * \{ */ @@ -42,7 +43,7 @@ public: /*! * \brief Constructor */ - explicit Fpga_dynamic_bit_selection(const std::string& device_name1, const std::string& device_name2); + explicit Fpga_dynamic_bit_selection(uint32_t num_freq_bands); /*! * \brief Destructor @@ -52,12 +53,12 @@ public: /*! * \brief This function configures the switch in th eFPGA */ - // void set_switch_position(int32_t switch_position); void bit_selection(void); private: + const std::string switch_device_name = std::string("AXIS_Switch_v1_0_0"); // Switch UIO device name + const std::string dyn_bit_sel_device_name = std::string("dynamic_bits_selector"); // Switch dhnamic bit selector device name static const size_t FPGA_PAGE_SIZE = 0x1000; - static const uint32_t Num_bits_ADC = 12; // Number of bits in the ADC static const uint32_t Num_bits_FPGA = 4; // Number of bits after the bit selection static const uint32_t shift_out_bits_default = Num_bits_ADC - Num_bits_FPGA; // take the most significant bits by default @@ -70,14 +71,11 @@ private: void close_devices(void); - uint32_t shift_out_bits_band1; // number of bits to shift for frequency band 1 - uint32_t shift_out_bits_band2; // number of bits to shift for frequency band 2 + std::vector d_map_base; + std::vector d_device_descriptors; + std::vector d_shift_out_bits; - volatile unsigned* d_map_base1; // driver memory map corresponding to frequency band 1 - int d_device_descriptor1; // driver descriptor corresponding to frequency band 1 - - volatile unsigned* d_map_base2; // driver memory map corresponding to frequency band 2 - int d_device_descriptor2; // driver descriptor corresponding to frequency band 2 + uint32_t d_num_freq_bands; // number of frequency bands }; diff --git a/src/core/libs/gnss_sdr_fpga_sample_counter.cc b/src/core/libs/gnss_sdr_fpga_sample_counter.cc index a54fd6270..6aa5c44a8 100644 --- a/src/core/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/core/libs/gnss_sdr_fpga_sample_counter.cc @@ -279,7 +279,11 @@ void gnss_sdr_fpga_sample_counter::wait_for_interrupt() const // enable interrupts int32_t reenable = 1; - write(fd, reinterpret_cast(&reenable), sizeof(int32_t)); + const ssize_t nbytes = TEMP_FAILURE_RETRY(write(fd, reinterpret_cast(&reenable), sizeof(int32_t))); + if (nbytes != sizeof(int32_t)) + { + std::cerr << "Error re-enabling FPGA sample counter interrupt.\n"; + } // wait for interrupt nb = read(fd, &irq_count, sizeof(irq_count)); From 7781d3c3b4ca1d70098d4f9f725596a3dfb3b33c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 15 Sep 2023 11:01:11 +0200 Subject: [PATCH 009/142] Make clang-tidy happy --- .../observables/gnuradio_blocks/hybrid_observables_gs.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index ddc32e2c0..c6541efa1 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -722,7 +722,10 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) { if (std::string(in[n][m].Signal, 2) == std::string("E6")) { - if (d_conf.enable_E6 == false) continue; + if (d_conf.enable_E6 == false) + { + continue; + } } if (d_gnss_synchro_history->size(n) > 0) { From 7df3b556cc2ef157f8a8cb280f0b6107c2d6c68c Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 18 Sep 2023 21:24:34 +0200 Subject: [PATCH 010/142] make the FPGA acqusition downsampling factor in the L1/E1 band configurable --- .../adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc | 2 +- .../adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h | 5 ++--- .../adapters/galileo_e5a_pcps_acquisition_fpga.cc | 2 +- .../acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h | 5 ++--- .../adapters/galileo_e5b_pcps_acquisition_fpga.cc | 2 +- .../acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h | 5 ++--- .../acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc | 2 +- .../acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h | 5 ++--- .../acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc | 2 +- .../acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h | 5 ++--- .../acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc | 2 +- .../acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h | 5 ++--- src/algorithms/acquisition/libs/acq_conf_fpga.cc | 5 +++-- src/algorithms/acquisition/libs/acq_conf_fpga.h | 2 +- 14 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 926b680e4..20efd8ae3 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -44,7 +44,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( out_streams_(out_streams), acquire_pilot_(configuration->property(role + ".acquire_pilot", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 209ba88d7..597d9975a 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -181,9 +181,8 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 0; // L1/E1 band - static const uint32_t fpga_blk_exp = 13; // default block exponent + static const uint32_t fpga_buff_num = 0; // L1/E1 band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 497da79e9..d049ccd37 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 9f9170c40..a33f6738e 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -188,9 +188,8 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 1; // L5/E5a band - static const uint32_t fpga_blk_exp = 13; // default block exponent + static const uint32_t fpga_buff_num = 1; // L5/E5a band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc index f75d29db4..4ec2c5341 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { acq_parameters_.doppler_max = FLAGS_doppler_max; diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index e3c43aeea..33545bd2b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -187,9 +187,8 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 1; // E5b band - static const uint32_t fpga_blk_exp = 13; // default block exponent + static const uint32_t fpga_buff_num = 1; // E5b band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 5b01d13f4..0b9ae0b9a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS); DLOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index addbdd5ec..f187d77c0 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -186,9 +186,8 @@ public: private: static const uint32_t NUM_PRNs = 32; - static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 0; // L1/E1 band - static const uint32_t fpga_blk_exp = 10; // default block exponent + static const uint32_t fpga_buff_num = 0; // L1/E1 band + static const uint32_t fpga_blk_exp = 10; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index 30680e011..c74f1275b 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index 67f8f621a..d105ea7e2 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -149,9 +149,8 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 0; // L2 band - static const uint32_t fpga_blk_exp = 13; // default block exponent + static const uint32_t fpga_buff_num = 0; // L2 band + static const uint32_t fpga_blk_exp = 13; // default block exponent static const uint32_t NUM_PRNs = 32; static const uint32_t QUANT_BITS_LOCAL_CODE = 16; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 269672f65..ebd701840 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -44,7 +44,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index a2e69c3df..c68cd7bda 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -186,9 +186,8 @@ public: private: static const uint32_t NUM_PRNs = 32; - static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA - static const uint32_t fpga_buff_num = 1; // L5/E5a band - static const uint32_t fpga_blk_exp = 13; // default block exponent + static const uint32_t fpga_buff_num = 1; // L5/E5a band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc index 94d9a321f..ac68a92ad 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.cc +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -23,7 +23,7 @@ #include void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configuration, - const std::string &role, uint32_t downs_factor, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips) + const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips) { // sampling frequency const int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", fs_in); @@ -33,7 +33,8 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura doppler_max = configuration->property(role + ".doppler_max", doppler_max); // downsampling factor - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", downs_factor); + downsampling_factor = configuration->property(role + ".downsampling_factor", downsampling_factor); + fs_in = fs_in / downsampling_factor; // code length in samples diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.h b/src/algorithms/acquisition/libs/acq_conf_fpga.h index 5bac585f4..c24cbb031 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.h +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.h @@ -35,7 +35,7 @@ class Acq_Conf_Fpga public: Acq_Conf_Fpga() = default; - void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t downs_factor, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips); + void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips); /* PCPS Acquisition configuration */ std::string device_name = "uio0"; From 5f5e861822341cd278f1f678a52b7233ffee146a Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 19 Sep 2023 13:10:56 +0200 Subject: [PATCH 011/142] Adding PVT UTC time string in rfc 3339 format to protobuf PVT monitor output --- docs/protobuf/monitor_pvt.proto | 1 + src/algorithms/PVT/libs/monitor_pvt.h | 6 ++++++ src/algorithms/PVT/libs/rtklib_solver.cc | 11 +++++++++++ src/algorithms/PVT/libs/serdes_monitor_pvt.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/docs/protobuf/monitor_pvt.proto b/docs/protobuf/monitor_pvt.proto index d8b9d7f54..d3a18f4f4 100644 --- a/docs/protobuf/monitor_pvt.proto +++ b/docs/protobuf/monitor_pvt.proto @@ -42,4 +42,5 @@ double hdop = 27; // Horizontal Dilution of Precision double vdop = 28; // Vertical Dilution of Precision double user_clk_drift_ppm = 29; // User clock drift [ppm] +string utc_time = 30; // PVT UTC time (rfc 3339 datetime string) } diff --git a/src/algorithms/PVT/libs/monitor_pvt.h b/src/algorithms/PVT/libs/monitor_pvt.h index 18c43229b..ce2ca815d 100644 --- a/src/algorithms/PVT/libs/monitor_pvt.h +++ b/src/algorithms/PVT/libs/monitor_pvt.h @@ -19,6 +19,7 @@ #include #include +#include /** \addtogroup PVT * \{ */ @@ -84,6 +85,10 @@ public: // User clock drift [ppm] double user_clk_drift_ppm; + // PVT UTC Time (rfc 3339 datetime string) + std::string utc_time; + + /*! * \brief This member function serializes and restores * Monitor_Pvt objects from a byte stream. @@ -131,6 +136,7 @@ public: ar& BOOST_SERIALIZATION_NVP(vdop); ar& BOOST_SERIALIZATION_NVP(user_clk_drift_ppm); + ar& BOOST_SERIALIZATION_NVP(utc_time); } }; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 8b9d5b8ee..443564819 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -1686,6 +1686,17 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // User clock drift [ppm] d_monitor_pvt.user_clk_drift_ppm = clock_drift_ppm; + //write UTC time string + + // Use a facet to display time in a custom format (only hour and minutes). + boost::posix_time::time_facet *facet = new boost::posix_time::time_facet(); + facet->format("%Y-%m-%dT%H:%M:%S%F"); + std::stringstream stream; + stream.imbue(std::locale(std::locale::classic(), facet)); + stream << p_time; + stream << 'Z'; + d_monitor_pvt.utc_time = stream.str(); + // ######## LOG FILE ######### if (d_flag_dump_enabled == true) { diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index a792e18d6..5d22f8519 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -112,6 +112,7 @@ public: monitor_.set_hdop(monitor->hdop); monitor_.set_vdop(monitor->vdop); monitor_.set_user_clk_drift_ppm(monitor->user_clk_drift_ppm); + monitor_.set_utc_time(monitor->utc_time); monitor_.SerializeToString(&data); return data; @@ -150,6 +151,7 @@ public: monitor.hdop = mon.hdop(); monitor.vdop = mon.vdop(); monitor.user_clk_drift_ppm = mon.user_clk_drift_ppm(); + monitor.utc_time = mon.utc_time(); return monitor; } From 6bf7b8c51f98393eddf3433c28fb961c89853a0b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 20 Sep 2023 09:08:55 +0200 Subject: [PATCH 012/142] Make clang-tidy happy --- src/algorithms/PVT/libs/rtklib_solver.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 443564819..a3a7b8ac6 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -1686,10 +1686,10 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // User clock drift [ppm] d_monitor_pvt.user_clk_drift_ppm = clock_drift_ppm; - //write UTC time string + // write UTC time string // Use a facet to display time in a custom format (only hour and minutes). - boost::posix_time::time_facet *facet = new boost::posix_time::time_facet(); + auto *facet = new boost::posix_time::time_facet(); facet->format("%Y-%m-%dT%H:%M:%S%F"); std::stringstream stream; stream.imbue(std::locale(std::locale::classic(), facet)); From 55df8d53334e7cdd8d85a80f7f9f4c7999dda38b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Sep 2023 09:04:24 +0200 Subject: [PATCH 013/142] Update changelog --- docs/CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 422237dd3..4d758ee5c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,7 +14,12 @@ All notable changes to GNSS-SDR will be documented in this file. ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) -### Improvements in Repeatability +### Improvements in Interoperability: + +- A new field `utc_time` (a [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) + datetime string) with the Time solution has been added to `monitor_pvt.proto`. + +### Improvements in Repeatability: - A Kalman filter is now available in the PVT block, smoothing the outputs of a simple Least Squares solution and improving the precision of delivered fixes. @@ -26,6 +31,16 @@ All notable changes to GNSS-SDR will be documented in this file. `PVT.kf_system_ecef_pos_sd_m=0.01`, in [m]; and `PVT.kf_system_ecef_vel_sd_ms=0.001`, in [m/s]. +### Improvements in Usability: + +- The Galileo E1B Reduced CED parameters usage has been set to `false` by + default. You can activate its usage with `Galileo_E1B_Telemetry_Decoder=true` + in your configuration file. + +- The generation of Galileo E6B observables has been disabled if the user sets + `PVT.use_e6_for_pvt=false`, fixing the PVT computation in some multi-band + configurations. + ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7805514.svg)](https://doi.org/10.5281/zenodo.7805514) From 7710701ca7f9f3eb24988aeb4a4820be05ea4d5e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 27 Sep 2023 08:59:44 +0200 Subject: [PATCH 014/142] Update Armadillo version, old branch disappeared --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2a91527b..c17bfdea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,7 +335,7 @@ set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") ################################################################################ # Versions to download and build (but not to install system-wide) if not found ################################################################################ -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.2.x") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.6.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") From bac997bb7c7c41221d0e09279ccc8feae002ce62 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Wed, 27 Sep 2023 09:43:08 +0200 Subject: [PATCH 015/142] Fix PVT monitor messages to obei the configured PVT output rate --- src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 83c6bb231..f39ff0867 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2438,7 +2438,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } // PVT MONITOR - if (d_user_pvt_solver->is_valid_position()) + if (d_user_pvt_solver->is_valid_position() && flag_compute_pvt_output == true) { const std::shared_ptr monitor_pvt = std::make_shared(d_user_pvt_solver->get_monitor_pvt()); From e24a5df69e05043471c2619bc1b037cc4d0bb282 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Wed, 27 Sep 2023 09:52:19 +0200 Subject: [PATCH 016/142] Increase the IIO API FIFO size --- src/algorithms/signal_source/libs/ad936x_iio_samples.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/libs/ad936x_iio_samples.h b/src/algorithms/signal_source/libs/ad936x_iio_samples.h index 96fd9e6ae..63d30545b 100644 --- a/src/algorithms/signal_source/libs/ad936x_iio_samples.h +++ b/src/algorithms/signal_source/libs/ad936x_iio_samples.h @@ -18,7 +18,7 @@ #ifndef SRC_LIBS_ad936x_iio_samples_H_ #define SRC_LIBS_ad936x_iio_samples_H_ -#define IIO_DEFAULTAD936XAPIFIFOSIZE_SAMPLES 32768 +#define IIO_DEFAULTAD936XAPIFIFOSIZE_SAMPLES 32768 * 4 #define IIO_INPUTRAMFIFOSIZE 256 From 6cb3ae99b3113cb2992be5b45213b16c222bd411 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 27 Sep 2023 10:34:17 +0200 Subject: [PATCH 017/142] Update changelog --- docs/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4d758ee5c..0d97548fc 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,10 +36,12 @@ All notable changes to GNSS-SDR will be documented in this file. - The Galileo E1B Reduced CED parameters usage has been set to `false` by default. You can activate its usage with `Galileo_E1B_Telemetry_Decoder=true` in your configuration file. - - The generation of Galileo E6B observables has been disabled if the user sets `PVT.use_e6_for_pvt=false`, fixing the PVT computation in some multi-band configurations. +- Fix bug in the custom binary output (`PVT.enable_monitor=true`) output rate. + Before this fix, it was outputting data every 20 ms, instead of observing the + `PVT.output_rate_ms` setting. ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 From a39144105c2c5e078ac2e17d4a56bc567f1d8015 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Thu, 28 Sep 2023 10:01:03 +0200 Subject: [PATCH 018/142] Adding Local frame ENU velocity and COG to PVT monitor serialization --- docs/protobuf/monitor_pvt.proto | 6 ++++++ src/algorithms/PVT/libs/monitor_pvt.h | 13 +++++++++++++ src/algorithms/PVT/libs/rtklib_solver.cc | 10 +++++++++- src/algorithms/PVT/libs/serdes_monitor_pvt.h | 9 ++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/protobuf/monitor_pvt.proto b/docs/protobuf/monitor_pvt.proto index d3a18f4f4..cfd855607 100644 --- a/docs/protobuf/monitor_pvt.proto +++ b/docs/protobuf/monitor_pvt.proto @@ -43,4 +43,10 @@ double vdop = 28; // Vertical Dilution of Precision double user_clk_drift_ppm = 29; // User clock drift [ppm] string utc_time = 30; // PVT UTC time (rfc 3339 datetime string) + +double vel_e = 31; // Velocity East component in Local frame, in m/s +double vel_n = 32; // Velocity Nord component in Local frame, in m/s +double vel_u = 33; // Velocity Up component in Local frame, in m/s + +double cog = 34; // Course Over Ground (cog) [deg] } diff --git a/src/algorithms/PVT/libs/monitor_pvt.h b/src/algorithms/PVT/libs/monitor_pvt.h index ce2ca815d..8526a5191 100644 --- a/src/algorithms/PVT/libs/monitor_pvt.h +++ b/src/algorithms/PVT/libs/monitor_pvt.h @@ -64,6 +64,13 @@ public: double longitude; // GEO user position Height [m] double height; + // East, Nord, Up (ENU) Velocity [m/s] + double vel_e; + double vel_n; + double vel_u; + + // Course Over Ground (COG) [deg] + double cog; // NUMBER OF VALID SATS uint8_t valid_sats; @@ -137,6 +144,12 @@ public: ar& BOOST_SERIALIZATION_NVP(user_clk_drift_ppm); ar& BOOST_SERIALIZATION_NVP(utc_time); + + ar& BOOST_SERIALIZATION_NVP(vel_e); + ar& BOOST_SERIALIZATION_NVP(vel_n); + ar& BOOST_SERIALIZATION_NVP(vel_u); + + ar& BOOST_SERIALIZATION_NVP(cog); } }; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index a3a7b8ac6..2f9f5d9e1 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -1598,7 +1598,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ ecef2pos(pvt_sol.rr, pos.data()); ecef2enu(pos.data(), &pvt_sol.rr[3], enuv.data()); this->set_speed_over_ground(norm_rtk(enuv.data(), 2)); - double new_cog; + double new_cog = -9999.0; // COG not estimated due to insuficient velocity if (ground_speed_ms >= 1.0) { new_cog = atan2(enuv[0], enuv[1]) * R2D; @@ -1680,6 +1680,14 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ this->set_rx_vel({enuv[0], enuv[1], enuv[2]}); + // ENU vel [m/s] + d_monitor_pvt.vel_e = enuv[0]; + d_monitor_pvt.vel_n = enuv[1]; + d_monitor_pvt.vel_u = enuv[2]; + + // Course Over Ground (cog) [deg] + d_monitor_pvt.cog = new_cog; + const double clock_drift_ppm = pvt_sol.dtr[5] / SPEED_OF_LIGHT_M_S * 1e6; this->set_clock_drift_ppm(clock_drift_ppm); diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index 5d22f8519..4eed61843 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -113,7 +113,10 @@ public: monitor_.set_vdop(monitor->vdop); monitor_.set_user_clk_drift_ppm(monitor->user_clk_drift_ppm); monitor_.set_utc_time(monitor->utc_time); - + monitor_.set_vel_e(monitor->vel_e); + monitor_.set_vel_n(monitor->vel_n); + monitor_.set_vel_u(monitor->vel_u); + monitor_.set_cog(monitor->cog); monitor_.SerializeToString(&data); return data; } @@ -152,6 +155,10 @@ public: monitor.vdop = mon.vdop(); monitor.user_clk_drift_ppm = mon.user_clk_drift_ppm(); monitor.utc_time = mon.utc_time(); + monitor.vel_e = mon.vel_e(); + monitor.vel_n = mon.vel_n(); + monitor.vel_u = mon.vel_u(); + monitor.cog = mon.cog(); return monitor; } From b971b61eed8192a7dc91110453dee8677ef10112 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Sat, 30 Sep 2023 14:48:04 +0200 Subject: [PATCH 019/142] Adding standard UNIX/POSIX signals listener. GNSS-SDR now can be safely stopped using CTL+C --- src/core/receiver/control_thread.cc | 40 +++++++++++++++++++++++++++++ src/core/receiver/control_thread.h | 7 +++++ 2 files changed, 47 insertions(+) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 18da0e6b0..1816e4d38 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -78,9 +78,49 @@ namespace wht = std; extern Concurrent_Map global_gps_acq_assist_map; extern Concurrent_Queue global_gps_acq_assist_queue; +ControlThread* ControlThread::me=nullptr; + + +/** + * \brief Callback function for handling signals. + * \param sig identifier of signal + */ +void ControlThread::handle_signal(int sig) +{ + if (sig == SIGINT) + { + std::cout << "Stopping GNSS-SDR via SIGINT...\n"; + + ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); + ControlThread::me->stop_ = true; + + /* Reset signal handling to default behavior */ + signal(SIGINT, SIG_DFL); + } + else if (sig == SIGHUP) + { + + std::cout << "Debug: received SIGHUP signal\n"; + //std::cout << "Debug: reloading daemon config file ...\n"; + //todo + } + else if (sig == SIGCHLD) + { + std::cout << "Debug: received SIGCHLD signal\n"; + //todo + } +} + ControlThread::ControlThread() { + + ControlThread::me=this; + + /* the class will handle two signals */ + signal(SIGINT, ControlThread::handle_signal); + signal(SIGHUP, ControlThread::handle_signal); + if (FLAGS_c == "-") { configuration_ = std::make_shared(FLAGS_config_file); diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 12f6fbc49..37fca1421 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -37,6 +37,7 @@ #include // for std::type_info, typeid #include // for pair #include // for vector +#include #ifdef ENABLE_FPGA #include // for boost::thread @@ -54,6 +55,7 @@ class ConfigurationInterface; class GNSSFlowgraph; class Gnss_Satellite; + /*! * \brief This class represents the main thread of the application, so the name is ControlThread. * This is the GNSS Receiver Control Plane: it connects the flowgraph, starts running it, @@ -63,6 +65,8 @@ class Gnss_Satellite; class ControlThread { public: + + static ControlThread* me; /*! * \brief Default constructor */ @@ -122,6 +126,9 @@ public: } private: + + static void handle_signal(int sig); + void init(); void apply_action(unsigned int what); From d487e4ce2cb59115d372f8c98c7546f14c8ce88f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 1 Oct 2023 09:03:14 +0200 Subject: [PATCH 020/142] Update changelog, fix formatting defects and typos --- docs/CHANGELOG.md | 10 ++++++++-- docs/protobuf/monitor_pvt.proto | 6 +++--- src/core/receiver/control_thread.cc | 15 +++++++-------- src/core/receiver/control_thread.h | 5 +---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0d97548fc..c56d240b6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -16,8 +16,11 @@ All notable changes to GNSS-SDR will be documented in this file. ### Improvements in Interoperability: -- A new field `utc_time` (a [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) - datetime string) with the Time solution has been added to `monitor_pvt.proto`. +- New fields have been added to the custom output stream defined by + `monitor_pvt.proto`: `utc_time` (a + [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) datetime string), velocity + in the local ENU frame (`vel_e`, `vel_n`, and `vel_u`), in m/s, and the course + over ground, `cog`, in degrees. ### Improvements in Repeatability: @@ -42,6 +45,9 @@ All notable changes to GNSS-SDR will be documented in this file. - Fix bug in the custom binary output (`PVT.enable_monitor=true`) output rate. Before this fix, it was outputting data every 20 ms, instead of observing the `PVT.output_rate_ms` setting. +- Now the program exits properly if a SIGINT signal is received (_e.g._, the + user pressing Ctrl+C, or another user application sending an interruption + signal). ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 diff --git a/docs/protobuf/monitor_pvt.proto b/docs/protobuf/monitor_pvt.proto index cfd855607..f5037ce99 100644 --- a/docs/protobuf/monitor_pvt.proto +++ b/docs/protobuf/monitor_pvt.proto @@ -44,9 +44,9 @@ double vdop = 28; // Vertical Dilution of Precision double user_clk_drift_ppm = 29; // User clock drift [ppm] string utc_time = 30; // PVT UTC time (rfc 3339 datetime string) -double vel_e = 31; // Velocity East component in Local frame, in m/s -double vel_n = 32; // Velocity Nord component in Local frame, in m/s -double vel_u = 33; // Velocity Up component in Local frame, in m/s +double vel_e = 31; // Velocity East component in the local frame, in m/s +double vel_n = 32; // Velocity North component in the local frame, in m/s +double vel_u = 33; // Velocity Up component in the local frame, in m/s double cog = 34; // Course Over Ground (cog) [deg] } diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 1816e4d38..371fb1776 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -55,6 +55,7 @@ #include // for find, min #include // for milliseconds #include // for floor, fmod, log +#include // for signal, SIGINT #include // for time_t, gmtime, strftime #include // for exception #include // for operator<< @@ -78,7 +79,7 @@ namespace wht = std; extern Concurrent_Map global_gps_acq_assist_map; extern Concurrent_Queue global_gps_acq_assist_queue; -ControlThread* ControlThread::me=nullptr; +ControlThread *ControlThread::me = nullptr; /** @@ -99,23 +100,21 @@ void ControlThread::handle_signal(int sig) } else if (sig == SIGHUP) { - - std::cout << "Debug: received SIGHUP signal\n"; - //std::cout << "Debug: reloading daemon config file ...\n"; - //todo + std::cout << "Debug: received SIGHUP signal\n"; + // std::cout << "Debug: reloading daemon config file ...\n"; + // todo } else if (sig == SIGCHLD) { std::cout << "Debug: received SIGCHLD signal\n"; - //todo + // todo } } ControlThread::ControlThread() { - - ControlThread::me=this; + ControlThread::me = this; /* the class will handle two signals */ signal(SIGINT, ControlThread::handle_signal); diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 37fca1421..217ad28bb 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -37,7 +37,6 @@ #include // for std::type_info, typeid #include // for pair #include // for vector -#include #ifdef ENABLE_FPGA #include // for boost::thread @@ -65,8 +64,7 @@ class Gnss_Satellite; class ControlThread { public: - - static ControlThread* me; + static ControlThread *me; /*! * \brief Default constructor */ @@ -126,7 +124,6 @@ public: } private: - static void handle_signal(int sig); void init(); From 8019f067e6c85182b3c029efac5f89e823d2c734 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 2 Oct 2023 10:23:58 +0200 Subject: [PATCH 021/142] Adding Galileo HAS status output to PVT monitor --- docs/protobuf/monitor_pvt.proto | 2 ++ src/algorithms/PVT/libs/monitor_pvt.h | 3 +++ src/algorithms/PVT/libs/rtklib_solver.cc | 10 ++++++++++ src/algorithms/PVT/libs/serdes_monitor_pvt.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/docs/protobuf/monitor_pvt.proto b/docs/protobuf/monitor_pvt.proto index f5037ce99..3e8e46df9 100644 --- a/docs/protobuf/monitor_pvt.proto +++ b/docs/protobuf/monitor_pvt.proto @@ -49,4 +49,6 @@ double vel_n = 32; // Velocity North component in the local frame, in m/s double vel_u = 33; // Velocity Up component in the local frame, in m/s double cog = 34; // Course Over Ground (cog) [deg] + +uint32 galhas_status = 35; // Galileo HAS status: 1- HAS messages decoded and applied, 0 - HAS not avaliable } diff --git a/src/algorithms/PVT/libs/monitor_pvt.h b/src/algorithms/PVT/libs/monitor_pvt.h index 8526a5191..97be9e0a4 100644 --- a/src/algorithms/PVT/libs/monitor_pvt.h +++ b/src/algorithms/PVT/libs/monitor_pvt.h @@ -72,6 +72,9 @@ public: // Course Over Ground (COG) [deg] double cog; + // Galileo HAS status: 1- HAS messages decoded and applied, 0 - HAS not avaliable + uint32_t galhas_status; + // NUMBER OF VALID SATS uint8_t valid_sats; // RTKLIB solution status diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 2f9f5d9e1..faf8af5f0 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -1688,6 +1688,16 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // Course Over Ground (cog) [deg] d_monitor_pvt.cog = new_cog; + // Galileo HAS status: 1- HAS messages decoded and applied, 0 - HAS not avaliable + if (d_has_obs_corr_map.empty()) + { + d_monitor_pvt.galhas_status = 0; + } + else + { + d_monitor_pvt.galhas_status = 1; + } + const double clock_drift_ppm = pvt_sol.dtr[5] / SPEED_OF_LIGHT_M_S * 1e6; this->set_clock_drift_ppm(clock_drift_ppm); diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index 4eed61843..e03d06b72 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -117,6 +117,7 @@ public: monitor_.set_vel_n(monitor->vel_n); monitor_.set_vel_u(monitor->vel_u); monitor_.set_cog(monitor->cog); + monitor_.set_galhas_status(monitor->galhas_status); monitor_.SerializeToString(&data); return data; } @@ -159,6 +160,7 @@ public: monitor.vel_n = mon.vel_n(); monitor.vel_u = mon.vel_u(); monitor.cog = mon.cog(); + monitor.galhas_status = mon.galhas_status(); return monitor; } From 145db1faa855663bba6e29a19f0581e8ff3dc8d2 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 2 Oct 2023 10:25:10 +0200 Subject: [PATCH 022/142] Write in INFO log file the OS signals received by gnss-sdr at runtime --- src/core/receiver/control_thread.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 371fb1776..9e954bb3f 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -88,6 +88,7 @@ ControlThread *ControlThread::me = nullptr; */ void ControlThread::handle_signal(int sig) { + DLOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; if (sig == SIGINT) { std::cout << "Stopping GNSS-SDR via SIGINT...\n"; From 59d70eb338158b9e399a96c01e5a8ae9ad2aa8d8 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 2 Oct 2023 17:24:03 +0200 Subject: [PATCH 023/142] Bug fix: increase the clock channel buffer capacity to prevent in some real-time configurations eliminate valid satellite observations --- .../observables/gnuradio_blocks/hybrid_observables_gs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index c6541efa1..d32f0ba68 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -93,7 +93,7 @@ hybrid_observables_gs::hybrid_observables_gs(const Obs_Conf &conf_) d_gnss_synchro_history = std::make_unique>(1000, d_nchannels_out); - d_Rx_clock_buffer.set_capacity(std::min(std::max(200U / d_T_rx_step_ms, 3U), 10U)); + d_Rx_clock_buffer.set_capacity(std::min(std::max(300U / d_T_rx_step_ms, 3U), 20U)); d_Rx_clock_buffer.clear(); d_channel_last_pll_lock = std::vector(d_nchannels_out, false); From 559e570cbc29517ae2d06c4657ebdf349aeabff7 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 3 Oct 2023 11:02:05 +0200 Subject: [PATCH 024/142] Add SIGTERM to control_thread signal handler --- src/core/receiver/control_thread.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 9e954bb3f..02a9b8124 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -89,15 +89,15 @@ ControlThread *ControlThread::me = nullptr; void ControlThread::handle_signal(int sig) { DLOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; - if (sig == SIGINT) + if (sig == SIGINT || sig == SIGTERM) { - std::cout << "Stopping GNSS-SDR via SIGINT...\n"; + std::cout << "Stopping GNSS-SDR via SIGINT or SIGTERM...\n"; ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); ControlThread::me->stop_ = true; /* Reset signal handling to default behavior */ - signal(SIGINT, SIG_DFL); + if (sig == SIGINT) signal(SIGINT, SIG_DFL); } else if (sig == SIGHUP) { @@ -117,8 +117,9 @@ ControlThread::ControlThread() { ControlThread::me = this; - /* the class will handle two signals */ + /* the class will handle signals */ signal(SIGINT, ControlThread::handle_signal); + signal(SIGTERM, ControlThread::handle_signal); signal(SIGHUP, ControlThread::handle_signal); if (FLAGS_c == "-") From 3474c9d8acb58789d7e661d7b220f934f0bd2e58 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 3 Oct 2023 11:23:11 +0200 Subject: [PATCH 025/142] Adding receiver stop action triggered by the SIGHUP signal --- src/core/receiver/control_thread.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 02a9b8124..8c581986f 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -88,8 +88,8 @@ ControlThread *ControlThread::me = nullptr; */ void ControlThread::handle_signal(int sig) { - DLOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; - if (sig == SIGINT || sig == SIGTERM) + LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; + if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) { std::cout << "Stopping GNSS-SDR via SIGINT or SIGTERM...\n"; @@ -99,15 +99,9 @@ void ControlThread::handle_signal(int sig) /* Reset signal handling to default behavior */ if (sig == SIGINT) signal(SIGINT, SIG_DFL); } - else if (sig == SIGHUP) - { - std::cout << "Debug: received SIGHUP signal\n"; - // std::cout << "Debug: reloading daemon config file ...\n"; - // todo - } else if (sig == SIGCHLD) { - std::cout << "Debug: received SIGCHLD signal\n"; + LOG(INFO) << "received SIGCHLD signal"; // todo } } From 99952f62753fd3d108b455696b9d88704b2114a9 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 3 Oct 2023 12:41:22 +0200 Subject: [PATCH 026/142] Adding PVT flag to enable or disable the log INFO position geohash output --- docs/CHANGELOG.md | 3 ++- src/algorithms/PVT/adapters/rtklib_pvt.cc | 3 +++ .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 16 ++++++++++------ .../PVT/gnuradio_blocks/rtklib_pvt_gs.h | 1 + src/algorithms/PVT/libs/pvt_conf.h | 1 + 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c56d240b6..bdf31d228 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,7 +15,8 @@ All notable changes to GNSS-SDR will be documented in this file. ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) ### Improvements in Interoperability: - +- Added a new PVT configuration boolean flag (`flag_geohash_log_out`) that enables or disables the + Position Geohash tag output in INFO log files. Set to `false` by default. - New fields have been added to the custom output stream defined by `monitor_pvt.proto`: `utc_time` (a [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) datetime string), velocity diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 9bf6174ab..a831ea2b2 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -74,6 +74,9 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, // display rate pvt_output_parameters.display_rate_ms = bc::lcm(pvt_output_parameters.output_rate_ms, configuration->property(role + ".display_rate_ms", 500)); + // log options + pvt_output_parameters.flag_geohash_log_out = configuration->property(role + ".flag_geohash_log_out", false); + // PVT KF settings pvt_output_parameters.enable_pvt_kf = configuration->property(role + ".enable_pvt_kf", false); pvt_output_parameters.measures_ecef_pos_sd_m = configuration->property(role + ".kf_measures_ecef_pos_sd_m", 1.0); diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index f39ff0867..b692fbea8 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -179,7 +179,8 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, d_an_printer_enabled(conf_.an_output_enabled), d_log_timetag(conf_.log_source_timetag), d_use_has_corrections(conf_.use_has_corrections), - d_use_unhealthy_sats(conf_.use_unhealthy_sats) + d_use_unhealthy_sats(conf_.use_unhealthy_sats), + d_flag_geohash_log_out(conf_.flag_geohash_log_out) { // Send feedback message to observables block with the receiver clock offset this->message_port_register_out(pmt::mp("pvt_to_observables")); @@ -2427,14 +2428,17 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // p_time += boost::posix_time::microseconds(round(rtklib_utc_time.sec * 1e6)); // std::cout << TEXT_MAGENTA << "Observable RX time (GPST) " << boost::posix_time::to_simple_string(p_time) << TEXT_RESET << '\n'; - LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) - << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() - << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; - LOG(INFO) << "geohash=" << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); - /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) + if (d_flag_geohash_log_out == true) + { + LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) + << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() + << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; + LOG(INFO) << "geohash=" << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); + /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " << d_user_pvt_solver->get_vdop() << " GDOP = " << d_user_pvt_solver->get_gdop() << '\n'; */ + } } // PVT MONITOR diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h index 83d1f830d..f6ad8b117 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h @@ -278,6 +278,7 @@ private: bool d_log_timetag; bool d_use_has_corrections; bool d_use_unhealthy_sats; + bool d_flag_geohash_log_out; }; diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index bf4a3501a..ce4c8d7ac 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -70,6 +70,7 @@ public: uint16_t rtcm_tcp_port = 0; uint16_t rtcm_station_id = 0; + bool flag_geohash_log_out = false; bool flag_nmea_tty_port = false; bool flag_rtcm_server = false; bool flag_rtcm_tty_port = false; From 757414dc9e8c61aa8a3658f956e1d713f271fcf2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 12:52:14 +0200 Subject: [PATCH 027/142] Add geohash to monitor_pvt and remove it from logs --- docs/protobuf/monitor_pvt.proto | 71 ++++++++++--------- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 3 +- src/algorithms/PVT/libs/monitor_pvt.h | 2 + src/algorithms/PVT/libs/serdes_monitor_pvt.h | 3 + 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/docs/protobuf/monitor_pvt.proto b/docs/protobuf/monitor_pvt.proto index 3e8e46df9..9b297bae7 100644 --- a/docs/protobuf/monitor_pvt.proto +++ b/docs/protobuf/monitor_pvt.proto @@ -7,48 +7,49 @@ package gnss_sdr; /* MonitorPvt represents a search query, with pagination options to * indicate which results to include in the response. */ message MonitorPvt { -uint32 tow_at_current_symbol_ms = 1; // Time of week of the current symbol, in ms -uint32 week = 2; // PVT GPS week -double rx_time = 3; // PVT GPS time -double user_clk_offset = 4; // User clock offset, in s + uint32 tow_at_current_symbol_ms = 1; // Time of week of the current symbol, in ms + uint32 week = 2; // PVT GPS week + double rx_time = 3; // PVT GPS time + double user_clk_offset = 4; // User clock offset, in s -double pos_x = 5; // Position X component in ECEF, expressed in m -double pos_y = 6; // Position Y component in ECEF, expressed in m -double pos_z = 7; // Position Z component in ECEF, expressed in m -double vel_x = 8; // Velocity X component in ECEF, in m/s -double vel_y = 9; // Velocity Y component in ECEF, in m/s -double vel_z = 10; // Velocity Z component in ECEF, in m/s + double pos_x = 5; // Position X component in ECEF, expressed in m + double pos_y = 6; // Position Y component in ECEF, expressed in m + double pos_z = 7; // Position Z component in ECEF, expressed in m + double vel_x = 8; // Velocity X component in ECEF, in m/s + double vel_y = 9; // Velocity Y component in ECEF, in m/s + double vel_z = 10; // Velocity Z component in ECEF, in m/s -double cov_xx = 11; // Position variance in the Y component, in m2 -double cov_yy = 12; // Position variance in the Y component, in m2 -double cov_zz = 13; // Position variance in the Z component, in m2 -double cov_xy = 14; // Position XY covariance, in m2 -double cov_yz = 15; // Position YZ covariance, in m2 -double cov_zx = 16; // Position ZX covariance, in m2 + double cov_xx = 11; // Position variance in the Y component, in m2 + double cov_yy = 12; // Position variance in the Y component, in m2 + double cov_zz = 13; // Position variance in the Z component, in m2 + double cov_xy = 14; // Position XY covariance, in m2 + double cov_yz = 15; // Position YZ covariance, in m2 + double cov_zx = 16; // Position ZX covariance, in m2 -double latitude = 17; // Latitude, in deg. Positive: North -double longitude = 18; // Longitude, in deg. Positive: East -double height = 19; // Height, in m + double latitude = 17; // Latitude, in deg. Positive: North + double longitude = 18; // Longitude, in deg. Positive: East + double height = 19; // Height, in m -uint32 valid_sats = 20; // Number of valid satellites -uint32 solution_status = 21; // RTKLIB solution status -uint32 solution_type = 22; // RTKLIB solution type (0: xyz-ecef, 1: enu-baseline) -float ar_ratio_factor = 23; // Ambiguity resolution ratio factor for validation -float ar_ratio_threshold = 24; // Ambiguity resolution ratio threshold for validation + uint32 valid_sats = 20; // Number of valid satellites + uint32 solution_status = 21; // RTKLIB solution status + uint32 solution_type = 22; // RTKLIB solution type (0: xyz-ecef, 1: enu-baseline) + float ar_ratio_factor = 23; // Ambiguity resolution ratio factor for validation + float ar_ratio_threshold = 24; // Ambiguity resolution ratio threshold for validation -double gdop = 25; // Geometric Dilution of Precision -double pdop = 26; // Position (3D) Dilution of Precision -double hdop = 27; // Horizontal Dilution of Precision -double vdop = 28; // Vertical Dilution of Precision + double gdop = 25; // Geometric Dilution of Precision + double pdop = 26; // Position (3D) Dilution of Precision + double hdop = 27; // Horizontal Dilution of Precision + double vdop = 28; // Vertical Dilution of Precision -double user_clk_drift_ppm = 29; // User clock drift [ppm] -string utc_time = 30; // PVT UTC time (rfc 3339 datetime string) + double user_clk_drift_ppm = 29; // User clock drift [ppm] + string utc_time = 30; // PVT UTC time (rfc 3339 datetime string) -double vel_e = 31; // Velocity East component in the local frame, in m/s -double vel_n = 32; // Velocity North component in the local frame, in m/s -double vel_u = 33; // Velocity Up component in the local frame, in m/s + double vel_e = 31; // Velocity East component in the local frame, in m/s + double vel_n = 32; // Velocity North component in the local frame, in m/s + double vel_u = 33; // Velocity Up component in the local frame, in m/s -double cog = 34; // Course Over Ground (cog) [deg] + double cog = 34; // Course Over Ground, in deg -uint32 galhas_status = 35; // Galileo HAS status: 1- HAS messages decoded and applied, 0 - HAS not avaliable + uint32 galhas_status = 35; // Galileo HAS status: 1- HAS messages decoded and applied, 0 - HAS not available + string geohash = 36; // Encoded geographic location. See https://en.wikipedia.org/wiki/Geohash } diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index f39ff0867..61847b705 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2430,7 +2430,6 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; - LOG(INFO) << "geohash=" << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " << d_user_pvt_solver->get_vdop() @@ -2441,7 +2440,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item if (d_user_pvt_solver->is_valid_position() && flag_compute_pvt_output == true) { const std::shared_ptr monitor_pvt = std::make_shared(d_user_pvt_solver->get_monitor_pvt()); - + monitor_pvt->geohash = d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); // publish new position to the gnss_flowgraph channel status monitor if (current_RX_time_ms % d_report_rate_ms == 0) { diff --git a/src/algorithms/PVT/libs/monitor_pvt.h b/src/algorithms/PVT/libs/monitor_pvt.h index 97be9e0a4..e70f681de 100644 --- a/src/algorithms/PVT/libs/monitor_pvt.h +++ b/src/algorithms/PVT/libs/monitor_pvt.h @@ -98,6 +98,7 @@ public: // PVT UTC Time (rfc 3339 datetime string) std::string utc_time; + std::string geohash; // See https://en.wikipedia.org/wiki/Geohash /*! * \brief This member function serializes and restores @@ -153,6 +154,7 @@ public: ar& BOOST_SERIALIZATION_NVP(vel_u); ar& BOOST_SERIALIZATION_NVP(cog); + ar& BOOST_SERIALIZATION_NVP(geohash); } }; diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index e03d06b72..f7ac8e72e 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -118,6 +118,8 @@ public: monitor_.set_vel_u(monitor->vel_u); monitor_.set_cog(monitor->cog); monitor_.set_galhas_status(monitor->galhas_status); + monitor_.set_geohash(monitor->geohash); + monitor_.SerializeToString(&data); return data; } @@ -161,6 +163,7 @@ public: monitor.vel_u = mon.vel_u(); monitor.cog = mon.cog(); monitor.galhas_status = mon.galhas_status(); + monitor.geohash = mon.geohash(); return monitor; } From 8d1ef54c65a28881211d507b281d035e5422b866 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 13:50:46 +0200 Subject: [PATCH 028/142] Update CHANGELOG --- docs/CHANGELOG.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index bdf31d228..160083a7a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,13 +15,21 @@ All notable changes to GNSS-SDR will be documented in this file. ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) ### Improvements in Interoperability: -- Added a new PVT configuration boolean flag (`flag_geohash_log_out`) that enables or disables the - Position Geohash tag output in INFO log files. Set to `false` by default. + +- Added a new PVT configuration boolean flag (`flag_geohash_log_out`) that + enables or disables the Position Geohash tag output in INFO log files. Set to + `false` by default. - New fields have been added to the custom output stream defined by - `monitor_pvt.proto`: `utc_time` (a - [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) datetime string), velocity - in the local ENU frame (`vel_e`, `vel_n`, and `vel_u`), in m/s, and the course - over ground, `cog`, in degrees. + `monitor_pvt.proto`: + - `utc_time` (a [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) datetime + string), + - velocity in the local ENU frame (`vel_e`, `vel_n`, and `vel_u`), in m/s, + - the course over ground, `cog`, in degrees, + - the status of the Galileo's High Accuracy Service, `galhas_status`: + - 0: HAS data not available + - 1: HAS Corrections applied + - `geohash`, an + [encoded geographic location](https://en.wikipedia.org/wiki/Geohash). ### Improvements in Repeatability: From 7eb6459bc4493f01dc553f3adf9afcb063a984f6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 14:23:56 +0200 Subject: [PATCH 029/142] Fix wrong commit --- src/algorithms/PVT/adapters/rtklib_pvt.cc | 3 --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 17 ++++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index a831ea2b2..9bf6174ab 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -74,9 +74,6 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, // display rate pvt_output_parameters.display_rate_ms = bc::lcm(pvt_output_parameters.output_rate_ms, configuration->property(role + ".display_rate_ms", 500)); - // log options - pvt_output_parameters.flag_geohash_log_out = configuration->property(role + ".flag_geohash_log_out", false); - // PVT KF settings pvt_output_parameters.enable_pvt_kf = configuration->property(role + ".enable_pvt_kf", false); pvt_output_parameters.measures_ecef_pos_sd_m = configuration->property(role + ".kf_measures_ecef_pos_sd_m", 1.0); diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 1e168a013..050e474e8 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2427,15 +2427,14 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // p_time += boost::posix_time::microseconds(round(rtklib_utc_time.sec * 1e6)); // std::cout << TEXT_MAGENTA << "Observable RX time (GPST) " << boost::posix_time::to_simple_string(p_time) << TEXT_RESET << '\n'; - DLOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) - << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() - << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; - - /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) - << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " - << d_user_pvt_solver->get_vdop() - << " GDOP = " << d_user_pvt_solver->get_gdop() << '\n'; */ - } + DLOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) + << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() + << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; + + /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) + << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " + << d_user_pvt_solver->get_vdop() + << " GDOP = " << d_user_pvt_solver->get_gdop() << '\n'; */ } // PVT MONITOR From 7d091afc263dd2bf7cf13321223548db77cda658 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 14:30:08 +0200 Subject: [PATCH 030/142] Bump max CMake version to 3.27 and PugiXML local version to 1.14 --- CMakeLists.txt | 11 +++++++++-- .../volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c17bfdea4..81f15e3b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # Build type can still be overridden by setting -DCMAKE_BUILD_TYPE= set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") -cmake_minimum_required(VERSION 2.8.12...3.26) +cmake_minimum_required(VERSION 2.8.12...3.27) project(gnss-sdr CXX C) set(GNSSSDR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Allows to be a sub-project @@ -340,7 +340,7 @@ set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.4") -set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") +set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.0.0") @@ -361,6 +361,13 @@ if(CMAKE_VERSION VERSION_LESS "3.0.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.4") # Fix for Ubuntu 14.04 endif() +if(CMAKE_VERSION VERSION_LESS "3.5") + set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") +endif() +if(CMAKE_VERSION VERSION_LESS "3.4") + set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.10") +endif() + if(CMAKE_CROSSCOMPILING OR CMAKE_VERSION VERSION_LESS "3.13") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.12") endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 0a668f741..4235cb586 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -8,7 +8,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.8.12...3.26) +cmake_minimum_required(VERSION 2.8.12...3.27) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) From b16c1de541b38d8dcd3cfb61e29fcf1b0affcd9d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 15:11:21 +0200 Subject: [PATCH 031/142] Fix breaking change in CMake 3.27: PythonInterp was removed --- CMakeLists.txt | 2 +- cmake/Modules/SetupPython.cmake | 4 +++- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 14 ++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81f15e3b6..56aeda777 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1116,7 +1116,7 @@ if(NOT VOLKGNSSSDR_FOUND) endif() endif() - if(PYTHONINTERP_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.27 AND PYTHONINTERP_FOUND) set_package_properties(PythonInterp PROPERTIES URL "https://www.python.org/" DESCRIPTION "An interpreted, high-level, general-purpose programming language (found: v${PYTHON_VERSION_STRING})" diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index 2260357ce..e203e21df 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -97,7 +97,9 @@ else() endif() if(NOT MAKO_FOUND OR NOT SIX_FOUND) unset(PYTHON_EXECUTABLE) - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION}) + if(CMAKE_VERSION VERSION_LESS 3.27) + find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION}) + endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) if(PYTHON_VERSION_STRING VERSION_LESS "3.0") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 2fc0819b7..8d724a2c0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -71,7 +71,9 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) else() if(PYTHON_EXECUTABLE) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") - find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.27") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(PYTHON_VERSION_STRING VERSION_LESS "3.0") volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) @@ -102,15 +104,19 @@ else() endif() if(NOT MAKO_FOUND OR NOT SIX_FOUND) unset(PYTHON_EXECUTABLE) - find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + if(CMAKE_VERSION VERSION_LESS "3.27") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() endif() endif() endif() -if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) - set(PYTHON3 TRUE) +if(CMAKE_VERSION VERSION_LESS "3.27") + if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) + set(PYTHON3 TRUE) + endif() endif() From 9b5739603a83ebef8ab726585fec2c36c520453e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 17:19:22 +0200 Subject: [PATCH 032/142] CI: Make clang-tidy happy --- src/core/receiver/control_thread.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 8c581986f..00ebe5129 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -91,17 +91,18 @@ void ControlThread::handle_signal(int sig) LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) { - std::cout << "Stopping GNSS-SDR via SIGINT or SIGTERM...\n"; - ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); ControlThread::me->stop_ = true; - /* Reset signal handling to default behavior */ - if (sig == SIGINT) signal(SIGINT, SIG_DFL); + // Reset signal handling to default behavior + if (sig == SIGINT) + { + signal(SIGINT, SIG_DFL); + } } else if (sig == SIGCHLD) { - LOG(INFO) << "received SIGCHLD signal"; + LOG(INFO) << "Received SIGCHLD signal"; // todo } } From 0da7fc67048b11915e6c80f3f138a66b8b666a98 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 17:25:06 +0200 Subject: [PATCH 033/142] More fixes for CMake 3.27 --- cmake/Modules/SetupPython.cmake | 24 +++++++++++++++---- .../cmake/Modules/VolkPython.cmake | 8 +++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index e203e21df..9cc71fc6c 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -60,10 +60,22 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) else() message(STATUS "PYTHON_EXECUTABLE not set - trying by default python3") set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9) - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN3_VERSION}) + if(CMAKE_VERSION VERSION_LESS "3.27") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") + endif() if(NOT PYTHONINTERP_FOUND) message(STATUS "python3 not found - trying with python2.7") - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.27") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + else() + find_package(Python2 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND) + set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") + endif() endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) @@ -97,8 +109,12 @@ else() endif() if(NOT MAKO_FOUND OR NOT SIX_FOUND) unset(PYTHON_EXECUTABLE) - if(CMAKE_VERSION VERSION_LESS 3.27) - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION}) + if(CMAKE_VERSION VERSION_LESS "3.27") + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 8d724a2c0..666346a36 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -73,6 +73,10 @@ else() message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") if(CMAKE_VERSION VERSION_LESS "3.27") find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(PYTHON_VERSION_STRING VERSION_LESS "3.0") @@ -106,6 +110,10 @@ else() unset(PYTHON_EXECUTABLE) if(CMAKE_VERSION VERSION_LESS "3.27") find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() From 707c7826fbeae69d68c7a12f6da2756f058bec04 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 17:47:13 +0200 Subject: [PATCH 034/142] Move signal handler after the constructor --- src/core/receiver/control_thread.cc | 49 +++++++++++++---------------- src/core/receiver/control_thread.h | 4 +++ 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 00ebe5129..a6791fd52 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -81,33 +81,6 @@ extern Concurrent_Queue global_gps_acq_assist_queue; ControlThread *ControlThread::me = nullptr; - -/** - * \brief Callback function for handling signals. - * \param sig identifier of signal - */ -void ControlThread::handle_signal(int sig) -{ - LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; - if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) - { - ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); - ControlThread::me->stop_ = true; - - // Reset signal handling to default behavior - if (sig == SIGINT) - { - signal(SIGINT, SIG_DFL); - } - } - else if (sig == SIGCHLD) - { - LOG(INFO) << "Received SIGCHLD signal"; - // todo - } -} - - ControlThread::ControlThread() { ControlThread::me = this; @@ -302,6 +275,28 @@ ControlThread::~ControlThread() // NOLINT(modernize-use-equals-default) } +void ControlThread::handle_signal(int sig) +{ + LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; + if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) + { + ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); + ControlThread::me->stop_ = true; + + // Reset signal handling to default behavior + if (sig == SIGINT) + { + signal(SIGINT, SIG_DFL); + } + } + else if (sig == SIGCHLD) + { + LOG(INFO) << "Received SIGCHLD signal"; + // todo + } +} + + void ControlThread::telecommand_listener() { if (telecommand_enabled_) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 217ad28bb..b3340e94b 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -124,6 +124,10 @@ public: } private: + /* + * Callback function for handling signals. + * sig identifier of signal + */ static void handle_signal(int sig); void init(); From 4149490bb6c3655fac22e1eeabeb9e5134eb52e0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 18:06:39 +0200 Subject: [PATCH 035/142] CI: Make cmakelint happy --- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 666346a36..a1fb57f74 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -72,7 +72,7 @@ else() if(PYTHON_EXECUTABLE) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") if(CMAKE_VERSION VERSION_LESS "3.27") - find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) else() find_package(Python COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) From d15422edba139702de44ebfcd5a70aeb0ab54816 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 7 Oct 2023 14:02:22 +0200 Subject: [PATCH 036/142] CMake: complete transition from FindPythonInterp to FindPython (FindPythonInterp was deprecated in CMake 3.24 and removed in CMake 3.27) --- cmake/Modules/SetupPython.cmake | 42 ++++++++++++++--- .../cmake/Modules/VolkPython.cmake | 47 +++++++++++++++---- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index 9cc71fc6c..b80994ee4 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -48,9 +48,25 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") string(FIND "${PYTHON_EXECUTABLE}" "python3" IS_PYTHON3) if(IS_PYTHON3 EQUAL -1) - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.24") + find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + else() + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + find_package(Python2 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND) + set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}") + set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") + endif() else() - find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.24") + find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) + else() + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + find_package(Python3 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python3_Interpreter_FOUND) + set(PYTHON_VERSION_MAJOR "${Python3_VERSION_MAJOR}") + set(PYTHON_VERSION_STRING "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") + endif() endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) @@ -59,21 +75,26 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) endif() else() message(STATUS "PYTHON_EXECUTABLE not set - trying by default python3") - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9) - if(CMAKE_VERSION VERSION_LESS "3.27") + if(CMAKE_VERSION VERSION_LESS "3.24") + set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11) find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) else() find_package(Python COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}") + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() if(NOT PYTHONINTERP_FOUND) message(STATUS "python3 not found - trying with python2.7") - if(CMAKE_VERSION VERSION_LESS "3.27") + if(CMAKE_VERSION VERSION_LESS "3.24") + set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11) find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) else() find_package(Python2 COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND) + set(PYTHON_EXECUTABLE "${Python2_EXECUTABLE}") + set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") endif() endif() @@ -88,13 +109,17 @@ else() set(_previous ${CMAKE_FIND_FRAMEWORK}) set(CMAKE_FIND_FRAMEWORK LAST) endif() + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() find_package(Python3 COMPONENTS Interpreter) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_FIND_FRAMEWORK ${_previous}) endif() if(Python3_FOUND) set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) - set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR}) + set(PYTHON_VERSION_MAJOR "${Python3_VERSION_MAJOR}") + set(PYTHON_VERSION_STRING "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) endif() @@ -103,18 +128,21 @@ else() if(Python2_FOUND) set(PYTHON_EXECUTABLE ${Python2_EXECUTABLE}) set(PYTHON_VERSION_MAJOR ${Python2_VERSION_MAJOR}) + set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) endif() if(NOT MAKO_FOUND OR NOT SIX_FOUND) unset(PYTHON_EXECUTABLE) - if(CMAKE_VERSION VERSION_LESS "3.27") + if(CMAKE_VERSION VERSION_LESS "3.24") find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) else() find_package(Python COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index a1fb57f74..6689c222e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -52,18 +52,42 @@ set(VOLK_PYTHON3_MIN_VERSION "3.4") if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) if(PYTHON_EXECUTABLE) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") - find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.24") # For cross-compiling + find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED) + else() + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") + endif() if(PYTHON_VERSION_STRING VERSION_LESS "3.0") volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) endif() else() message(STATUS "PYTHON_EXECUTABLE not set - trying by default python3") message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python to build for python 2.7") - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9) - find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION}) + if(CMAKE_VERSION VERSION_LESS "3.24") # For cross-compiling + set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11) + find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED) + else() + find_package(Python COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}") + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") + set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") + endif() if(NOT PYTHONINTERP_FOUND) message(STATUS "python3 not found - trying with python2.7") - find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.24") + find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED) + else() + find_package(Python2 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND) + set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}") + set(PYTHON_EXECUTABLE "${Python2_EXECUTABLE}") + set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") + endif() volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) endif() endif() @@ -71,11 +95,13 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) else() if(PYTHON_EXECUTABLE) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") - if(CMAKE_VERSION VERSION_LESS "3.27") + if(CMAKE_VERSION VERSION_LESS "3.24") find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED) else() + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) find_package(Python COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) @@ -108,11 +134,13 @@ else() endif() if(NOT MAKO_FOUND OR NOT SIX_FOUND) unset(PYTHON_EXECUTABLE) - if(CMAKE_VERSION VERSION_LESS "3.27") + if(CMAKE_VERSION VERSION_LESS "3.24") find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION}) else() find_package(Python COMPONENTS Interpreter) set(PYTHONINTERP_FOUND Python_Interpreter_FOUND) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}") + set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) @@ -121,13 +149,12 @@ else() endif() endif() -if(CMAKE_VERSION VERSION_LESS "3.27") - if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) - set(PYTHON3 TRUE) - endif() +if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) + set(PYTHON3 TRUE) endif() + ######################################################################## # Sets the python installation directory VOLK_PYTHON_DIR ######################################################################## From 12f363dbd0726cadcb037b0fffcae3c04fa1524c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 8 Oct 2023 09:41:12 +0200 Subject: [PATCH 037/142] Try hard to find python --- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 6689c222e..52bf6c61e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -143,6 +143,12 @@ else() set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() + if(NOT PYTHON_EXECUTABLE) + find_program(PYTHON_EXECUTABLE NAMES python3 python) + if(PYTHON_EXECUTABLE) + set(PYTHONINTERP_FOUND TRUE) + endif() + endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() endif() From e86047d12ed336710585f764123d209293ab6025 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 8 Oct 2023 09:49:32 +0200 Subject: [PATCH 038/142] Try hard to find python --- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 52bf6c61e..b435b5901 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -143,13 +143,14 @@ else() set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}") set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") endif() - if(NOT PYTHON_EXECUTABLE) + volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) + if(NOT MAKO_FOUND) find_program(PYTHON_EXECUTABLE NAMES python3 python) if(PYTHON_EXECUTABLE) set(PYTHONINTERP_FOUND TRUE) endif() + volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() - volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() endif() endif() From 30f624e548a7f7cb07fb24e01e9b21d6ebc5e5fb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 8 Oct 2023 10:26:47 +0200 Subject: [PATCH 039/142] Try hard to find python --- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index b435b5901..13b8a2759 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -145,6 +145,7 @@ else() endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(NOT MAKO_FOUND) + unset(PYTHON_EXECUTABLE) find_program(PYTHON_EXECUTABLE NAMES python3 python) if(PYTHON_EXECUTABLE) set(PYTHONINTERP_FOUND TRUE) From c47ad2d9023c75671219128d235eb920f26a8fad Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 13 Oct 2023 11:38:54 +0200 Subject: [PATCH 040/142] Try hard to find Python version --- cmake/Modules/SetupPython.cmake | 21 ++++++++++++++++++- .../cmake/Modules/VolkPython.cmake | 15 ++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index b80994ee4..2dc93b955 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -146,7 +146,26 @@ else() endif() gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) - if(PYTHON_VERSION_STRING VERSION_LESS "3.0") + if(NOT MAKO_FOUND) + unset(PYTHON_EXECUTABLE) + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + find_program(PYTHON_EXECUTABLE NAMES python3 python) + if(PYTHON_EXECUTABLE) + set(PYTHONINTERP_FOUND TRUE) + execute_process(COMMAND "${PYTHON_EXECUTABLE} --version" OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX) + string(FIND "${PYTHON_VERSION_STRING_AUX}" " " blank_char_index) + if(blank_char_index GREATER -1) + math(EXPR start_index "${blank_char_index} + 1") + string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} -1 PYTHON_VERSION_STRING) + string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING) + string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR) + message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})") + endif() + endif() + volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) + endif() + if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0") gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) endif() endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 13b8a2759..697fe8c3b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -146,11 +146,24 @@ else() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(NOT MAKO_FOUND) unset(PYTHON_EXECUTABLE) + unset(PYTHON_VERSION_STRING) find_program(PYTHON_EXECUTABLE NAMES python3 python) if(PYTHON_EXECUTABLE) set(PYTHONINTERP_FOUND TRUE) + execute_process(COMMAND ${PYTHON_EXECUTABLE} --version OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX) + string(FIND "${PYTHON_VERSION_STRING_AUX}" " " blank_char_index) + if(blank_char_index GREATER -1) + math(EXPR start_index "${blank_char_index} + 1") + string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} -1 PYTHON_VERSION_STRING) + string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING) + string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR) + message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})") + endif() + volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) + if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0") + gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + endif() endif() - volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() endif() endif() From 62a8547e62605a6b9fa6b1e128beceb046bde2dc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 15 Oct 2023 15:09:27 +0200 Subject: [PATCH 041/142] CI: Workaround for failing macos-based jobs --- .github/workflows/main.yml | 69 ++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26108abcf..ac057c239 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: build-ubuntu: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | sudo apt-get update -y @@ -39,14 +39,23 @@ jobs: build-macos: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | brew update - brew install --overwrite python@3.10 python@3.11 - python3.11 -m pip install mako - brew install ninja pkg-config hdf5 automake armadillo lapack \ + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true + brew install ninja hdf5 automake armadillo lapack \ gflags glog gnuradio log4cpp openssl pugixml protobuf + pip3 install mako - name: configure run: cd build && cmake -GNinja .. - name: build @@ -59,14 +68,23 @@ jobs: build-macos-xcode: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | brew update - brew install --overwrite python@3.10 python@3.11 - python3.11 -m pip install mako + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ gnuradio log4cpp openssl pugixml protobuf + pip3 install mako - name: configure run: cd build && cmake -GXcode .. - name: build @@ -87,7 +105,7 @@ jobs: clang-format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: run clang-format uses: jidicula/clang-format-action@v4.11.0 with: @@ -98,14 +116,23 @@ jobs: clang-tidy: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | brew update - brew install --overwrite python@3.10 python@3.11 - python3.11 -m pip install mako + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \ log4cpp openssl pugixml protobuf + pip3 install mako ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin ln -s $(brew --prefix llvm)/bin/clang-apply-replacements /usr/local/bin ln -s $(brew --prefix llvm)/bin/run-clang-tidy /usr/local/bin @@ -123,7 +150,7 @@ jobs: cpplint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: sudo apt-get install python3-pip && sudo pip3 install cpplint - name: run checks @@ -144,7 +171,7 @@ jobs: prettier-markdown: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: sudo npm install --global prettier - name: check markdown @@ -153,7 +180,7 @@ jobs: cmakelint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | sudo python -m pip install --upgrade pip @@ -164,7 +191,7 @@ jobs: volk-gnsssdr-windows: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 - name: Install dependencies run: | @@ -186,7 +213,7 @@ jobs: volk-gnsssdr-ubuntu: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: sudo apt install python3-mako liborc-dev - name: configure @@ -201,7 +228,7 @@ jobs: volk-gnsssdr-macos: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: pip3 install mako - name: configure @@ -214,7 +241,7 @@ jobs: volk-gnsssdr-macos-xcode: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: pip3 install mako - name: configure @@ -229,7 +256,7 @@ jobs: shellcheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: sudo apt install shellcheck - name: check scripts @@ -238,7 +265,7 @@ jobs: REUSE-compliance: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check REUSE compliance uses: docker://fsfe/reuse with: From 4a8f137dd9ab8771bcf502f7a169e8151320c847 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 15 Oct 2023 16:47:48 +0200 Subject: [PATCH 042/142] Fix wrong name in CMake module --- cmake/Modules/SetupPython.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index 2dc93b955..89e7bbc2d 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -163,7 +163,7 @@ else() message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})") endif() endif() - volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) + gnsssdr_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) endif() if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0") gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) From a1a683fc7b5d9084e7621ee23e6937770cedb856 Mon Sep 17 00:00:00 2001 From: Perrielornitorrinco Date: Mon, 16 Oct 2023 11:38:35 +0200 Subject: [PATCH 043/142] Update branch python --- src/utils/python/dll_pll_veml_plot_sample.py | 110 ++++++++ src/utils/python/gps_l1_ca_kf_plot_sample.py | 98 +++++++ .../python/gps_l1_ca_pvt_raw_plot_sample.py | 101 +++++++ .../python/gps_l1_ca_telemetry_plot_sample.py | 99 +++++++ .../python/hybrid_observables_plot_sample.py | 139 ++++++++++ .../lib/dll_pll_veml_read_tracking_dump.py | 222 +++++++++++++++ .../lib/gps_l1_ca_kf_read_tracking_dump.py | 225 +++++++++++++++ .../python/lib/gps_l1_ca_read_pvt_dump.py | 249 +++++++++++++++++ .../lib/gps_l1_ca_read_telemetry_dump.py | 86 ++++++ src/utils/python/lib/plotKalman.py | 140 ++++++++++ src/utils/python/lib/plotNavigation.py | 134 +++++++++ src/utils/python/lib/plotPosition.py | 208 ++++++++++++++ src/utils/python/lib/plotTracking.py | 190 +++++++++++++ src/utils/python/lib/plotVEMLTracking.py | 171 ++++++++++++ .../lib/read_hybrid_observables_dump.py | 112 ++++++++ src/utils/python/plot_acq_grid.py | 262 ++++++++++++++++++ .../plot_tracking_quality_indicators.py | 76 +++++ 17 files changed, 2622 insertions(+) create mode 100644 src/utils/python/dll_pll_veml_plot_sample.py create mode 100644 src/utils/python/gps_l1_ca_kf_plot_sample.py create mode 100644 src/utils/python/gps_l1_ca_pvt_raw_plot_sample.py create mode 100644 src/utils/python/gps_l1_ca_telemetry_plot_sample.py create mode 100644 src/utils/python/hybrid_observables_plot_sample.py create mode 100644 src/utils/python/lib/dll_pll_veml_read_tracking_dump.py create mode 100644 src/utils/python/lib/gps_l1_ca_kf_read_tracking_dump.py create mode 100644 src/utils/python/lib/gps_l1_ca_read_pvt_dump.py create mode 100644 src/utils/python/lib/gps_l1_ca_read_telemetry_dump.py create mode 100644 src/utils/python/lib/plotKalman.py create mode 100644 src/utils/python/lib/plotNavigation.py create mode 100644 src/utils/python/lib/plotPosition.py create mode 100644 src/utils/python/lib/plotTracking.py create mode 100644 src/utils/python/lib/plotVEMLTracking.py create mode 100644 src/utils/python/lib/read_hybrid_observables_dump.py create mode 100644 src/utils/python/plot_acq_grid.py create mode 100644 src/utils/python/plot_tracking_quality_indicators.py diff --git a/src/utils/python/dll_pll_veml_plot_sample.py b/src/utils/python/dll_pll_veml_plot_sample.py new file mode 100644 index 000000000..c7eac6a52 --- /dev/null +++ b/src/utils/python/dll_pll_veml_plot_sample.py @@ -0,0 +1,110 @@ +""" + dll_pll_veml_plot_sample.py + + Reads GNSS-SDR Tracking dump binary file using the provided function and + plots some internal variables + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + plot_last_outputs - If 0 -> process everything / number of items processed + channels - Number of channels + first_channel - Number of the first channel + doppler_opt - = 1 -> Plot // = 0 -> No plot + path - Path to folder which contains raw files + fig_path - Path where doppler plots will be save + 'trk_dump_ch' - Fixed part of the tracking dump files names + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import os +import numpy as np +import matplotlib.pyplot as plt +from lib.dll_pll_veml_read_tracking_dump import dll_pll_veml_read_tracking_dump +from lib.plotVEMLTracking import plotVEMLTracking + +trackResults = [] +settings = {} +GNSS_tracking = [] + +# ---------- CHANGE HERE: +sampling_freq = 3000000 +plot_last_outputs = 0 +channels = 5 +first_channel = 0 +doppler_opt = 1 +settings['numberOfChannels'] = channels + +path = '/home/labnav/Desktop/TEST_IRENE/tracking' +fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/Doppler' + +for N in range(1, channels+1): + tracking_log_path = os.path.join(path, + f'trk_dump_ch{N-1+first_channel}.dat') + GNSS_tracking.append(dll_pll_veml_read_tracking_dump(tracking_log_path)) + +# GNSS-SDR format conversion to Python GPS receiver +for N in range (1, channels+1): + if 0 < plot_last_outputs < len(GNSS_tracking[N - 1].get("code_freq_hz")): + start_sample = (len(GNSS_tracking[N-1].get("code_freq_hz")) - + plot_last_outputs) + else: + start_sample = 0 + + trackResult = { + 'status': 'T', # fake track + 'codeFreq': np.copy(GNSS_tracking[N-1]["code_freq_hz"][start_sample:]), + 'carrFreq': np.copy(GNSS_tracking[N-1]["carrier_doppler_hz"][start_sample:]), + 'dllDiscr': np.copy(GNSS_tracking[N-1]["code_error"][start_sample:]), + 'dllDiscrFilt': np.copy(GNSS_tracking[N-1]["code_nco"][start_sample:]), + 'pllDiscr': np.copy(GNSS_tracking[N-1]["carr_error"][start_sample:]), + 'pllDiscrFilt': np.copy(GNSS_tracking[N-1]["carr_nco"][start_sample:]), + + 'I_P': np.copy(GNSS_tracking[N-1]["P"][start_sample:]), + 'Q_P': np.zeros(len(GNSS_tracking[N-1]["P"][start_sample:])), + + 'I_VE': np.copy(GNSS_tracking[N-1]["VE"][start_sample:]), + 'I_E': np.copy(GNSS_tracking[N-1]["E"][start_sample:]), + 'I_L': np.copy(GNSS_tracking[N-1]["L"][start_sample:]), + 'I_VL': np.copy(GNSS_tracking[N-1]["VL"][start_sample:]), + 'Q_VE': np.zeros(len(GNSS_tracking[N-1]["VE"][start_sample:])), + 'Q_E': np.zeros(len(GNSS_tracking[N-1]["E"][start_sample:])), + 'Q_L': np.zeros(len(GNSS_tracking[N-1]["L"][start_sample:])), + 'Q_VL': np.zeros(len(GNSS_tracking[N-1]["VL"][start_sample:])), + 'data_I': np.copy(GNSS_tracking[N-1]["prompt_I"][start_sample:]), + 'data_Q': np.copy(GNSS_tracking[N-1]["prompt_Q"][start_sample:]), + 'PRN': np.copy(GNSS_tracking[N-1]["PRN"][start_sample:]), + 'CNo': np.copy(GNSS_tracking[N-1]["CN0_SNV_dB_Hz"][start_sample:]), + 'prn_start_time_s': np.copy(GNSS_tracking[N-1]["PRN_start_sample"] + [start_sample:]) / sampling_freq + } + trackResults.append(trackResult) + + # Plot results: + plotVEMLTracking(N,trackResults,settings) + + # Plot Doppler according to selected in doppler_opt variable: + if doppler_opt == 1: + if not os.path.exists(fig_path): + os.makedirs(fig_path) + + plt.figure() + plt.plot(trackResults[N - 1]['prn_start_time_s'], + [x/1000 for x in GNSS_tracking[N - 1]['carrier_doppler_hz'] + [start_sample:]]) + plt.xlabel('Time(s)') + plt.ylabel('Doppler(KHz)') + plt.title('Doppler frequency channel ' + str(N)) + + plt.savefig(os.path.join(fig_path, f'Doppler_freq_ch_{N}.png')) + plt.show() diff --git a/src/utils/python/gps_l1_ca_kf_plot_sample.py b/src/utils/python/gps_l1_ca_kf_plot_sample.py new file mode 100644 index 000000000..26e0f3287 --- /dev/null +++ b/src/utils/python/gps_l1_ca_kf_plot_sample.py @@ -0,0 +1,98 @@ +""" + gps_l1_ca_kf_plot_sample.py + + Reads GNSS-SDR Tracking dump binary file using the provided + function and plots some internal variables + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + channels - Number of channels to check if they exist + first_channel - Number of the first channel + path - Path to folder which contains raw file + 'trk_dump_ch' - Fixed part in tracking dump files names + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import os +import numpy as np +from lib.gps_l1_ca_kf_read_tracking_dump import gps_l1_ca_kf_read_tracking_dump +from lib.plotTracking import plotTracking +from lib.plotKalman import plotKalman + +GNSS_tracking = [] +trackResults = [] +kalmanResults = [] + +# ---------- CHANGE HERE: +# Signal parameters: +samplingFreq = 6625000 +channels = 5 +first_channel = 0 +code_period = 0.001 + +path = '/home/labnav/Desktop/TEST_IRENE/tracking' + +for N in range(1, channels + 1): + tracking_log_path = os.path.join(path, + f'trk_dump_ch{N-1+first_channel}.dat') + GNSS_tracking.append(gps_l1_ca_kf_read_tracking_dump(tracking_log_path)) + +# todo lee lo mismo que dll_pll_velm_plot_sample y guarda diferente v13 y v14 +# GNSS-SDR format conversion to Python GPS receiver +for N in range(1, channels + 1): + trackResult= { + 'status': 'T', # fake track + 'codeFreq': np.copy(GNSS_tracking[N - 1]["code_freq_hz"]), + 'carrFreq': np.copy(GNSS_tracking[N - 1]["carrier_doppler_hz"]), + 'carrFreqRate': + np.copy(GNSS_tracking[N - 1]["carrier_doppler_rate_hz2"]),#todo no se usa en dll, carrier_doppler_rate_hz_s segun dll + 'dllDiscr': np.copy(GNSS_tracking[N - 1]["code_error"]), + 'dllDiscrFilt': np.copy(GNSS_tracking[N - 1]["code_nco"]), + 'pllDiscr': np.copy(GNSS_tracking[N - 1]["carr_error"]),#todo code_freq_rate_hz_s segun dll + 'pllDiscrFilt': np.copy(GNSS_tracking[N - 1]["carr_nco"]), + + 'I_P': np.copy(GNSS_tracking[N - 1]["prompt_I"]),#todo distinto de dll + 'Q_P': np.copy(GNSS_tracking[N - 1]["prompt_Q"]),#todo distinto de dll + + 'I_E': np.copy(GNSS_tracking[N - 1]["E"]), + 'I_L': np.copy(GNSS_tracking[N - 1]["L"]), + 'Q_E': np.zeros(len(GNSS_tracking[N - 1]["E"])), + 'Q_L': np.zeros(len(GNSS_tracking[N - 1]["L"])), + 'PRN': np.copy(GNSS_tracking[N - 1]["PRN"]), + 'CNo': np.copy(GNSS_tracking[N - 1]["CN0_SNV_dB_Hz"]) + } + + kalmanResult= { + 'PRN': np.copy(GNSS_tracking[N - 1]["PRN"]), + 'innovation': np.copy(GNSS_tracking[N - 1]["carr_error"]),#todo code_freq_rate_hz_s segun dll + 'state1': np.copy(GNSS_tracking[N - 1]["carr_nco"]), + 'state2': np.copy(GNSS_tracking[N - 1]["carrier_doppler_hz"]), + 'state3': GNSS_tracking[N - 1]["carrier_doppler_rate_hz2"],#todo segun el dll es carrier_doppler_rate_hz_s + 'r_noise_cov': np.copy(GNSS_tracking[N - 1]["carr_noise_sigma2"]),#todo carr_error segun dll + 'CNo': np.copy(GNSS_tracking[N - 1]["CN0_SNV_dB_Hz"]) + } + + trackResults.append(trackResult) + kalmanResults.append(kalmanResult) + + settings = { + 'numberOfChannels': channels, + 'msToProcess': len(GNSS_tracking[N-1]['E']), + 'codePeriod': code_period, + 'timeStartInSeconds': 20 + } + + # Create and save graphics as PNG + plotTracking(N, trackResults, settings) + plotKalman(N, kalmanResults, settings) diff --git a/src/utils/python/gps_l1_ca_pvt_raw_plot_sample.py b/src/utils/python/gps_l1_ca_pvt_raw_plot_sample.py new file mode 100644 index 000000000..fb922b5e5 --- /dev/null +++ b/src/utils/python/gps_l1_ca_pvt_raw_plot_sample.py @@ -0,0 +1,101 @@ +""" + gps_l1_ca_pvt_raw_plot_sample.py + + Reads GNSS-SDR PVT raw dump binary file using the provided function and plots + some internal variables + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + channels - Number of channels to check if they exist + path - Path to folder which contains raw file + pvt_raw_log_path - Completed path to PVT raw data file + nav_sol_period - Measurement period [ms] + plot_skyplot - = 1 -> Sky Plot (TO DO) // = 0 -> No Sky Plot + true_position - In settings, If not known enter all NaN's and mean + position will be used as a reference in UTM + coordinate system + plot_position - Optional function at the end + plot_oneVStime - Optional function at the end, select variable to plot + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import utm +import numpy as np +from lib.gps_l1_ca_read_pvt_dump import gps_l1_ca_read_pvt_dump +from lib.plotNavigation import plotNavigation +import pyproj +from lib.plotPosition import plot_position, plot_oneVStime + +settings = {} +utm_e = [] +utm_n = [] +E_UTM = [] +N_UTM = [] +utm_zone = [] + +# ---------- CHANGE HERE: +samplingFreq = 64e6 / 16 +channels = 5 +path = '/home/labnav/Desktop/TEST_IRENE/' +pvt_raw_log_path = path + 'PVT.dat' +nav_sol_period = 10 +plot_skyplot = 0 + +settings['true_position'] = {'E_UTM':np.nan,'N_UTM':np.nan,'U_UTM':np.nan} +settings['navSolPeriod'] = nav_sol_period + +navSolutions = gps_l1_ca_read_pvt_dump(pvt_raw_log_path) +X, Y, Z = navSolutions['X'], navSolutions['Y'], navSolutions['Z'] + +utm_coords = [] + +for i in range(len(navSolutions['longitude'])): + utm_coords.append(utm.from_latlon(navSolutions['latitude'][i], + navSolutions['longitude'][i])) + + + +for i in range(len(utm_coords)): + utm_e.append(utm_coords[i][0]) + utm_n.append(utm_coords[i][1]) + utm_zone.append(utm_coords[i][2]) + +# Transform from Lat Long degrees to UTM coordinate system +# It's supposed utm_zone and letter will not change during tracking +input_projection = pyproj.CRS.from_string("+proj=longlat " + "+datum=WGS84 +no_defs") + +utm_e = [] +utm_n = [] +for i in range(len(navSolutions['longitude'])): + output_projection = pyproj.CRS (f"+proj=utm +zone={utm_zone[i]} " + f"+datum=WGS84 +units=m +no_defs") + transformer = pyproj.Transformer.from_crs(input_projection, + output_projection) + utm_e, utm_n = transformer.transform(navSolutions['longitude'][i], + navSolutions['latitude'][i]) + E_UTM.append(utm_e) + N_UTM.append(utm_n) + + +navSolutions['E_UTM'] = E_UTM +navSolutions['N_UTM'] = N_UTM +navSolutions['U_UTM'] = navSolutions['Z'] + +plotNavigation(navSolutions,settings,plot_skyplot) + +# OPTIONAL: Other plots -> +plot_position(navSolutions) +plot_oneVStime(navSolutions, 'X_vel') +plot_oneVStime(navSolutions, 'Tot_Vel') \ No newline at end of file diff --git a/src/utils/python/gps_l1_ca_telemetry_plot_sample.py b/src/utils/python/gps_l1_ca_telemetry_plot_sample.py new file mode 100644 index 000000000..51e456d66 --- /dev/null +++ b/src/utils/python/gps_l1_ca_telemetry_plot_sample.py @@ -0,0 +1,99 @@ +""" + gps_l1_ca_telemetry_plot_sample.py + + Reads GNSS-SDR Tracking dump binary file using the provided function and + plots some internal variables + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + channels - Number of channels to check if they exist + doppler_opt - = 1 -> Plot // = 0 -> No plot + path - Path to folder which contains raw file + fig_path - Path where plots will be save + chn_num_a / b - Channel which will be plotted + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import os +import matplotlib.pyplot as plt +from lib.gps_l1_ca_read_telemetry_dump import gps_l1_ca_read_telemetry_dump + +GNSS_telemetry = [] + +# ---------- CHANGE HERE: +sampling_freq = 2000000 +channels = list(range(18)) +path = '/home/labnav/Desktop/TEST_IRENE/' +fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/Telemetry' + +if not os.path.exists(fig_path): + os.makedirs(fig_path) + +i = 0 +for N in channels: + try: + telemetry_log_path = os.path.join(path, f'telemetry{N}.dat') + telemetry_data = gps_l1_ca_read_telemetry_dump(telemetry_log_path) + GNSS_telemetry.append(telemetry_data) + i += 1 + except: + pass + +# ---------- CHANGE HERE: +chn_num_a = 0 +chn_num_b = 5 + +# Plotting values +if chn_num_a in range(i) and chn_num_b in range(i): + + # First Plot: + plt.figure() + plt.gcf().canvas.manager.set_window_title(f'Telem_Current_Simbol_TOW_' + f'{chn_num_a}_{chn_num_b}.png') + + plt.plot(GNSS_telemetry[chn_num_a]['tracking_sample_counter'], + [x / 1000 for x in GNSS_telemetry[chn_num_a] + ['tow_current_symbol_ms']], 'b') + plt.plot(GNSS_telemetry[chn_num_b]['tracking_sample_counter'], + GNSS_telemetry[chn_num_b]['tow_current_symbol_ms'], 'r') + + plt.grid(True) + plt.xlabel('TRK Sampling Counter') + plt.ylabel('Current Symbol TOW') + plt.legend([f'CHN-{chn_num_a-1}', f'CHN-{chn_num_b-1}']) + plt.tight_layout() + + plt.savefig(os.path.join(fig_path, f'Telem_Current_Simbol_TOW_{chn_num_a}' + f'_{chn_num_b}.png')) + plt.show() + + # Second Plot: + plt.figure() + plt.gcf().canvas.manager.set_window_title(f'Telem_TRK_Sampling_Counter_' + f'{chn_num_a}_{chn_num_b}.png') + + plt.plot(GNSS_telemetry[chn_num_a]['tracking_sample_counter'], + GNSS_telemetry[chn_num_a]['tow'], 'b') + plt.plot(GNSS_telemetry[chn_num_b]['tracking_sample_counter'], + GNSS_telemetry[chn_num_b]['tow'], 'r') + + plt.grid(True) + plt.xlabel('TRK Sampling Counter') + plt.ylabel('Decoded Nav TOW') + plt.legend([f'CHN-{chn_num_a-1}', f'CHN-{chn_num_b-1}']) + plt.tight_layout() + + plt.savefig(os.path.join(fig_path, f'Telem_TRK_Sampling_Counter_' + f'{chn_num_a}_{chn_num_b}.png')) + plt.show() diff --git a/src/utils/python/hybrid_observables_plot_sample.py b/src/utils/python/hybrid_observables_plot_sample.py new file mode 100644 index 000000000..c4d932529 --- /dev/null +++ b/src/utils/python/hybrid_observables_plot_sample.py @@ -0,0 +1,139 @@ +""" + hybrid_observables_plot_sample.py + + Reads GNSS-SDR observables raw dump binary file using the provided function + and plots some internal variables + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + channels - Number of channels to check if they exist + path - Path to folder which contains raw file + fig_path - Path where plots will be save + observables_log_path - Completed path to observables raw data file + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import numpy as np +import matplotlib.pyplot as plt +from lib.read_hybrid_observables_dump import read_hybrid_observables_dump +import os + +observables = {} +double_size_bytes = 8 +bytes_shift = 0 + +# ---------- CHANGE HERE: +samplingFreq = 2000000 +channels = 5 +path = '/home/labnav/Desktop/TEST_IRENE/' +fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/HybridObservables/' +observables_log_path = path + 'observables.dat' + +if not os.path.exists(fig_path): + os.makedirs(fig_path) + +GNSS_observables = read_hybrid_observables_dump(channels,observables_log_path) + +# Plot data +# --- optional: plot since it detect the first satellite connected +min_tow_idx = 1 +obs_idx = 1 + +for n in range(0, channels): + + idx = np.where(np.array(GNSS_observables['valid'][n])>0)[0][0] + # Find the index from the first satellite connected + if n == 0: + min_tow_idx = idx + if min_tow_idx > idx: + min_tow_idx = idx + obs_idx = n + +# Plot observables from that index +# First plot +plt.figure() +plt.title('Pseudorange') +for i in range(channels): + plt.scatter(GNSS_observables['RX_time'][i][min_tow_idx:], + GNSS_observables['Pseudorange_m'][i][min_tow_idx:],s=1, + label=f'Channel {i}') +plt.xlim(GNSS_observables['RX_time'][obs_idx][min_tow_idx]-100, + GNSS_observables['RX_time'][obs_idx][-1]+100) +plt.grid(True) +plt.xlabel('TOW [s]') +plt.ylabel('Pseudorange [m]') +plt.legend() +plt.gcf().canvas.manager.set_window_title('Pseudorange.png') +plt.tight_layout() +plt.savefig(os.path.join(fig_path, 'Pseudorange.png')) +plt.show() + +# Second plot +plt.figure() +plt.title('Carrier Phase') +for i in range(channels): + plt.scatter(GNSS_observables['RX_time'][i][min_tow_idx:], + GNSS_observables['Carrier_phase_hz'][i][min_tow_idx:],s=1, + label=f'Channel {i}') +plt.xlim(GNSS_observables['RX_time'][obs_idx][min_tow_idx]-100, + GNSS_observables['RX_time'][obs_idx][-1]+100) +plt.xlabel('TOW [s]') +plt.ylabel('Accumulated Carrier Phase [cycles]') +plt.grid(True) +plt.legend() +plt.gcf().canvas.manager.set_window_title('AccumulatedCarrierPhase.png') +plt.tight_layout() +plt.savefig(os.path.join(fig_path, 'AccumulatedCarrierPhase.png')) +plt.show() + +# Third plot +plt.figure() +plt.title('Doppler Effect') +for i in range(channels): + plt.scatter(GNSS_observables['RX_time'][i][min_tow_idx:], + GNSS_observables['Carrier_Doppler_hz'][i][min_tow_idx:],s=1, + label=f'Channel {i}') +plt.xlim(GNSS_observables['RX_time'][obs_idx][min_tow_idx]-100, + GNSS_observables['RX_time'][obs_idx][-1]+100) +plt.xlabel('TOW [s]') +plt.ylabel('Doppler Frequency [Hz]') +plt.grid(True) +plt.legend() +plt.gcf().canvas.manager.set_window_title('DopplerFrequency.png') +plt.tight_layout() +plt.savefig(os.path.join(fig_path, 'DopplerFrequency.png')) +plt.show() + +# Fourth plot +plt.figure() +plt.title('GNSS Channels captured') +for i in range(channels): + lab = 0 + a = 0 + while lab == 0: + lab = int(GNSS_observables["PRN"][i][min_tow_idx+a]) + a += 1 + plt.scatter(GNSS_observables['RX_time'][i][min_tow_idx:], + GNSS_observables['PRN'][i][min_tow_idx:], s=1, + label=f'PRN {i} = {lab}') +plt.xlim(GNSS_observables['RX_time'][obs_idx][min_tow_idx]-100, + GNSS_observables['RX_time'][obs_idx][-1]+100) +plt.xlabel('TOW [s]') +plt.ylabel('PRN') +plt.grid(True) +plt.legend() +plt.gcf().canvas.manager.set_window_title('PRNs.png') +plt.tight_layout() +plt.savefig(os.path.join(fig_path, 'PRNs.png')) +plt.show() \ No newline at end of file diff --git a/src/utils/python/lib/dll_pll_veml_read_tracking_dump.py b/src/utils/python/lib/dll_pll_veml_read_tracking_dump.py new file mode 100644 index 000000000..98cb82906 --- /dev/null +++ b/src/utils/python/lib/dll_pll_veml_read_tracking_dump.py @@ -0,0 +1,222 @@ +""" + dll_pll_veml_read_tracking_dump.py + dll_pll_veml_read_tracking_dump (filename) + + Read GNSS-SDR Tracking dump binary file into Python. + Opens GNSS-SDR tracking binary log file .dat and returns the contents + + Irene Pérez Riega, 2023. iperrie@inta.es + + Args: + filename: path to file .dat with the raw data + + Return: + GNSS_tracking: A dictionary with the processed data in lists + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import struct +import sys + + +def dll_pll_veml_read_tracking_dump (filename): + + v1 = [] + v2 = [] + v3 = [] + v4 = [] + v5 = [] + v6 = [] + v7 = [] + v8 = [] + v9 = [] + v10= [] + v11 = [] + v12 = [] + v13 = [] + v14 = [] + v15 = [] + v16 = [] + v17 = [] + v18 = [] + v19 = [] + v20 = [] + v21 = [] + v22 = [] + GNSS_tracking = {} + + bytes_shift = 0 + + if sys.maxsize > 2 ** 36: # 64 bits computer + float_size_bytes = 4 + unsigned_long_int_size_bytes = 8 + double_size_bytes = 8 + unsigned_int_size_bytes = 4 + + else: # 32 bits + float_size_bytes = 4 + unsigned_long_int_size_bytes = 4 + double_size_bytes = 8 + unsigned_int_size_bytes = 4 + + f = open(filename, 'rb') + if f is None: + return None + else: + while True: + f.seek(bytes_shift, 0) + # VE -> Magnitude of the Very Early correlator. + v1.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # E -> Magnitude of the Early correlator. + v2.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # P -> Magnitude of the Prompt correlator. + v3.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # L -> Magnitude of the Late correlator. + v4.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # VL -> Magnitude of the Very Late correlator. + v5.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # promp_I -> Value of the Prompt correlator in the In-phase + # component. + v6.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # promp_Q -> Value of the Prompt correlator in the Quadrature + # component. + v7.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # PRN_start_sample -> Sample counter from tracking start. + if unsigned_long_int_size_bytes == 8: + v8.append(struct.unpack( + 'Q', f.read(unsigned_long_int_size_bytes))[0]) + bytes_shift += unsigned_long_int_size_bytes + else: + v8.append(struct.unpack('I', + f.read(unsigned_int_size_bytes))[0]) + bytes_shift += unsigned_int_size_bytes + f.seek(bytes_shift, 0) + # acc_carrier_phase_rad - > Accumulated carrier phase, in rad. + v9.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier doppler hz -> Doppler shift, in Hz. + v10.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier doppler rate hz s -> Doppler rate, in Hz/s. + v11.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code freq hz -> Code frequency, in chips/s. + v12.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code_freq_rate_hz_s -> Code frequency rate, in chips/s². + v13.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carr_error -> Raw carrier error (unfiltered) at the PLL + # output, in Hz. + v14.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carr_nco -> Carrier error at the output of the PLL + # filter, in Hz. + v15.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code error -> Raw code error (unfiltered) at the DLL + # output, in chips. + v16.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code nco -> Code error at the output of the DLL + # filter, in chips. + v17.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # CN0_SNV_dB_Hz -> C/N0 estimation, in dB-Hz. + v18.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier lock test -> Output of the carrier lock test. + v19.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # var 1 -> not used ? + v20.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # var 2 -> not used ? + v21.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # PRN -> Satellite ID. + v22.append(struct.unpack('I', + f.read(unsigned_int_size_bytes))[0]) + bytes_shift += unsigned_int_size_bytes + f.seek(bytes_shift, 0) + + # Check file + linea = f.readline() + if not linea: + break + + f.close() + + GNSS_tracking['VE'] = v1 + GNSS_tracking['E'] = v2 + GNSS_tracking['P'] = v3 + GNSS_tracking['L'] = v4 + GNSS_tracking['VL'] = v5 + GNSS_tracking['prompt_I'] = v6 + GNSS_tracking['prompt_Q'] = v7 + GNSS_tracking['PRN_start_sample'] = v8 + GNSS_tracking['acc_carrier_phase_rad'] = v9 + GNSS_tracking['carrier_doppler_hz'] = v10 + GNSS_tracking['carrier_doppler_rate_hz_s'] = v11 + GNSS_tracking['code_freq_hz'] = v12 + GNSS_tracking['code_freq_rate_hz_s'] = v13 + GNSS_tracking['carr_error'] = v14 + GNSS_tracking['carr_nco'] = v15 + GNSS_tracking['code_error'] = v16 + GNSS_tracking['code_nco'] = v17 + GNSS_tracking['CN0_SNV_dB_Hz'] = v18 + GNSS_tracking['carrier_lock_test'] = v19 + GNSS_tracking['var1'] = v20 + GNSS_tracking['var2'] = v21 + GNSS_tracking['PRN'] = v22 + + return GNSS_tracking diff --git a/src/utils/python/lib/gps_l1_ca_kf_read_tracking_dump.py b/src/utils/python/lib/gps_l1_ca_kf_read_tracking_dump.py new file mode 100644 index 000000000..3d809d889 --- /dev/null +++ b/src/utils/python/lib/gps_l1_ca_kf_read_tracking_dump.py @@ -0,0 +1,225 @@ +""" + gps_l1_ca_kf_read_tracking_dump.py + + Read GNSS-SDR Tracking dump binary file into Python. + Opens GNSS-SDR tracking binary log file .dat and returns the contents in a dictionary + + gps_l1_ca_kf_read_tracking_dump(filename) + + Args: + filename - Path to file .dat with the raw data + + Return: + GNSS_tracking - A dictionary with the processed data in lists + + Irene Pérez Riega, 2023. iperrie@inta.es + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import struct +import sys + + +def gps_l1_ca_kf_read_tracking_dump(filename): + + bytes_shift = 0 + + GNSS_tracking = {} + + v1 = [] + v2 = [] + v3 = [] + v4 = [] + v5 = [] + v6 = [] + v7 = [] + v8 = [] + v9 = [] + v10= [] + v11 = [] + v12 = [] + v13 = [] + v14 = [] + v15 = [] + v16 = [] + v17 = [] + v18 = [] + v19 = [] + v20 = [] + v21 = [] + v22 = [] + + if sys.maxsize > 2 ** 36: # 64 bits computer + float_size_bytes = 4 + unsigned_long_int_size_bytes = 8 + double_size_bytes = 8 + unsigned_int_size_bytes = 4 + + else: # 32 bits + float_size_bytes = 4 + unsigned_long_int_size_bytes = 4 + double_size_bytes = 8 + unsigned_int_size_bytes = 4 + + f = open(filename, 'rb') + if f is None: + help(gps_l1_ca_kf_read_tracking_dump) + return None + + else: + while True: + f.seek(bytes_shift, 0) + # VE -> Magnitude of the Very Early correlator. + v1.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # E -> Magnitude of the Early correlator. + v2.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # P -> Magnitude of the Prompt correlator. + v3.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # L -> Magnitude of the Late correlator. + v4.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # VL -> Magnitude of the Very Late correlator. + v5.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # promp_I -> Value of the Prompt correlator in the + # In-phase component. + v6.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # promp_Q -> Value of the Prompt correlator in the + # Quadrature component. + v7.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # PRN_start_sample -> Sample counter from tracking start. + if unsigned_long_int_size_bytes == 8: + v8.append(struct.unpack( + 'Q', f.read(unsigned_long_int_size_bytes))[0]) + bytes_shift += unsigned_long_int_size_bytes + else: + v8.append(struct.unpack( + 'I', f.read(unsigned_int_size_bytes))[0]) + bytes_shift += unsigned_int_size_bytes + f.seek(bytes_shift, 0) + # acc_carrier_phase_rad - > Accumulated carrier phase, in rad. + v9.append(struct.unpack('f', f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier doppler hz -> Doppler shift, in Hz. + v10.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier doppler rate hz s -> Doppler rate, in Hz/s. + v11.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code freq hz -> Code frequency, in chips/s. + v12.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code_freq_rate_hz_s -> Code frequency rate, in chips/s². + #todo carr_error in gps_l1_ca_kf_read_tracking_dump.m + v13.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carr_error -> Raw carrier error (unfiltered) at the PLL + # output, in Hz. + #todo carr_noise_sigma2 in gps_l1_ca_kf_read_tracking_dump.m + v14.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carr_nco -> Carrier error at the output of the PLL + # filter, in Hz. + v15.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code error -> Raw code error (unfiltered) at the DLL + # output, in chips. + v16.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # code nco -> Code error at the output of the DLL + # filter, in chips. + v17.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # CN0_SNV_dB_Hz -> C/N0 estimation, in dB-Hz. + v18.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # carrier lock test -> Output of the carrier lock test. + v19.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # var 1 -> not used ? + v20.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # var 2 -> not used ? + v21.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # PRN -> Satellite ID. + v22.append(struct.unpack('I', + f.read(unsigned_int_size_bytes))[0]) + bytes_shift += unsigned_int_size_bytes + f.seek(bytes_shift, 0) + + linea = f.readline() + if not linea: + break + f.close() + + GNSS_tracking['VE'] = v1 + GNSS_tracking['E'] = v2 + GNSS_tracking['P'] = v3 + GNSS_tracking['L'] = v4 + GNSS_tracking['VL'] = v5 + GNSS_tracking['prompt_I'] = v6 + GNSS_tracking['prompt_Q'] = v7 + GNSS_tracking['PRN_start_sample'] = v8 + GNSS_tracking['acc_carrier_phase_rad'] = v9 + GNSS_tracking['carrier_doppler_hz'] = v10 + GNSS_tracking['carrier_doppler_rate_hz2'] = v11 #todo segun el dll es carrier_doppler_rate_hz_s + GNSS_tracking['code_freq_hz'] = v12 + GNSS_tracking['carr_error'] = v13 #todo code_freq_rate_hz_s segun dll + GNSS_tracking['carr_noise_sigma2'] = v14 #todo carr_error segun dll + GNSS_tracking['carr_nco'] = v15 + GNSS_tracking['code_error'] = v16 + GNSS_tracking['code_nco'] = v17 + GNSS_tracking['CN0_SNV_dB_Hz'] = v18 + GNSS_tracking['carrier_lock_test'] = v19 + GNSS_tracking['var1'] = v20 + GNSS_tracking['var2'] = v21 + GNSS_tracking['PRN'] = v22 + + return GNSS_tracking diff --git a/src/utils/python/lib/gps_l1_ca_read_pvt_dump.py b/src/utils/python/lib/gps_l1_ca_read_pvt_dump.py new file mode 100644 index 000000000..2600c5a2d --- /dev/null +++ b/src/utils/python/lib/gps_l1_ca_read_pvt_dump.py @@ -0,0 +1,249 @@ +""" + gps_l1_ca_read_pvt_dump.py + gps_l1_ca_read_pvt_dump (filename) + + Open and read GNSS-SDR PVT binary log file (.dat) into Python, and + return the contents. + + Irene Pérez Riega, 2023. iperrie@inta.es + + Args: + filename: path to file PVT.dat with the raw data + + Return: + nav_solutions: A dictionary with the processed data in lists + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import math +import struct +import numpy as np + + +def gps_l1_ca_read_pvt_dump(filename): + + uint8_size_bytes = 1 + uint32_size_bytes = 4 + double_size_bytes = 8 + float_size_bytes = 4 + bytes_shift = 0 + + TOW = [] + WEEK =[] + PVT_GPS_time = [] + Clock_Offset = [] + ECEF_X_POS = [] + ECEF_Y_POS = [] + ECEF_Z_POS = [] + ECEF_X_VEL = [] + ECEF_Y_VEL = [] + ECEF_Z_VEL = [] + C_XX = [] + C_YY = [] + C_ZZ = [] + C_XY = [] + C_YZ = [] + C_ZX = [] + Lat = [] + Long = [] + Height = [] + num_valid_sats = [] + RTKLIB_status = [] + RTKLIB_type = [] + AR_factor = [] + AR_threshold = [] + GDOP = [] + PDOP = [] + HDOP = [] + VDOP = [] + + f = open(filename, 'rb') + if f is None: + return None + else: + while True: + f.seek(bytes_shift, 0) + # TOW -> (Time Of Week) [usually sec] uint32 + TOW.append(struct.unpack('I', + f.read(uint32_size_bytes))[0]) + bytes_shift += uint32_size_bytes + f.seek(bytes_shift, 0) + # WEEK -> uint32 + WEEK.append(struct.unpack('I', + f.read(uint32_size_bytes))[0]) + bytes_shift += uint32_size_bytes + f.seek(bytes_shift, 0) + # PVT_GPS_time -> double + PVT_GPS_time.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # User_clock_offset -> [s] double + Clock_Offset.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # ##### ECEF POS X,Y,X [m] + ECEF VEL X,Y,X [m/s] (6 x double) ###### + ECEF_X_POS.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + ECEF_Y_POS.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + ECEF_Z_POS.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + ECEF_X_VEL.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + ECEF_Y_VEL.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + ECEF_Z_VEL.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # #### Position variance/covariance [m²] + # {c_xx,c_yy,c_zz,c_xy,c_yz,c_zx} (6 x double) ###### + C_XX.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + C_YY.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + C_ZZ.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + C_XY.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + C_YZ.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + C_ZX.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # GEO user position Latitude -> [deg] double + Lat.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # GEO user position Longitude -> [deg] double + Long.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # GEO user position Height -> [m] double + Height.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + # NUMBER OF VALID SATS -> uint8 + num_valid_sats.append(struct.unpack('B', + f.read(uint8_size_bytes))[0]) + bytes_shift += uint8_size_bytes + f.seek(bytes_shift, 0) + # RTKLIB solution status (Real-Time Kinematic) -> uint8 + RTKLIB_status.append(struct.unpack('B', + f.read(uint8_size_bytes))[0]) + bytes_shift += uint8_size_bytes + f.seek(bytes_shift, 0) + # RTKLIB solution type (0:xyz-ecef,1:enu-baseline) -> uint8 + RTKLIB_type.append(struct.unpack('B', + f.read(uint8_size_bytes))[0]) + bytes_shift += uint8_size_bytes + f.seek(bytes_shift, 0) + # AR ratio factor for validation -> float + AR_factor.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # AR ratio threshold for validation -> float + AR_threshold.append(struct.unpack('f', + f.read(float_size_bytes))[0]) + bytes_shift += float_size_bytes + f.seek(bytes_shift, 0) + # ##### GDOP / PDOP / HDOP / VDOP (4 * double) ##### + GDOP.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + PDOP.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + HDOP.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + VDOP.append(struct.unpack('d', + f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + # Check file + linea = f.readline() + if not linea: + break + + f.close() + + # Creating a list with total velocities [m/s] + vel = [] + for i in range(len(ECEF_X_VEL)): + vel.append(math.sqrt(ECEF_X_VEL[i]**2 + ECEF_Y_VEL[i]**2 + + ECEF_Z_VEL[i]**2)) + + navSolutions = { + 'TOW': TOW, + 'WEEK': WEEK, + 'TransmitTime': PVT_GPS_time, + 'dt': Clock_Offset, + 'X': ECEF_X_POS, + 'Y': ECEF_Y_POS, + 'Z': ECEF_Z_POS, + 'X_vel': ECEF_X_VEL, + 'Y_vel': ECEF_Y_VEL, + 'Z_vel': ECEF_Z_VEL, + 'Tot_Vel': vel, + 'C_XX': C_XX, + 'C_YY': C_YY, + 'C_ZZ': C_ZZ, + 'C_XY': C_XY, + 'C_YZ': C_YZ, + 'C_ZX': C_ZX, + 'latitude': Lat, + 'longitude': Long, + 'height': Height, + 'SATS': num_valid_sats, + 'RTK_status': RTKLIB_status, + 'RTK_type': RTKLIB_type, + 'AR_factor': AR_factor, + 'AR_threshold': AR_threshold, + 'GDOP': np.array(GDOP), + 'PDOP': np.array(PDOP), + 'HDOP': np.array(HDOP), + 'VDOP': np.array(VDOP) + } + + return navSolutions diff --git a/src/utils/python/lib/gps_l1_ca_read_telemetry_dump.py b/src/utils/python/lib/gps_l1_ca_read_telemetry_dump.py new file mode 100644 index 000000000..fa8b17d0e --- /dev/null +++ b/src/utils/python/lib/gps_l1_ca_read_telemetry_dump.py @@ -0,0 +1,86 @@ +""" + gps_l1_ca_read_telemetry_dump.py + gps_l1_ca_read_telemetry_dump (filename) + + Open and read GNSS-SDR telemetry binary log files (.dat) into Python, and + return the contents. + + Irene Pérez Riega, 2023. iperrie@inta.es + + Args: + filename - Path to file telemetry[N].dat with the raw data + + Return: + telemetry - A dictionary with the processed data + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import struct + + +def gps_l1_ca_read_telemetry_dump(filename): + + double_size_bytes = 8 + int_size_bytes = 4 + bytes_shift = 0 + + tow_current_symbol_ms = [] + tracking_sample_counter = [] + tow = [] + nav_simbols = [] + prn = [] + + f = open(filename, 'rb') + if f is None: + return None + else: + while True: + f.seek(bytes_shift, 0) + + tow_current_symbol_ms.append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + tracking_sample_counter.append(struct.unpack( + 'Q', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + tow.append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + nav_simbols.append(struct.unpack( + 'I', f.read(int_size_bytes))[0]) + bytes_shift += int_size_bytes + f.seek(bytes_shift, 0) + + prn.append(struct.unpack('I', f.read(int_size_bytes))[0]) + bytes_shift += int_size_bytes + f.seek(bytes_shift, 0) + + # Check file + linea = f.readline() + if not linea: + break + + telemetry = { + 'tow_current_symbol_ms': tow_current_symbol_ms, + 'tracking_sample_counter': tracking_sample_counter, + 'tow': tow, + 'nav_simbols': nav_simbols, + 'prn': prn + } + + return telemetry diff --git a/src/utils/python/lib/plotKalman.py b/src/utils/python/lib/plotKalman.py new file mode 100644 index 000000000..38001af45 --- /dev/null +++ b/src/utils/python/lib/plotKalman.py @@ -0,0 +1,140 @@ +""" + plotKalman.py + plotKalman (channelNr, trackResults, settings) + + This function plots the tracking results for the given channel list. + + Irene Pérez Riega, 2023. iperrie@inta.es + + Args: + channelList - list of channels to be plotted. + trackResults - tracking results from the tracking function. + settings - receiver settings. + + Modifiable in the file: + fig_path - Path where doppler plots will be save + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import matplotlib.pyplot as plt +import numpy as np +import os + + +def plotKalman(channelNr, trackResults, settings): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/PlotKalman' + + if not os.path.exists(fig_path): + os.makedirs(fig_path) + + # Protection - if the list contains incorrect channel numbers + channelNr = np.intersect1d(channelNr, + np.arange(1, settings['numberOfChannels'] + 1)) + + for channelNr in channelNr: + time_start = settings['timeStartInSeconds'] + time_axis_in_seconds = np.arange(1, settings['msToProcess']+1)/1000 + + # Plot all figures + plt.figure(figsize=(1920 / 100, 1080 / 100)) + plt.clf() + plt.gcf().canvas.set_window_title( + f'Channel {channelNr} (PRN ' + f'{str(trackResults[channelNr-1]["PRN"][-2])}) results') + plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1, + hspace=0.4, wspace=0.4) + plt.tight_layout() + + # Row 1 + # ----- CNo for signal ----------------------------------------------- + # Measure of the ratio between carrier signal power and noise power + plt.subplot(4, 2, 1) + plt.plot(time_axis_in_seconds, + trackResults[channelNr-1]['CNo'][:settings['msToProcess']], + 'b') + plt.grid() + plt.axis('tight') + plt.xlabel('Time (s)') + plt.ylabel('CNo (dB-Hz)') + plt.title('Carrier to Noise Ratio', fontweight='bold') + + # ----- PLL discriminator filtered ----------------------------------- + plt.subplot(4, 2, 2) + plt.plot(time_axis_in_seconds, + trackResults[channelNr-1]['state1'] + [:settings['msToProcess']], 'b') + plt.grid() + plt.axis('tight') + plt.xlim([time_start, time_axis_in_seconds[-1]]) + plt.xlabel('Time (s)') + plt.ylabel('Phase Amplitude') + plt.title('Filtered Carrier Phase', fontweight='bold') + + # Row 2 + # ----- Carrier Frequency -------------------------------------------- + # Filtered carrier frequency of (transmitted by a satellite) + # for a specific channel + plt.subplot(4, 2, 3) + plt.plot(time_axis_in_seconds[1:], + trackResults[channelNr-1]['state2'] + [1:settings['msToProcess']], color=[0.42, 0.25, 0.39]) + plt.grid() + plt.axis('auto') + plt.xlim(time_start, time_axis_in_seconds[-1]) + plt.xlabel('Time (s)') + plt.ylabel('Freq (Hz)') + plt.title('Filtered Carrier Frequency', fontweight='bold') + + # ----- Carrier Frequency Rate --------------------------------------- + plt.subplot(4, 2, 4) + plt.plot(time_axis_in_seconds[1:], + trackResults[channelNr-1]['state3'] + [1:settings['msToProcess']], color=[0.42, 0.25, 0.39]) + plt.grid() + plt.axis('auto') + plt.xlim(time_start, time_axis_in_seconds[-1]) + plt.xlabel('Time (s)') + plt.ylabel('Freq (Hz)') + plt.title('Filtered Carrier Frequency Rate', fontweight='bold') + + # Row 3 + # ----- PLL discriminator unfiltered---------------------------------- + plt.subplot(4, 2, (5,6)) + plt.plot(time_axis_in_seconds, + trackResults[channelNr-1]['innovation'], 'r') + plt.grid() + plt.axis('auto') + plt.xlim(time_start, time_axis_in_seconds[-1]) + plt.xlabel('Time (s)') + plt.ylabel('Amplitude') + plt.title('Raw PLL discriminator (Innovation)',fontweight='bold') + + # Row 4 + # ----- PLL discriminator covariance --------------------------------- + plt.subplot(4, 2, (7,8)) + plt.plot(time_axis_in_seconds, + trackResults[channelNr-1]['r_noise_cov'], 'r') + plt.grid() + plt.axis('auto') + plt.xlim(time_start, time_axis_in_seconds[-1]) + plt.xlabel('Time (s)') + plt.ylabel('Variance') + plt.title('Estimated Noise Variance', fontweight='bold') + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, + f'kalman_ch{channelNr}_PRN_' + f'{trackResults[channelNr - 1]["PRN"][-1]}' + f'.png')) + plt.show() diff --git a/src/utils/python/lib/plotNavigation.py b/src/utils/python/lib/plotNavigation.py new file mode 100644 index 000000000..661f38b29 --- /dev/null +++ b/src/utils/python/lib/plotNavigation.py @@ -0,0 +1,134 @@ +""" + plotNavigation.py + + Function plots variations of coordinates over time and a 3D position + plot. It plots receiver coordinates in UTM system or coordinate offsets if + the true UTM receiver coordinates are provided. + + Irene Pérez Riega, 2023. iperrie@inta.es + + plotNavigation(navSolutions, settings, plot_skyplot) + + Args: + navSolutions - Results from navigation solution function. It + contains measured pseudoranges and receiver + coordinates. + settings - Receiver settings. The true receiver coordinates + are contained in this structure. + plot_skyplot - If == 1 then use satellite coordinates to plot the + satellite positions (not implemented yet TO DO) + + Modifiable in the file: + fig_path - Path where plots will be save + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import numpy as np +import matplotlib.pyplot as plt +import os + + +def plotNavigation(navSolutions, settings, plot_skyplot=0): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/PlotNavigation' + + if not os.path.exists(fig_path): + os.makedirs(fig_path) + + if navSolutions: + if (np.isnan(settings['true_position']['E_UTM']) or + np.isnan(settings['true_position']['N_UTM']) or + np.isnan(settings['true_position']['U_UTM'])): + + # Compute mean values + ref_coord = { + 'E_UTM': np.nanmean(navSolutions['E_UTM']), + 'N_UTM': np.nanmean(navSolutions['N_UTM']), + 'U_UTM': np.nanmean(navSolutions['U_UTM']) + } + + mean_latitude = np.nanmean(navSolutions['latitude']) + mean_longitude = np.nanmean(navSolutions['longitude']) + mean_height = np.nanmean(navSolutions['height']) + ref_point_lg_text = (f"Mean Position\nLat: {mean_latitude}º\n" + f"Long: {mean_longitude}º\n" + f"Hgt: {mean_height:+6.1f}") + + else: + # Compute the mean error for static receiver + ref_coord = { + 'E_UTM': settings.truePosition['E_UTM'], + 'N_UTM': settings.truePosition['N_UTM'], + 'U_UTM': settings.truePosition['U_UTM'] + } + + mean_position = { + 'E_UTM': np.nanmean(navSolutions['E_UTM']), + 'N_UTM': np.nanmean(navSolutions['N_UTM']), + 'U_UTM': np.nanmean(navSolutions['U_UTM']) + } + + error_meters = np.sqrt( + (mean_position['E_UTM'] - ref_coord['E_UTM']) ** 2 + + (mean_position['N_UTM'] - ref_coord['N_UTM']) ** 2 + + (mean_position['U_UTM'] - ref_coord['U_UTM']) ** 2) + + ref_point_lg_text = (f"Reference Position, Mean 3D error = " + f"{error_meters} [m]") + + #Create plot and subplots + plt.figure(figsize=(1920 / 120, 1080 / 120)) + plt.clf() + plt.title('Navigation solutions',fontweight='bold') + + ax1 = plt.subplot(4, 2, (1, 4)) + ax2 = plt.subplot(4, 2, (5, 7), projection='3d') + ax3 = plt.subplot(4, 2, (6, 8), projection='3d') + + # (ax1) Coordinate differences in UTM system from reference point + ax1.plot(np.vstack([navSolutions['E_UTM'] - ref_coord['E_UTM'], + navSolutions['N_UTM'] - ref_coord['N_UTM'], + navSolutions['U_UTM'] - ref_coord['U_UTM']]).T) + ax1.set_title('Coordinates variations in UTM system', fontweight='bold') + ax1.legend(['E_UTM', 'N_UTM', 'U_UTM']) + ax1.set_xlabel(f"Measurement period: {settings['navSolPeriod']} ms") + ax1.set_ylabel('Variations (m)') + ax1.grid(True) + ax1.axis('tight') + + # (ax2) Satellite sky plot + if plot_skyplot: #todo posicion de los satelites + skyPlot(ax2, navSolutions['channel']['az'], + navSolutions['channel']['el'], + navSolutions['channel']['PRN'][:, 0]) + ax2.set_title(f'Sky plot (mean PDOP: ' + f'{np.nanmean(navSolutions["DOP"][1, :]):.1f})', + fontweight='bold') + + # (ax3) Position plot in UTM system + ax3.scatter(navSolutions['E_UTM'] - ref_coord['E_UTM'], + navSolutions['N_UTM'] - ref_coord['N_UTM'], + navSolutions['U_UTM'] - ref_coord['U_UTM'], marker='+') + ax3.scatter([0], [0], [0], color='r', marker='+', linewidth=1.5) + ax3.view_init(0, 90) + ax3.set_box_aspect([1, 1, 1]) + ax3.grid(True, which='minor') + ax3.legend(['Measurements', ref_point_lg_text]) + ax3.set_title('Positions in UTM system (3D plot)',fontweight='bold') + ax3.set_xlabel('East (m)') + ax3.set_ylabel('North (m)') + ax3.set_zlabel('Upping (m)') + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, 'measures_UTM.png')) + plt.show() diff --git a/src/utils/python/lib/plotPosition.py b/src/utils/python/lib/plotPosition.py new file mode 100644 index 000000000..3284b16cb --- /dev/null +++ b/src/utils/python/lib/plotPosition.py @@ -0,0 +1,208 @@ +""" + plotPosition.py + + plot_position(navSolutions) + Graph Latitude-Longitude and X-Y-X as a function of Transmit Time + Args: + navSolutions - A dictionary with the processed information in lists + + plot_oneVStime(navSolutions, name) + Graph of a variable as a function of transmission time + Args: + navSolutions - A dictionary with the processed information in lists + name - navSolutions variable name that we want to plot + + calcularCEFP(percentil, navSolutions, m_lat, m_long) + Calculate CEFP radio [m] for n percentil. + Args: + percentil - Number of measures that will be inside the circumference + navSolutions - A dictionary with the processed information in lists + m_lat - Mean latitude measures [º] + m_long - Mean longitude measures [º] + + Modifiable in the file: + fig_path - Path where plots will be save + fig_path_maps - Path where the maps will be save + filename_map - Path where map will be save + filename_map_t - Path where terrain map will be save + + Irene Pérez Riega, 2023. iperrie@inta.es + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import math +import os.path +import webbrowser +import numpy as np +import matplotlib.pyplot as plt +import folium + + +def plot_position(navSolutions): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/PlotPosition/' + fig_path_maps = fig_path + 'maps/' + filename_map = 'mapPlotPosition.html' + filename_map_t = 'mapTerrainPotPosition.html' + + if not os.path.exists(fig_path_maps): + os.mkdir(fig_path_maps) + + # Statics Positions: + m_lat = sum(navSolutions['latitude']) / len(navSolutions['latitude']) + m_long = sum(navSolutions['longitude']) / len(navSolutions['longitude']) + + # CEFP_n -> Include the n% of the dots in the circle + r_CEFP_95 = calcularCEFP(95, navSolutions, m_lat, m_long) + r_CEFP_50 = calcularCEFP(50, navSolutions, m_lat, m_long) + + # Generate and save html with the positions + m = folium.Map(location=[navSolutions['latitude'][0], + navSolutions['longitude'][0]], zoom_start=100) + c_CEFP95 = folium.Circle(location=[m_lat, m_long], + radius=r_CEFP_95, color='green', fill=True, + fill_color='green', fill_opacity=0.5) + c_CEFP50 = folium.Circle(location=[m_lat, m_long], radius=r_CEFP_50, + color='red', fill=True, fill_color='red', + fill_opacity=0.5) + + # POP-UPs + popup95 = folium.Popup("(Green)CEFP95 diameter: {} " + "metres".format(2 * r_CEFP_95)) + popup95.add_to(c_CEFP95) + popup50 = folium.Popup("(Red)CEFP50 diameter: {} " + "metres".format(2 * r_CEFP_50)) + popup50.add_to(c_CEFP50) + + c_CEFP95.add_to(m) + c_CEFP50.add_to(m) + + # Optional: Plot each point -> + """ + for i in range(len(navSolutions['latitude'])): + folium.Marker(location=[navSolutions['latitude'][i], + navSolutions['longitude'][i]], + icon=folium.Icon(color='red')).add_to(m) + """ + + m.save(fig_path_maps + filename_map) + webbrowser.open(fig_path_maps + filename_map) + + # Optional: with terrain -> + """ + n = folium.Map(location=[navSolutions['latitude'][0], + navSolutions['longitude'][0]], zoom_start=100, + tiles='Stamen Terrain') + c_CEFP95.add_to(n) + c_CEFP50.add_to(n) + n.save(fig_path_maps + filename_map_t) + webbrowser.open(fig_path_maps + filename_map_t) + """ + + # Plot -> + time = [] + for i in range(len(navSolutions['TransmitTime'])): + time.append(round(navSolutions['TransmitTime'][i] - + min(navSolutions['TransmitTime']), 3)) + + plt.figure(figsize=(1920 / 120, 1080 / 120)) + plt.clf() + plt.suptitle(f'Plot file PVT process data results') + + # Latitude and Longitude + plt.subplot(1, 2, 1) + scatter = plt.scatter(navSolutions['latitude'], navSolutions['longitude'], + c=time, marker='.') + plt.grid() + plt.ticklabel_format(style='plain', axis='both', useOffset=False) + plt.title('Positions latitud-longitud') + plt.xlabel('Latitude º') + plt.ylabel('Longitude º') + plt.axis('tight') + + # Colors + cmap = plt.get_cmap('viridis') + norm = plt.Normalize(vmin=min(time), vmax=max(time)) + scatter.set_cmap(cmap) + scatter.set_norm(norm) + colors = plt.colorbar(scatter) + colors.set_label('TransmitTime [s]') + + # X, Y, Z + ax = plt.subplot(1, 2, 2, projection='3d') + plt.ticklabel_format(style='plain', axis='both', useOffset=False) + ax.scatter(navSolutions['X'], navSolutions['Y'], navSolutions['Z'], + c=time, marker='.') + ax.set_xlabel('Eje X [m]') + ax.set_ylabel('Eje Y [m]') + ax.set_zlabel('Eje Z [m]') + ax.set_title('Positions x-y-z') + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, f'PVT_ProcessDataResults.png')) + plt.show() + + +def plot_oneVStime(navSolutions, name): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/PlotPosition/' + if not os.path.exists(fig_path): + os.mkdir(fig_path) + + time = [] + for i in range(len(navSolutions['TransmitTime'])): + time.append(round(navSolutions['TransmitTime'][i] - + min(navSolutions['TransmitTime']), 3)) + + plt.clf() + plt.scatter(time, navSolutions[name], marker='.') + plt.grid() + plt.title(f'{name} vs Time') + plt.xlabel('Time [s]') + plt.ylabel(name) + plt.axis('tight') + plt.ticklabel_format(style='plain', axis='both', useOffset=False) + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, f'{name}VSTime.png')) + plt.show() + +def calcularCEFP(percentil, navSolutions, m_lat, m_long): + + r_earth = 6371000 + lat = [] + long = [] + dlat = [] + dlong = [] + dist = [] + + m_lat = math.radians(m_lat) + m_long = math.radians(m_long) + + for i in range(len(navSolutions['latitude'])): + lat.append(math.radians(navSolutions['latitude'][i])) + long.append(math.radians(navSolutions['longitude'][i])) + + for i in range(len(lat)): + dlat.append(m_lat - lat[i]) + dlong.append(m_long - long[i]) + # Haversine: + a = (math.sin(dlat[i] / 2) ** 2 + + math.cos(lat[i]) * math.cos(m_lat) * math.sin(dlong[i] / 2) ** 2) + c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) + dist.append(r_earth * c) + + # Radio CEFP + radio_CEFP_p = np.percentile(dist, percentil) + return radio_CEFP_p diff --git a/src/utils/python/lib/plotTracking.py b/src/utils/python/lib/plotTracking.py new file mode 100644 index 000000000..248091d12 --- /dev/null +++ b/src/utils/python/lib/plotTracking.py @@ -0,0 +1,190 @@ +""" + plotTracking.py + + This function plots the tracking results for the given channel list. + + Irene Pérez Riega, 2023. iperrie@inta.es + + plotTracking(channelList, trackResults, settings) + + Args: + channelList - list of channels to be plotted. + trackResults - tracking results from the tracking function. + settings - receiver settings. + + Modifiable in the file: + fig_path - Path where plots will be save + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import numpy as np +import os +import matplotlib.pyplot as plt + +def plotTracking(channelNr, trackResults, settings): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/PlotTracking' + + if not os.path.exists(fig_path): + os.makedirs(fig_path) + + # Protection - if the list contains incorrect channel numbers + if channelNr in list(range(1,settings["numberOfChannels"]+1)): + + plt.figure(figsize=(1920 / 120, 1080 / 120)) + plt.clf() + plt.gcf().canvas.set_window_title( + f'Channel {channelNr} (PRN ' + f'{trackResults[channelNr-1]["PRN"][0]}) results') + plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1, + hspace=0.4, wspace=0.4) + plt.tight_layout() + + # Extract timeAxis and time_label + if 'prn_start_time_s' in trackResults[channelNr-1]: + timeAxis = trackResults[channelNr-1]['prn_start_time_s'] + time_label = 'RX Time (s)' + else: + timeAxis = np.arange(1, len(trackResults[channelNr-1]['PRN']) + 1) + time_label = 'Epoch' + + + # Row 1 ============================================================== + # Discrete-Time Scatter Plot + plt.subplot(4, 3, 1) + plt.plot(trackResults[channelNr-1]['I_P'], + trackResults[channelNr-1]['Q_P'], marker='.', markersize=1, + linestyle=' ') + plt.grid() + plt.axis('equal') + plt.title('Discrete-Time Scatter Plot', fontweight='bold') + plt.xlabel('I prompt') + plt.ylabel('Q prompt') + + # Nav bits + plt.subplot(4, 3, (2, 3)) + plt.plot(timeAxis, trackResults[channelNr-1]['I_P'], linewidth=1) + plt.grid() + plt.title('Bits of the navigation message', fontweight='bold') + plt.xlabel(time_label) + plt.axis('tight') + + # Row 2 ============================================================== + # Raw PLL discriminator unfiltered + plt.subplot(4, 3, 4) + plt.plot(timeAxis, trackResults[channelNr-1]['pllDiscr'], + color='r', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Raw PLL discriminator', fontweight='bold') + + # Correlation results + plt.subplot(4, 3, (5, 6)) + corr_data = [ + np.sqrt(trackResults[channelNr-1]['I_E'] ** 2 + + trackResults[channelNr-1]['Q_E'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_P'] ** 2 + + trackResults[channelNr-1]['Q_P'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_L'] ** 2 + + trackResults[channelNr - 1]['Q_L'] ** 2) + ] + + line = [] + colors = ['b', '#FF6600', '#FFD700', 'purple', 'g'] + + for i, data in enumerate(corr_data): + line.append(plt.plot(timeAxis, data, + label=f'Data {i+1}', color=colors[i], + marker='*', linestyle=' ', linewidth=1)) + + plt.grid() + plt.title('Correlation results', fontweight='bold') + plt.xlabel(time_label) + plt.axis('tight') + plt.legend([r'$\sqrt{I_{VE}^2 + Q_{VE}^2}$', + r'$\sqrt{I_{E}^2 + Q_{E}^2}$', + r'$\sqrt{I_{P}^2 + Q_{P}^2}$', + r'$\sqrt{I_{L}^2 + Q_{L}^2}$', + r'$\sqrt{I_{VL}^2 + Q_{VL}^2}$'], loc='best') + + # Row 3 ============================================================== + # Filtered PLL discriminator + plt.subplot(4, 3, 7) + plt.plot(timeAxis, trackResults[channelNr-1]['pllDiscrFilt'], + 'b', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Filtered PLL discriminator', fontweight='bold') + + # Raw DLL discriminator unfiltered + plt.subplot(4, 3, 8) + plt.plot(timeAxis, trackResults[channelNr-1]['dllDiscr'], + 'r', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Raw DLL discriminator', fontweight='bold') + + # Filtered DLL discriminator + plt.subplot(4, 3, 9) + plt.plot(timeAxis, trackResults[channelNr-1]['dllDiscrFilt'], + 'b', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Filtered DLL discriminator', fontweight='bold') + + # Row 4 ============================================================== + # CNo for signal + plt.subplot(4, 3, 10) + plt.plot(timeAxis, trackResults[channelNr-1]['CNo'], 'b', + linewidth=1) + plt.grid() + plt.axis('equal') + plt.xlabel('Time (s)') + plt.ylabel('CNo (dB-Hz)') + plt.title('Carrier to Noise Ratio', fontweight='bold') + + # Carrier Frequency + plt.subplot(4, 3, 11) + plt.plot(timeAxis, trackResults[channelNr-1]['carrFreq'], + marker='.', markersize=1, linestyle=' ') + plt.grid() + plt.axis('equal') + plt.xlabel('Time (s)') + plt.ylabel('Freq (hz)') + plt.title('Carrier Frequency', fontweight='bold') + + # Code Frequency + # Skip sample 0 to help with results display + plt.subplot(4, 3, 12) + plt.plot(timeAxis, trackResults[channelNr-1]['codeFreq'], + marker='.', markersize=1, linestyle=' ') + plt.grid() + plt.axis('equal') + plt.xlabel('Time (s)') + plt.ylabel('Freq (Hz)') + plt.title('Code Frequency',fontweight='bold') + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, + f'trk_dump_ch{channelNr}_PRN_' + f'{trackResults[channelNr - 1]["PRN"][-1]}' + f'.png')) + plt.show() diff --git a/src/utils/python/lib/plotVEMLTracking.py b/src/utils/python/lib/plotVEMLTracking.py new file mode 100644 index 000000000..2af50e03a --- /dev/null +++ b/src/utils/python/lib/plotVEMLTracking.py @@ -0,0 +1,171 @@ +""" + plotVEMLTracking.py + + This function plots the tracking results for the given channel list. + + Irene Pérez Riega, 2023. iperrie@inta.es + + plotVEMLTracking(channelNr, trackResults, settings) + + Args: + channelList - list of channels to be plotted. + trackResults - tracking results from the tracking function. + settings - receiver settings. + + Modifiable in the file: + fig_path - Path where plots will be save + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import matplotlib.pyplot as plt +import numpy as np +import os + + +def plotVEMLTracking(channelNr, trackResults, settings): + + # ---------- CHANGE HERE: + fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/VEMLTracking' + if not os.path.exists(fig_path): + os.makedirs(fig_path) + + # Protection - if the list contains incorrect channel numbers + if channelNr in list(range(1,settings["numberOfChannels"]+1)): + + plt.figure(figsize=(1920 / 120, 1080 / 120)) + plt.clf() + plt.gcf().canvas.set_window_title( + f'Channel {channelNr} (PRN ' + f'{trackResults[channelNr-1]["PRN"][0]}) results') + plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1, + hspace=0.4, wspace=0.4) + + # Extract timeAxis and time_label + if 'prn_start_time_s' in trackResults[channelNr-1]: + timeAxis = trackResults[channelNr-1]['prn_start_time_s'] + time_label = 'RX Time (s)' + else: + timeAxis = np.arange(1, len(trackResults[channelNr-1]['PRN']) + 1) + time_label = 'Epoch' + + len_dataI = len (trackResults[channelNr-1]["data_I"]) + len_dataQ = len (trackResults[channelNr-1]["data_Q"]) + + if len_dataI < len_dataQ: + dif = len_dataQ - len_dataI + trackResults[channelNr-1]["data_I"] = np.pad( + trackResults[channelNr-1]["data_I"], pad_width=(0,dif), + mode="constant", constant_values=0) + elif len_dataQ < len_dataI: + dif = len_dataI - len_dataQ + trackResults[channelNr-1]["data_Q"] = np.pad( + trackResults[channelNr-1]["data_Q"], pad_width=(0,dif), + mode="constant", constant_values=0 ) + + # Discrete-Time Scatter Plot + plt.subplot(3, 3, 1) + plt.plot(trackResults[channelNr-1]['data_I'], + trackResults[channelNr-1]['data_Q'], marker='.', + markersize=1, linestyle=' ') + plt.grid() + plt.axis('equal') + plt.title('Discrete-Time Scatter Plot', fontweight='bold') + plt.xlabel('I prompt') + plt.ylabel('Q prompt') + + # Nav bits + plt.subplot(3, 3, (2, 3)) + plt.plot(timeAxis, trackResults[channelNr-1]['data_I'], + linewidth=1) + plt.grid() + plt.title('Bits of the navigation message', fontweight='bold') + plt.xlabel(time_label) + plt.axis('tight') + + # Raw PLL discriminator unfiltered + plt.subplot(3, 3, 4) + plt.plot(timeAxis, trackResults[channelNr-1]['pllDiscr'], + color='r', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Raw PLL discriminator', fontweight='bold') + + # Correlation results + plt.subplot(3, 3, (5, 6)) + corr_data = [ + np.sqrt(trackResults[channelNr-1]['I_VE'] ** 2 + + trackResults[channelNr-1]['Q_VE'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_E'] ** 2 + + trackResults[channelNr-1]['Q_E'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_P'] ** 2 + + trackResults[channelNr-1]['Q_P'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_L'] ** 2 + + trackResults[channelNr-1]['Q_L'] ** 2), + np.sqrt(trackResults[channelNr-1]['I_VL'] ** 2 + + trackResults[channelNr-1]['Q_VL'] ** 2) + ] + + line = [] + colors = ['b','#FF6600','#FFD700','purple','g'] + + for i, data in enumerate(corr_data): + line.append(plt.plot(timeAxis, data, label=f'Data {i+1}', + color=colors[i], marker='*', linestyle=' ', + linewidth=1)) + + plt.grid() + plt.title('Correlation results',fontweight='bold') + plt.xlabel(time_label) + plt.axis('tight') + plt.legend([r'$\sqrt{I_{VE}^2 + Q_{VE}^2}$', + r'$\sqrt{I_{E}^2 + Q_{E}^2}$', + r'$\sqrt{I_{P}^2 + Q_{P}^2}$', + r'$\sqrt{I_{L}^2 + Q_{L}^2}$', + r'$\sqrt{I_{VL}^2 + Q_{VL}^2}$'], loc='best') + + # Filtered PLL discriminator + plt.subplot(3, 3, 7) + plt.plot(timeAxis, trackResults[channelNr-1]['pllDiscrFilt'], + 'b', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Filtered PLL discriminator', fontweight='bold') + + # Raw DLL discriminator unfiltered + plt.subplot(3, 3, 8) + plt.plot(timeAxis, trackResults[channelNr-1]['dllDiscr'], 'r', + linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Raw DLL discriminator',fontweight='bold') + + # Filtered DLL discriminator + plt.subplot(3, 3, 9) + plt.plot(timeAxis, trackResults[channelNr-1]['dllDiscrFilt'], + 'b', linewidth=1) + plt.grid() + plt.axis('tight') + plt.xlabel(time_label) + plt.ylabel('Amplitude') + plt.title('Filtered DLL discriminator',fontweight='bold') + + plt.savefig(os.path.join(fig_path, + f'Ch{channelNr}_PRN' + f'{trackResults[channelNr-1]["PRN"][0]}' + f'_results')) + plt.show() diff --git a/src/utils/python/lib/read_hybrid_observables_dump.py b/src/utils/python/lib/read_hybrid_observables_dump.py new file mode 100644 index 000000000..dc7cf09d2 --- /dev/null +++ b/src/utils/python/lib/read_hybrid_observables_dump.py @@ -0,0 +1,112 @@ +""" + read_hybrid_observables_dump.py + + This function plots the tracking results for the given channel list. + + Irene Pérez Riega, 2023. iperrie@inta.es + + read_hybrid_observables_dump(channels, filename) + + Args: + channels - list of channels to be processed + filename - path to the observables file + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import struct + +def read_hybrid_observables_dump(channels, filename): + + double_size_bytes = 8 + bytes_shift = 0 + + RX_time = [[] for _ in range(channels+1)] + d_TOW_at_current_symbol = [[] for _ in range(channels+1)] + Carrier_Doppler_hz = [[] for _ in range(channels+1)] + Carrier_phase_hz = [[] for _ in range(channels+1)] + Pseudorange_m = [[] for _ in range(channels+1)] + PRN = [[] for _ in range(channels+1)] + valid = [[] for _ in range(channels+1)] + + f = open(filename, 'rb') + if f is None: + return None + else: + while True: + try: + # There is an empty channel at the end (Channel-6) + for N in range(0, channels+1): + f.seek(bytes_shift, 0) + + RX_time[N].append(struct.unpack( + 'd',f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + d_TOW_at_current_symbol[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + Carrier_Doppler_hz[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + Carrier_phase_hz[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + Pseudorange_m[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + PRN[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + valid[N].append(struct.unpack( + 'd', f.read(double_size_bytes))[0]) + bytes_shift += double_size_bytes + f.seek(bytes_shift, 0) + + except: + break + + # Delete last Channel: + RX_time = [row for i, row in enumerate(RX_time) if i != 5] + d_TOW_at_current_symbol = [row for i, row in enumerate( + d_TOW_at_current_symbol)if i != 5] + Carrier_Doppler_hz = [row for i, row in enumerate( + Carrier_Doppler_hz) if i != 5] + Carrier_phase_hz = [row for i, row in enumerate( + Carrier_phase_hz) if i != 5] + Pseudorange_m = [row for i, row in enumerate(Pseudorange_m) if i != 5] + PRN = [row for i, row in enumerate(PRN) if i != 5] + valid = [row for i, row in enumerate(valid) if i != 5] + + observables = { + 'RX_time': RX_time, + 'd_TOW_at_current_symbol': d_TOW_at_current_symbol, + 'Carrier_Doppler_hz': Carrier_Doppler_hz, + 'Carrier_phase_hz': Carrier_phase_hz, + 'Pseudorange_m': Pseudorange_m, + 'PRN': PRN, + 'valid':valid + } + + f.close() + + return observables diff --git a/src/utils/python/plot_acq_grid.py b/src/utils/python/plot_acq_grid.py new file mode 100644 index 000000000..674b13ca9 --- /dev/null +++ b/src/utils/python/plot_acq_grid.py @@ -0,0 +1,262 @@ +""" + plot_acq_grid.py + + Reads GNSS-SDR Acquisition dump .mat file using the provided function and + plots acquisition grid of acquisition statistic of PRN sat + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + sampling_freq - Sampling frequency [Hz] + channels - Number of channels to check if they exist + path - Path to folder which contains raw file + fig_path - Path where plots will be save + plot_all_files - Plot all the files in a folder (True/False) + ---- + file - Fixed part in files names. In our case: acq_dump + sat - Satellite. In our case: 1 + channel - Channel. In our case: 1 + execution - In our case: 0 + signal_type - In our case: 1 + ---- + lite_view - True for light grid representation + + File format: + {path}/{file}_ch_{system}_{signal}_ch_{channel}_{execution}_sat_{sat}.mat + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + +import os +import sys +import numpy as np +import matplotlib.pyplot as plt +from scipy.interpolate import CubicSpline +import h5py + +# ---------- CHANGE HERE: +path = '/home/labnav/Desktop/TEST_IRENE/acquisition/' +fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/Acquisition/' +plot_all_files = False + +if not os.path.exists(fig_path): + os.makedirs(fig_path) + +if not plot_all_files: + + # ---------- CHANGE HERE: + file = 'acq_dump' + sat = 1 + channel = 0 + execution = 1 + signal_type = 1 + lite_view = True + + # If lite_view -> sets the number of samples per chip in the graphical + # representation + n_samples_per_chip = 3 + d_samples_per_code = 25000 + + signal_types = { + 1: ('G', '1C', 1023), # GPS L1 + 2: ('G', '2S', 10230), # GPS L2M + 3: ('G', 'L5', 10230), # GPS L5 + 4: ('E', '1B', 4092), # Galileo E1B + 5: ('E', '5X', 10230), # Galileo E5 + 6: ('R', '1G', 511), # Glonass 1G + 7: ('R', '2G', 511), # Glonass 2G + 8: ('C', 'B1', 2048), # Beidou B1 + 9: ('C', 'B3', 10230), # Beidou B3 + 10: ('C', '5C', 10230) # Beidou B2a + } + system, signal, n_chips = signal_types.get(signal_type) + + # Load data + filename = (f'{path}{file}_ch_{system}_{signal}_ch_{channel}_{execution}' + f'_sat_{sat}.mat') + img_name_root = (f'{fig_path}{file}_ch_{system}_{signal}_ch_{channel}_' + f'{execution}_sat_{sat}') + + with h5py.File(filename, 'r') as data: + acq_grid = data['acq_grid'][:] + n_fft, n_dop_bins = acq_grid.shape + d_max, f_max = np.unravel_index(np.argmax(acq_grid), acq_grid.shape) + doppler_step = data['doppler_step'][0] + doppler_max = data['doppler_max'][0] + freq = np.arange(n_dop_bins) * doppler_step - doppler_max + delay = np.arange(n_fft) / n_fft * n_chips + + # Plot data + # --- Acquisition grid (3D) + fig = plt.figure() + plt.gcf().canvas.manager.set_window_title(filename) + if not lite_view: + ax = fig.add_subplot(111, projection='3d') + X, Y = np.meshgrid(freq, delay) + ax.plot_surface(X, Y, acq_grid, cmap='viridis') + ax.set_ylim([min(delay), max(delay)]) + else: + delay_interp = (np.arange(n_samples_per_chip * n_chips) + / n_samples_per_chip) + spline = CubicSpline(delay, acq_grid) + grid_interp = spline(delay_interp) + ax = fig.add_subplot(111, projection='3d') + X, Y = np.meshgrid(freq, delay_interp) + ax.plot_surface(X, Y, grid_interp, cmap='inferno') + ax.set_ylim([min(delay_interp), max(delay_interp)]) + + ax.set_xlabel('Doppler shift (Hz)') + ax.set_xlim([min(freq), max(freq)]) + ax.set_ylabel('Code delay (chips)') + ax.set_zlabel('Test Statistics') + + plt.tight_layout() + plt.savefig(img_name_root + '_sample_3D.png') + plt.show() + + # --- Acquisition grid (2D) + input_power = 100 # Change Test statistics in Doppler wipe-off plot + + fig2, axes = plt.subplots(2, 1, figsize=(8, 6)) + plt.gcf().canvas.manager.set_window_title(filename) + axes[0].plot(freq, acq_grid[d_max, :]) + axes[0].set_xlim([min(freq), max(freq)]) + axes[0].set_xlabel('Doppler shift (Hz)') + axes[0].set_ylabel('Test statistics') + axes[0].set_title(f'Fixed code delay to {(d_max - 1) / n_fft * n_chips} ' + f'chips') + + normalization = (d_samples_per_code**4) * input_power + axes[1].plot(delay, acq_grid[:, f_max] / normalization) + axes[1].set_xlim([min(delay), max(delay)]) + axes[1].set_xlabel('Code delay (chips)') + axes[1].set_ylabel('Test statistics') + axes[1].set_title(f'Doppler wipe-off = ' + f'{str((f_max-1) * doppler_step - doppler_max)} Hz') + + plt.tight_layout() + plt.savefig(img_name_root + '_sample_2D.png') + plt.show() + +else: + # ---------- CHANGE HERE: + lite_view = True + # If lite_view -> sets the number of samples per chip in the graphical + # representation + n_samples_per_chip = 3 + d_samples_per_code = 25000 + + filenames = os.listdir(path) + for filename in filenames: + sat = 1 + channel = 0 + execution = 1 + + system = filename[12] + signal = filename[14:16] + if system == "G": + if signal == "1C": + n_chips = 1023 + elif signal == "2S" or "L5": + n_chips = 10230 + else: + print("Incorrect files format. Change the code or the " + "filenames.") + sys.exit() + elif system == "E": + if signal == "1B": + n_chips = 4092 + elif signal == "5X": + n_chips = 10230 + else: + print("Incorrect files format. Change the code or the " + "filenames.") + sys.exit() + elif system == "R": + if signal == "1G" or "2G": + n_chips = 511 + else: + print("Incorrect files format. Change the code or the " + "filenames.") + sys.exit() + elif system == "C": + if signal == "B1": + n_chips = 2048 + elif signal == "B3" or "5C": + n_chips = 10230 + else: + print("Incorrect files format. Change the code or the " + "filenames.") + sys.exit() + + complete_path = path + filename + with h5py.File(complete_path, 'r') as data: + acq_grid = data['acq_grid'][:] + n_fft, n_dop_bins = acq_grid.shape + d_max, f_max = np.unravel_index(np.argmax(acq_grid), + acq_grid.shape) + doppler_step = data['doppler_step'][0] + doppler_max = data['doppler_max'][0] + freq = np.arange(n_dop_bins) * doppler_step - doppler_max + delay = np.arange(n_fft) / n_fft * n_chips + + # Plot data + # --- Acquisition grid (3D) + fig = plt.figure() + plt.gcf().canvas.manager.set_window_title(filename) + if not lite_view: + ax = fig.add_subplot(111, projection='3d') + X, Y = np.meshgrid(freq, delay) + ax.plot_surface(X, Y, acq_grid, cmap='viridis') + ax.set_ylim([min(delay), max(delay)]) + else: + delay_interp = (np.arange(n_samples_per_chip * n_chips) + / n_samples_per_chip) + spline = CubicSpline(delay, acq_grid) + grid_interp = spline(delay_interp) + ax = fig.add_subplot(111, projection='3d') + X, Y = np.meshgrid(freq, delay_interp) + ax.plot_surface(X, Y, grid_interp, cmap='inferno') + ax.set_ylim([min(delay_interp), max(delay_interp)]) + + ax.set_xlabel('Doppler shift (Hz)') + ax.set_xlim([min(freq), max(freq)]) + ax.set_ylabel('Code delay (chips)') + ax.set_zlabel('Test Statistics') + + plt.savefig(os.path.join(fig_path, filename[:-4]) + '_3D.png') + + plt.close() + + # --- Acquisition grid (2D) + input_power = 100 # Change Test statistics in Doppler wipe-off plot + + fig2, axes = plt.subplots(2, 1, figsize=(8, 6)) + plt.gcf().canvas.manager.set_window_title(filename) + axes[0].plot(freq, acq_grid[d_max, :]) + axes[0].set_xlim([min(freq), max(freq)]) + axes[0].set_xlabel('Doppler shift (Hz)') + axes[0].set_ylabel('Test statistics') + axes[0].set_title(f'Fixed code delay to ' + f'{(d_max - 1) / n_fft * n_chips} chips') + + normalization = (d_samples_per_code ** 4) * input_power + axes[1].plot(delay, acq_grid[:, f_max] / normalization) + axes[1].set_xlim([min(delay), max(delay)]) + axes[1].set_xlabel('Code delay (chips)') + axes[1].set_ylabel('Test statistics') + axes[1].set_title(f'Doppler wipe-off = ' + f'{str((f_max - 1) * doppler_step - doppler_max)} ' + f'Hz') + + plt.tight_layout() + plt.savefig(os.path.join(fig_path, filename[:-4]) + '_2D.png') + # plt.show() + plt.close() diff --git a/src/utils/python/plot_tracking_quality_indicators.py b/src/utils/python/plot_tracking_quality_indicators.py new file mode 100644 index 000000000..434a7febd --- /dev/null +++ b/src/utils/python/plot_tracking_quality_indicators.py @@ -0,0 +1,76 @@ +""" + plot_tracking_quality_indicators.py + + + + Irene Pérez Riega, 2023. iperrie@inta.es + + Modifiable in the file: + channels - Number of channels + firs_channel - Number of the first channel + path - Path to folder which contains raw files + fig_path - Path where doppler plots will be save + 'trk_dump_ch' - Fixed part of the tracking dump files names + + ----------------------------------------------------------------------------- + + GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + This file is part of GNSS-SDR. + + Copyright (C) 2022 (see AUTHORS file for a list of contributors) + SPDX-License-Identifier: GPL-3.0-or-later + + ----------------------------------------------------------------------------- +""" + + +import matplotlib.pyplot as plt +import numpy as np +import os +from lib.dll_pll_veml_read_tracking_dump import dll_pll_veml_read_tracking_dump + +GNSS_tracking = [] +plot_names = [] + +# ---------- CHANGE HERE: +channels = 5 +first_channel = 0 +path = '/home/labnav/Desktop/TEST_IRENE/tracking' +fig_path = '/home/labnav/Desktop/TEST_IRENE/PLOTS/TrackingQualityIndicator' + +for N in range(1, channels + 1): + tracking_log_path = os.path.join(path, + f'trk_dump_ch{N-1+first_channel}.dat') + GNSS_tracking.append(dll_pll_veml_read_tracking_dump(tracking_log_path)) + +if not os.path.exists(fig_path): + os.makedirs(fig_path) + +# Plot tracking quality indicators +# First plot +plt.figure() +plt.gcf().canvas.manager.set_window_title('Carrier lock test output for all ' + 'the channels') +plt.title('Carrier lock test output for all the channels') +for n in range(len(GNSS_tracking)): + plt.plot(GNSS_tracking[n]['carrier_lock_test']) + plot_names.append(f'SV {str(round(np.mean(GNSS_tracking[n]["PRN"])))}') +plt.legend(plot_names) +plt.savefig(os.path.join(fig_path, + f'carrier_lock_test ' + f'{str(round(np.mean(GNSS_tracking[n]["PRN"])))}')) +plt.show() + +# Second plot +plt.figure() +plt.gcf().canvas.manager.set_window_title('Carrier CN0 output for all the ' + 'channels') +plt.title('Carrier CN0 output for all the channels') +for n in range(len(GNSS_tracking)): + plt.plot(GNSS_tracking[n]['CN0_SNV_dB_Hz']) + plot_names.append(f'CN0_SNV_dB_Hz ' + f'{str(round(np.mean(GNSS_tracking[n]["PRN"])))}') +plt.legend(plot_names) +plt.savefig(os.path.join( + fig_path, f'SV {str(round(np.mean(GNSS_tracking[n]["PRN"])))}')) +plt.show() From 322b498d8abc2636165b3386ae232f0adbb64bce Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 18 Oct 2023 21:43:22 +0200 Subject: [PATCH 044/142] Fix urls due to changes in Zenodo --- src/utils/reproducibility/ieee-access18/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/reproducibility/ieee-access18/README.md b/src/utils/reproducibility/ieee-access18/README.md index 6e3ff5797..67f59ad6d 100644 --- a/src/utils/reproducibility/ieee-access18/README.md +++ b/src/utils/reproducibility/ieee-access18/README.md @@ -19,7 +19,7 @@ IEEE Access, Vol. 6, No. 1, pp. 20451-20463, April 2018. DOI: [10.1109/ACCESS.2018.2822835](https://doi.org/10.1109/ACCESS.2018.2822835) The data set used in this paper is available at -https://zenodo.org/record/1184601 +https://zenodo.org/records/1184601 The sample format is `ibyte`: Interleaved (I&Q) stream of samples of type signed integer, 8-bit two’s complement number ranging from -128 to 127. The sampling @@ -53,7 +53,7 @@ $ cd gnss-sdr $ git checkout next $ mkdir -p exp-access18/data $ cd exp-access18/data -$ curl https://zenodo.org/record/1184601/files/L2_signal_samples.tar.xz --output L2_signal_samples.tar.xz +$ curl https://zenodo.org/records/1184601/files/L2_signal_samples.tar.xz --output L2_signal_samples.tar.xz $ tar xvfJ L2_signal_samples.tar.xz $ echo "3a04c1eeb970776bb77f5e3b7eaff2df L2_signal_samples.tar.xz" > data.md5 $ md5sum -c data.md5 From 177ad70dec99b5c1233acf7edd5385981273353b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 23 Oct 2023 13:02:34 +0200 Subject: [PATCH 045/142] Add boost to list of dependencies in Macports --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 315b0cdae..7dfb672cd 100644 --- a/README.md +++ b/README.md @@ -830,9 +830,9 @@ In a terminal, type: ``` $ sudo port selfupdate $ sudo port upgrade outdated -$ sudo port install armadillo cmake gnuradio gnutls lapack libad9361-iio libiio \ +$ sudo port install armadillo boost cmake gnuradio gnutls lapack libad9361-iio libiio \ matio pkgconfig protobuf3-cpp pugixml google-glog +gflags -$ sudo port install py37-mako +$ sudo port install py311-mako $ sudo port install doxygen +docs ``` From 4416e20077548a8d7ee3f094df0185b6fb60d3f4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 26 Oct 2023 09:51:10 +0200 Subject: [PATCH 046/142] Bump local versions of Google Benchmarks and Protocol Buffers --- CMakeLists.txt | 4 ++-- cmake/Modules/BuildProtobuf.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56aeda777..ac275151c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,12 +339,12 @@ set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.6.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") -set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.4") +set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "24.4") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.0.0") -set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.8.2") +set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.8.3") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") # Downgrade versions if requirements are not met diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake index 5b7a995eb..48418d608 100644 --- a/cmake/Modules/BuildProtobuf.cmake +++ b/cmake/Modules/BuildProtobuf.cmake @@ -13,7 +13,7 @@ if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION) - set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.4") + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "24.4") endif() if(NOT GNSSSDR_BINARY_DIR) From a46f9f77feb97e76b8f8fbb555190074ff92bcf0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 26 Oct 2023 10:25:39 +0200 Subject: [PATCH 047/142] Fix CMake error --- cmake/Modules/SetupPython.cmake | 2 +- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index 89e7bbc2d..e7930778d 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -172,7 +172,7 @@ else() endif() endif() -if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) +if("${PYTHON_VERSION_MAJOR}" VERSION_EQUAL 3) set(PYTHON3 TRUE) endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 697fe8c3b..c3d4f61ee 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -170,7 +170,7 @@ else() endif() endif() -if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3) +if("${PYTHON_VERSION_MAJOR}" VERSION_EQUAL 3) set(PYTHON3 TRUE) endif() From f965f4921d79ca28661847b32e612fce4310ad01 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 26 Oct 2023 13:23:05 +0200 Subject: [PATCH 048/142] Improve Python detection --- cmake/Modules/SetupPython.cmake | 11 ++++++++++- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index e7930778d..234a3d33e 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -153,7 +153,7 @@ else() find_program(PYTHON_EXECUTABLE NAMES python3 python) if(PYTHON_EXECUTABLE) set(PYTHONINTERP_FOUND TRUE) - execute_process(COMMAND "${PYTHON_EXECUTABLE} --version" OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX) + execute_process(COMMAND ${PYTHON_EXECUTABLE} --version OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX) string(FIND "${PYTHON_VERSION_STRING_AUX}" " " blank_char_index) if(blank_char_index GREATER -1) math(EXPR start_index "${blank_char_index} + 1") @@ -161,6 +161,15 @@ else() string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING) string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR) message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})") + else() + string(FIND ${PYTHON_EXECUTABLE} "python3" is_python3) + if(is_python3 GREATER -1) + set(PYTHON_VERSION_MAJOR "3") + set(PYTHON_VERSION_STRING "3.10") # ? + else() + set(PYTHON_VERSION_MAJOR "2") + set(PYTHON_VERSION_STRING "2.7") + endif() endif() endif() gnsssdr_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index c3d4f61ee..507e3809c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -158,6 +158,15 @@ else() string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING) string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR) message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})") + else() + string(FIND ${PYTHON_EXECUTABLE} "python3" is_python3) + if(is_python3 GREATER -1) + set(PYTHON_VERSION_MAJOR "3") + set(PYTHON_VERSION_STRING "3.10") # ? + else() + set(PYTHON_VERSION_MAJOR "2") + set(PYTHON_VERSION_STRING "2.7") + endif() endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0") From b116c17937a5899e3bf8e985284605b42043b7e3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 26 Oct 2023 18:57:24 +0200 Subject: [PATCH 049/142] Print estimated CN0 on the terminal when navigation data is decoded --- docs/CHANGELOG.md | 2 + .../beidou_b1i_telemetry_decoder_gs.cc | 40 +++++-- .../beidou_b1i_telemetry_decoder_gs.h | 2 +- .../beidou_b3i_telemetry_decoder_gs.cc | 36 ++++-- .../beidou_b3i_telemetry_decoder_gs.h | 2 +- .../galileo_telemetry_decoder_gs.cc | 110 +++++++++++++----- .../galileo_telemetry_decoder_gs.h | 6 +- .../glonass_l1_ca_telemetry_decoder_gs.cc | 22 +++- .../glonass_l1_ca_telemetry_decoder_gs.h | 2 +- .../glonass_l2_ca_telemetry_decoder_gs.cc | 23 +++- .../glonass_l2_ca_telemetry_decoder_gs.h | 2 +- .../gps_l1_ca_telemetry_decoder_gs.cc | 19 +-- .../gps_l1_ca_telemetry_decoder_gs.h | 2 +- .../gps_l2c_telemetry_decoder_gs.cc | 19 ++- .../gps_l5_telemetry_decoder_gs.cc | 19 ++- 15 files changed, 225 insertions(+), 81 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 160083a7a..ff80de84e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -57,6 +57,8 @@ All notable changes to GNSS-SDR will be documented in this file. - Now the program exits properly if a SIGINT signal is received (_e.g._, the user pressing Ctrl+C, or another user application sending an interruption signal). +- The estimated CN0 value is now printed in the terminal when navigation data is + succesfully decoded. ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index 1cd4d849a..c8d512ed9 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include // for size_t #include // for abs #include // for exception +#include // for setprecision #include // for cout #include // for shared_ptr, make_shared @@ -239,7 +240,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_word( } -void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) +void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, double cn0) { // 1. Transform from symbols to bits std::string data_bits; @@ -296,32 +297,49 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) // get object for this SV (mandatory) const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << "New BEIDOU B1I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << '\n'; + LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; + std::cout << "New BEIDOU B1I DNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << " dB-Hz" << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << "New BEIDOU B1I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << '\n'; + LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; + std::cout << "New BEIDOU B1I DNAV utc model message received in channel " + << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } if (d_nav.have_new_iono() == true) { // get object for this SV (mandatory) const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << '\n'; + LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; + std::cout << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel + << ": Iono model parameters from satellite " << d_satellite + << " with CN0=" << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } if (d_nav.have_new_almanac() == true) { // uint32_t slot_nbr = d_nav.i_alm_satellite_PRN; // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << '\n'; - std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << '\n'; + LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; + std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel + << " from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } } @@ -506,7 +524,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ } // call the decoder - decode_subframe(d_subframe_symbols.data()); + decode_subframe(d_subframe_symbols.data(), current_symbol.CN0_dB_hz); if (d_nav.get_flag_CRC_test() == true) { @@ -563,7 +581,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ } // call the decoder - decode_subframe(d_subframe_symbols.data()); + decode_subframe(d_subframe_symbols.data(), current_symbol.CN0_dB_hz); if (d_nav.get_flag_CRC_test() == true) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h index b00afac59..25ef1185e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h @@ -75,7 +75,7 @@ private: beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf); - void decode_subframe(float *symbols); + void decode_subframe(float *symbols, double cn0); void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols); void decode_bch15_11_01(const int32_t *bits, std::array &decbits); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index 8088f51d7..07bb79339 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -32,6 +32,7 @@ #include // for size_t #include // for abs #include // for exception +#include // for setprecision #include // for cout #include // for shared_ptr, make_shared @@ -239,7 +240,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_word( } -void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) +void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, double cn0) { // 1. Transform from symbols to bits std::string data_bits; @@ -278,12 +279,12 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) if (crc_ok) { DLOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel - << " from satellite " << d_satellite; + << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; } else { DLOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel - << " from satellite " << d_satellite; + << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; } if (d_dump_crc_stats) { @@ -298,9 +299,12 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" - << d_channel << " from satellite " << d_satellite; + << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV message received in channel " << d_channel - << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_nav.have_new_utc_model() == true) { @@ -310,9 +314,12 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; + const auto default_precision{std::cout.precision()}; std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " - << d_satellite << TEXT_RESET << '\n'; + << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_nav.have_new_iono() == true) { @@ -321,10 +328,12 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel - << " from satellite " << d_satellite; + << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " - << d_satellite << TEXT_RESET << '\n'; + << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_nav.have_new_almanac() == true) { @@ -334,9 +343,12 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) // this->message_port_pub(pmt::mp("telemetry"), // pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" - << d_channel << " from satellite " << d_satellite << '\n'; + << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; + const auto default_precision{std::cout.precision()}; std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV almanac received in channel " << d_channel - << " from satellite " << d_satellite << TEXT_RESET << '\n'; + << " from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } } @@ -530,7 +542,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } // call the decoder - decode_subframe(d_subframe_symbols.data()); + decode_subframe(d_subframe_symbols.data(), current_symbol.CN0_dB_hz); if (d_nav.get_flag_CRC_test() == true) { @@ -590,7 +602,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } // call the decoder - decode_subframe(d_subframe_symbols.data()); + decode_subframe(d_subframe_symbols.data(), current_symbol.CN0_dB_hz); if (d_nav.get_flag_CRC_test() == true) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h index a18e06ad7..eb7b14705 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h @@ -73,7 +73,7 @@ private: beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf); - void decode_subframe(float *symbols); + void decode_subframe(float *symbols, double cn0); void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols); void decode_bch15_11_01(const int32_t *bits, std::array &decbits); 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 ea99988d8..dbc905c18 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 @@ -41,6 +41,7 @@ #include // for std::fmod, std::abs #include // for size_t #include // for std::exception +#include // for std::setprecision #include // for std::cout #include // for std::numeric_limits #include // for std::map @@ -350,7 +351,7 @@ void galileo_telemetry_decoder_gs::deinterleaver(int32_t rows, int32_t cols, con } -void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, int32_t frame_length) +void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, int32_t frame_length, double cn0) { // 1. De-interleave std::vector page_part_symbols_soft_value(frame_length); @@ -431,11 +432,20 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); if (d_band == '1') { - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } else if (d_band == '7') { - std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE + << "New Galileo E5b I/NAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); d_first_eph_sent = true; // do not send reduced CED anymore, since we have the full ephemeris set @@ -446,8 +456,12 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in if ((d_band == '1') && d_use_ced && !d_first_eph_sent && (d_inav_nav.have_new_reduced_ced() == true)) { const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_reduced_ced()); - std::cout << "New Galileo E1 I/NAV reduced CED message received in channel " << d_channel << " from satellite " << d_satellite << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << "New Galileo E1 I/NAV reduced CED message received in channel " + << d_channel << " from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } } @@ -455,30 +469,48 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in { // get object for this SV (mandatory) const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_iono()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel + << ": iono/GST model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } else if (d_band == '7') { - std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " + << d_channel << ": iono/GST model parameters from satellite " + << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_inav_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_utc_model()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { - std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } else if (d_band == '7') { - std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " + << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + d_delta_t = tmp_obj->A_0G + tmp_obj->A_1G * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - tmp_obj->t_0G + 604800 * (std::fmod(static_cast(d_inav_nav.get_Galileo_week() - tmp_obj->WN_0G), 64.0))); DLOG(INFO) << "delta_t=" << d_delta_t << "[s]"; } @@ -490,11 +522,18 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in // debug if (d_band == '1') { - std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel + << " from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; } else if (d_band == '7') { - std::cout << TEXT_BLUE << "Galileo E5b I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "Galileo E5b I/NAV almanac received in channel " + << d_channel << " from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } DLOG(INFO) << "Current parameters:"; DLOG(INFO) << "d_TOW_at_current_symbol_ms=" << d_TOW_at_current_symbol_ms; @@ -503,7 +542,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } -void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t frame_length) +void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t frame_length, double cn0) { // 1. De-interleave std::vector page_symbols_soft_value(frame_length); @@ -547,38 +586,51 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t d_fnav_nav.split_page(page_String); if (d_fnav_nav.get_flag_CRC_test() == true) { - DLOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; } else { - DLOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; } // 4. Push the new navigation data to the queues if (d_fnav_nav.have_new_ephemeris() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_ephemeris()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " + << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 + << " dB-Hz" << TEXT_RESET << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } if (d_fnav_nav.have_new_iono_and_GST() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_iono()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " + << d_channel << ": iono/GST model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 + << " dB-Hz" << TEXT_RESET << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } if (d_fnav_nav.have_new_utc_model() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_utc_model()); - std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " + << d_channel << ": UTC model parameters from satellite " << d_satellite + << " dB-Hz" << TEXT_RESET << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } } -void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float *page_symbols, int32_t page_length) +void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float *page_symbols, int32_t page_length, double cn0) { // 1. De-interleave std::vector page_symbols_soft_value(page_length); @@ -630,9 +682,13 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (is_page_dummy != d_cnav_dummy_page) { d_cnav_dummy_page = is_page_dummy; + const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "Receiving Galileo E6 CNAV dummy pages in channel " - << d_channel << " from satellite " << d_satellite - << TEXT_RESET << '\n'; + << d_channel << " from satellite " + << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << " dB-Hz" + << TEXT_RESET << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } } else @@ -646,10 +702,12 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (d_print_cnav_page == true) { d_print_cnav_page = false; // only print the first page + const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "Receiving Galileo E6 HAS pages" << (d_cnav_nav.is_HAS_in_test_mode() == true ? " (test mode) " : " ") - << "in channel " << d_channel << " from satellite " << d_satellite - << TEXT_RESET << '\n'; + << "in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << " dB-Hz" + << TEXT_RESET << std::endl; + std::cout << std::setprecision(default_precision); // restore defaults } } } @@ -912,13 +970,13 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( switch (d_frame_type) { case 1: // INAV - decode_INAV_word(d_page_part_symbols.data(), d_frame_length_symbols); + decode_INAV_word(d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); break; case 2: // FNAV - decode_FNAV_word(d_page_part_symbols.data(), d_frame_length_symbols); + decode_FNAV_word(d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); break; case 3: // CNAV - decode_CNAV_word(current_symbol.Tracking_sample_counter / static_cast(current_symbol.fs), d_page_part_symbols.data(), d_frame_length_symbols); + decode_CNAV_word(current_symbol.Tracking_sample_counter / static_cast(current_symbol.fs), d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); break; default: return -1; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h index 39f2936c9..f571fea86 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h @@ -82,9 +82,9 @@ private: void msg_handler_read_galileo_tow_map(const pmt::pmt_t &msg); void deinterleaver(int32_t rows, int32_t cols, const float *in, float *out); - void decode_INAV_word(float *page_part_symbols, int32_t frame_length); - void decode_FNAV_word(float *page_symbols, int32_t frame_length); - void decode_CNAV_word(uint64_t time_stamp, float *page_symbols, int32_t page_length); + void decode_INAV_word(float *page_part_symbols, int32_t frame_length, double cn0); + void decode_FNAV_word(float *page_symbols, int32_t frame_length, double cn0); + void decode_CNAV_word(uint64_t time_stamp, float *page_symbols, int32_t page_length, double cn0); std::unique_ptr d_viterbi; std::vector d_preamble_samples; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index 44d0bf1f9..b35fddef2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -30,6 +30,7 @@ #include // for size_t #include // for abs #include // for exception +#include // for std::setprecision #include // for cout #include // for shared_ptr, make_shared @@ -152,7 +153,7 @@ glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs() } -void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbols, int32_t frame_length) +void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbols, int32_t frame_length, double cn0) { double chip_acc = 0.0; int32_t chip_acc_counter = 0; @@ -238,7 +239,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } if (d_nav.have_new_utc_model() == true) { @@ -246,7 +251,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } if (d_nav.have_new_almanac() == true) { @@ -255,7 +264,10 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; - std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; } // 5. Update satellite information on system if (d_nav.get_flag_update_slot_number() == true) @@ -405,7 +417,7 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu } // call the decoder - decode_string(string_symbols.data(), string_length); + decode_string(string_symbols.data(), string_length, current_symbol.CN0_dB_hz); bool crc_ok = d_nav.get_flag_CRC_test(); if (crc_ok == true) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h index af36b8b9e..e6b22ba2a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h @@ -81,7 +81,7 @@ private: const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - void decode_string(const double *symbols, int32_t frame_length); + void decode_string(const double *symbols, int32_t frame_length, double cn0); // Help with coherent tracking diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index a115907a6..8e2df1ff2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -30,6 +30,7 @@ #include // for size_t #include // for abs #include // for exception +#include // for std::setprecision #include // for cout #include // for shared_ptr, make_shared @@ -152,7 +153,7 @@ glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs() } -void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbols, int32_t frame_length) +void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbols, int32_t frame_length, double cn0) { double chip_acc = 0.0; int32_t chip_acc_counter = 0; @@ -238,7 +239,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_nav.have_new_utc_model() == true) { @@ -246,7 +251,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; - std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_nav.have_new_almanac() == true) { @@ -254,7 +263,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; - std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << '\n'; + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel + << " from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } // 5. Update satellite information on system if (d_nav.get_flag_update_slot_number() == true) @@ -404,7 +417,7 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu } // call the decoder - decode_string(string_symbols.data(), string_length); + decode_string(string_symbols.data(), string_length, current_symbol.CN0_dB_hz); if (d_nav.get_flag_CRC_test() == true) { d_CRC_error_counter = 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h index 53c0ed03f..fb3a93c38 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h @@ -79,7 +79,7 @@ private: const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - void decode_string(const double *symbols, int32_t frame_length); + void decode_string(const double *symbols, int32_t frame_length, double cn0); // Storage for incoming data boost::circular_buffer d_symbol_history; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index e03d02eaa..0ca6f9219 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include // for size_t #include // for memcpy #include // for exception +#include // for setprecision #include // for cout #include // for shared_ptr #include @@ -254,7 +255,7 @@ void gps_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel) } -bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(bool flag_invert) +bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(double cn0, bool flag_invert) { std::array subframe{}; int32_t frame_bit_index = 0; @@ -350,11 +351,6 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(bool flag_invert) const int32_t subframe_ID = d_nav.subframe_decoder(subframe.data()); // decode the subframe if (subframe_ID > 0 && subframe_ID < 6) { - std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " - << "subframe " - << subframe_ID << " from satellite " - << Gnss_Satellite(std::string("GPS"), d_nav.get_satellite_PRN()) << '\n'; - switch (subframe_ID) { case 1: @@ -401,6 +397,13 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(bool flag_invert) default: break; } + const auto default_precision{std::cout.precision()}; + std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " + << "subframe " + << subframe_ID << " from satellite " + << Gnss_Satellite(std::string("GPS"), d_nav.get_satellite_PRN()) + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) + << " dB-Hz" << std::endl; return true; } } @@ -499,7 +502,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ } DLOG(INFO) << "Preamble detection for GPS L1 satellite " << this->d_satellite; d_prev_GPS_frame_4bytes = 0; - if (decode_subframe(d_flag_PLL_180_deg_phase_locked)) + if (decode_subframe(current_symbol.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) { d_CRC_error_counter = 0; d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) @@ -525,7 +528,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ // 0. fetch the symbols into an array d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) - if (decode_subframe(d_flag_PLL_180_deg_phase_locked)) + if (decode_subframe(current_symbol.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) { d_CRC_error_counter = 0; d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h index da9dbc50d..07bfdeee2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h @@ -74,7 +74,7 @@ private: gps_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf); bool gps_word_parityCheck(uint32_t gpsword); - bool decode_subframe(bool flag_invert); + bool decode_subframe(double cn0, bool flag_invert); Gps_Navigation_Message d_nav; Gnss_Satellite d_satellite; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index cd0c817f6..0b2947e17 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -32,6 +32,7 @@ #include // for round #include // for size_t #include // for exception +#include // for setprecision #include // for cout #include // for shared_ptr, make_shared @@ -257,21 +258,33 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); - std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_CNAV_Message.have_new_iono() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); - std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel + << ": iono model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_CNAV_Message.have_new_utc_model() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); - std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } // update TOW at the preamble instant diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index d4c915cc5..c93572019 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -31,6 +31,7 @@ #include // for size_t #include // for std::llabs #include // for std::exception +#include // for std::setprecision #include // for std::cout gps_l5_telemetry_decoder_gs_sptr @@ -254,21 +255,33 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u { // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); - std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz + << std::setprecision(default_precision) << " dB-Hz" << std::endl; } if (d_CNAV_Message.have_new_iono() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); - std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel + << ": iono model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) + << " dB-Hz" << TEXT_RESET << std::endl; } if (d_CNAV_Message.have_new_utc_model() == true) { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); - std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << '\n'; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + const auto default_precision{std::cout.precision()}; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel + << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz + << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; } // update TOW at the preamble instant From 84b5cfe0045f3d4706534b463fa0d7d402cf70b4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 28 Oct 2023 20:11:52 +0200 Subject: [PATCH 050/142] Bump local version of Matio to 1.5.24 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac275151c..13b5ae872 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,7 +338,7 @@ set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.6.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.24") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "24.4") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") From 3ecf1c4ef4a3b4eacb07db181d5230e47a16b7ba Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 1 Nov 2023 09:17:11 +0100 Subject: [PATCH 051/142] volk_gnsssdr: improve random integer generation --- .../volk_gnsssdr/lib/qa_utils.cc | 115 ++++++++++++------ 1 file changed, 75 insertions(+), 40 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index 311122427..2257e51f0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -33,59 +33,94 @@ void random_values(T *buf, unsigned int n, std::default_random_engine &e1) void load_random_data(void *data, volk_gnsssdr_type_t type, unsigned int n) { - std::random_device r; - std::default_random_engine e1(r()); - std::default_random_engine e2(r()); + std::random_device rnd_device; + std::default_random_engine rnd_engine(rnd_device()); if (type.is_complex) n *= 2; if (type.is_float) { if (type.size == 8) - random_values((double *)data, n, e1); + random_values((double *)data, n, rnd_engine); else - random_values((float *)data, n, e1); + random_values((float *)data, n, rnd_engine); } else { - float int_max = float(uint64_t(2) << (type.size * 8)); - if (type.is_signed) int_max /= 2.0; - std::uniform_real_distribution uniform_dist(-int_max, int_max); - for (unsigned int i = 0; i < n; i++) + switch (type.size) { - float scaled_rand = uniform_dist(e2); - - switch (type.size) + case 8: + if (type.is_signed) { - case 8: - if (type.is_signed) - ((int64_t *)data)[i] = (int64_t)scaled_rand; - else - ((uint64_t *)data)[i] = (uint64_t)scaled_rand; - break; - case 4: - if (type.is_signed) - ((int32_t *)data)[i] = (int32_t)scaled_rand; - else - ((uint32_t *)data)[i] = (uint32_t)scaled_rand; - break; - case 2: - // 16 bit multiplication saturates very fast - // we produce here only 3 bits input range - if (type.is_signed) - ((int16_t *)data)[i] = (int16_t)((int16_t)scaled_rand % 8); - else - ((uint16_t *)data)[i] = (uint16_t)(int16_t)((int16_t)scaled_rand % 8); - break; - case 1: - if (type.is_signed) - ((int8_t *)data)[i] = (int8_t)scaled_rand; - else - ((uint8_t *)data)[i] = (uint8_t)scaled_rand; - break; - default: - throw "load_random_data: no support for data size > 8 or < 1"; // no shenanigans here + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((int64_t *)data)[i] = uniform_dist(rnd_engine); } + else + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((uint64_t *)data)[i] = uniform_dist(rnd_engine); + } + break; + case 4: + if (type.is_signed) + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((int32_t *)data)[i] = uniform_dist(rnd_engine); + } + else + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((uint32_t *)data)[i] = uniform_dist(rnd_engine); + } + break; + case 2: + if (type.is_signed) + { + std::uniform_int_distribution uniform_dist(-7, 7); + for (unsigned int i = 0; i < n; i++) + ((int16_t *)data)[i] = uniform_dist(rnd_engine); + } + else + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((uint16_t *)data)[i] = uniform_dist(rnd_engine); + } + break; + case 1: + if (type.is_signed) + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((int8_t *)data)[i] = uniform_dist(rnd_engine); + } + else + { + std::uniform_int_distribution uniform_dist( + std::numeric_limits::min(), + std::numeric_limits::max()); + for (unsigned int i = 0; i < n; i++) + ((uint8_t *)data)[i] = uniform_dist(rnd_engine); + } + break; + default: + throw "load_random_data: no support for data size > 8 or < 1"; // no shenanigans here } } } From a4ea1f55716033c747399a4cb9373e9d32a43e47 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 1 Nov 2023 23:04:04 +0100 Subject: [PATCH 052/142] Galileo telemetry: restore default precision as soon as possible --- .../galileo_telemetry_decoder_gs.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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 dbc905c18..660564c14 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 @@ -600,9 +600,9 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " - << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 + << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" + << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults } if (d_fnav_nav.have_new_iono_and_GST() == true) @@ -612,9 +612,8 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite - << " with CN0=" << std::setprecision(2) << cn0 + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults } if (d_fnav_nav.have_new_utc_model() == true) @@ -624,8 +623,8 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults } } @@ -686,9 +685,8 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * std::cout << TEXT_MAGENTA << "Receiving Galileo E6 CNAV dummy pages in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" - << std::setprecision(2) << cn0 << " dB-Hz" + << std::setprecision(2) << cn0 << " dB-Hz" << std::setprecision(default_precision) << TEXT_RESET << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults } } else @@ -705,9 +703,9 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * const auto default_precision{std::cout.precision()}; std::cout << TEXT_MAGENTA << "Receiving Galileo E6 HAS pages" << (d_cnav_nav.is_HAS_in_test_mode() == true ? " (test mode) " : " ") - << "in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << " dB-Hz" + << "in channel " << d_channel << " from satellite " << d_satellite + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults } } } From c004232518a52baa9c03f442dff6e5024f1e450b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 2 Nov 2023 14:53:38 +0100 Subject: [PATCH 053/142] Do not search for Python six if not required --- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 2 +- .../volk_gnsssdr/cmake/Modules/VolkPython.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 4235cb586..433170e12 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -307,7 +307,7 @@ if(NOT MAKO_FOUND) endif() # Six -if(Python2_VERSION OR (PYTHON_VERSION_STRING VERSION_LESS "3.0")) +if(PYTHON_VERSION_STRING VERSION_LESS "3.0") if(NOT SIX_FOUND) message(FATAL_ERROR "six - python 2 and 3 compatibility library required to build VOLK_GNSSSDR") endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 507e3809c..325e93a1f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -87,8 +87,8 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING) set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}") set(PYTHON_EXECUTABLE "${Python2_EXECUTABLE}") set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}") - endif() - volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) + endif() endif() endif() volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) From a897e56e05a835ad89c62d45f5b507f613316e42 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2023 00:32:00 +0100 Subject: [PATCH 054/142] Fox for C++11 --- .../beidou_b1i_telemetry_decoder_gs.cc | 19 ++++++- .../beidou_b3i_telemetry_decoder_gs.cc | 16 ++++++ .../galileo_telemetry_decoder_gs.cc | 56 +++++++++++++++++++ .../glonass_l1_ca_telemetry_decoder_gs.cc | 12 ++++ .../glonass_l2_ca_telemetry_decoder_gs.cc | 12 ++++ .../gps_l1_ca_telemetry_decoder_gs.cc | 4 ++ .../gps_l2c_telemetry_decoder_gs.cc | 12 ++++ .../gps_l5_telemetry_decoder_gs.cc | 12 ++++ 8 files changed, 141 insertions(+), 2 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index c8d512ed9..6798a2e17 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -298,11 +298,14 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite - << " with CN0=" << std::setprecision(2) << cn0 << " dB-Hz" << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; } if (d_nav.have_new_utc_model() == true) { @@ -310,7 +313,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -323,7 +330,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << " with CN0=" << cn0 << std::setprecision(default_precision) @@ -335,7 +346,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index 07bb79339..dcd4609d0 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -300,7 +300,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -314,7 +318,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -329,7 +337,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -344,7 +356,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub // pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) 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 660564c14..37beb5d43 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 @@ -432,7 +432,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -440,7 +444,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" @@ -457,7 +465,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in { const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_reduced_ced()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV reduced CED message received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -472,7 +484,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -480,7 +496,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -495,7 +515,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -503,7 +527,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -522,14 +550,22 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in // debug if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "Galileo E5b I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -598,7 +634,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -609,7 +649,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -620,7 +664,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -681,7 +729,11 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (is_page_dummy != d_cnav_dummy_page) { d_cnav_dummy_page = is_page_dummy; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "Receiving Galileo E6 CNAV dummy pages in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" @@ -700,7 +752,11 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (d_print_cnav_page == true) { d_print_cnav_page = false; // only print the first page +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "Receiving Galileo E6 HAS pages" << (d_cnav_nav.is_HAS_in_test_mode() == true ? " (test mode) " : " ") << "in channel " << d_channel << " from satellite " << d_satellite diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index b35fddef2..3d6aacbcc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -239,7 +239,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -251,7 +255,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -264,7 +272,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index 8e2df1ff2..2340b59ff 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -239,7 +239,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -251,7 +255,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -263,7 +271,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 0ca6f9219..bf8b9ba21 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -397,7 +397,11 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(double cn0, bool flag_inver default: break; } +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " << "subframe " << subframe_ID << " from satellite " diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index 0b2947e17..60b33d5b7 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -259,7 +259,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -269,7 +273,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -280,7 +288,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index c93572019..2c0ab7083 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -256,7 +256,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz @@ -266,7 +270,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -277,7 +285,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz From 710f85dc035319e88c2dbfcbc734d847d7951599 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2023 11:54:16 +0100 Subject: [PATCH 055/142] Update local version of cpu_features to 0.9.0 --- .github/workflows/volk_gnsssdr_archs.yml | 1 - CMakeLists.txt | 14 +- docs/CHANGELOG.md | 4 + .../volk_gnsssdr/CMakeLists.txt | 53 +++- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 2 +- .../volk_gnsssdr/cpu_features/CMakeLists.txt | 135 +++++--- .../volk_gnsssdr/cpu_features/README.md | 18 +- .../include/cpu_features_macros.h | 15 +- .../cpu_features/include/cpuinfo_aarch64.h | 44 ++- .../cpu_features/include/cpuinfo_loongarch.h | 70 +++++ .../cpu_features/include/cpuinfo_mips.h | 2 +- .../cpu_features/include/cpuinfo_riscv.h | 2 + .../cpu_features/include/cpuinfo_s390x.h | 3 +- .../cpu_features/include/cpuinfo_x86.h | 10 +- .../include/internal/cpuid_aarch64.h | 293 ++++++++++++++++++ .../cpu_features/include/internal/cpuid_x86.h | 2 +- .../cpu_features/include/internal/hwcaps.h | 40 ++- .../include/internal/windows_utils.h | 2 +- .../volk_gnsssdr/cpu_features/src/hwcaps.c | 162 +--------- .../cpu_features/src/hwcaps_freebsd.c | 45 +++ .../src/hwcaps_linux_or_android.c | 166 ++++++++++ .../src/impl_aarch64__base_implementation.inl | 106 +++++++ .../cpu_features/src/impl_aarch64_cpuid.c | 32 ++ .../cpu_features/src/impl_aarch64_freebsd.c | 39 +++ .../src/impl_aarch64_linux_or_android.c | 77 +---- .../src/impl_aarch64_macos_or_iphone.c | 81 +++++ .../cpu_features/src/impl_aarch64_windows.c | 4 +- .../cpu_features/src/impl_loongarch_linux.c | 86 +++++ .../cpu_features/src/impl_ppc_linux.c | 4 +- .../cpu_features/src/impl_riscv_linux.c | 3 +- .../cpu_features/src/impl_s390x_linux.c | 3 +- .../src/impl_x86__base_implementation.inl | 26 +- .../cpu_features/src/impl_x86_windows.c | 6 +- .../src/utils/list_cpu_features.c | 19 +- .../cpu_features/test/CMakeLists.txt | 26 +- .../cpu_features/test/cpuinfo_aarch64_test.cc | 208 +++++++++++-- .../test/cpuinfo_loongarch_test.cc | 171 ++++++++++ .../cpu_features/test/cpuinfo_riscv_test.cc | 50 ++- .../cpu_features/test/cpuinfo_x86_test.cc | 79 +++++ .../volk_gnsssdr/lib/CMakeLists.txt | 1 - .../beidou_b1i_telemetry_decoder_gs.cc | 19 +- .../beidou_b3i_telemetry_decoder_gs.cc | 16 + .../galileo_telemetry_decoder_gs.cc | 56 ++++ .../glonass_l1_ca_telemetry_decoder_gs.cc | 12 + .../glonass_l2_ca_telemetry_decoder_gs.cc | 12 + .../gps_l1_ca_telemetry_decoder_gs.cc | 4 + .../gps_l2c_telemetry_decoder_gs.cc | 12 + .../gps_l5_telemetry_decoder_gs.cc | 12 + 48 files changed, 1862 insertions(+), 385 deletions(-) create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_loongarch.h create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_aarch64.h create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_freebsd.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_linux_or_android.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64__base_implementation.inl create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_cpuid.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_freebsd.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_macos_or_iphone.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_loongarch_linux.c create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_loongarch_test.cc diff --git a/.github/workflows/volk_gnsssdr_archs.yml b/.github/workflows/volk_gnsssdr_archs.yml index a40c1c163..edc0721b1 100644 --- a/.github/workflows/volk_gnsssdr_archs.yml +++ b/.github/workflows/volk_gnsssdr_archs.yml @@ -71,7 +71,6 @@ jobs: cmake ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/ echo "Build with $(nproc) thread(s)" make -j$(nproc) - ./cpu_features/list_cpu_features ./apps/volk_gnsssdr-config-info --alignment ./apps/volk_gnsssdr-config-info --avail-machines ./apps/volk_gnsssdr-config-info --all-machines diff --git a/CMakeLists.txt b/CMakeLists.txt index 13b5ae872..86373d868 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1208,8 +1208,14 @@ if(NOT VOLKGNSSSDR_FOUND) endif() include(GNUInstallDirs) set(SUPPORTED_CPU_FEATURES_ARCH FALSE) - if(CMAKE_SYSTEM_PROCESSOR MATCHES - "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)|(^s390x)|^riscv") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)|(^ARM64)" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(x86_64)|(AMD64|amd64)|(^i.86$)" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch") set(SUPPORTED_CPU_FEATURES_ARCH TRUE) endif() if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64) @@ -1248,14 +1254,14 @@ if(NOT VOLKGNSSSDR_FOUND) set_package_properties(CPUFEATURES PROPERTIES DESCRIPTION "A cross platform C99 library to get CPU features at runtime (version: ${CPUFEATURES_VERSION})" ) - if((CMAKE_SYSTEM_PROCESSOR MATCHES "(^s390x)|^riscv") AND (CPUFEATURES_VERSION VERSION_LESS "0.8.0")) # detect cpu_features without s390x / riscv support + if((CMAKE_SYSTEM_PROCESSOR MATCHES "(^s390x)|(^riscv)|(^loongarch)") AND (CPUFEATURES_VERSION VERSION_LESS "0.8.0")) # detect cpu_features without s390x / riscv support set(ENABLE_CPUFEATURES OFF) endif() else() set_package_properties(CPUFEATURES PROPERTIES DESCRIPTION "A cross platform C99 library to get CPU features at runtime" ) - if(DEFINED VOLK_VERSION AND VOLK_VERSION VERSION_GREATER "2.3") # avoid clash with volk's cpufeatures. + if((DEFINED VOLK_VERSION AND VOLK_VERSION VERSION_GREATER "2.3") OR (CMAKE_VERSION VERSION_LESS "3.13")) # avoid clash with volk's cpufeatures. set(ENABLE_CPUFEATURES OFF) else() set_package_properties(CPUFEATURES PROPERTIES diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ff80de84e..581c9f239 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -31,6 +31,10 @@ All notable changes to GNSS-SDR will be documented in this file. - `geohash`, an [encoded geographic location](https://en.wikipedia.org/wiki/Geohash). +### Improvements in Portability: + +- Updated local `cpu_features` library to v0.9.0. + ### Improvements in Repeatability: - A Kalman filter is now available in the PVT block, smoothing the outputs of a diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 433170e12..89594968b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -257,8 +257,14 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^cortex") endif() # cpu_features - sensible defaults, user settable option -if(CMAKE_SYSTEM_PROCESSOR MATCHES - "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)|(^s390x)|^riscv") +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)|(^ARM64)" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(x86_64)|(AMD64|amd64)|(^i.86$)" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv" OR +CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch") option(VOLK_CPU_FEATURES "volk-gnsssdr uses cpu_features" ON) else() option(VOLK_CPU_FEATURES "volk-gnsssdr uses cpu_features" OFF) @@ -266,7 +272,7 @@ endif() if(CMAKE_VERSION VERSION_GREATER 3.0 AND VOLK_CPU_FEATURES) find_package(CPUFEATURES) - if(CPUFEATURES_FOUND AND (CMAKE_SYSTEM_PROCESSOR MATCHES "(^s390x)|^riscv") AND (CPUFEATURES_VERSION VERSION_LESS "0.8.0")) + if(CPUFEATURES_FOUND AND (CMAKE_SYSTEM_PROCESSOR MATCHES "(^s390x)|^riscv|^loongarch") AND (CPUFEATURES_VERSION VERSION_LESS "0.8.0")) set(USE_CPU_FEATURES OFF) unset(CPUFEATURES_FOUND CACHE) message(STATUS "Building volk-gnsssdr without cpu_features, installed version v${CPUFEATURES_VERSION} does not support the ${CMAKE_SYSTEM_PROCESSOR} architecture") @@ -274,20 +280,33 @@ if(CMAKE_VERSION VERSION_GREATER 3.0 AND VOLK_CPU_FEATURES) set(USE_CPU_FEATURES ON) endif() if(NOT CPUFEATURES_FOUND) - message(STATUS "Building volk-gnsssdr with cpu_features") - set(BUILD_TESTING OFF CACHE BOOL "Build cpu_features without tests." FORCE) - set(BUILD_PIC ON CACHE BOOL - "Build cpu_features with Position Independent Code (PIC)." - FORCE - ) - set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL - "Build cpu_features with Position Independent Code (PIC)." - FORCE - ) - set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") - set(BUILD_SHARED_LIBS OFF) - add_subdirectory(cpu_features) - set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") + if(CMAKE_VERSION VERSION_LESS 3.13) + message(STATUS "Building volk-gnsssdr without cpu_features") + else() + message(STATUS "Building volk-gnsssdr with cpu_features") + set(BUILD_TESTING OFF CACHE BOOL "Build cpu_features without tests." FORCE) + set(BUILD_PIC ON CACHE BOOL + "Build cpu_features with Position Independent Code (PIC)." + FORCE + ) + set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL + "Build cpu_features with Position Independent Code (PIC)." + FORCE + ) + set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") + set(BUILD_SHARED_LIBS OFF) + if(ENABLE_INSTALL) + set(ENABLE_INSTALL_AUX ${ENABLE_INSTALL}) + endif() + set(ENABLE_INSTALL ON) + add_subdirectory(cpu_features) + unset(ENABLE_INSTALL) + if(ENABLE_INSTALL_AUX) + set(ENABLE_INSTALL ${ENABLE_INSTALL_AUX}) + unset(ENABLE_INSTALL_AUX) + endif() + set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") + endif() endif() else() message(STATUS "Building volk-gnsssdr without cpu_features") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 5a060c3d1..d3c9269e0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -232,7 +232,7 @@ void read_results(std::vector *results, std::string if (single_kernel_result.size() == 3) { - volk_gnsssdr_test_results_t kernel_result{}; + volk_gnsssdr_test_results_t kernel_result; kernel_result.name = std::string(single_kernel_result[0]); kernel_result.config_name = std::string(single_kernel_result[0]); kernel_result.best_arch_u = std::string(single_kernel_result[1]); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt index c213b6016..7e7f7b90b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2017 Google LLC # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.13) # option() honors normal variables. # see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html @@ -9,11 +9,16 @@ if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif() -project(CpuFeatures VERSION 0.7.0 LANGUAGES C) +project(CpuFeatures VERSION 0.9.0 LANGUAGES C) set(CMAKE_C_STANDARD 99) -if(CMAKE_VERSION LESS "3.1") - add_compile_options("$<$,C>:-std=gnu99>") + +# when cpu_features is included as subproject (i.e. using add_subdirectory(cpu_features)) +# in the source tree of a project that uses it, test rules are disabled. +if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option(BUILD_TESTING "Enable test rule" OFF) +else() + option(BUILD_TESTING "Enable test rule" ON) endif() # Default Build Type to be Release @@ -23,6 +28,22 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif() +# An option to enable/disable the executable target list_cpu_features. +# Disable it by default if the project is included as a subproject. +if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option(BUILD_EXECUTABLE "Build list_cpu_features executable." OFF) +else() + option(BUILD_EXECUTABLE "Build list_cpu_features executable." ON) +endif() + +# An option which allows to switch off install steps. Useful for embedding. +# Disable it by default if the project is included as a subproject. +if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option(ENABLE_INSTALL "Enable install targets" OFF) +else() + option(ENABLE_INSTALL "Enable install targets" ON) +endif() + # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make # it prominent in the GUI. # cpu_features uses bit-fields which are - to some extends - implementation-defined (see https://en.cppreference.com/w/c/language/bit_field). @@ -57,14 +78,15 @@ set(PROCESSOR_IS_X86 FALSE) set(PROCESSOR_IS_POWER FALSE) set(PROCESSOR_IS_S390X FALSE) set(PROCESSOR_IS_RISCV FALSE) +set(PROCESSOR_IS_LOONGARCH FALSE) if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") set(PROCESSOR_IS_MIPS TRUE) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)|(^ARM64)") set(PROCESSOR_IS_AARCH64 TRUE) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") set(PROCESSOR_IS_ARM TRUE) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(x86_64)|(AMD64|amd64)|(^i.86$)") set(PROCESSOR_IS_X86 TRUE) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") set(PROCESSOR_IS_POWER TRUE) @@ -72,6 +94,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)") set(PROCESSOR_IS_S390X TRUE) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv") set(PROCESSOR_IS_RISCV TRUE) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch") + set(PROCESSOR_IS_LOONGARCH TRUE) endif() macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) @@ -85,6 +109,7 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_arm.h) elseif(PROCESSOR_IS_AARCH64) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_aarch64.h) + list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_aarch64.h) list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/windows_utils.h) elseif(PROCESSOR_IS_X86) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h) @@ -96,6 +121,8 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_s390x.h) elseif(PROCESSOR_IS_RISCV) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_riscv.h) + elseif(PROCESSOR_IS_LOONGARCH) + list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_loongarch.h) else() message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}") endif() @@ -123,6 +150,8 @@ setup_include_and_definitions(utils) if(UNIX) add_library(unix_based_hardware_detection OBJECT ${PROJECT_SOURCE_DIR}/include/internal/hwcaps.h + ${PROJECT_SOURCE_DIR}/src/hwcaps_linux_or_android.c + ${PROJECT_SOURCE_DIR}/src/hwcaps_freebsd.c ${PROJECT_SOURCE_DIR}/src/hwcaps.c ) setup_include_and_definitions(unix_based_hardware_detection) @@ -131,9 +160,13 @@ if(UNIX) target_compile_definitions(unix_based_hardware_detection PRIVATE HAVE_DLFCN_H) endif() check_symbol_exists(getauxval "sys/auxv.h" HAVE_STRONG_GETAUXVAL) + check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_STRONG_ELF_AUX_INFO) if(HAVE_STRONG_GETAUXVAL) target_compile_definitions(unix_based_hardware_detection PRIVATE HAVE_STRONG_GETAUXVAL) endif() + if(HAVE_STRONG_ELF_AUX_INFO) + target_compile_definitions(unix_based_hardware_detection PUBLIC HAVE_STRONG_ELF_AUX_INFO) + endif() endif() # @@ -153,20 +186,21 @@ target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS}) target_include_directories(cpu_features PUBLIC $ ) -if(PROCESSOR_IS_X86) - if(APPLE) - target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME) - endif() + +if(APPLE) + target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME) endif() -add_library(CpuFeature::cpu_features ALIAS cpu_features) +add_library(CpuFeatures::cpu_features ALIAS cpu_features) # # program : list_cpu_features # -add_executable(list_cpu_features ${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features.c) -target_link_libraries(list_cpu_features PRIVATE cpu_features) -add_executable(CpuFeature::list_cpu_features ALIAS list_cpu_features) +if(BUILD_EXECUTABLE) + add_executable(list_cpu_features ${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features.c) + target_link_libraries(list_cpu_features PRIVATE cpu_features) + add_executable(CpuFeatures::list_cpu_features ALIAS list_cpu_features) +endif() # # ndk_compat @@ -232,36 +266,47 @@ endif() # # Install cpu_features and list_cpu_features # - -include(GNUInstallDirs) -install(TARGETS cpu_features list_cpu_features - EXPORT CpuFeaturesTargets - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} -) -install(EXPORT CpuFeaturesTargets - NAMESPACE CpuFeatures:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures - COMPONENT Devel -) -include(CMakePackageConfigHelpers) -configure_package_config_file(cmake/CpuFeaturesConfig.cmake.in - "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" - NO_SET_AND_CHECK_MACRO - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) -write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake" - COMPATIBILITY SameMajorVersion -) -install( - FILES +if(ENABLE_INSTALL) + include(GNUInstallDirs) + install(TARGETS cpu_features + EXPORT CpuFeaturesTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + if(BUILD_EXECUTABLE) + install(TARGETS list_cpu_features + EXPORT CpuFeaturesTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endif() + install(EXPORT CpuFeaturesTargets + NAMESPACE CpuFeatures:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures + COMPONENT Devel + ) + include(CMakePackageConfigHelpers) + configure_package_config_file(cmake/CpuFeaturesConfig.cmake.in "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + write_basic_package_version_file( "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" - COMPONENT Devel -) + COMPATIBILITY SameMajorVersion + ) + install( + FILES + "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake" + "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" + COMPONENT Devel + ) +endif() \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/README.md b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/README.md index b23e8dec6..c39e6b076 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/README.md +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/README.md @@ -158,14 +158,14 @@ flags : aes,avx,cx16,smx,sse4_1,sse4_2,ssse3 ## What's supported -| | x86³ | AArch64 | ARM | MIPS⁴ | POWER | RISCV | s390x | -| ------- | :--: | :-----: | :-----: | :-----: | :-----: | :---: | :-----: | -| Linux | yes² | yes¹ | yes¹ | yes¹ | yes¹ | yes¹ | yes¹ | -| FreeBSD | yes² | not yet | not yet | not yet | not yet | N/A | not yet | -| MacOs | yes² | not yet | N/A | N/A | no | N/A | no | -| Windows | yes² | not yet | not yet | N/A | N/A | N/A | N/A | -| Android | yes² | yes¹ | yes¹ | yes¹ | N/A | N/A | N/A | -| iOS | N/A | not yet | not yet | N/A | N/A | N/A | N/A | +| | x86³ | AArch64 | ARM | MIPS⁴ | POWER | RISCV | Loongarch | s390x | +| ------- | :--: | :-----: | :-----: | :-----: | :-----: | :---: | :-------: | :-----: | +| Linux | yes² | yes¹ | yes¹ | yes¹ | yes¹ | yes¹ | yes¹ | yes¹ | +| FreeBSD | yes² | not yet | not yet | not yet | not yet | N/A | not yet | not yet | +| MacOs | yes² | yes⁵ | N/A | N/A | N/A | N/A | N/A | N/A | +| Windows | yes² | not yet | not yet | N/A | N/A | N/A | N/A | N/A | +| Android | yes² | yes¹ | yes¹ | yes¹ | N/A | N/A | N/A | N/A | +| iOS | N/A | not yet | not yet | N/A | N/A | N/A | N/A | N/A | 1. **Features revealed from Linux.** We gather data from several sources depending on availability: @@ -180,6 +180,8 @@ flags : aes,avx,cx16,smx,sse4_1,sse4_2,ssse3 microarchitecture allows the client to reject particular microarchitectures. 4. All flavors of Mips are supported, little and big endian as well as 32/64 bits. +5. **Features revealed from sysctl.** features are retrieved by the `sysctl` + instruction. diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h index 2a8442db9..42b4e55b1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h @@ -4,6 +4,7 @@ #ifndef CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ #define CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ +#include //////////////////////////////////////////////////////////////////////////////// // Architectures //////////////////////////////////////////////////////////////////////////////// @@ -52,14 +53,14 @@ #define CPU_FEATURES_ARCH_PPC #endif -#if defined(__riscv) -#define CPU_FEATURES_ARCH_RISCV -#endif - #if defined(__s390x__) #define CPU_FEATURES_ARCH_S390X #endif +#if defined(__riscv) +#define CPU_FEATURES_ARCH_RISCV +#endif + #if defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 32 #define CPU_FEATURES_ARCH_RISCV32 #endif @@ -72,6 +73,10 @@ #define CPU_FEATURES_ARCH_RISCV128 #endif +#if defined(__loongarch64) +#define CPU_FEATURES_ARCH_LOONGARCH +#endif + //////////////////////////////////////////////////////////////////////////////// // Os //////////////////////////////////////////////////////////////////////////////// @@ -372,4 +377,4 @@ #define CPU_FEATURES_DEPRECATED(message) #endif -#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ +#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h index 9fafccab8..618f17def 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h @@ -159,6 +159,27 @@ typedef struct int ecv : 1; // Enhanced counter virtualization. int afp : 1; // Alternate floating-point behaviour. int rpres : 1; // 12-bit reciprocal (square root) estimate precision. + int mte3 : 1; // MTE asymmetric fault handling. + int sme : 1; // Scalable Matrix Extension. + int smei16i64 : 1; // 16-bit to 64-bit integer widening outer product. + int smef64f64 : 1; // FP64 to FP64 outer product. + int smei8i32 : 1; // 8-bit to 32-bit integer widening outer product. + int smef16f32 : 1; // FP16 to FP32 outer product. + int smeb16f32 : 1; // BFloat16 to FP32 outper product. + int smef32f32 : 1; // FP32 to FP32 outer product. + int smefa64 : 1; // Full A64 support for SME in streaming mode. + int wfxt : 1; // WFE and WFI with timeout. + int ebf16 : 1; // Extended BFloat16 instructions. + int sveebf16 : 1; // SVE BFloat16 instructions. + int cssc : 1; // Common short sequence compression instructions. + int rprfm : 1; // Range Prefetch Memory hint instruction. + int sve2p1 : 1; // Scalable Vector Extension (version 2.1). + int sme2 : 1; // Scalable Matrix Extension (version 2). + int sme2p1 : 1; // Scalable Matrix Extension (version 2.1). + int smei16i32 : 1; // 16-bit to 64-bit integer widening outer product. + int smebi32i32 : 1; // 1-bit binary to 32-bit integer outer product. + int smeb16b16 : 1; // SME2.1 BFloat16 instructions. + int smef16f16 : 1; // FP16 to FP16 outer product. // Make sure to update Aarch64FeaturesEnum below if you add a field here. } Aarch64Features; @@ -234,6 +255,27 @@ typedef enum AARCH64_ECV, AARCH64_AFP, AARCH64_RPRES, + AARCH64_MTE3, + AARCH64_SME, + AARCH64_SME_I16I64, + AARCH64_SME_F64F64, + AARCH64_SME_I8I32, + AARCH64_SME_F16F32, + AARCH64_SME_B16F32, + AARCH64_SME_F32F32, + AARCH64_SME_FA64, + AARCH64_WFXT, + AARCH64_EBF16, + AARCH64_SVE_EBF16, + AARCH64_CSSC, + AARCH64_RPRFM, + AARCH64_SVE2P1, + AARCH64_SME2, + AARCH64_SME2P1, + AARCH64_SME_I16I32, + AARCH64_SME_BI32I32, + AARCH64_SME_B16B16, + AARCH64_SME_F16F16, AARCH64_LAST_, } Aarch64FeaturesEnum; @@ -248,4 +290,4 @@ CPU_FEATURES_END_CPP_NAMESPACE #error "Including cpuinfo_aarch64.h from a non-aarch64 target." #endif -#endif // CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ +#endif // CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_loongarch.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_loongarch.h new file mode 100644 index 000000000..9c4510144 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_loongarch.h @@ -0,0 +1,70 @@ +// SPDX-FileCopyrightText: 2013 Google LLC +// SPDX-License-Identifier: Apache-2.0 + + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_LOONGARCH_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_LOONGARCH_H_ + +#include "cpu_features_cache_info.h" +#include "cpu_features_macros.h" + +#if !defined(CPU_FEATURES_ARCH_LOONGARCH) +#error "Including cpuinfo_loongarch.h from a non-loongarch target." +#endif + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct +{ + // Base + int CPUCFG : 1; // Instruction for Identify CPU Features + + // Extension + int LAM : 1; // Extension for Atomic Memory Access Instructions + int UAL : 1; // Extension for Non-Aligned Memory Access + int FPU : 1; // Extension for Basic Floating-Point Instructions + int LSX : 1; // Extension for Loongson SIMD eXtension + int LASX : 1; // Extension for Loongson Advanced SIMD eXtension + int CRC32 : 1; // Extension for Cyclic Redundancy Check Instructions + int COMPLEX : 1; // Extension for Complex Vector Operation Instructions + int CRYPTO : 1; // Extension for Encryption And Decryption Vector + // Instructions + int LVZ : 1; // Extension for Virtualization + int LBT_X86 : 1; // Extension for X86 Binary Translation Extension + int LBT_ARM : 1; // Extension for ARM Binary Translation Extension + int LBT_MIPS : 1; // Extension for MIPS Binary Translation Extension + int PTW : 1; // Extension for Page Table Walker +} LoongArchFeatures; + +typedef struct +{ + LoongArchFeatures features; +} LoongArchInfo; + +typedef enum +{ + LOONGARCH_CPUCFG, + LOONGARCH_LAM, + LOONGARCH_UAL, + LOONGARCH_FPU, + LOONGARCH_LSX, + LOONGARCH_LASX, + LOONGARCH_CRC32, + LOONGARCH_COMPLEX, + LOONGARCH_CRYPTO, + LOONGARCH_LVZ, + LOONGARCH_LBT_X86, + LOONGARCH_LBT_ARM, + LOONGARCH_LBT_MIPS, + LOONGARCH_PTW, + LOONGARCH_LAST_, +} LoongArchFeaturesEnum; + +LoongArchInfo GetLoongArchInfo(void); +int GetLoongArchFeaturesEnumValue(const LoongArchFeatures* features, + LoongArchFeaturesEnum value); +const char* GetLoongArchFeaturesEnumName(LoongArchFeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_LOONGARCH_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_mips.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_mips.h index 038232bd0..333ea1d5a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_mips.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_mips.h @@ -63,4 +63,4 @@ CPU_FEATURES_END_CPP_NAMESPACE #error "Including cpuinfo_mips.h from a non-mips target." #endif -#endif // CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ +#endif // CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_riscv.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_riscv.h index 85bea6027..a9a59fd2a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_riscv.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_riscv.h @@ -26,6 +26,7 @@ typedef struct int D : 1; // Standard Extension for Double-Precision Floating-Point int Q : 1; // Standard Extension for Quad-Precision Floating-Point int C : 1; // Standard Extension for Compressed Instructions + int V : 1; // Standard Extension for Vector Instructions int Zicsr : 1; // Control and Status Register (CSR) int Zifencei : 1; // Instruction-Fetch Fence } RiscvFeatures; @@ -47,6 +48,7 @@ typedef enum RISCV_D, RISCV_Q, RISCV_C, + RISCV_V, RISCV_Zicsr, RISCV_Zifencei, RISCV_LAST_, diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_s390x.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_s390x.h index aad885e50..a76512c03 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_s390x.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_s390x.h @@ -89,7 +89,8 @@ typedef enum S390X_LAST_, } S390XFeaturesEnum; -int GetS390XFeaturesEnumValue(const S390XFeatures* features, S390XFeaturesEnum value); +int GetS390XFeaturesEnumValue(const S390XFeatures* features, + S390XFeaturesEnum value); const char* GetS390XFeaturesEnumName(S390XFeaturesEnum); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_x86.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_x86.h index 4db5efa4c..8bc36d143 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_x86.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_x86.h @@ -75,6 +75,7 @@ typedef struct int amx_bf16 : 1; int amx_tile : 1; int amx_int8 : 1; + int amx_fp16 : 1; int pclmulqdq : 1; int smx : 1; @@ -96,7 +97,10 @@ typedef struct int fz_rep_movsb : 1; // Fast zero-length REP MOVSB int fs_rep_stosb : 1; // Fast short REP STOSB int fs_rep_cmpsb_scasb : 1; // Fast short REP CMPSB/SCASB - // Make sure to update X86FeaturesEnum below if you add a field here. + + int lam : 1; // Intel Linear Address Mask + int uai : 1; // AMD Upper Address Ignore + // Make sure to update X86FeaturesEnum below if you add a field here. } X86Features; typedef struct @@ -114,7 +118,6 @@ X86Info GetX86Info(void); // Returns cache hierarchy informations. // Can call cpuid multiple times. -// Only works on Intel CPU at the moment. CacheInfo GetX86CacheInfo(void); typedef enum @@ -244,6 +247,7 @@ typedef enum X86_AMX_BF16, X86_AMX_TILE, X86_AMX_INT8, + X86_AMX_FP16, X86_PCLMULQDQ, X86_SMX, X86_SGX, @@ -263,6 +267,8 @@ typedef enum X86_FZ_REP_MOVSB, X86_FS_REP_STOSB, X86_FS_REP_CMPSB_SCASB, + X86_LAM, + X86_UAI, X86_LAST_, } X86FeaturesEnum; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_aarch64.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_aarch64.h new file mode 100644 index 000000000..618f17def --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_aarch64.h @@ -0,0 +1,293 @@ +// SPDX-FileCopyrightText: 2017 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +//////////////////////////////////////////////////////////////////////////////// +// A note on Windows AArch64 implementation +//////////////////////////////////////////////////////////////////////////////// + +// Getting cpu info via EL1 system registers is not possible, so we delegate it +// to the Windows API (i.e., IsProcessorFeaturePresent and GetNativeSystemInfo). +// The `implementer`, `variant` and `part` fields of the `Aarch64Info` struct +// are not used, so they are set to 0. To get `revision` we use +// `wProcessorRevision` from `SYSTEM_INFO`. +// +// Cryptographic Extension: +// ----------------------------------------------------------------------------- +// According to documentation Arm Architecture Reference Manual for +// A-profile architecture. A2.3 The Armv8 Cryptographic Extension. The Armv8.0 +// Cryptographic Extension provides instructions for the acceleration of +// encryption and decryption, and includes the following features: FEAT_AES, +// FEAT_PMULL, FEAT_SHA1, FEAT_SHA256. +// see: https://developer.arm.com/documentation/ddi0487/latest +// +// We use `PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE` to detect all Armv8.0 crypto +// features. This value reports all features or nothing, so even if you only +// have support FEAT_AES and FEAT_PMULL, it will still return false. +// +// From Armv8.2, an implementation of the Armv8.0 Cryptographic Extension can +// include either or both of: +// +// • The AES functionality, including support for multiplication of 64-bit +// polynomials. The ID_AA64ISAR0_EL1.AES field indicates whether this +// functionality is supported. +// • The SHA1 and SHA2-256 functionality. The ID_AA64ISAR0_EL1.{SHA2, SHA1} +// fields indicate whether this functionality is supported. +// +// ID_AA64ISAR0_EL1.AES, bits [7:4]: +// Indicates support for AES instructions in AArch64 state. Defined values are: +// - 0b0000 No AES instructions implemented. +// - 0b0001 AESE, AESD, AESMC, and AESIMC instructions implemented. +// - 0b0010 As for 0b0001, plus PMULL/PMULL2 instructions operating on 64-bit +// data quantities. +// +// FEAT_AES implements the functionality identified by the value 0b0001. +// FEAT_PMULL implements the functionality identified by the value 0b0010. +// From Armv8, the permitted values are 0b0000 and 0b0010. +// +// ID_AA64ISAR0_EL1.SHA1, bits [11:8]: +// Indicates support for SHA1 instructions in AArch64 state. Defined values are: +// - 0b0000 No SHA1 instructions implemented. +// - 0b0001 SHA1C, SHA1P, SHA1M, SHA1H, SHA1SU0, and SHA1SU1 instructions +// implemented. +// +// FEAT_SHA1 implements the functionality identified by the value 0b0001. +// From Armv8, the permitted values are 0b0000 and 0b0001. +// If the value of ID_AA64ISAR0_EL1.SHA2 is 0b0000, this field must have the +// value 0b0000. +// +// ID_AA64ISAR0_EL1.SHA2, bits [15:12]: +// Indicates support for SHA2 instructions in AArch64 state. Defined values are: +// - 0b0000 No SHA2 instructions implemented. +// - 0b0001 Implements instructions: SHA256H, SHA256H2, SHA256SU0, and +// SHA256SU1. +// - 0b0010 Implements instructions: +// • SHA256H, SHA256H2, SHA256SU0, and SHA256SU1. +// • SHA512H, SHA512H2, SHA512SU0, and SHA512SU1. +// +// FEAT_SHA256 implements the functionality identified by the value 0b0001. +// FEAT_SHA512 implements the functionality identified by the value 0b0010. +// +// In Armv8, the permitted values are 0b0000 and 0b0001. +// From Armv8.2, the permitted values are 0b0000, 0b0001, and 0b0010. +// +// If the value of ID_AA64ISAR0_EL1.SHA1 is 0b0000, this field must have the +// value 0b0000. +// +// If the value of this field is 0b0010, ID_AA64ISAR0_EL1.SHA3 +// must have the value 0b0001. +// +// Other cryptographic features that we cannot detect such as sha512, sha3, sm3, +// sm4, sveaes, svepmull, svesha3, svesm4 we set to 0. +// +// FP/SIMD: +// ----------------------------------------------------------------------------- +// FP/SIMD must be implemented on all Armv8.0 implementations, but +// implementations targeting specialized markets may support the following +// combinations: +// +// • No NEON or floating-point. +// • Full floating-point and SIMD support with exception trapping. +// • Full floating-point and SIMD support without exception trapping. +// +// ref: +// https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON +// +// So, we use `PF_ARM_VFP_32_REGISTERS_AVAILABLE`, +// `PF_ARM_NEON_INSTRUCTIONS_AVAILABLE` to detect `asimd` and `fp` + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ + +#include "cpu_features_cache_info.h" +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct +{ + int fp : 1; // Floating-point. + int asimd : 1; // Advanced SIMD. + int evtstrm : 1; // Generic timer generated events. + int aes : 1; // Hardware-accelerated Advanced Encryption Standard. + int pmull : 1; // Polynomial multiply long. + int sha1 : 1; // Hardware-accelerated SHA1. + int sha2 : 1; // Hardware-accelerated SHA2-256. + int crc32 : 1; // Hardware-accelerated CRC-32. + int atomics : 1; // Armv8.1 atomic instructions. + int fphp : 1; // Half-precision floating point support. + int asimdhp : 1; // Advanced SIMD half-precision support. + int cpuid : 1; // Access to certain ID registers. + int asimdrdm : 1; // Rounding Double Multiply Accumulate/Subtract. + int jscvt : 1; // Support for JavaScript conversion. + int fcma : 1; // Floating point complex numbers. + int lrcpc : 1; // Support for weaker release consistency. + int dcpop : 1; // Data persistence writeback. + int sha3 : 1; // Hardware-accelerated SHA3. + int sm3 : 1; // Hardware-accelerated SM3. + int sm4 : 1; // Hardware-accelerated SM4. + int asimddp : 1; // Dot product instruction. + int sha512 : 1; // Hardware-accelerated SHA512. + int sve : 1; // Scalable Vector Extension. + int asimdfhm : 1; // Additional half-precision instructions. + int dit : 1; // Data independent timing. + int uscat : 1; // Unaligned atomics support. + int ilrcpc : 1; // Additional support for weaker release consistency. + int flagm : 1; // Flag manipulation instructions. + int ssbs : 1; // Speculative Store Bypass Safe PSTATE bit. + int sb : 1; // Speculation barrier. + int paca : 1; // Address authentication. + int pacg : 1; // Generic authentication. + int dcpodp : 1; // Data cache clean to point of persistence. + int sve2 : 1; // Scalable Vector Extension (version 2). + int sveaes : 1; // SVE AES instructions. + int svepmull : 1; // SVE polynomial multiply long instructions. + int svebitperm : 1; // SVE bit permute instructions. + int svesha3 : 1; // SVE SHA3 instructions. + int svesm4 : 1; // SVE SM4 instructions. + int flagm2 : 1; // Additional flag manipulation instructions. + int frint : 1; // Floating point to integer rounding. + int svei8mm : 1; // SVE Int8 matrix multiplication instructions. + int svef32mm : 1; // SVE FP32 matrix multiplication instruction. + int svef64mm : 1; // SVE FP64 matrix multiplication instructions. + int svebf16 : 1; // SVE BFloat16 instructions. + int i8mm : 1; // Int8 matrix multiplication instructions. + int bf16 : 1; // BFloat16 instructions. + int dgh : 1; // Data Gathering Hint instruction. + int rng : 1; // True random number generator support. + int bti : 1; // Branch target identification. + int mte : 1; // Memory tagging extension. + int ecv : 1; // Enhanced counter virtualization. + int afp : 1; // Alternate floating-point behaviour. + int rpres : 1; // 12-bit reciprocal (square root) estimate precision. + int mte3 : 1; // MTE asymmetric fault handling. + int sme : 1; // Scalable Matrix Extension. + int smei16i64 : 1; // 16-bit to 64-bit integer widening outer product. + int smef64f64 : 1; // FP64 to FP64 outer product. + int smei8i32 : 1; // 8-bit to 32-bit integer widening outer product. + int smef16f32 : 1; // FP16 to FP32 outer product. + int smeb16f32 : 1; // BFloat16 to FP32 outper product. + int smef32f32 : 1; // FP32 to FP32 outer product. + int smefa64 : 1; // Full A64 support for SME in streaming mode. + int wfxt : 1; // WFE and WFI with timeout. + int ebf16 : 1; // Extended BFloat16 instructions. + int sveebf16 : 1; // SVE BFloat16 instructions. + int cssc : 1; // Common short sequence compression instructions. + int rprfm : 1; // Range Prefetch Memory hint instruction. + int sve2p1 : 1; // Scalable Vector Extension (version 2.1). + int sme2 : 1; // Scalable Matrix Extension (version 2). + int sme2p1 : 1; // Scalable Matrix Extension (version 2.1). + int smei16i32 : 1; // 16-bit to 64-bit integer widening outer product. + int smebi32i32 : 1; // 1-bit binary to 32-bit integer outer product. + int smeb16b16 : 1; // SME2.1 BFloat16 instructions. + int smef16f16 : 1; // FP16 to FP16 outer product. + + // Make sure to update Aarch64FeaturesEnum below if you add a field here. +} Aarch64Features; + +typedef struct +{ + Aarch64Features features; + int implementer; // We set 0 for Windows. + int variant; // We set 0 for Windows. + int part; // We set 0 for Windows. + int revision; // We use GetNativeSystemInfo to get processor revision for + // Windows. +} Aarch64Info; + +Aarch64Info GetAarch64Info(void); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum +{ + AARCH64_FP, + AARCH64_ASIMD, + AARCH64_EVTSTRM, + AARCH64_AES, + AARCH64_PMULL, + AARCH64_SHA1, + AARCH64_SHA2, + AARCH64_CRC32, + AARCH64_ATOMICS, + AARCH64_FPHP, + AARCH64_ASIMDHP, + AARCH64_CPUID, + AARCH64_ASIMDRDM, + AARCH64_JSCVT, + AARCH64_FCMA, + AARCH64_LRCPC, + AARCH64_DCPOP, + AARCH64_SHA3, + AARCH64_SM3, + AARCH64_SM4, + AARCH64_ASIMDDP, + AARCH64_SHA512, + AARCH64_SVE, + AARCH64_ASIMDFHM, + AARCH64_DIT, + AARCH64_USCAT, + AARCH64_ILRCPC, + AARCH64_FLAGM, + AARCH64_SSBS, + AARCH64_SB, + AARCH64_PACA, + AARCH64_PACG, + AARCH64_DCPODP, + AARCH64_SVE2, + AARCH64_SVEAES, + AARCH64_SVEPMULL, + AARCH64_SVEBITPERM, + AARCH64_SVESHA3, + AARCH64_SVESM4, + AARCH64_FLAGM2, + AARCH64_FRINT, + AARCH64_SVEI8MM, + AARCH64_SVEF32MM, + AARCH64_SVEF64MM, + AARCH64_SVEBF16, + AARCH64_I8MM, + AARCH64_BF16, + AARCH64_DGH, + AARCH64_RNG, + AARCH64_BTI, + AARCH64_MTE, + AARCH64_ECV, + AARCH64_AFP, + AARCH64_RPRES, + AARCH64_MTE3, + AARCH64_SME, + AARCH64_SME_I16I64, + AARCH64_SME_F64F64, + AARCH64_SME_I8I32, + AARCH64_SME_F16F32, + AARCH64_SME_B16F32, + AARCH64_SME_F32F32, + AARCH64_SME_FA64, + AARCH64_WFXT, + AARCH64_EBF16, + AARCH64_SVE_EBF16, + AARCH64_CSSC, + AARCH64_RPRFM, + AARCH64_SVE2P1, + AARCH64_SME2, + AARCH64_SME2P1, + AARCH64_SME_I16I32, + AARCH64_SME_BI32I32, + AARCH64_SME_B16B16, + AARCH64_SME_F16F16, + AARCH64_LAST_, +} Aarch64FeaturesEnum; + +int GetAarch64FeaturesEnumValue(const Aarch64Features* features, + Aarch64FeaturesEnum value); + +const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#if !defined(CPU_FEATURES_ARCH_AARCH64) +#error "Including cpuinfo_aarch64.h from a non-aarch64 target." +#endif + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_x86.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_x86.h index 4f743147c..c236cf05b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_x86.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/cpuid_x86.h @@ -23,4 +23,4 @@ uint32_t GetXCR0Eax(void); CPU_FEATURES_END_CPP_NAMESPACE -#endif // CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ +#endif // CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h index c5836af35..a787aa966 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h @@ -71,6 +71,27 @@ CPU_FEATURES_START_CPP_NAMESPACE #define AARCH64_HWCAP2_ECV (1UL << 19) #define AARCH64_HWCAP2_AFP (1UL << 20) #define AARCH64_HWCAP2_RPRES (1UL << 21) +#define AARCH64_HWCAP2_MTE3 (1UL << 22) +#define AARCH64_HWCAP2_SME (1UL << 23) +#define AARCH64_HWCAP2_SME_I16I64 (1UL << 24) +#define AARCH64_HWCAP2_SME_F64F64 (1UL << 25) +#define AARCH64_HWCAP2_SME_I8I32 (1UL << 26) +#define AARCH64_HWCAP2_SME_F16F32 (1UL << 27) +#define AARCH64_HWCAP2_SME_B16F32 (1UL << 28) +#define AARCH64_HWCAP2_SME_F32F32 (1UL << 29) +#define AARCH64_HWCAP2_SME_FA64 (1UL << 30) +#define AARCH64_HWCAP2_WFXT (1UL << 31) +#define AARCH64_HWCAP2_EBF16 (1UL << 32) +#define AARCH64_HWCAP2_SVE_EBF16 (1UL << 33) +#define AARCH64_HWCAP2_CSSC (1UL << 34) +#define AARCH64_HWCAP2_RPRFM (1UL << 35) +#define AARCH64_HWCAP2_SVE2P1 (1UL << 36) +#define AARCH64_HWCAP2_SME2 (1UL << 37) +#define AARCH64_HWCAP2_SME2P1 (1UL << 38) +#define AARCH64_HWCAP2_SME_I16I32 (1UL << 39) +#define AARCH64_HWCAP2_SME_BI32I32 (1UL << 40) +#define AARCH64_HWCAP2_SME_B16B16 (1UL << 41) +#define AARCH64_HWCAP2_SME_F16F16 (1UL << 42) // http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/uapi/asm/hwcap.h #define ARM_HWCAP_SWP (1UL << 0) @@ -202,6 +223,23 @@ CPU_FEATURES_START_CPP_NAMESPACE #define RISCV_HWCAP_D (1UL << ('D' - 'A')) #define RISCV_HWCAP_Q (1UL << ('Q' - 'A')) #define RISCV_HWCAP_C (1UL << ('C' - 'A')) +#define RISCV_HWCAP_V (1UL << ('V' - 'A')) + +// https://github.com/torvalds/linux/blob/master/arch/loongarch/include/uapi/asm/hwcap.h +#define HWCAP_LOONGARCH_CPUCFG (1 << 0) +#define HWCAP_LOONGARCH_LAM (1 << 1) +#define HWCAP_LOONGARCH_UAL (1 << 2) +#define HWCAP_LOONGARCH_FPU (1 << 3) +#define HWCAP_LOONGARCH_LSX (1 << 4) +#define HWCAP_LOONGARCH_LASX (1 << 5) +#define HWCAP_LOONGARCH_CRC32 (1 << 6) +#define HWCAP_LOONGARCH_COMPLEX (1 << 7) +#define HWCAP_LOONGARCH_CRYPTO (1 << 8) +#define HWCAP_LOONGARCH_LVZ (1 << 9) +#define HWCAP_LOONGARCH_LBT_X86 (1 << 10) +#define HWCAP_LOONGARCH_LBT_ARM (1 << 11) +#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12) +#define HWCAP_LOONGARCH_PTW (1 << 13) typedef struct { @@ -225,4 +263,4 @@ const char* CpuFeatures_GetBasePlatformPointer(void); CPU_FEATURES_END_CPP_NAMESPACE -#endif // CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ +#endif // CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h index cc08d3c9f..49a64164f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h @@ -55,4 +55,4 @@ #endif #endif // CPU_FEATURES_OS_WINDOWS -#endif // CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ +#endif // CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps.c index 9a13d8b75..6b5f571e0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps.c @@ -2,11 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "internal/hwcaps.h" -#include "cpu_features_macros.h" -#include "internal/filesystem.h" -#include "internal/string_view.h" -#include -#include +#include static bool IsSet(const uint32_t mask, const uint32_t value) { @@ -20,159 +16,3 @@ bool CpuFeatures_IsHwCapsSet(const HardwareCapabilities hwcaps_mask, return IsSet(hwcaps_mask.hwcaps, hwcaps.hwcaps) || IsSet(hwcaps_mask.hwcaps2, hwcaps.hwcaps2); } - -#ifdef CPU_FEATURES_TEST -// In test mode, hwcaps_for_testing will define the following functions. -HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void); -const char* CpuFeatures_GetPlatformPointer(void); -const char* CpuFeatures_GetBasePlatformPointer(void); -#else - -// Debug facilities -#if defined(NDEBUG) -#define D(...) -#else -#include -#define D(...) \ - do \ - { \ - printf(__VA_ARGS__); \ - fflush(stdout); \ - } \ - while (0) -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Implementation of GetElfHwcapFromGetauxval -//////////////////////////////////////////////////////////////////////////////// - -#define AT_HWCAP 16 -#define AT_HWCAP2 26 -#define AT_PLATFORM 15 -#define AT_BASE_PLATFORM 24 - -#if defined(HAVE_STRONG_GETAUXVAL) -#include -static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) -{ - return getauxval(hwcap_type); -} -#elif defined(HAVE_DLFCN_H) -// On Android we probe the system's C library for a 'getauxval' function and -// call it if it exits, or return 0 for failure. This function is available -// since API level 18. -// -// Note that getauxval() can't really be re-implemented here, because its -// implementation does not parse /proc/self/auxv. Instead it depends on values -// that are passed by the kernel at process-init time to the C runtime -// initialization layer. - -#include - -typedef unsigned long getauxval_func_t(unsigned long); - -static uint32_t GetElfHwcapFromGetauxval(uint32_t hwcap_type) -{ - uint32_t ret = 0; - void *libc_handle = NULL; - getauxval_func_t *func = NULL; - - dlerror(); // Cleaning error state before calling dlopen. - libc_handle = dlopen("libc.so", RTLD_NOW); - if (!libc_handle) - { - D("Could not dlopen() C library: %s\n", dlerror()); - return 0; - } - func = (getauxval_func_t *)dlsym(libc_handle, "getauxval"); - if (!func) - { - D("Could not find getauxval() in C library\n"); - } - else - { - // Note: getauxval() returns 0 on failure. Doesn't touch errno. - ret = (uint32_t)(*func)(hwcap_type); - } - dlclose(libc_handle); - return ret; -} -#else -#error "This platform does not provide hardware capabilities." -#endif - -// Implementation of GetHardwareCapabilities for OS that provide -// GetElfHwcapFromGetauxval(). - -// Fallback when getauxval is not available, retrieves hwcaps from -// "/proc/self/auxv". -static uint32_t GetElfHwcapFromProcSelfAuxv(uint32_t hwcap_type) -{ - struct - { - uint32_t tag; - uint32_t value; - } entry; - uint32_t result = 0; - const char filepath[] = "/proc/self/auxv"; - const int fd = CpuFeatures_OpenFile(filepath); - if (fd < 0) - { - D("Could not open %s\n", filepath); - return 0; - } - for (;;) - { - const int ret = CpuFeatures_ReadFile(fd, (char *)&entry, sizeof entry); - if (ret < 0) - { - D("Error while reading %s\n", filepath); - break; - } - // Detect end of list. - if (ret == 0 || (entry.tag == 0 && entry.value == 0)) - { - break; - } - if (entry.tag == hwcap_type) - { - result = entry.value; - break; - } - } - CpuFeatures_CloseFile(fd); - return result; -} - -// Retrieves hardware capabilities by first trying to call getauxval, if not -// available falls back to reading "/proc/self/auxv". -static unsigned long GetHardwareCapabilitiesFor(uint32_t type) -{ - unsigned long hwcaps = GetElfHwcapFromGetauxval(type); - if (!hwcaps) - { - D("Parsing /proc/self/auxv to extract ELF hwcaps!\n"); - hwcaps = GetElfHwcapFromProcSelfAuxv(type); - } - return hwcaps; -} - -HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) -{ - HardwareCapabilities capabilities; - capabilities.hwcaps = GetHardwareCapabilitiesFor(AT_HWCAP); - capabilities.hwcaps2 = GetHardwareCapabilitiesFor(AT_HWCAP2); - return capabilities; -} - -const char *CpuFeatures_GetPlatformPointer(void) -{ - return (const char *)GetHardwareCapabilitiesFor(AT_PLATFORM); -} - -const char *CpuFeatures_GetBasePlatformPointer(void) -{ - return (const char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM); -} - -#endif // CPU_FEATURES_TEST diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_freebsd.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_freebsd.c new file mode 100644 index 000000000..34c29e7ae --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_freebsd.c @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_OS_FREEBSD + +#include "internal/hwcaps.h" + +#ifdef CPU_FEATURES_TEST +// In test mode, hwcaps_for_testing will define the following functions. +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void); +const char* CpuFeatures_GetPlatformPointer(void); +const char* CpuFeatures_GetBasePlatformPointer(void); +#else + +#ifdef HAVE_STRONG_ELF_AUX_INFO +#include +#include + +static unsigned long GetElfHwcapFromElfAuxInfo(int hwcap_type) +{ + unsigned long hwcap; + elf_aux_info(hwcap_type, &hwcap, sizeof(hwcap)); + return hwcap; +} + +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) +{ + HardwareCapabilities capabilities; + capabilities.hwcaps = GetElfHwcapFromElfAuxInfo(AT_HWCAP); + capabilities.hwcaps2 = GetElfHwcapFromElfAuxInfo(AT_HWCAP2); + return capabilities; +} + +const char *CpuFeatures_GetPlatformPointer(void) { return NULL; } + +const char *CpuFeatures_GetBasePlatformPointer(void) { return NULL; } + +#else +#error "FreeBSD needs support for elf_aux_info" +#endif // HAVE_STRONG_ELF_AUX_INFO + +#endif // CPU_FEATURES_TEST +#endif // CPU_FEATURES_OS_FREEBSD \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_linux_or_android.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_linux_or_android.c new file mode 100644 index 000000000..0ee0b142d --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/hwcaps_linux_or_android.c @@ -0,0 +1,166 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) + +#include "cpu_features_macros.h" +#include "internal/filesystem.h" +#include "internal/hwcaps.h" +#include "internal/string_view.h" +#include +#include + +#ifdef CPU_FEATURES_TEST +// In test mode, hwcaps_for_testing will define the following functions. +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void); +const char* CpuFeatures_GetPlatformPointer(void); +const char* CpuFeatures_GetBasePlatformPointer(void); +#else + +// Debug facilities +#if defined(NDEBUG) +#define D(...) +#else +#include +// clang-format off +#define D(...) \ + do { \ + printf(__VA_ARGS__); \ + fflush(stdout); \ + } \ + while (0) +// clang-format on +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Implementation of GetElfHwcapFromGetauxval +//////////////////////////////////////////////////////////////////////////////// + +#if defined(HAVE_STRONG_GETAUXVAL) +#include +static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) +{ + return getauxval(hwcap_type); +} +#elif defined(HAVE_DLFCN_H) +// On Android we probe the system's C library for a 'getauxval' function and +// call it if it exits, or return 0 for failure. This function is available +// since API level 18. +// +// Note that getauxval() can't really be re-implemented here, because its +// implementation does not parse /proc/self/auxv. Instead it depends on values +// that are passed by the kernel at process-init time to the C runtime +// initialization layer. + +#include + +typedef unsigned long getauxval_func_t(unsigned long); + +static uint32_t GetElfHwcapFromGetauxval(uint32_t hwcap_type) +{ + uint32_t ret = 0; + void *libc_handle = NULL; + getauxval_func_t *func = NULL; + + dlerror(); // Cleaning error state before calling dlopen. + libc_handle = dlopen("libc.so", RTLD_NOW); + if (!libc_handle) + { + D("Could not dlopen() C library: %s\n", dlerror()); + return 0; + } + func = (getauxval_func_t *)dlsym(libc_handle, "getauxval"); + if (!func) + { + D("Could not find getauxval() in C library\n"); + } + else + { + // Note: getauxval() returns 0 on failure. Doesn't touch errno. + ret = (uint32_t)(*func)(hwcap_type); + } + dlclose(libc_handle); + return ret; +} +#else +#error "This platform does not provide hardware capabilities." +#endif + +// Implementation of GetHardwareCapabilities for OS that provide +// GetElfHwcapFromGetauxval(). + +// Fallback when getauxval is not available, retrieves hwcaps from +// "/proc/self/auxv". +static uint32_t GetElfHwcapFromProcSelfAuxv(uint32_t hwcap_type) +{ + struct + { + uint32_t tag; + uint32_t value; + } entry; + uint32_t result = 0; + const char filepath[] = "/proc/self/auxv"; + const int fd = CpuFeatures_OpenFile(filepath); + if (fd < 0) + { + D("Could not open %s\n", filepath); + return 0; + } + for (;;) + { + const int ret = CpuFeatures_ReadFile(fd, (char *)&entry, sizeof entry); + if (ret < 0) + { + D("Error while reading %s\n", filepath); + break; + } + // Detect end of list. + if (ret == 0 || (entry.tag == 0 && entry.value == 0)) + { + break; + } + if (entry.tag == hwcap_type) + { + result = entry.value; + break; + } + } + CpuFeatures_CloseFile(fd); + return result; +} + +// Retrieves hardware capabilities by first trying to call getauxval, if not +// available falls back to reading "/proc/self/auxv". +static unsigned long GetHardwareCapabilitiesFor(uint32_t type) +{ + unsigned long hwcaps = GetElfHwcapFromGetauxval(type); + if (!hwcaps) + { + D("Parsing /proc/self/auxv to extract ELF hwcaps!\n"); + hwcaps = GetElfHwcapFromProcSelfAuxv(type); + } + return hwcaps; +} + +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) +{ + HardwareCapabilities capabilities; + capabilities.hwcaps = GetHardwareCapabilitiesFor(AT_HWCAP); + capabilities.hwcaps2 = GetHardwareCapabilitiesFor(AT_HWCAP2); + return capabilities; +} + +const char *CpuFeatures_GetPlatformPointer(void) +{ + return (const char *)GetHardwareCapabilitiesFor(AT_PLATFORM); +} + +const char *CpuFeatures_GetBasePlatformPointer(void) +{ + return (const char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM); +} + +#endif // CPU_FEATURES_TEST +#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64__base_implementation.inl b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64__base_implementation.inl new file mode 100644 index 000000000..36fd9a65c --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64__base_implementation.inl @@ -0,0 +1,106 @@ +// SPDX-FileCopyrightText: 2021 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" +#include "cpuinfo_aarch64.h" +#include "internal/bit_utils.h" +#include "internal/filesystem.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" +#include + +#if !defined(CPU_FEATURES_ARCH_AARCH64) +#error "Cannot compile aarch64_base on a non aarch64 platform." +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Definitions for introspection. +//////////////////////////////////////////////////////////////////////////////// +#define INTROSPECTION_TABLE \ + LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \ + LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \ + LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \ + LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \ + LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \ + LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \ + LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \ + LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \ + LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \ + LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \ + LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \ + LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \ + LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \ + LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \ + LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \ + LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \ + LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \ + LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \ + LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \ + LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \ + LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \ + LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \ + LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \ + LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \ + LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \ + LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \ + LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \ + LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \ + LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \ + LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \ + LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \ + LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \ + LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \ + LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \ + LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \ + LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \ + LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \ + AARCH64_HWCAP2_SVEBITPERM) \ + LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \ + LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \ + LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \ + LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \ + LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \ + LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \ + LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \ + LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \ + LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \ + LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \ + LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \ + LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \ + LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \ + LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE) \ + LINE(AARCH64_ECV, ecv, "ecv", 0, AARCH64_HWCAP2_ECV) \ + LINE(AARCH64_AFP, afp, "afp", 0, AARCH64_HWCAP2_AFP) \ + LINE(AARCH64_RPRES, rpres, "rpres", 0, AARCH64_HWCAP2_RPRES) \ + LINE(AARCH64_MTE3, mte3, "mte3", 0, AARCH64_HWCAP2_MTE3) \ + LINE(AARCH64_SME, sme, "sme", 0, AARCH64_HWCAP2_SME) \ + LINE(AARCH64_SME_I16I64, smei16i64, "smei16i64", 0, \ + AARCH64_HWCAP2_SME_I16I64) \ + LINE(AARCH64_SME_F64F64, smef64f64, "smef64f64", 0, \ + AARCH64_HWCAP2_SME_F64F64) \ + LINE(AARCH64_SME_I8I32, smei8i32, "smei8i32", 0, AARCH64_HWCAP2_SME_I8I32) \ + LINE(AARCH64_SME_F16F32, smef16f32, "smef16f32", 0, \ + AARCH64_HWCAP2_SME_F16F32) \ + LINE(AARCH64_SME_B16F32, smeb16f32, "smeb16f32", 0, \ + AARCH64_HWCAP2_SME_B16F32) \ + LINE(AARCH64_SME_F32F32, smef32f32, "smef32f32", 0, \ + AARCH64_HWCAP2_SME_F32F32) \ + LINE(AARCH64_SME_FA64, smefa64, "smefa64", 0, AARCH64_HWCAP2_SME_FA64) \ + LINE(AARCH64_WFXT, wfxt, "wfxt", 0, AARCH64_HWCAP2_WFXT) \ + LINE(AARCH64_EBF16, ebf16, "ebf16", 0, AARCH64_HWCAP2_EBF16) \ + LINE(AARCH64_SVE_EBF16, sveebf16, "sveebf16", 0, AARCH64_HWCAP2_SVE_EBF16) \ + LINE(AARCH64_CSSC, cssc, "cssc", 0, AARCH64_HWCAP2_CSSC) \ + LINE(AARCH64_RPRFM, rprfm, "rprfm", 0, AARCH64_HWCAP2_RPRFM) \ + LINE(AARCH64_SVE2P1, sve2p1, "sve2p1", 0, AARCH64_HWCAP2_SVE2P1) \ + LINE(AARCH64_SME2, sme2, "sme2", 0, AARCH64_HWCAP2_SME2) \ + LINE(AARCH64_SME2P1, sme2p1, "sme2p1", 0, AARCH64_HWCAP2_SME2P1) \ + LINE(AARCH64_SME_I16I32, smei16i32, "smei16i32", 0, \ + AARCH64_HWCAP2_SME_I16I32) \ + LINE(AARCH64_SME_BI32I32, smebi32i32, "smebi32i32", 0, \ + AARCH64_HWCAP2_SME_BI32I32) \ + LINE(AARCH64_SME_B16B16, smeb16b16, "smeb16b16", 0, \ + AARCH64_HWCAP2_SME_B16B16) \ + LINE(AARCH64_SME_F16F16, smef16f16, "smef16f16", 0, AARCH64_HWCAP2_SME_F16F16) +#define INTROSPECTION_PREFIX Aarch64 +#define INTROSPECTION_ENUM_PREFIX AARCH64 +#include "define_introspection_and_hwcaps.inl" \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_cpuid.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_cpuid.c new file mode 100644 index 000000000..5ae3a1df7 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_cpuid.c @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_ARCH_AARCH64 +#if (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) || \ + defined(CPU_FEATURES_OS_ANDROID)) +#if (defined(CPU_FEATURES_COMPILER_GCC) || defined(CPU_FEATURES_COMPILER_CLANG)) + +#include "internal/cpuid_aarch64.h" + +#ifdef CPU_FEATURES_MOCK_CPUID_AARCH64 +// Implementation will be provided by test/cpuinfo_aarch64_test.cc. +#else +uint64_t GetMidrEl1(void) +{ + uint64_t midr_el1; + // clang-format off + __asm("mrs %0, MIDR_EL1" : "=r"(midr_el1)); + // clang-format on + return midr_el1; +} +#endif // CPU_FEATURES_MOCK_CPUID_AARCH64 + +#else +#error "Unsupported compiler, aarch64 cpuid requires either GCC or Clang." +#endif // (defined(CPU_FEATURES_COMPILER_GCC) || + // defined(CPU_FEATURES_COMPILER_CLANG)) +#endif // (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) + // || defined(CPU_FEATURES_OS_ANDROID)) +#endif // CPU_FEATURES_ARCH_AARCH64 \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_freebsd.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_freebsd.c new file mode 100644 index 000000000..7360da790 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_freebsd.c @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_ARCH_AARCH64 +#ifdef CPU_FEATURES_OS_FREEBSD + +#include "cpuinfo_aarch64.h" +#include "internal/cpuid_aarch64.h" +#include "internal/hwcaps.h" +#include "impl_aarch64__base_implementation.inl" + +static const Aarch64Info kEmptyAarch64Info; + +Aarch64Info GetAarch64Info(void) +{ + Aarch64Info info = kEmptyAarch64Info; + const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities(); + for (size_t i = 0; i < AARCH64_LAST_; ++i) + { + if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps)) + { + kSetters[i](&info.features, true); + } + } + if (info.features.cpuid) + { + const uint64_t midr_el1 = GetMidrEl1(); + info.implementer = (int)ExtractBitRange(midr_el1, 31, 24); + info.variant = (int)ExtractBitRange(midr_el1, 23, 20); + info.part = (int)ExtractBitRange(midr_el1, 15, 4); + info.revision = (int)ExtractBitRange(midr_el1, 3, 0); + } + return info; +} + +#endif // CPU_FEATURES_OS_FREEBSD +#endif // CPU_FEATURES_ARCH_AARCH64 diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_linux_or_android.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_linux_or_android.c index 98417fbdf..3c84074f1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_linux_or_android.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_linux_or_android.c @@ -6,80 +6,7 @@ #ifdef CPU_FEATURES_ARCH_AARCH64 #if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) -#include "cpuinfo_aarch64.h" - -//////////////////////////////////////////////////////////////////////////////// -// Definitions for introspection. -//////////////////////////////////////////////////////////////////////////////// -#define INTROSPECTION_TABLE \ - LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \ - LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \ - LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \ - LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \ - LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \ - LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \ - LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \ - LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \ - LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \ - LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \ - LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \ - LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \ - LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \ - LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \ - LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \ - LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \ - LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \ - LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \ - LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \ - LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \ - LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \ - LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \ - LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \ - LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \ - LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \ - LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \ - LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \ - LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \ - LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \ - LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \ - LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \ - LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \ - LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \ - LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \ - LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \ - LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \ - LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \ - AARCH64_HWCAP2_SVEBITPERM) \ - LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \ - LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \ - LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \ - LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \ - LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \ - LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \ - LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \ - LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \ - LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \ - LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \ - LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \ - LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \ - LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \ - LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE) \ - LINE(AARCH64_ECV, ecv, "ecv", 0, AARCH64_HWCAP2_ECV) \ - LINE(AARCH64_AFP, afp, "afp", 0, AARCH64_HWCAP2_AFP) \ - LINE(AARCH64_RPRES, rpres, "rpres", 0, AARCH64_HWCAP2_RPRES) -#define INTROSPECTION_PREFIX Aarch64 -#define INTROSPECTION_ENUM_PREFIX AARCH64 -#include "define_introspection_and_hwcaps.inl" - -//////////////////////////////////////////////////////////////////////////////// -// Implementation. -//////////////////////////////////////////////////////////////////////////////// - -#include "internal/bit_utils.h" -#include "internal/filesystem.h" -#include "internal/stack_line_reader.h" -#include "internal/string_view.h" -#include +#include "impl_aarch64__base_implementation.inl" static bool HandleAarch64Line(const LineResult result, Aarch64Info* const info) @@ -157,4 +84,4 @@ Aarch64Info GetAarch64Info(void) } #endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) -#endif // CPU_FEATURES_ARCH_AARCH64 +#endif // CPU_FEATURES_ARCH_AARCH64 \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_macos_or_iphone.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_macos_or_iphone.c new file mode 100644 index 000000000..0c71e9fef --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_macos_or_iphone.c @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: 2021 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_ARCH_AARCH64 +#if defined(CPU_FEATURES_OS_MACOS) || defined(CPU_FEATURES_OS_IPHONE) + +#include "impl_aarch64__base_implementation.inl" + +#if !defined(HAVE_SYSCTLBYNAME) +#error "Darwin needs support for sysctlbyname" +#endif +#include + +#if defined(CPU_FEATURES_MOCK_SYSCTL_AARCH64) +extern bool GetDarwinSysCtlByName(const char*); +extern int GetDarwinSysCtlByNameValue(const char* name); +#else +static int GetDarwinSysCtlByNameValue(const char* name) +{ + int enabled; + size_t enabled_len = sizeof(enabled); + const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0); + return failure ? 0 : enabled; +} + +static bool GetDarwinSysCtlByName(const char* name) +{ + return GetDarwinSysCtlByNameValue(name) != 0; +} +#endif + +static const Aarch64Info kEmptyAarch64Info; + +Aarch64Info GetAarch64Info(void) +{ + Aarch64Info info = kEmptyAarch64Info; + + // Handling Darwin platform through sysctlbyname. + info.implementer = GetDarwinSysCtlByNameValue("hw.cputype"); + info.variant = GetDarwinSysCtlByNameValue("hw.cpusubtype"); + info.part = GetDarwinSysCtlByNameValue("hw.cpufamily"); + info.revision = GetDarwinSysCtlByNameValue("hw.cpusubfamily"); + + info.features.fp = GetDarwinSysCtlByName("hw.optional.floatingpoint"); + info.features.asimd = GetDarwinSysCtlByName("hw.optional.AdvSIMD"); + info.features.aes = GetDarwinSysCtlByName("hw.optional.arm.FEAT_AES"); + info.features.pmull = GetDarwinSysCtlByName("hw.optional.arm.FEAT_PMULL"); + info.features.sha1 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA1"); + info.features.sha2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA256"); + info.features.crc32 = GetDarwinSysCtlByName("hw.optional.armv8_crc32"); + info.features.atomics = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LSE"); + info.features.fphp = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FP16"); + info.features.asimdhp = + GetDarwinSysCtlByName("hw.optional.arm.AdvSIMD_HPFPCvt"); + info.features.asimdrdm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_RDM"); + info.features.jscvt = GetDarwinSysCtlByName("hw.optional.arm.FEAT_JSCVT"); + info.features.fcma = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FCMA"); + info.features.lrcpc = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LRCPC"); + info.features.dcpop = GetDarwinSysCtlByName("hw.optional.arm.FEAT_DPB"); + info.features.sha3 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA3"); + info.features.asimddp = GetDarwinSysCtlByName("hw.optional.arm.FEAT_DotProd"); + info.features.sha512 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA512"); + info.features.asimdfhm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FHM"); + info.features.dit = GetDarwinSysCtlByName("hw.optional.arm.FEAT_DIT"); + info.features.uscat = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LSE2"); + info.features.flagm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FlagM"); + info.features.ssbs = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SSBS"); + info.features.sb = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SB"); + info.features.flagm2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FlagM2"); + info.features.frint = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FRINTTS"); + info.features.i8mm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_I8MM"); + info.features.bf16 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BF16"); + info.features.bti = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BTI"); + + return info; +} + +#endif // defined(CPU_FEATURES_OS_MACOS) || defined(CPU_FEATURES_OS_IPHONE) +#endif // CPU_FEATURES_ARCH_AARCH64 diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c index dd830863b..1158a8982 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c @@ -81,8 +81,7 @@ extern bool GetWindowsIsProcessorFeaturePresent(DWORD); extern WORD GetWindowsNativeSystemInfoProcessorRevision(); #else // CPU_FEATURES_MOCK_CPUID_AARCH64 -static bool -GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) +static bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { return IsProcessorFeaturePresent(dwProcessorFeature); } @@ -116,7 +115,6 @@ Aarch64Info GetAarch64Info(void) info.features.atomics = GetWindowsIsProcessorFeaturePresent( PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE); - bool is_crypto_available = GetWindowsIsProcessorFeaturePresent( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); info.features.aes = is_crypto_available; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_loongarch_linux.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_loongarch_linux.c new file mode 100644 index 000000000..f2a168279 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_loongarch_linux.c @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_ARCH_LOONGARCH +#if defined(CPU_FEATURES_OS_LINUX) + +#include "cpuinfo_loongarch.h" + +//////////////////////////////////////////////////////////////////////////////// +// Definitions for introspection. +//////////////////////////////////////////////////////////////////////////////// +#define INTROSPECTION_TABLE \ + LINE(LOONGARCH_CPUCFG, CPUCFG, "cfg", HWCAP_LOONGARCH_CPUCFG, 0) \ + LINE(LOONGARCH_LAM, LAM, "lam", HWCAP_LOONGARCH_LAM, 0) \ + LINE(LOONGARCH_UAL, UAL, "ual", HWCAP_LOONGARCH_UAL, 0) \ + LINE(LOONGARCH_FPU, FPU, "fpu", HWCAP_LOONGARCH_FPU, 0) \ + LINE(LOONGARCH_LSX, LSX, "lsx", HWCAP_LOONGARCH_LSX, 0) \ + LINE(LOONGARCH_LASX, LASX, "lasx", HWCAP_LOONGARCH_LASX, 0) \ + LINE(LOONGARCH_CRC32, CRC32, "crc32", HWCAP_LOONGARCH_CRC32, 0) \ + LINE(LOONGARCH_COMPLEX, COMPLEX, "complex", HWCAP_LOONGARCH_COMPLEX, 0) \ + LINE(LOONGARCH_CRYPTO, CRYPTO, "crypto", HWCAP_LOONGARCH_CRYPTO, 0) \ + LINE(LOONGARCH_LVZ, LVZ, "lvz", HWCAP_LOONGARCH_LVZ, 0) \ + LINE(LOONGARCH_LBT_X86, LBT_X86, "lbt_x86", HWCAP_LOONGARCH_LBT_X86, 0) \ + LINE(LOONGARCH_LBT_ARM, LBT_ARM, "lbt_arm", HWCAP_LOONGARCH_LBT_ARM, 0) \ + LINE(LOONGARCH_LBT_MIPS, LBT_MIPS, "lbt_mips", HWCAP_LOONGARCH_LBT_MIPS, 0) \ + LINE(LOONGARCH_PTW, PTW, "ptw", HWCAP_LOONGARCH_PTW, 0) +#define INTROSPECTION_PREFIX LoongArch +#define INTROSPECTION_ENUM_PREFIX LOONGARCH +#include "define_introspection_and_hwcaps.inl" + +//////////////////////////////////////////////////////////////////////////////// +// Implementation. +//////////////////////////////////////////////////////////////////////////////// + +#include "internal/filesystem.h" +#include "internal/stack_line_reader.h" +#include +#include + +static const LoongArchInfo kEmptyLoongArchInfo; + +static bool HandleLoongArchLine(const LineResult result, + LoongArchInfo* const info) +{ + StringView line = result.line; + StringView key, value; + if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) + { + if (CpuFeatures_StringView_IsEquals(key, str("Features"))) + { + for (size_t i = 0; i < LOONGARCH_LAST_; ++i) + { + kSetters[i](&info->features, CpuFeatures_StringView_HasWord( + value, kCpuInfoFlags[i], ' ')); + } + } + } + return !result.eof; +} + +static void FillProcCpuInfoData(LoongArchInfo* const info) +{ + const int fd = CpuFeatures_OpenFile("/proc/cpuinfo"); + if (fd >= 0) + { + StackLineReader reader; + StackLineReader_Initialize(&reader, fd); + for (;;) + { + if (!HandleLoongArchLine(StackLineReader_NextLine(&reader), info)) break; + } + CpuFeatures_CloseFile(fd); + } +} + +LoongArchInfo GetLoongArchInfo(void) +{ + LoongArchInfo info = kEmptyLoongArchInfo; + FillProcCpuInfoData(&info); + return info; +} + +#endif // defined(CPU_FEATURES_OS_LINUX) +#endif // CPU_FEATURES_ARCH_LOONGARCH diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_ppc_linux.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_ppc_linux.c index 9f9b3eef5..9ac6a6107 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_ppc_linux.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_ppc_linux.c @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2017 Google LLC +// SPDX-FileCopyrightText: 2018 IBM // SPDX-License-Identifier: Apache-2.0 #include "cpu_features_macros.h" @@ -165,4 +165,4 @@ PPCPlatformStrings GetPPCPlatformStrings(void) } #endif // CPU_FEATURES_OS_LINUX -#endif // CPU_FEATURES_ARCH_PPC +#endif // CPU_FEATURES_ARCH_PPC \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_riscv_linux.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_riscv_linux.c index 4bcf440d5..4aec57257 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_riscv_linux.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_riscv_linux.c @@ -28,6 +28,7 @@ LINE(RISCV_D, D, "d", RISCV_HWCAP_D, 0) \ LINE(RISCV_Q, Q, "q", RISCV_HWCAP_Q, 0) \ LINE(RISCV_C, C, "c", RISCV_HWCAP_C, 0) \ + LINE(RISCV_V, V, "v", RISCV_HWCAP_V, 0) \ LINE(RISCV_Zicsr, Zicsr, "_zicsr", 0, 0) \ LINE(RISCV_Zifencei, Zifencei, "_zifencei", 0, 0) #define INTROSPECTION_PREFIX Riscv @@ -106,4 +107,4 @@ RiscvInfo GetRiscvInfo(void) } #endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) -#endif // CPU_FEATURES_ARCH_RISCV \ No newline at end of file +#endif // CPU_FEATURES_ARCH_RISCV diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_s390x_linux.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_s390x_linux.c index f161009dd..444d4f4c3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_s390x_linux.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_s390x_linux.c @@ -59,7 +59,8 @@ static bool HandleS390XLine(const LineResult result, { if (CpuFeatures_StringView_IsEquals(key, str("# processors"))) { - strings->num_processors = CpuFeatures_StringView_ParsePositiveNumber(value); + strings->num_processors = + CpuFeatures_StringView_ParsePositiveNumber(value); } } return !result.eof; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl index e067f22cd..e75bb7655 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl @@ -36,9 +36,7 @@ uint32_t GetXCR0Eax(void) /* named form of xgetbv not supported on OSX, so must use byte form, see: https://github.com/asmjit/asmjit/issues/78 */ - __asm(".byte 0x0F, 0x01, 0xd0" - : "=a"(eax), "=d"(edx) - : "c"(0)); + __asm(".byte 0x0F, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0)); return eax; } @@ -93,6 +91,7 @@ typedef struct Leaf leaf_80000002; // brand string Leaf leaf_80000003; // brand string Leaf leaf_80000004; // brand string + Leaf leaf_80000021; // AMD Extended Feature Identification 2 } Leaves; static Leaves ReadLeaves(void) @@ -114,12 +113,12 @@ static Leaves ReadLeaves(void) .leaf_80000002 = SafeCpuIdEx(max_cpuid_leaf_ext, 0x80000002, 0), .leaf_80000003 = SafeCpuIdEx(max_cpuid_leaf_ext, 0x80000003, 0), .leaf_80000004 = SafeCpuIdEx(max_cpuid_leaf_ext, 0x80000004, 0), + .leaf_80000021 = SafeCpuIdEx(max_cpuid_leaf_ext, 0x80000021, 0), }; } //////////////////////////////////////////////////////////////////////////////// // OS support -// TODO: Add documentation //////////////////////////////////////////////////////////////////////////////// #define MASK_XMM 0x2 @@ -333,6 +332,7 @@ static void ParseCpuId(const Leaves* leaves, X86Info* info, features->fs_rep_cmpsb_scasb = IsBitSet(leaf_7_1.eax, 12); features->adx = IsBitSet(leaf_7.ebx, 19); features->lzcnt = IsBitSet(leaf_80000001.ecx, 5); + features->lam = IsBitSet(leaf_7_1.eax, 26); ///////////////////////////////////////////////////////////////////////////// // The following section is devoted to Vector Extensions. @@ -395,6 +395,7 @@ static void ParseCpuId(const Leaves* leaves, X86Info* info, features->amx_bf16 = IsBitSet(leaf_7.edx, 22); features->amx_tile = IsBitSet(leaf_7.edx, 24); features->amx_int8 = IsBitSet(leaf_7.edx, 25); + features->amx_fp16 = IsBitSet(leaf_7_1.eax, 21); } } else @@ -413,6 +414,7 @@ static void ParseExtraAMDCpuId(const Leaves* leaves, X86Info* info, OsPreserves os_preserves) { const Leaf leaf_80000001 = leaves->leaf_80000001; + const Leaf leaf_80000021 = leaves->leaf_80000021; X86Features* const features = &info->features; @@ -425,6 +427,8 @@ static void ParseExtraAMDCpuId(const Leaves* leaves, X86Info* info, { features->fma4 = IsBitSet(leaf_80000001.ecx, 16); } + + features->uai = IsBitSet(leaf_80000021.eax, 7); } static const X86Info kEmptyX86Info; @@ -460,7 +464,7 @@ X86Info GetX86Info(void) // Microarchitecture //////////////////////////////////////////////////////////////////////////////// -#define CPUID(FAMILY, MODEL) ((((FAMILY)&0xFF) << 8) | ((MODEL)&0xFF)) +#define CPUID(FAMILY, MODEL) ((((FAMILY) & 0xFF) << 8) | ((MODEL) & 0xFF)) X86Microarchitecture GetX86Microarchitecture(const X86Info* info) { @@ -605,6 +609,7 @@ X86Microarchitecture GetX86Microarchitecture(const X86Info* info) } case CPUID(0x06, 0x97): case CPUID(0x06, 0x9A): + case CPUID(0x06, 0xBE): // https://en.wikichip.org/wiki/intel/microarchitectures/alder_lake return INTEL_ADL; case CPUID(0x06, 0xA5): @@ -781,8 +786,10 @@ X86Microarchitecture GetX86Microarchitecture(const X86Info* info) case CPUID(0x17, 0x60): case CPUID(0x17, 0x68): case CPUID(0x17, 0x71): + case CPUID(0x17, 0x84): case CPUID(0x17, 0x90): case CPUID(0x17, 0x98): + case CPUID(0x17, 0xA0): // https://en.wikichip.org/wiki/amd/microarchitectures/zen_2 return AMD_ZEN2; case CPUID(0x19, 0x00): @@ -796,7 +803,9 @@ X86Microarchitecture GetX86Microarchitecture(const X86Info* info) // https://en.wikichip.org/wiki/amd/microarchitectures/zen_3 return AMD_ZEN3; case CPUID(0x19, 0x10): + case CPUID(0x19, 0x11): case CPUID(0x19, 0x61): + case CPUID(0x19, 0x74): // https://en.wikichip.org/wiki/amd/microarchitectures/zen_4 return AMD_ZEN4; default: @@ -1958,6 +1967,7 @@ CacheInfo GetX86CacheInfo(void) LINE(X86_AMX_BF16, amx_bf16, , , ) \ LINE(X86_AMX_TILE, amx_tile, , , ) \ LINE(X86_AMX_INT8, amx_int8, , , ) \ + LINE(X86_AMX_FP16, amx_fp16, , , ) \ LINE(X86_PCLMULQDQ, pclmulqdq, , , ) \ LINE(X86_SMX, smx, , , ) \ LINE(X86_SGX, sgx, , , ) \ @@ -1976,7 +1986,9 @@ CacheInfo GetX86CacheInfo(void) LINE(X86_FS_REP_MOV, fs_rep_mov, , , ) \ LINE(X86_FZ_REP_MOVSB, fz_rep_movsb, , , ) \ LINE(X86_FS_REP_STOSB, fs_rep_stosb, , , ) \ - LINE(X86_FS_REP_CMPSB_SCASB, fs_rep_cmpsb_scasb, , , ) + LINE(X86_FS_REP_CMPSB_SCASB, fs_rep_cmpsb_scasb, , , ) \ + LINE(X86_LAM, lam, , , ) \ + LINE(X86_UAI, uai, , , ) #define INTROSPECTION_PREFIX X86 #define INTROSPECTION_ENUM_PREFIX X86 #include "define_introspection.inl" @@ -2045,4 +2057,4 @@ const char* GetX86MicroarchitectureName(X86Microarchitecture value) #undef LINE if (value >= X86_MICROARCHITECTURE_LAST_) return "unknown microarchitecture"; return kMicroarchitectureNames[value]; -} +} \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c index 44dfde643..b26c603a2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c @@ -42,9 +42,9 @@ static void DetectFeaturesFromOs(X86Info* info, X86Features* features) features->sse4_2 = GetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); - // do not bother checking PF_AVX* - // cause AVX enabled processor will have XCR0 be exposed and this function will be skipped at all + // Do not bother checking PF_AVX* : AVX enabled processor will have their XCR0 + // register exposed and this function will be skipped altogether. } #endif // CPU_FEATURES_OS_WINDOWS -#endif // CPU_FEATURES_ARCH_X86 +#endif // CPU_FEATURES_ARCH_X86 \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c index 647c4e05f..fdbb1ba51 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c @@ -27,6 +27,8 @@ #include "cpuinfo_s390x.h" #elif defined(CPU_FEATURES_ARCH_RISCV) #include "cpuinfo_riscv.h" +#elif defined(CPU_FEATURES_ARCH_LOONGARCH) +#include "cpuinfo_loongarch.h" #endif // Design principles @@ -217,11 +219,14 @@ DEFINE_ADD_FLAGS(GetMipsFeaturesEnumValue, GetMipsFeaturesEnumName, DEFINE_ADD_FLAGS(GetPPCFeaturesEnumValue, GetPPCFeaturesEnumName, PPCFeatures, PPC_LAST_) #elif defined(CPU_FEATURES_ARCH_S390X) -DEFINE_ADD_FLAGS(GetS390XFeaturesEnumValue, GetS390XFeaturesEnumName, S390XFeatures, - S390X_LAST_) +DEFINE_ADD_FLAGS(GetS390XFeaturesEnumValue, GetS390XFeaturesEnumName, + S390XFeatures, S390X_LAST_) #elif defined(CPU_FEATURES_ARCH_RISCV) -DEFINE_ADD_FLAGS(GetRiscvFeaturesEnumValue, GetRiscvFeaturesEnumName, RiscvFeatures, - RISCV_LAST_) +DEFINE_ADD_FLAGS(GetRiscvFeaturesEnumValue, GetRiscvFeaturesEnumName, + RiscvFeatures, RISCV_LAST_) +#elif defined(CPU_FEATURES_ARCH_LOONGARCH) +DEFINE_ADD_FLAGS(GetLoongArchFeaturesEnumValue, GetLoongArchFeaturesEnumName, + LoongArchFeatures, LOONGARCH_LAST_) #endif // Prints a json string with characters escaping. @@ -458,6 +463,10 @@ static Node* CreateTree(void) AddMapEntry(root, "vendor", CreateString(info.vendor)); AddMapEntry(root, "microarchitecture", CreateString(info.uarch)); AddFlags(root, &info.features); +#elif defined(CPU_FEATURES_ARCH_LOONGARCH) + const LoongArchInfo info = GetLoongArchInfo(); + AddMapEntry(root, "arch", CreateString("loongarch")); + AddFlags(root, &info.features); #endif return root; } @@ -489,4 +498,4 @@ int main(int argc, char** argv) printTextRoot(root); putchar('\n'); return EXIT_SUCCESS; -} +} \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt index 5d41179e5..71ae6527c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt @@ -25,7 +25,11 @@ add_library(stack_line_reader_for_test ../src/stack_line_reader.c) target_compile_definitions(stack_line_reader_for_test PUBLIC STACK_LINE_READER_BUFFER_SIZE=16) target_link_libraries(stack_line_reader_for_test string_view filesystem_for_testing) ##------------------------------------------------------------------------------ -add_library(all_libraries ../src/hwcaps.c ../src/stack_line_reader.c) +add_library(all_libraries + ../src/hwcaps.c + ../src/hwcaps_linux_or_android.c + ../src/hwcaps_freebsd.c + ../src/stack_line_reader.c) target_link_libraries(all_libraries hwcaps_for_testing stack_line_reader string_view) # @@ -76,9 +80,18 @@ endif() if(PROCESSOR_IS_AARCH64) add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc + ../src/impl_aarch64_cpuid.c ../src/impl_aarch64_linux_or_android.c - ../src/impl_aarch64_windows.c) - target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_CPUID_AARCH64) + ../src/impl_aarch64_windows.c + ../src/impl_aarch64_macos_or_iphone.c + ../src/impl_aarch64_freebsd.c + ) + if(APPLE) + target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_SYSCTL_AARCH64) + target_compile_definitions(cpuinfo_aarch64_test PRIVATE HAVE_SYSCTLBYNAME) + else() + target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_CPUID_AARCH64) + endif() target_link_libraries(cpuinfo_aarch64_test all_libraries) add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test) endif() @@ -109,4 +122,11 @@ if(PROCESSOR_IS_RISCV) add_executable(cpuinfo_riscv_test cpuinfo_riscv_test.cc ../src/impl_riscv_linux.c) target_link_libraries(cpuinfo_riscv_test all_libraries) add_test(NAME cpuinfo_riscv_test COMMAND cpuinfo_riscv_test) +endif() +##------------------------------------------------------------------------------ +## cpuinfo_loongarch_test +if(PROCESSOR_IS_LOONGARCH) + add_executable(cpuinfo_loongarch_test cpuinfo_loongarch_test.cc ../src/impl_loongarch_linux.c) + target_link_libraries(cpuinfo_loongarch_test all_libraries) + add_test(NAME cpuinfo_loongarch_test COMMAND cpuinfo_loongarch_test) endif() \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc index d2450752a..d6ac50110 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc @@ -6,17 +6,56 @@ #include "gtest/gtest.h" #include "hwcaps_for_testing.h" #include - #if defined(CPU_FEATURES_OS_WINDOWS) #include "internal/windows_utils.h" #endif // CPU_FEATURES_OS_WINDOWS +#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) +#include "internal/cpuid_aarch64.h" +#endif // defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) namespace cpu_features { class FakeCpuAarch64 { +#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) +public: + uint64_t GetMidrEl1() const { return _midr_el1; } + + void SetMidrEl1(uint64_t midr_el1) { _midr_el1 = midr_el1; } + +private: + uint64_t _midr_el1; +#elif defined(CPU_FEATURES_OS_MACOS) + std::set darwin_sysctlbyname_; + std::map darwin_sysctlbynamevalue_; + +public: + bool GetDarwinSysCtlByName(std::string name) const + { + return darwin_sysctlbyname_.count(name); + } + + int GetDarwinSysCtlByNameValue(std::string name) const + { + const auto iter = darwin_sysctlbynamevalue_.find(name); + if (iter != darwin_sysctlbynamevalue_.end()) return iter->second; + return 0; + } + + void SetDarwinSysCtlByName(std::string name) + { + darwin_sysctlbyname_.insert(name); + } + + void SetDarwinSysCtlByNameValue(std::string name, int value) + { + darwin_sysctlbynamevalue_[name] = value; + } +#elif defined(CPU_FEATURES_OS_WINDOWS) + std::set windows_isprocessorfeaturepresent_; + WORD processor_revision_{}; + public: -#if defined(CPU_FEATURES_OS_WINDOWS) bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { return windows_isprocessorfeaturepresent_.count(dwProcessorFeature); @@ -36,11 +75,7 @@ public: { processor_revision_ = wProcessorRevision; } - -private: - std::set windows_isprocessorfeaturepresent_; - WORD processor_revision_{}; -#endif // CPU_FEATURES_OS_WINDOWS +#endif }; static FakeCpuAarch64* g_fake_cpu_instance = nullptr; @@ -51,7 +86,23 @@ static FakeCpuAarch64& cpu() return *g_fake_cpu_instance; } -#if defined(CPU_FEATURES_OS_WINDOWS) +// Define OS dependent mock functions +#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) +extern "C" uint64_t GetMidrEl1(void) +{ + return cpu().GetMidrEl1(); +} +#elif defined(CPU_FEATURES_OS_MACOS) +extern "C" bool GetDarwinSysCtlByName(const char* name) +{ + return cpu().GetDarwinSysCtlByName(name); +} + +extern "C" int GetDarwinSysCtlByNameValue(const char* name) +{ + return cpu().GetDarwinSysCtlByNameValue(name); +} +#elif defined(CPU_FEATURES_OS_WINDOWS) extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { return cpu().GetWindowsIsProcessorFeaturePresent(dwProcessorFeature); @@ -61,7 +112,7 @@ extern "C" WORD GetWindowsNativeSystemInfoProcessorRevision() { return cpu().GetWindowsNativeSystemInfoProcessorRevision(); } -#endif // CPU_FEATURES_OS_WINDOWS +#endif namespace { @@ -81,7 +132,7 @@ protected: } }; -TEST(CpuinfoAarch64Test, Aarch64FeaturesEnum) +TEST_F(CpuidAarch64Test, Aarch64FeaturesEnum) { const char* last_name = GetAarch64FeaturesEnumName(AARCH64_LAST_); EXPECT_STREQ(last_name, "unknown_feature"); @@ -96,13 +147,9 @@ TEST(CpuinfoAarch64Test, Aarch64FeaturesEnum) } } -#if defined(CPU_FEATURES_OS_LINUX) -void DisableHardwareCapabilities() -{ - SetHardwareCapabilities(0, 0); -} - -TEST(CpuinfoAarch64Test, FromHardwareCap) +// AT_HWCAP tests +#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD) +TEST_F(CpuidAarch64Test, FromHardwareCap) { ResetHwcaps(); SetHardwareCapabilities(AARCH64_HWCAP_FP | AARCH64_HWCAP_AES, 0); @@ -142,7 +189,7 @@ TEST(CpuinfoAarch64Test, FromHardwareCap) EXPECT_FALSE(info.features.pacg); } -TEST(CpuinfoAarch64Test, FromHardwareCap2) +TEST_F(CpuidAarch64Test, FromHardwareCap2) { ResetHwcaps(); SetHardwareCapabilities(AARCH64_HWCAP_FP, @@ -171,8 +218,11 @@ TEST(CpuinfoAarch64Test, FromHardwareCap2) EXPECT_FALSE(info.features.dgh); EXPECT_FALSE(info.features.rng); } +#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD) -TEST(CpuinfoAarch64Test, ARMCortexA53) +// OS dependent tests +#if defined(CPU_FEATURES_OS_LINUX) +TEST_F(CpuidAarch64Test, ARMCortexA53) { ResetHwcaps(); auto& fs = GetEmptyFilesystem(); @@ -253,10 +303,91 @@ CPU revision : 3)"); EXPECT_FALSE(info.features.ecv); EXPECT_FALSE(info.features.afp); EXPECT_FALSE(info.features.rpres); + EXPECT_FALSE(info.features.mte3); + EXPECT_FALSE(info.features.sme); + EXPECT_FALSE(info.features.smei16i64); + EXPECT_FALSE(info.features.smef64f64); + EXPECT_FALSE(info.features.smei8i32); + EXPECT_FALSE(info.features.smef16f32); + EXPECT_FALSE(info.features.smeb16f32); + EXPECT_FALSE(info.features.smef32f32); + EXPECT_FALSE(info.features.smefa64); + EXPECT_FALSE(info.features.wfxt); + EXPECT_FALSE(info.features.ebf16); + EXPECT_FALSE(info.features.sveebf16); + EXPECT_FALSE(info.features.cssc); + EXPECT_FALSE(info.features.rprfm); + EXPECT_FALSE(info.features.sve2p1); + EXPECT_FALSE(info.features.sme2); + EXPECT_FALSE(info.features.sme2p1); + EXPECT_FALSE(info.features.smei16i32); + EXPECT_FALSE(info.features.smebi32i32); + EXPECT_FALSE(info.features.smeb16b16); + EXPECT_FALSE(info.features.smef16f16); } -#endif // CPU_FEATURES_OS_LINUX +#elif defined(CPU_FEATURES_OS_MACOS) +TEST_F(CpuidAarch64Test, FromDarwinSysctlFromName) +{ + cpu().SetDarwinSysCtlByName("hw.optional.floatingpoint"); + cpu().SetDarwinSysCtlByName("hw.optional.neon"); + cpu().SetDarwinSysCtlByName("hw.optional.AdvSIMD_HPFPCvt"); + cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_FP16"); + cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_LSE"); + cpu().SetDarwinSysCtlByName("hw.optional.armv8_crc32"); + cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_FHM"); + cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA512"); + cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA3"); + cpu().SetDarwinSysCtlByName("hw.optional.amx_version"); + cpu().SetDarwinSysCtlByName("hw.optional.ucnormal_mem"); + cpu().SetDarwinSysCtlByName("hw.optional.arm64"); -#if defined(CPU_FEATURES_OS_WINDOWS) + cpu().SetDarwinSysCtlByNameValue("hw.cputype", 16777228); + cpu().SetDarwinSysCtlByNameValue("hw.cpusubtype", 2); + cpu().SetDarwinSysCtlByNameValue("hw.cpu64bit", 1); + cpu().SetDarwinSysCtlByNameValue("hw.cpufamily", 458787763); + cpu().SetDarwinSysCtlByNameValue("hw.cpusubfamily", 2); + + const auto info = GetAarch64Info(); + + EXPECT_EQ(info.implementer, 0x100000C); + EXPECT_EQ(info.variant, 2); + EXPECT_EQ(info.part, 0x1B588BB3); + EXPECT_EQ(info.revision, 2); + + EXPECT_TRUE(info.features.fp); + EXPECT_FALSE(info.features.asimd); + EXPECT_FALSE(info.features.evtstrm); + EXPECT_FALSE(info.features.aes); + EXPECT_FALSE(info.features.pmull); + EXPECT_FALSE(info.features.sha1); + EXPECT_FALSE(info.features.sha2); + EXPECT_TRUE(info.features.crc32); + EXPECT_TRUE(info.features.atomics); + EXPECT_TRUE(info.features.fphp); + EXPECT_FALSE(info.features.asimdhp); + EXPECT_FALSE(info.features.cpuid); + EXPECT_FALSE(info.features.asimdrdm); + EXPECT_FALSE(info.features.jscvt); + EXPECT_FALSE(info.features.fcma); + EXPECT_FALSE(info.features.lrcpc); + EXPECT_FALSE(info.features.dcpop); + EXPECT_TRUE(info.features.sha3); + EXPECT_FALSE(info.features.sm3); + EXPECT_FALSE(info.features.sm4); + EXPECT_FALSE(info.features.asimddp); + EXPECT_TRUE(info.features.sha512); + EXPECT_FALSE(info.features.sve); + EXPECT_TRUE(info.features.asimdfhm); + EXPECT_FALSE(info.features.dit); + EXPECT_FALSE(info.features.uscat); + EXPECT_FALSE(info.features.ilrcpc); + EXPECT_FALSE(info.features.flagm); + EXPECT_FALSE(info.features.ssbs); + EXPECT_FALSE(info.features.sb); + EXPECT_FALSE(info.features.paca); + EXPECT_FALSE(info.features.pacg); +} +#elif defined(CPU_FEATURES_OS_WINDOWS) TEST_F(CpuidAarch64Test, WINDOWS_AARCH64_RPI4) { cpu().SetWindowsNativeSystemInfoProcessorRevision(0x03); @@ -280,7 +411,38 @@ TEST_F(CpuidAarch64Test, WINDOWS_AARCH64_RPI4) EXPECT_FALSE(info.features.jscvt); EXPECT_FALSE(info.features.lrcpc); } -#endif // CPU_FEATURES_OS_WINDOWS +#elif defined(CPU_FEATURES_OS_FREEBSD) +TEST_F(CpuidAarch64Test, MrsMidrEl1_RPI4) +{ + ResetHwcaps(); + SetHardwareCapabilities(AARCH64_HWCAP_FP | AARCH64_HWCAP_CPUID, 0); + cpu().SetMidrEl1(0x410FD083); + const auto info = GetAarch64Info(); + EXPECT_EQ(info.implementer, 0x41); + EXPECT_EQ(info.variant, 0); + EXPECT_EQ(info.part, 0xD08); + EXPECT_EQ(info.revision, 0x3); + + EXPECT_TRUE(info.features.fp); + + EXPECT_FALSE(info.features.dcpodp); + EXPECT_FALSE(info.features.sveaes); + EXPECT_FALSE(info.features.svepmull); + EXPECT_FALSE(info.features.svebitperm); + EXPECT_FALSE(info.features.svesha3); + EXPECT_FALSE(info.features.svesm4); + EXPECT_FALSE(info.features.flagm2); + EXPECT_FALSE(info.features.frint); + EXPECT_FALSE(info.features.svei8mm); + EXPECT_FALSE(info.features.svef32mm); + EXPECT_FALSE(info.features.svef64mm); + EXPECT_FALSE(info.features.svebf16); + EXPECT_FALSE(info.features.i8mm); + EXPECT_FALSE(info.features.bf16); + EXPECT_FALSE(info.features.dgh); + EXPECT_FALSE(info.features.rng); +} +#endif // CPU_FEATURES_OS_FREEBSD } // namespace -} // namespace cpu_features \ No newline at end of file +} // namespace cpu_features diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_loongarch_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_loongarch_test.cc new file mode 100644 index 000000000..e782905bf --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_loongarch_test.cc @@ -0,0 +1,171 @@ +// SPDX-FileCopyrightText: 2022 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpuinfo_loongarch.h" +#include "filesystem_for_testing.h" +#include "gtest/gtest.h" +#include "hwcaps_for_testing.h" + +namespace cpu_features +{ +namespace +{ + +TEST(CpuinfoLoongArchvTest, UnknownFromCpuInfo) +{ + ResetHwcaps(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"( +system type : generic-loongson-machine + +processor : 0 +package : 0 +core : 0 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000-HV +CPU Revision : 0x11 +FPU Revision : 0x00 +CPU MHz : 2500.00 +BogoMIPS : 5000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu lsx lasx crc32 complex crypto lvz lbt_x86 lbt_arm lbt_mips +Hardware Watchpoint : yes, iwatch count: 8, dwatch count: 8 + +processor : 1 +package : 0 +core : 1 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000-HV +CPU Revision : 0x11 +FPU Revision : 0x00 +CPU MHz : 2500.00 +BogoMIPS : 5000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu lsx lasx crc32 complex crypto lvz lbt_x86 lbt_arm lbt_mips +Hardware Watchpoint : yes, iwatch count: 8, dwatch count: 8 + +processor : 2 +package : 0 +core : 2 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000-HV +CPU Revision : 0x11 +FPU Revision : 0x00 +CPU MHz : 2500.00 +BogoMIPS : 5000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu lsx lasx crc32 complex crypto lvz lbt_x86 lbt_arm lbt_mips +Hardware Watchpoint : yes, iwatch count: 8, dwatch count: 8 + +processor : 3 +package : 0 +core : 3 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000-HV +CPU Revision : 0x11 +FPU Revision : 0x00 +CPU MHz : 2500.00 +BogoMIPS : 5000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu lsx lasx crc32 complex crypto lvz lbt_x86 lbt_arm lbt_mips +Hardware Watchpoint : yes, iwatch count: 8, dwatch count: 8)"); + const auto info = GetLoongArchInfo(); + EXPECT_FALSE(info.features.CPUCFG); + EXPECT_TRUE(info.features.LAM); + EXPECT_TRUE(info.features.UAL); + EXPECT_TRUE(info.features.FPU); + EXPECT_TRUE(info.features.LSX); + EXPECT_TRUE(info.features.LASX); + EXPECT_TRUE(info.features.CRC32); + EXPECT_TRUE(info.features.COMPLEX); + EXPECT_TRUE(info.features.CRYPTO); + EXPECT_TRUE(info.features.LVZ); + EXPECT_TRUE(info.features.LBT_X86); + EXPECT_TRUE(info.features.LBT_ARM); + EXPECT_TRUE(info.features.LBT_MIPS); +} + +TEST(CpuinfoLoongArchvTest, QemuCpuInfo) +{ + ResetHwcaps(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"( +system type : generic-loongson-machine + +processor : 0 +package : 0 +core : 0 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000 +CPU Revision : 0x10 +FPU Revision : 0x01 +CPU MHz : 2000.00 +BogoMIPS : 4000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu crc32 +Hardware Watchpoint : yes, iwatch count: 0, dwatch count: 0 + +processor : 1 +package : 0 +core : 1 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000 +CPU Revision : 0x10 +FPU Revision : 0x01 +CPU MHz : 2000.00 +BogoMIPS : 4000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu crc32 +Hardware Watchpoint : yes, iwatch count: 0, dwatch count: 0 + +processor : 2 +package : 0 +core : 2 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000 +CPU Revision : 0x10 +FPU Revision : 0x01 +CPU MHz : 2000.00 +BogoMIPS : 4000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu crc32 +Hardware Watchpoint : yes, iwatch count: 0, dwatch count: 0 + +processor : 3 +package : 0 +core : 3 +CPU Family : Loongson-64bit +Model Name : Loongson-3A5000 +CPU Revision : 0x10 +FPU Revision : 0x01 +CPU MHz : 2000.00 +BogoMIPS : 4000.00 +TLB Entries : 2112 +Address Sizes : 48 bits physical, 48 bits virtual +ISA : loongarch32 loongarch64 +Features : cpucfg lam ual fpu crc32 +Hardware Watchpoint : yes, iwatch count: 0, dwatch count: 0)"); + const auto info = GetLoongArchInfo(); + EXPECT_FALSE(info.features.CPUCFG); + EXPECT_TRUE(info.features.LAM); + EXPECT_TRUE(info.features.UAL); + EXPECT_TRUE(info.features.FPU); + EXPECT_TRUE(info.features.CRC32); +} + +} // namespace +} // namespace cpu_features diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_riscv_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_riscv_test.cc index ff22a18d9..67a846473 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_riscv_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_riscv_test.cc @@ -32,6 +32,7 @@ uarch : thead,c906)"); EXPECT_TRUE(info.features.D); EXPECT_FALSE(info.features.Q); EXPECT_TRUE(info.features.C); + EXPECT_FALSE(info.features.V); } // https://github.com/ThomasKaiser/sbc-bench/blob/284e82b016ec1beeac42a5fcbe556b670f68441a/results/Kendryte-K510-4.17.0.cpuinfo @@ -41,15 +42,16 @@ TEST(CpuinfoRiscvTest, Kendryte_K510_FromCpuInfo) auto& fs = GetEmptyFilesystem(); fs.CreateFile("/proc/cpuinfo", R"( hart : 0 -isa : rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0 -mmu : sv39 +isa : rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0 +mmu : sv39 hart : 1 -isa : rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0 -mmu : sv39"); +isa : rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0 +mmu : sv39"); const auto info = GetRiscvInfo(); EXPECT_STREQ(info.uarch, ""); EXPECT_STREQ(info.vendor, ""); + EXPECT_FALSE(info.features.RV32I); EXPECT_TRUE(info.features.RV64I); EXPECT_TRUE(info.features.M); @@ -58,6 +60,7 @@ mmu : sv39"); EXPECT_TRUE(info.features.D); EXPECT_FALSE(info.features.Q); EXPECT_TRUE(info.features.C); + EXPECT_FALSE(info.features.V); } // https://github.com/ThomasKaiser/sbc-bench/blob/284e82b016ec1beeac42a5fcbe556b670f68441a/results/T-Head-C910-5.10.4.cpuinfo @@ -67,8 +70,8 @@ TEST(CpuinfoRiscvTest, T_Head_C910_FromCpuInfo) { fs.CreateFile("/proc/cpuinfo", R"( processor : 0 hart : 0 -isa : rv64imafdcsu -mmu : sv39 +isa : rv64imafdcsu +mmu : sv39 cpu-freq : 1.2Ghz cpu-icache : 64KB cpu-dcache : 64KB @@ -76,10 +79,11 @@ cpu-l2cache : 2MB cpu-tlb : 1024 4-ways cpu-cacheline : 64Bytes cpu-vector : 0.7.1 + processor : 1 hart : 1 -isa : rv64imafdcsu -mmu : sv39 +isa : rv64imafdcsu +mmu : sv39 cpu-freq : 1.2Ghz cpu-icache : 64KB cpu-dcache : 64KB @@ -90,6 +94,7 @@ cpu-vector : 0.7.1"); const auto info = GetRiscvInfo(); EXPECT_STREQ(info.uarch, ""); EXPECT_STREQ(info.vendor, ""); + EXPECT_FALSE(info.features.RV32I); EXPECT_TRUE(info.features.RV64I); EXPECT_TRUE(info.features.M); @@ -98,7 +103,9 @@ cpu-vector : 0.7.1"); EXPECT_TRUE(info.features.D); EXPECT_FALSE(info.features.Q); EXPECT_TRUE(info.features.C); + EXPECT_FALSE(info.features.V); } + TEST(CpuinfoRiscvTest, UnknownFromCpuInfo) { ResetHwcaps(); auto& fs = GetEmptyFilesystem(); @@ -108,16 +115,19 @@ hart : 2 isa : rv64imafdc mmu : sv39 uarch : sifive,bullet0 + processor : 1 hart : 1 isa : rv64imafdc mmu : sv39 uarch : sifive,bullet0 + processor : 2 hart : 3 isa : rv64imafdc mmu : sv39 uarch : sifive,bullet0 + processor : 3 hart : 4 isa : rv64imafdc @@ -135,7 +145,29 @@ uarch : sifive,bullet0)"); EXPECT_TRUE(info.features.D); EXPECT_FALSE(info.features.Q); EXPECT_TRUE(info.features.C); + EXPECT_FALSE(info.features.V); +} + +TEST(CpuinfoRiscvTest, QemuCpuInfo) +{ + ResetHwcaps(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"( +processor : 0 +hart : 0 +isa : rv64imafdcvh_zba_zbb_zbc_zbs +mmu : sv48)"); + const auto info = GetRiscvInfo(); + EXPECT_FALSE(info.features.RV32I); + EXPECT_TRUE(info.features.RV64I); + EXPECT_TRUE(info.features.M); + EXPECT_TRUE(info.features.A); + EXPECT_TRUE(info.features.F); + EXPECT_TRUE(info.features.D); + EXPECT_FALSE(info.features.Q); + EXPECT_TRUE(info.features.C); + EXPECT_TRUE(info.features.V); } } // namespace -} // namespace cpu_features \ No newline at end of file +} // namespace cpu_features diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc index 3948e1399..81e1a1d97 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc @@ -195,6 +195,8 @@ TEST_F(CpuidX86Test, SandyBridge) EXPECT_FALSE(features.movbe); EXPECT_FALSE(features.rdrnd); EXPECT_FALSE(features.adx); + EXPECT_FALSE(features.lam); + EXPECT_FALSE(features.uai); } const int UNDEF = -1; @@ -802,6 +804,21 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN2_XBOX_SERIES_X) EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2); } +// http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0880F40_K17_CPUID.txt +TEST_F(CpuidX86Test, AMD_K17_ZEN2_4800S) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000010, 0x68747541, 0x444D4163, 0x69746E65}}, + {{0x00000001, 0}, Leaf{0x00880F40, 0x00100800, 0x7ED8320B, 0x178BFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_AUTHENTIC_AMD); + EXPECT_EQ(info.family, 0x17); + EXPECT_EQ(info.model, 0x84); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2); +} + // http://users.atw.hu/instlatx64/HygonGenuine/HygonGenuine0900F02_Hygon_CPUID3.txt TEST_F(CpuidX86Test, AMD_K18_ZEN_DHYANA) { @@ -931,6 +948,7 @@ TEST_F(CpuidX86Test, AMD_K19_ZEN4_RAPHAEL) {{0x80000002, 0}, Leaf{0x20444D41, 0x657A7952, 0x2035206E, 0x30303637}}, {{0x80000003, 0}, Leaf{0x2D362058, 0x65726F43, 0x6F725020, 0x73736563}}, {{0x80000004, 0}, Leaf{0x2020726F, 0x20202020, 0x20202020, 0x00202020}}, + {{0x80000021, 0}, Leaf{0x00062FCF, 0x0000015C, 0x00000000, 0x00000000}}, }); const auto info = GetX86Info(); @@ -939,9 +957,26 @@ TEST_F(CpuidX86Test, AMD_K19_ZEN4_RAPHAEL) EXPECT_EQ(info.model, 0x61); EXPECT_STREQ(info.brand_string, "AMD Ryzen 5 7600X 6-Core Processor "); + EXPECT_TRUE(info.features.uai); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN4); } +// http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0A70F41_K19_Phoenix_03_CPUID.txt +TEST_F(CpuidX86Test, AMD_K19_ZEN4_PHOENIX) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000010, 0x68747541, 0x444D4163, 0x69746E65}}, + {{0x00000001, 0}, Leaf{0x00A70F41, 0x00100800, 0x7EF8320B, 0x178BFBFF}}, + {{0x80000000, 0}, Leaf{0x80000028, 0x68747541, 0x444D4163, 0x69746E65}}, + {{0x80000001, 0}, Leaf{0x00A70F41, 0x50000000, 0x75C237FF, 0x2FD3FBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_AUTHENTIC_AMD); + EXPECT_EQ(info.family, 0x19); + EXPECT_EQ(info.model, 0x74); +} + // http://users.atw.hu/instlatx64/HygonGenuine/HygonGenuine0900F11_Hygon_01_CPUID.txt TEST_F(CpuidX86Test, AMD_K18_ZEN_DHYANA_OCTAL_CORE_C86_3250) { @@ -964,6 +999,36 @@ TEST_F(CpuidX86Test, AMD_K18_ZEN_DHYANA_OCTAL_CORE_C86_3250) EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN); } +// http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD08A0F00_K17_Mendocino_01_CPUID.txt +TEST_F(CpuidX86Test, AMD_ZEN2_MENDOCINO) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000010, 0x68747541, 0x444D4163, 0x69746E65}}, + {{0x00000001, 0}, Leaf{0x008A0F00, 0x00080800, 0x7EF8320B, 0x178BFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_EQ(info.model, 0xA0); + EXPECT_EQ(info.family, 0x17); + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_AUTHENTIC_AMD); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2); +} + +// http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0A10F11_K19_Genoa_02_CPUID.txt +TEST_F(CpuidX86Test, AMD_K19_ZEN4_GENOA) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000010, 0x68747541, 0x444D4163, 0x69746E65}}, + {{0x00000001, 0}, Leaf{0x00A10F11, 0x00200800, 0x7EFA320B, 0x178BFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_EQ(info.model, 0x11); + EXPECT_EQ(info.family, 0x19); + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_AUTHENTIC_AMD); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN4); +} + // http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00906A4_AlderLakeP_00_CPUID.txt TEST_F(CpuidX86Test, INTEL_ALDER_LAKE_AVX_VNNI) { @@ -1742,6 +1807,20 @@ TEST_F(CpuidX86Test, INTEL_RAPTOR_LAKE_S) EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_RPL); } +// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00B06E0_AlderLakeN_03_CPUID.txt +TEST_F(CpuidX86Test, INTEL_ALDER_LAKE_N) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000020, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {{0x00000001, 0}, Leaf{0x000B06E0, 0x00800800, 0x7FFAFBBF, 0xBFEBFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_GENUINE_INTEL); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0xBE); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_ADL); +} // https://github.com/google/cpu_features/issues/200 // http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00206F2_Eagleton_CPUID.txt diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index 95045aa74..2d5553917 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -544,7 +544,6 @@ if(NOT (CMAKE_GENERATOR STREQUAL Xcode)) PRIVATE $ ) - add_dependencies(volk_gnsssdr_obj list_cpu_features) endif() endif() # Configure object target properties diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index c8d512ed9..6798a2e17 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -298,11 +298,14 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite - << " with CN0=" << std::setprecision(2) << cn0 << " dB-Hz" << std::endl; - std::cout << std::setprecision(default_precision); // restore defaults + << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; } if (d_nav.have_new_utc_model() == true) { @@ -310,7 +313,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -323,7 +330,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << " with CN0=" << cn0 << std::setprecision(default_precision) @@ -335,7 +346,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index 07bb79339..dcd4609d0 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -300,7 +300,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -314,7 +318,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV utc model message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -329,7 +337,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Iono data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV Iono message received in channel " << d_channel << ": Iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -344,7 +356,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols, doub // pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac data have been received in channel" << d_channel << " from satellite " << d_satellite << " with CN0=" << cn0 << " dB-Hz"; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_YELLOW << "New BEIDOU B3I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) 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 660564c14..37beb5d43 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 @@ -432,7 +432,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_ephemeris()); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -440,7 +444,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" @@ -457,7 +465,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in { const std::shared_ptr tmp_obj = std::make_shared(d_inav_nav.get_reduced_ced()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV reduced CED message received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -472,7 +484,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -480,7 +496,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -495,7 +515,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -503,7 +527,11 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New Galileo E5b I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite @@ -522,14 +550,22 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in // debug if (d_band == '1') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; } else if (d_band == '7') { +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "Galileo E5b I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -598,7 +634,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -609,7 +649,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -620,7 +664,11 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t { const std::shared_ptr tmp_obj = std::make_shared(d_fnav_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -681,7 +729,11 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (is_page_dummy != d_cnav_dummy_page) { d_cnav_dummy_page = is_page_dummy; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "Receiving Galileo E6 CNAV dummy pages in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" @@ -700,7 +752,11 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float * if (d_print_cnav_page == true) { d_print_cnav_page = false; // only print the first page +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "Receiving Galileo E6 HAS pages" << (d_cnav_nav.is_HAS_in_test_mode() == true ? " (test mode) " : " ") << "in channel " << d_channel << " from satellite " << d_satellite diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index b35fddef2..3d6aacbcc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -239,7 +239,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -251,7 +255,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -264,7 +272,11 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) << " dB-Hz" << std::endl; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index 8e2df1ff2..2340b59ff 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -239,7 +239,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -251,7 +255,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV UTC Model data have been received in channel" << d_channel << " from satellite " << d_satellite; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) @@ -263,7 +271,11 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "GLONASS GNAV Almanac data have been received in channel" << d_channel << " in slot number " << slot_nbr; +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << cn0 << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 0ca6f9219..bf8b9ba21 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -397,7 +397,11 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(double cn0, bool flag_inver default: break; } +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " << "subframe " << subframe_ID << " from satellite " diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index 0b2947e17..60b33d5b7 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -259,7 +259,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -269,7 +273,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -280,7 +288,11 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index c93572019..2c0ab7083 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -256,7 +256,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u // get ephemeris object for this SV const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz @@ -266,7 +270,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz << std::setprecision(default_precision) @@ -277,7 +285,11 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u { const std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); +#if __cplusplus == 201103L + const int default_precision = std::cout.precision(); +#else const auto default_precision{std::cout.precision()}; +#endif std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz From db5d218f069e4506ccf7ae3732fdcf2ec7574712 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2023 15:41:21 +0100 Subject: [PATCH 056/142] pvt_conf.h: initialize all variables --- src/algorithms/PVT/libs/pvt_conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index bf4a3501a..517465350 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -90,7 +90,7 @@ public: bool pre_2009_file = false; bool dump = false; bool dump_mat = true; - bool log_source_timetag; + bool log_source_timetag = false; bool use_e6_for_pvt = true; bool use_has_corrections = true; bool use_unhealthy_sats = false; From 392b557a0ab0cdb7e6a885565cceb8bcf1f2442e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2023 15:42:05 +0100 Subject: [PATCH 057/142] four_bit_cpx_file_signal_source: initialize all variables --- .../signal_source/adapters/four_bit_cpx_file_signal_source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc index fecf2d28f..cdc1dfc8b 100644 --- a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc @@ -45,7 +45,8 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource( } else { - LOG(WARNING) << sample_type_ << " unrecognized sample type. Assuming: "; + reverse_interleaving_ = false; + LOG(WARNING) << sample_type_ << " unrecognized sample type. Assuming: iq"; } if (in_streams > 0) From 955770eb11e7a1c61dabc82e2780ae29508c300e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2023 10:13:11 +0100 Subject: [PATCH 058/142] Fix performance inefficiency detected by Coverity Scan --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 6 +++--- src/algorithms/PVT/libs/rtklib_solver.cc | 14 ++++++------- src/algorithms/PVT/libs/rtklib_solver.h | 5 +++-- .../pvt/nmea_printer_test.cc | 2 +- .../pvt/rinex_printer_test.cc | 20 +++++++++---------- .../pvt/rtklib_solver_test.cc | 2 +- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 050e474e8..fc79642ea 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -534,19 +534,19 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, { // setup two PVT solvers: internal solver for rx clock and user solver // user PVT solver - d_user_pvt_solver = std::make_shared(rtk, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat, conf_); + d_user_pvt_solver = std::make_shared(rtk, conf_, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat); d_user_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); // internal PVT solver, mainly used to estimate the receiver clock rtk_t internal_rtk = rtk; internal_rtk.opt.mode = PMODE_SINGLE; // use single positioning mode in internal PVT solver - d_internal_pvt_solver = std::make_shared(internal_rtk, dump_ls_pvt_filename, d_type_of_rx, false, false, conf_); + d_internal_pvt_solver = std::make_shared(internal_rtk, conf_, dump_ls_pvt_filename, d_type_of_rx, false, false); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); } else { // only one solver, customized by the user options - d_internal_pvt_solver = std::make_shared(rtk, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat, conf_); + d_internal_pvt_solver = std::make_shared(rtk, conf_, dump_ls_pvt_filename, d_type_of_rx, d_dump, d_dump_mat); d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); d_user_pvt_solver = d_internal_pvt_solver; } diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index faf8af5f0..c7528749c 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -45,16 +45,16 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, + const Pvt_Conf &conf, const std::string &dump_filename, uint32_t type_of_rx, bool flag_dump_to_file, - bool flag_dump_to_mat, - Pvt_Conf conf) : d_dump_filename(dump_filename), - d_rtk(rtk), - d_conf(std::move(conf)), - d_type_of_rx(type_of_rx), - d_flag_dump_enabled(flag_dump_to_file), - d_flag_dump_mat_enabled(flag_dump_to_mat) + bool flag_dump_to_mat) : d_dump_filename(dump_filename), + d_rtk(rtk), + d_conf(std::move(conf)), + d_type_of_rx(type_of_rx), + d_flag_dump_enabled(flag_dump_to_file), + d_flag_dump_mat_enabled(flag_dump_to_mat) { // see freq index at src/algorithms/libs/rtklib/rtklib_rtkcmn.cc // function: satwavelen diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index f24a37b2a..3fcb50172 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -82,11 +82,12 @@ class Rtklib_Solver : public Pvt_Solution { public: Rtklib_Solver(const rtk_t& rtk, + const Pvt_Conf& conf, const std::string& dump_filename, uint32_t type_of_rx, bool flag_dump_to_file, - bool flag_dump_to_mat, - Pvt_Conf conf); + bool flag_dump_to_mat); + ~Rtklib_Solver(); bool get_PVT(const std::map& gnss_observables_map, double kf_update_interval_s); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 5c56c6f7f..eac226411 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -147,7 +147,7 @@ TEST_F(NmeaPrinterTest, PrintLine) std::string filename("nmea_test.nmea"); Pvt_Conf conf; conf.use_e6_for_pvt = false; - std::shared_ptr pvt_solution = std::make_shared(rtk, "filename", 1, false, false, conf); + std::shared_ptr pvt_solution = std::make_shared(rtk, conf, "filename", 1, false, false); boost::posix_time::ptime pt(boost::gregorian::date(1994, boost::date_time::Nov, 19), boost::posix_time::hours(22) + boost::posix_time::minutes(54) + boost::posix_time::seconds(46)); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index a4a4fe90a..8885e7367 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -145,7 +145,7 @@ TEST_F(RinexPrinterTest, GalileoObsHeader) { Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 4, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 4, false, false); auto eph = Galileo_Ephemeris(); eph.PRN = 1; pvt_solution->galileo_ephemeris_map[1] = eph; @@ -233,7 +233,7 @@ TEST_F(RinexPrinterTest, GlonassObsHeader) { Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 28, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 28, false, false); auto eph = Glonass_Gnav_Ephemeris(); eph.PRN = 1; pvt_solution->glonass_gnav_ephemeris_map[1] = eph; @@ -295,7 +295,7 @@ TEST_F(RinexPrinterTest, MixedObsHeader) eph_gps.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 106, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 106, false, false); pvt_solution->galileo_ephemeris_map[1] = eph_gal; pvt_solution->gps_ephemeris_map[1] = eph_gps; @@ -367,7 +367,7 @@ TEST_F(RinexPrinterTest, MixedObsHeaderGpsGlo) eph_gps.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 26, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 26, false, false); pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo; pvt_solution->gps_ephemeris_map[1] = eph_gps; @@ -436,7 +436,7 @@ TEST_F(RinexPrinterTest, GalileoObsLog) eph.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 4, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 4, false, false); pvt_solution->galileo_ephemeris_map[1] = eph; std::map gnss_observables_map; @@ -518,7 +518,7 @@ TEST_F(RinexPrinterTest, GlonassObsLog) eph.PRN = 22; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 23, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 23, false, false); pvt_solution->glonass_gnav_ephemeris_map[1] = eph; std::map gnss_observables_map; @@ -602,7 +602,7 @@ TEST_F(RinexPrinterTest, GpsObsLogDualBand) eph_cnav.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 7, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 7, false, false); pvt_solution->gps_ephemeris_map[1] = eph; pvt_solution->gps_cnav_ephemeris_map[1] = eph_cnav; std::map gnss_observables_map; @@ -692,7 +692,7 @@ TEST_F(RinexPrinterTest, GalileoObsLogDualBand) { Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 14, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 14, false, false); auto eph = Galileo_Ephemeris(); eph.PRN = 1; pvt_solution->galileo_ephemeris_map[1] = eph; @@ -794,7 +794,7 @@ TEST_F(RinexPrinterTest, MixedObsLog) eph_gal.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 9, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 9, false, false); pvt_solution->gps_ephemeris_map[1] = eph_gps; pvt_solution->galileo_ephemeris_map[1] = eph_gal; std::map gnss_observables_map; @@ -920,7 +920,7 @@ TEST_F(RinexPrinterTest, MixedObsLogGpsGlo) eph_glo.PRN = 1; Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto pvt_solution = std::make_shared(rtk, "filename", 26, false, false, conf); + auto pvt_solution = std::make_shared(rtk, conf, "filename", 26, false, false); pvt_solution->gps_ephemeris_map[1] = eph_gps; pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo; std::map gnss_observables_map; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc index 805ffdb9e..fe2aa27af 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc @@ -386,7 +386,7 @@ TEST(RTKLibSolverTest, test1) Pvt_Conf conf; conf.use_e6_for_pvt = false; - auto d_ls_pvt = std::make_unique(rtk, nchannels, dump_filename, 1, flag_dump_to_file, save_to_mat, conf); + auto d_ls_pvt = std::make_unique(rtk, conf, nchannels, dump_filename, 1, flag_dump_to_file, save_to_mat); d_ls_pvt->set_averaging_depth(1); // load ephemeris From 2dfd79d45c96dce9b2336a83bdb1b0b2304d87d2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2023 10:14:36 +0100 Subject: [PATCH 059/142] Avoid potential undefined behaviour detected by Coverity Scan --- .../observables/gnuradio_blocks/hybrid_observables_gs.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index d32f0ba68..8569dde24 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -431,6 +431,10 @@ bool hybrid_observables_gs::interp_trk_obs(Gnss_Synchro &interpolated_obs, uint3 // 1st: copy the nearest gnss_synchro data for that channel interpolated_obs = d_gnss_synchro_history->get(ch, nearest_element); + if (interpolated_obs.fs == 0LL) + { + return false; + } // 2nd: Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) const double T_rx_s = static_cast(rx_clock) / static_cast(interpolated_obs.fs); From f6a1777a2103ac772ba655e18a8829f1d67f0ba1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2023 10:16:26 +0100 Subject: [PATCH 060/142] Fix defect detected by Coverity Scan --- src/algorithms/PVT/libs/rinex_printer.cc | 20 ++++++------------ src/algorithms/PVT/libs/rinex_printer.h | 26 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index ceb62548f..fe01e7cd8 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -65,14 +65,6 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, d_pre_2009_file(false) { - // RINEX v3.02 codes - satelliteSystem["GPS"] = "G"; - satelliteSystem["GLONASS"] = "R"; - satelliteSystem["SBAS payload"] = "S"; - satelliteSystem["Galileo"] = "E"; - satelliteSystem["Beidou"] = "C"; - satelliteSystem["Mixed"] = "M"; - observationCode["GPS_L1_CA"] = "1C"; // "1C" GPS L1 C/A observationCode["GPS_L1_P"] = "1P"; // "1P" GPS L1 P observationCode["GPS_L1_Z_TRACKING"] = "1W"; // "1W" GPS L1 Z-tracking and similar (AS on) @@ -6364,7 +6356,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -6724,7 +6716,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -7049,7 +7041,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -8199,7 +8191,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -8571,7 +8563,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -9215,7 +9207,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem["Mixed"]; + line += satelliteSystem.find("Mixed")->second; line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 537f2167a..3d1c42229 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -39,14 +39,15 @@ #define GNSS_SDR_RINEX_PRINTER_H #include -#include // for int32_t -#include // for strtol, strtod -#include // for fstream -#include // for setprecision -#include // for map -#include // for stringstream -#include // for string -#include +#include // for int32_t +#include // for strtol, strtod +#include // for fstream +#include // for setprecision +#include // for map +#include // for stringstream +#include // for string +#include // for unordered_map +#include // for vector /** \addtogroup PVT @@ -232,6 +233,14 @@ public: private: + const std::unordered_map satelliteSystem = { + {"GPS", "G"}, + {"GLONASS", "R"}, + {"SBAS payload", "S"}, + {"Galileo", "E"}, + {"Beidou", "C"}, + {"Mixed", "M"}}; // RINEX v3.02 codes + /* * Generates the GPS Observation data header */ @@ -984,7 +993,6 @@ private: inline std::string asFixWidthString(int x, int width, char fill_digit) const; - std::map satelliteSystem; // GPS, GLONASS, SBAS payload, Galileo or Beidou std::map observationType; // PSEUDORANGE, CARRIER_PHASE, DOPPLER, SIGNAL_STRENGTH std::map observationCode; // GNSS observation descriptors From 4ec232fe2d6b8eefd33c6b8d21b14d9e8460b522 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2023 12:53:47 +0100 Subject: [PATCH 061/142] Fix defects detected by Coverity Scan --- src/algorithms/PVT/libs/rinex_printer.cc | 325 ++++++++++++++++++----- 1 file changed, 260 insertions(+), 65 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index fe01e7cd8..f6deb47f9 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -4979,7 +4979,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } if (gps_ephemeris_iter->second.PRN < 10) { line += std::string("0"); @@ -5289,7 +5292,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } if (gps_ephemeris_iter->second.PRN < 10) { line += std::string("0"); @@ -5453,7 +5459,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } if (galileo_ephemeris_iter->second.PRN < 10) { line += std::string("0"); @@ -5713,7 +5722,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } if (glonass_gnav_ephemeris_iter->second.PRN < 10) { line += std::string("0"); @@ -5882,7 +5894,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Beidou")->second; + } if (bds_ephemeris_iter->second.PRN < 10) { line += std::string("0"); @@ -6020,7 +6035,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -6178,7 +6196,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- SYS / OBS TYPES // one line per available system line.clear(); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = 4; @@ -6296,7 +6317,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number @@ -6356,7 +6380,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -6507,7 +6534,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { // one line per available system line.clear(); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = 4; @@ -6550,7 +6580,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps number_of_observations_glo = number_of_observations_glo + 4; } line.clear(); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); if (found_1G != std::string::npos) @@ -6656,7 +6689,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number @@ -6716,7 +6752,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -6864,7 +6903,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- SYS / OBS TYPES // one line per available system line.clear(); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = 4; @@ -6907,7 +6949,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris number_of_observations_glo = number_of_observations_glo + 4; } line.clear(); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); if (found_1G != std::string::npos) @@ -6981,7 +7026,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number @@ -7041,7 +7089,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -7205,7 +7256,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& number_of_observations_gal = number_of_observations_gal + 4; } - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -7293,7 +7347,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& number_of_observations_glo = number_of_observations_glo + 4; } - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); @@ -7383,7 +7440,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -7541,7 +7601,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- SYS / OBS TYPES // one line per available system line.clear(); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = 4; @@ -7651,7 +7714,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -7800,7 +7866,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gps = number_of_observations_gps + 4; } - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = number_of_observations_gps; @@ -7906,7 +7975,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -8061,7 +8133,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { number_of_observations_gps = number_of_observations_gps + 4; } - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = number_of_observations_gps; @@ -8191,7 +8266,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -8346,7 +8424,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { number_of_observations_gps = number_of_observations_gps + 4; } - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = number_of_observations_gps; @@ -8442,7 +8523,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { number_of_observations_gal = number_of_observations_gal + 4; } - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); if (found_1B != std::string::npos) @@ -8563,7 +8647,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -8712,7 +8799,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gps = number_of_observations_gps + 4; } - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = number_of_observations_gps; @@ -8788,7 +8878,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gal = number_of_observations_gal + 4; } - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); if (found_1B != std::string::npos) @@ -8914,7 +9007,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -9079,7 +9175,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line.clear(); - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); @@ -9207,7 +9306,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Mixed")->second; + if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Mixed")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -9343,7 +9445,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- SYS / OBS TYPES // one line per available system line.clear(); - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } line += std::string(2, ' '); std::stringstream strm; d_numberTypesObservations = 4; @@ -9401,7 +9506,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } line.clear(); - line += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Galileo")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -9524,7 +9632,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - line += satelliteSystem.find("Beidou")->second; + if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Beidou")->second; + } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); Rinex_Printer::lengthCheck(line); @@ -9667,7 +9778,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line.clear(); - line += satelliteSystem.find("Beidou")->second; + if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + { + line += satelliteSystem.find("Beidou")->second; + } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); @@ -10093,7 +10207,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri observables_iter != observables.cend(); observables_iter++) { - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -10213,7 +10330,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { std::string lineObs; lineObs.clear(); - lineObs += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -10430,7 +10550,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesG1C.cend(); observables_iter++) { - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -10442,7 +10565,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR1C.cend(); observables_iter++) { - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -10454,7 +10580,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR2C.cend(); observables_iter++) { - line += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GLONASS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -10481,11 +10610,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // Specify system only if in version 3 if (s == "G") { - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } } if (s == "R") { - lineObs += satelliteSystem.find("GLONASS")->second; // should not happen + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10554,7 +10689,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs.clear(); if (d_version == 3) { - lineObs += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -10742,11 +10880,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // Specify system only if in version 3 if (s == "G") { - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } } if (s == "R") { - lineObs += satelliteSystem.find("GLONASS")->second; // should not happen + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10812,7 +10956,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g it++) { lineObs.clear(); - lineObs += satelliteSystem.find("GLONASS")->second; + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -11000,11 +11147,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga s.assign(1, observables_iter->second.System); if (s == "E") { - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } } if (s == "R") { - lineObs += satelliteSystem.find("GLONASS")->second; // should not happen + if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GLONASS")->second; + } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11068,7 +11221,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -11201,7 +11357,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d observables_iter != observables.cend(); observables_iter++) { - line += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + line += satelliteSystem.find("GPS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -11322,7 +11481,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { std::string lineObs; lineObs.clear(); - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -11449,7 +11611,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { std::string lineObs; lineObs.clear(); - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -11673,7 +11838,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c it++) { lineObs.clear(); - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -11926,7 +12094,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -12148,11 +12319,17 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep s.assign(1, observables_iter->second.System); if (s == "G") { - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } } if (s == "E") { - lineObs += satelliteSystem.find("Galileo")->second; // should not happen + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) { @@ -12216,7 +12393,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -12469,7 +12649,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e it++) { lineObs.clear(); - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -12531,7 +12714,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -12802,7 +12988,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - lineObs += satelliteSystem.find("GPS")->second; + if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("GPS")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -12875,7 +13064,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Galileo")->second; + if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Galileo")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -13060,7 +13252,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris it++) { lineObs.clear(); - lineObs += satelliteSystem.find("Beidou")->second; + if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + { + lineObs += satelliteSystem.find("Beidou")->second; + } if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); From 7d9d090a212806d14ce77820d885c3a4d9f2a797 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2023 17:59:55 +0100 Subject: [PATCH 062/142] Make clang-tidy happy --- src/algorithms/PVT/libs/rtklib_solver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index c7528749c..44f568531 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -51,7 +51,7 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, bool flag_dump_to_file, bool flag_dump_to_mat) : d_dump_filename(dump_filename), d_rtk(rtk), - d_conf(std::move(conf)), + d_conf(conf), d_type_of_rx(type_of_rx), d_flag_dump_enabled(flag_dump_to_file), d_flag_dump_mat_enabled(flag_dump_to_mat) From ab4cc295e891aa5cf6c8dea8abd33dd8966f218d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 6 Nov 2023 14:01:42 +0100 Subject: [PATCH 063/142] volk_gnsssdr: Fix syntax for Python 3.12 Without breaking older versions, including 2.7 --- docs/CHANGELOG.md | 2 ++ .../cmake/Modules/VolkPython.cmake | 2 +- .../gen/volk_gnsssdr_compile_utils.py | 26 +++++++++++-------- .../gen/volk_gnsssdr_kernel_defs.py | 6 +++-- .../gen/volk_gnsssdr_tmpl_utils.py | 17 ++++++------ .../volk_gnsssdr/lib/CMakeLists.txt | 2 +- .../volk_gnsssdr_modtool_generate.py | 4 +-- 7 files changed, 33 insertions(+), 26 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 581c9f239..930a5c59c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -34,6 +34,8 @@ All notable changes to GNSS-SDR will be documented in this file. ### Improvements in Portability: - Updated local `cpu_features` library to v0.9.0. +- `volk_gnsssdr`: fix syntax for Python 3.12 without breaking backward + compatibility with Python 2.7. ### Improvements in Repeatability: diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake index 325e93a1f..3730e8e7f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkPython.cmake @@ -221,7 +221,7 @@ function(VOLK_UNIQUE_TARGET desc) file(RELATIVE_PATH reldir ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib unique = hashlib.sha256(b'${reldir}${ARGN}').hexdigest()[:5] -print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" +print(re.sub(r'\\W', '_', '${desc} ${reldir} ' + unique))" OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_target(${_target} ALL DEPENDS ${ARGN}) endfunction() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_compile_utils.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_compile_utils.py index dcd26d25d..0a763ddca 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_compile_utils.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_compile_utils.py @@ -8,7 +8,7 @@ from __future__ import print_function -import optparse +import argparse import volk_gnsssdr_arch_defs import volk_gnsssdr_machine_defs @@ -20,6 +20,7 @@ def do_arch_flags_list(compiler): output.append(','.join(fields)) print(';'.join(output)) + def do_machines_list(arch_names): output = list() for machine in volk_gnsssdr_machine_defs.machines: @@ -28,6 +29,7 @@ def do_machines_list(arch_names): output.append(machine.name) print(';'.join(output)) + def do_machine_flags_list(compiler, machine_name): output = list() machine = volk_gnsssdr_machine_defs.machine_dict[machine_name] @@ -35,16 +37,18 @@ def do_machine_flags_list(compiler, machine_name): output.extend(arch.get_flags(compiler)) print(' '.join(output)) + def main(): - parser = optparse.OptionParser() - parser.add_option('--mode', type='string') - parser.add_option('--compiler', type='string') - parser.add_option('--archs', type='string') - parser.add_option('--machine', type='string') - (opts, args) = parser.parse_args() + parser = argparse.ArgumentParser() + parser.add_argument('--mode', type=str) + parser.add_argument('--compiler', type=str) + parser.add_argument('--archs', type=str) + parser.add_argument('--machine', type=str) + args = parser.parse_args() - if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower()) - if opts.mode == 'machines': return do_machines_list(opts.archs.split(';')) - if opts.mode == 'machine_flags': return do_machine_flags_list(opts.compiler.lower(), opts.machine) + if args.mode == 'arch_flags': return do_arch_flags_list(args.compiler.lower()) + if args.mode == 'machines': return do_machines_list(args.archs.split(';')) + if args.mode == 'machine_flags': return do_machine_flags_list(args.compiler.lower(), args.machine) -if __name__ == '__main__': main() +if __name__ == '__main__': + main() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py index e919caa09..84c217ec4 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_kernel_defs.py @@ -16,7 +16,7 @@ import glob ######################################################################## # Strip comments from a c/cpp file. # Input is code string, output is code string without comments. -# https://stackoverflow.com/questions/241327/remove-c-and-c-comments-using-python +# https://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments ######################################################################## def comment_remover(text): def replacer(match): @@ -120,7 +120,7 @@ class impl_class(object): self.args = list() fcn_args = the_rest.split(',') for fcn_arg in fcn_args: - arg_matcher = re.compile(r'^\s*(.*\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE) + arg_matcher = re.compile(r'^\s*(.*[^\w])\s*(\w+)\s*$', re.DOTALL | re.MULTILINE) m = arg_matcher.match(fcn_arg) arg_type, arg_name = m.groups() self.args.append((arg_type, arg_name)) @@ -164,6 +164,8 @@ class kernel_class(object): kern_name=self.name, header=sub_hdr, body=body, )) assert(self._impls) + if "generic" not in [impl.name for impl in self._impls]: + raise Exception("{} does not have a generic protokernel.".format(self.name)) self.has_dispatcher = False for impl in self._impls: if impl.name == 'dispatcher': diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_tmpl_utils.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_tmpl_utils.py index 9a2379e15..3baf83bd7 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_tmpl_utils.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_tmpl_utils.py @@ -11,7 +11,7 @@ from __future__ import print_function import os import re import sys -import optparse +import argparse import volk_gnsssdr_arch_defs import volk_gnsssdr_machine_defs import volk_gnsssdr_kernel_defs @@ -34,13 +34,14 @@ def __parse_tmpl(_tmpl, **kwargs): return str(Template(_tmpl).render(**defs)) def main(): - parser = optparse.OptionParser() - parser.add_option('--input', type='string') - parser.add_option('--output', type='string') - (opts, args) = parser.parse_args() + parser = argparse.ArgumentParser() + parser.add_argument('--input', type=str) + parser.add_argument('--output', type=str) + args, extras = parser.parse_known_args() - output = __parse_tmpl(open(opts.input).read(), args=args) - if opts.output: open(opts.output, 'w').write(output) + output = __parse_tmpl(open(args.input).read(), args=extras) + if args.output: open(args.output, 'w').write(output) else: print(output) -if __name__ == '__main__': main() +if __name__ == '__main__': + main() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index 2d5553917..f22441f69 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -113,7 +113,7 @@ macro(check_arch arch_name) set(have_flag have${flag}) # make the have_flag have nice alphanum chars (just for looks/not necessary) execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub('\\W', '_', '${have_flag}'))" + COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub(r'\\W', '_', '${have_flag}'))" OUTPUT_VARIABLE have_flag OUTPUT_STRIP_TRAILING_WHITESPACE ) if(VOLK_FLAG_CHECK_FLAGS) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py index a8fe52b58..6a9a8ca11 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/volk_gnsssdr_modtool_generate.py @@ -290,9 +290,7 @@ class volk_gnsssdr_modtool(object): inserted = False; insert = False for otherline in otherlines: - - if (re.match('\s*', otherline) == None or re.match('\s*#.*', otherline) == None): - + if re.match(r'\s*', otherline) is None or re.match(r'\s*#.*', otherline) is None: insert = True; if insert and not inserted: inserted = True; From 419172ae3b62ff7ebc5420d4f104ae0e01d1961c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 7 Nov 2023 11:40:47 +0100 Subject: [PATCH 064/142] Rinex_Printer: Better usage of unordered_map --- src/algorithms/PVT/libs/rinex_printer.cc | 459 +++++++++++++---------- 1 file changed, 260 insertions(+), 199 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index f6deb47f9..f140270d4 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -187,9 +187,9 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, Rinex_Printer::navGloFile.open(navGlofilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::navBdsFile.open(navBdsfilename, std::ios::out | std::ios::in | std::ios::app); - if (!Rinex_Printer::navFile.is_open() or !Rinex_Printer::obsFile.is_open() or - !Rinex_Printer::sbsFile.is_open() or !Rinex_Printer::navGalFile.is_open() or - !Rinex_Printer::navMixFile.is_open() or !Rinex_Printer::navGloFile.is_open()) + if (!Rinex_Printer::navFile.is_open() || !Rinex_Printer::obsFile.is_open() or + !Rinex_Printer::sbsFile.is_open() || !Rinex_Printer::navGalFile.is_open() or + !Rinex_Printer::navMixFile.is_open() || !Rinex_Printer::navGloFile.is_open()) { std::cout << "RINEX files cannot be saved. Wrong permissions?\n"; } @@ -374,7 +374,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 7: // GPS L1 C/A + GPS L2C - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { const std::string signal("1C 2S"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, signal); @@ -385,7 +385,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 8: // GPS L1 + GPS L5 - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { const std::string signal("1C L5"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, signal); @@ -396,7 +396,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 9: // GPS L1 C/A + Galileo E1B - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string gal_signal("1B"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gal_signal); @@ -407,7 +407,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 10: // GPS L1 C/A + Galileo E5a - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string gal_signal("5X"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gal_signal); @@ -418,7 +418,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 11: // GPS L1 C/A + Galileo E5b - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string gal_signal("7X"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gal_signal); @@ -429,7 +429,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 13: // L5+E5a - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { const std::string gal_signal("5X"); const std::string gps_signal("L5"); @@ -507,7 +507,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 26: // GPS L1 C/A + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string glo_signal("1G"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, glo_signal); @@ -530,7 +530,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 27: // Galileo E1B + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { const std::string glo_signal("1G"); const std::string gal_signal("1B"); @@ -542,7 +542,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 28: // GPS L2C + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { const std::string glo_signal("1G"); rinex_obs_header(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, glo_signal); @@ -553,7 +553,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 29: // GPS L1 C/A + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string glo_signal("2G"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, glo_signal); @@ -576,7 +576,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 30: // Galileo E1B + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { const std::string glo_signal("2G"); const std::string gal_signal("1B"); @@ -588,7 +588,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 31: // GPS L2C + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { const std::string glo_signal("2G"); rinex_obs_header(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, glo_signal); @@ -691,7 +691,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 106: // GPS L1 C/A + Galileo E1B + Galileo E6B - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { const std::string gal_signal("1B E6"); rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gal_signal); @@ -736,7 +736,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons break; case 501: // BeiDou B1I + GPS L1 C/A - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend())) { const std::string bds_signal("B1"); // rinex_obs_header(obsFile, gps_ephemeris_iter->second, beidou_dnav_ephemeris_iter->second, rx_time, bds_signal); @@ -746,7 +746,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons break; case 502: // BeiDou B1I + Galileo E1B - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend())) { const std::string bds_signal("B1"); const std::string gal_signal("1B"); @@ -838,7 +838,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); @@ -852,7 +852,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->gps_cnav_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); update_nav_header(navFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono); @@ -864,7 +864,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -876,7 +876,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "5X"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -888,7 +888,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "7X"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -896,10 +896,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 7: // GPS L1 C/A + GPS L2C - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); @@ -908,10 +908,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 8: // L1+L5 - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and ((pvt_solver->gps_cnav_utc_model.A0 != 0) or (pvt_solver->gps_utc_model.A0 != 0))) + if (!d_rinex_header_updated && ((pvt_solver->gps_cnav_utc_model.A0 != 0) || (pvt_solver->gps_utc_model.A0 != 0))) { if (pvt_solver->gps_cnav_utc_model.A0 != 0) { @@ -928,10 +928,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 9: // GPS L1 C/A + Galileo E1B - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -940,11 +940,11 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 13: // L5+E5a - if ((gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->gps_cnav_utc_model.A0 != 0) and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); update_nav_header(navMixFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -956,7 +956,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B 5X"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -968,7 +968,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B 7X"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -980,7 +980,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "5X 7X"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -992,7 +992,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map, "1C"); } - if (!d_rinex_header_updated and (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + if (!d_rinex_header_updated && (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) { update_nav_header(navGloFile, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); update_obs_header(obsFile, pvt_solver->glonass_gnav_utc_model); @@ -1004,7 +1004,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map, "2C"); } - if (!d_rinex_header_updated and (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + if (!d_rinex_header_updated && (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) { update_nav_header(navGloFile, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); update_obs_header(obsFile, pvt_solver->glonass_gnav_utc_model); @@ -1016,7 +1016,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map, "1C 2C"); } - if (!d_rinex_header_updated and (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) + if (!d_rinex_header_updated && (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) { update_nav_header(navMixFile, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); update_obs_header(obsFile, pvt_solver->glonass_gnav_utc_model); @@ -1024,10 +1024,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 26: // GPS L1 C/A + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1036,11 +1036,11 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 27: // Galileo E1B + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->galileo_utc_model); update_nav_header(navMixFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1048,11 +1048,11 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 28: // GPS L2C + GLONASS L1 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->gps_cnav_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); update_nav_header(navMixFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1060,10 +1060,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 29: // GPS L1 C/A + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1072,11 +1072,11 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 30: // Galileo E1B + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->galileo_utc_model); update_nav_header(navMixFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1084,11 +1084,11 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 31: // GPS L2C + GLONASS L2 C/A - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } - if (!d_rinex_header_updated and (pvt_solver->gps_cnav_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); update_nav_header(navMixFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1096,10 +1096,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 32: // L1+E1+L5+E5a - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and ((pvt_solver->gps_cnav_utc_model.A0 != 0) or (pvt_solver->gps_utc_model.A0 != 0)) and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && ((pvt_solver->gps_cnav_utc_model.A0 != 0) || (pvt_solver->gps_utc_model.A0 != 0)) && (pvt_solver->galileo_utc_model.A0 != 0)) { if (pvt_solver->gps_cnav_utc_model.A0 != 0) { @@ -1116,10 +1116,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 33: // L1+E1+E5a - if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0) and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -1132,7 +1132,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1144,7 +1144,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1156,7 +1156,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "5X E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1168,7 +1168,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "7X E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1180,7 +1180,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B 5X E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1192,7 +1192,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "1B 7X E6"); } - if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); update_obs_header(obsFile, pvt_solver->galileo_utc_model); @@ -1200,10 +1200,10 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 106: // GPS L1 C/A + Galileo E1B + Galileo E6B - if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -1218,7 +1218,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { // we have Galileo ephemeris, maybe from assistance log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -1229,7 +1229,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { // we do not have galileo ephemeris, print only GPS data log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); @@ -1244,7 +1244,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, beidou_dnav_ephemeris_iter->second, rx_time, gnss_observables_map, "B1"); } - if (!d_rinex_header_updated and (pvt_solver->beidou_dnav_utc_model.A0_UTC != 0)) + if (!d_rinex_header_updated && (pvt_solver->beidou_dnav_utc_model.A0_UTC != 0)) { update_obs_header(obsFile, pvt_solver->beidou_dnav_utc_model); update_nav_header(navFile, pvt_solver->beidou_dnav_utc_model, pvt_solver->beidou_dnav_iono); @@ -1256,7 +1256,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, beidou_dnav_ephemeris_iter->second, rx_time, gnss_observables_map, "B3"); } - if (!d_rinex_header_updated and (pvt_solver->beidou_dnav_utc_model.A0_UTC != 0)) + if (!d_rinex_header_updated && (pvt_solver->beidou_dnav_utc_model.A0_UTC != 0)) { update_obs_header(obsFile, pvt_solver->beidou_dnav_utc_model); update_nav_header(navFile, pvt_solver->beidou_dnav_utc_model, pvt_solver->beidou_dnav_iono); @@ -1269,7 +1269,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map, true); } - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); @@ -1283,7 +1283,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, true); } - if (!d_rinex_header_updated and (pvt_solver->gps_utc_model.A0 != 0) and (pvt_solver->galileo_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -4979,9 +4979,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + line += satsys->second; } if (gps_ephemeris_iter->second.PRN < 10) { @@ -5292,9 +5293,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + line += satsys->second; } if (gps_ephemeris_iter->second.PRN < 10) { @@ -5459,9 +5461,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + line += satsys_gal->second; } if (galileo_ephemeris_iter->second.PRN < 10) { @@ -5722,9 +5725,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + line += satsys->second; } if (glonass_gnav_ephemeris_iter->second.PRN < 10) { @@ -5894,9 +5898,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; + line += satsys_bds->second; } if (bds_ephemeris_iter->second.PRN < 10) { @@ -6035,9 +6040,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys_glo = satelliteSystem.find("GLONASS"); + if (satsys_glo != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys_glo->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -6196,9 +6202,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- SYS / OBS TYPES // one line per available system line.clear(); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } line += std::string(2, ' '); std::stringstream strm; @@ -6317,9 +6324,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); @@ -6380,9 +6388,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -6534,9 +6543,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { // one line per available system line.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GPS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys->second; } line += std::string(2, ' '); std::stringstream strm; @@ -6580,9 +6590,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps number_of_observations_glo = number_of_observations_glo + 4; } line.clear(); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys_glo = satelliteSystem.find("GLONASS"); + if (satsys_glo != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys_glo->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); @@ -6689,9 +6700,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); @@ -6752,9 +6764,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -6903,9 +6916,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- SYS / OBS TYPES // one line per available system line.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -6949,9 +6963,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris number_of_observations_glo = number_of_observations_glo + 4; } line.clear(); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys_glo = satelliteSystem.find("GLONASS"); + if (satsys_glo != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys_glo->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); @@ -7026,9 +7041,9 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line.clear(); line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list line += std::string(1, ' '); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + if (satsys_glo != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys_glo->second; } line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); @@ -7089,9 +7104,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -7256,9 +7272,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& number_of_observations_gal = number_of_observations_gal + 4; } - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("Galileo"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -7347,9 +7364,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& number_of_observations_glo = number_of_observations_glo + 4; } - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys_glo = satelliteSystem.find("GLONASS"); + if (satsys_glo != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys_glo->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); @@ -7440,9 +7458,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -7601,9 +7620,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- SYS / OBS TYPES // one line per available system line.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GPS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys->second; } line += std::string(2, ' '); std::stringstream strm; @@ -7714,9 +7734,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -7866,9 +7887,9 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gps = number_of_observations_gps + 4; } - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -7975,9 +7996,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += d_stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -8133,9 +8155,9 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { number_of_observations_gps = number_of_observations_gps + 4; } - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -8266,9 +8288,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -8424,9 +8447,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { number_of_observations_gps = number_of_observations_gps + 4; } - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -8523,9 +8547,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { number_of_observations_gal = number_of_observations_gal + 4; } - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("Galileo"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -8647,9 +8672,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -8799,9 +8825,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gps = number_of_observations_gps + 4; } - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -8878,9 +8905,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { number_of_observations_gal = number_of_observations_gal + 4; } - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("Galileo"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -9007,9 +9035,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("Galileo"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -9175,9 +9204,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); @@ -9306,9 +9336,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Mixed") != satelliteSystem.cend()) + const auto satsys_mix = satelliteSystem.find("Mixed"); + if (satsys_mix != satelliteSystem.cend()) { - line += satelliteSystem.find("Mixed")->second; + line += satsys_mix->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -9445,9 +9476,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- SYS / OBS TYPES // one line per available system line.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } line += std::string(2, ' '); std::stringstream strm; @@ -9506,9 +9538,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } line.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("Galileo"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("Galileo")->second; + line += satsys->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); @@ -9632,9 +9665,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line += "3.02"; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); - if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + const auto satsys_bds = satelliteSystem.find("Beidou"); + if (satsys_bds != satelliteSystem.cend()) { - line += satelliteSystem.find("Beidou")->second; + line += satsys_bds->second; } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); @@ -9778,9 +9812,9 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line.clear(); - if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + if (satsys_bds != satelliteSystem.cend()) { - line += satelliteSystem.find("Beidou")->second; + line += satsys_bds->second; } line += std::string(2, ' '); line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); @@ -10207,9 +10241,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri observables_iter != observables.cend(); observables_iter++) { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10330,9 +10365,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { std::string lineObs; lineObs.clear(); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10550,9 +10586,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesG1C.cend(); observables_iter++) { - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GPS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10565,9 +10602,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR1C.cend(); observables_iter++) { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10580,9 +10618,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR2C.cend(); observables_iter++) { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10610,16 +10649,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // Specify system only if in version 3 if (s == "G") { - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GPS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys->second; } } if (s == "R") { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -10689,9 +10730,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs.clear(); if (d_version == 3) { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(*it) < 10) { @@ -10880,16 +10922,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // Specify system only if in version 3 if (s == "G") { - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } } if (s == "R") { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -10956,9 +11000,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g it++) { lineObs.clear(); - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } if (static_cast(*it) < 10) { @@ -11147,16 +11192,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga s.assign(1, observables_iter->second.System); if (s == "E") { - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } } if (s == "R") { - if (satelliteSystem.find("GLONASS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GLONASS"); + if (satsys != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GLONASS")->second; + line += satsys->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -11221,9 +11268,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga it++) { lineObs.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -11357,9 +11405,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d observables_iter != observables.cend(); observables_iter++) { - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys = satelliteSystem.find("GPS"); + if (satsys != satelliteSystem.cend()) { - line += satelliteSystem.find("GPS")->second; + line += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11481,9 +11530,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { std::string lineObs; lineObs.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11611,9 +11661,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { std::string lineObs; lineObs.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11838,9 +11889,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c it++) { lineObs.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -11856,7 +11908,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c { have_l2 = true; } - if (triple_band and sig_ == "L5" and have_l2 == false) + if (triple_band && sig_ == "L5" && have_l2 == false) { lineObs += std::string(62, ' '); } @@ -12094,9 +12146,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep it++) { lineObs.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -12319,16 +12372,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep s.assign(1, observables_iter->second.System); if (s == "G") { - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } } if (s == "E") { - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -12393,9 +12448,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -12649,9 +12705,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e it++) { lineObs.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -12714,9 +12771,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e it++) { lineObs.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -12988,9 +13046,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - if (satelliteSystem.find("GPS") != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("GPS")->second; + line += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -13006,7 +13065,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { have_l2 = true; } - if (triple_band and sig_ == "L5" and have_l2 == false) + if (triple_band && sig_ == "L5" && have_l2 == false) { lineObs += std::string(62, ' '); } @@ -13064,9 +13123,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - if (satelliteSystem.find("Galileo") != satelliteSystem.cend()) + const auto satsys_gal = satelliteSystem.find("Galileo"); + if (satsys_gal != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Galileo")->second; + line += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -13252,9 +13312,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris it++) { lineObs.clear(); - if (satelliteSystem.find("Beidou") != satelliteSystem.cend()) + const auto satsys_bds = satelliteSystem.find("Beidou"); + if (satsys_bds != satelliteSystem.cend()) { - lineObs += satelliteSystem.find("Beidou")->second; + line += satsys_bds->second; } if (static_cast(*it) < 10) { From b7378e4fd8714f440d375d4215f5c519270dcdc5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 7 Nov 2023 11:58:42 +0100 Subject: [PATCH 065/142] Add guard to avoid division by zero --- .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 37beb5d43..227bf8e05 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 @@ -1030,7 +1030,10 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( decode_FNAV_word(d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); break; case 3: // CNAV - decode_CNAV_word(current_symbol.Tracking_sample_counter / static_cast(current_symbol.fs), d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); + if (current_symbol.fs != 0LL) + { + decode_CNAV_word(current_symbol.Tracking_sample_counter / static_cast(current_symbol.fs), d_page_part_symbols.data(), d_frame_length_symbols, current_symbol.CN0_dB_hz); + } break; default: return -1; From 79b6312e3c1db57f2c44fca1bf640bf09084c5df Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 7 Nov 2023 13:19:57 +0100 Subject: [PATCH 066/142] Fix API usage error reported by Coverity Scan --- src/core/libs/gnss_sdr_supl_client.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 73905ee25..51aabe4f7 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -248,17 +248,20 @@ void Gnss_Sdr_Supl_Client::read_supl_data() gps_almanac_map.insert(std::pair(a->prn, gps_almanac_entry)); gps_almanac_iterator = this->gps_almanac_map.find(a->prn); } - gps_almanac_iterator->second.PRN = a->prn; - gps_almanac_iterator->second.af0 = static_cast(a->AF0) * pow(2.0, -20); - gps_almanac_iterator->second.af1 = static_cast(a->AF1) * pow(2.0, -38); - gps_almanac_iterator->second.delta_i = static_cast(a->Ksii) * pow(2.0, -19); - gps_almanac_iterator->second.omega = static_cast(a->w) * pow(2.0, -23); - gps_almanac_iterator->second.OMEGA_0 = static_cast(a->OMEGA_0) * pow(2.0, -23); - gps_almanac_iterator->second.sqrtA = static_cast(a->A_sqrt) * pow(2.0, -11); - gps_almanac_iterator->second.OMEGAdot = static_cast(a->OMEGA_dot) * pow(2.0, -38); - gps_almanac_iterator->second.toa = static_cast(a->toa * pow(2.0, 12)); - gps_almanac_iterator->second.ecc = static_cast(a->e) * pow(2.0, -21); - gps_almanac_iterator->second.M_0 = static_cast(a->M0) * pow(2.0, -23); + if (gps_almanac_iterator != gps_almanac_map.end()) + { + gps_almanac_iterator->second.PRN = a->prn; + gps_almanac_iterator->second.af0 = static_cast(a->AF0) * pow(2.0, -20); + gps_almanac_iterator->second.af1 = static_cast(a->AF1) * pow(2.0, -38); + gps_almanac_iterator->second.delta_i = static_cast(a->Ksii) * pow(2.0, -19); + gps_almanac_iterator->second.omega = static_cast(a->w) * pow(2.0, -23); + gps_almanac_iterator->second.OMEGA_0 = static_cast(a->OMEGA_0) * pow(2.0, -23); + gps_almanac_iterator->second.sqrtA = static_cast(a->A_sqrt) * pow(2.0, -11); + gps_almanac_iterator->second.OMEGAdot = static_cast(a->OMEGA_dot) * pow(2.0, -38); + gps_almanac_iterator->second.toa = static_cast(a->toa * pow(2.0, 12)); + gps_almanac_iterator->second.ecc = static_cast(a->e) * pow(2.0, -21); + gps_almanac_iterator->second.M_0 = static_cast(a->M0) * pow(2.0, -23); + } } } From bf84a659a8019a80c6911351aa339d1e5cf50a3c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 7 Nov 2023 13:21:51 +0100 Subject: [PATCH 067/142] Rinex_Printer: fixes after last change, some improvements --- src/algorithms/PVT/libs/rinex_printer.cc | 106 +++++++++++------------ 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index f140270d4..9b0c2f814 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -5446,6 +5446,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; + const auto satsys_gal = satelliteSystem.find("Galileo"); std::map::const_iterator galileo_ephemeris_iter; line.clear(); for (galileo_ephemeris_iter = eph_map.cbegin(); @@ -5461,7 +5462,6 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond; @@ -10359,16 +10359,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri Rinex_Printer::lengthCheck(line); out << line << '\n'; + const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - const auto satsys = satelliteSystem.find("GLONASS"); if (satsys != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10582,14 +10582,14 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (d_version == 2) { // Add list of GPS satellites + const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observablesG1C.cbegin(); observables_iter != observablesG1C.cend(); observables_iter++) { - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) + if (satsys_gps != satelliteSystem.cend()) { - line += satsys->second; + line += satsys_gps->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10598,14 +10598,14 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L1 satellites + const auto satsys_glo = satelliteSystem.find("GLONASS"); for (observables_iter = observablesR1C.cbegin(); observables_iter != observablesR1C.cend(); observables_iter++) { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) + if (satsys_glo != satelliteSystem.cend()) { - line += satsys->second; + line += satsys_glo->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10618,10 +10618,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR2C.cend(); observables_iter++) { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) + if (satsys_glo != satelliteSystem.cend()) { - line += satsys->second; + line += satsys_glo->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -10649,18 +10648,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // Specify system only if in version 3 if (s == "G") { - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) + const auto satsys_gps = satelliteSystem.find("GPS"); + if (satsys_gps != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys_gps->second; } } if (s == "R") { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) + const auto satsys_glo = satelliteSystem.find("GLONASS"); + if (satsys_glo != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys_glo->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -10733,7 +10732,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep const auto satsys = satelliteSystem.find("GLONASS"); if (satsys != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys->second; } if (static_cast(*it) < 10) { @@ -10912,6 +10911,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // -------- OBSERVATION record std::string s; std::string lineObs; + const auto satsys_gps = satelliteSystem.find("GPS"); + const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observablesG2S.cbegin(); observables_iter != observablesG2S.cend(); observables_iter++) @@ -10922,18 +10923,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // Specify system only if in version 3 if (s == "G") { - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } } if (s == "R") { - const auto satsys = satelliteSystem.find("GLONASS"); if (satsys != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -11000,10 +10999,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g it++) { lineObs.clear(); - const auto satsys = satelliteSystem.find("GLONASS"); if (satsys != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys->second; } if (static_cast(*it) < 10) { @@ -11183,6 +11181,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga std::string s; std::string lineObs; + const auto satsys_gal = satelliteSystem.find("Galileo"); + const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observablesE1B.cbegin(); observables_iter != observablesE1B.cend(); observables_iter++) @@ -11192,18 +11192,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga s.assign(1, observables_iter->second.System); if (s == "E") { - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } } if (s == "R") { - const auto satsys = satelliteSystem.find("GLONASS"); if (satsys != satelliteSystem.cend()) { - line += satsys->second; + lineObs += satsys->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -11271,7 +11269,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -11524,16 +11522,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d Rinex_Printer::lengthCheck(line); out << line << '\n'; + const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11655,16 +11653,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e Rinex_Printer::lengthCheck(line); out << line << '\n'; + const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } if (static_cast(observables_iter->second.PRN) < 10) { @@ -11883,16 +11881,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c out << line << '\n'; std::string lineObs; + const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -12141,15 +12139,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string lineObs; std::pair::iterator, std::multimap::iterator> ret; + const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -12363,6 +12361,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep std::string s; std::string lineObs; + const auto satsys_gps = satelliteSystem.find("GPS"); + const auto satsys_gal = satelliteSystem.find("Galileo"); + for (observables_iter = observablesG1C.cbegin(); observables_iter != observablesG1C.cend(); observables_iter++) @@ -12372,18 +12373,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep s.assign(1, observables_iter->second.System); if (s == "G") { - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } } if (s == "E") { - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } // should not happen } if (static_cast(observables_iter->second.PRN) < 10) @@ -12448,10 +12447,9 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -12699,16 +12697,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e std::string s; std::string lineObs; + const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_gps_prns.cbegin(); it != available_gps_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -12766,15 +12764,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e out << lineObs << '\n'; } + const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_gal_prns.cbegin(); it != available_gal_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -13040,16 +13038,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep std::string s; std::string lineObs; + const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_gps_prns.cbegin(); it != available_gps_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { - line += satsys_gps->second; + lineObs += satsys_gps->second; } if (static_cast(*it) < 10) { @@ -13118,15 +13116,15 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep out << lineObs << '\n'; } + const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_gal_prns.cbegin(); it != available_gal_prns.cend(); it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { - line += satsys_gal->second; + lineObs += satsys_gal->second; } if (static_cast(*it) < 10) { @@ -13306,16 +13304,16 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris out << line << '\n'; std::string lineObs; + const auto satsys_bds = satelliteSystem.find("Beidou"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - const auto satsys_bds = satelliteSystem.find("Beidou"); if (satsys_bds != satelliteSystem.cend()) { - line += satsys_bds->second; + lineObs += satsys_bds->second; } if (static_cast(*it) < 10) { From 3ddfdb9167e44e81347271a6258cf0b2767bae2c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 7 Nov 2023 13:41:54 +0100 Subject: [PATCH 068/142] CI: set python-version in volk-gnsssdr-windows job --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ac057c239..bc1fb280f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -193,6 +193,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 + with: + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip From fe3d704c9d23ac158b6f27cacf9c8c737980d340 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 8 Nov 2023 11:57:15 +0100 Subject: [PATCH 069/142] Fix defects detected by Coverity Scan --- src/algorithms/PVT/libs/rinex_printer.cc | 2 +- src/core/libs/gnss_sdr_supl_client.cc | 110 ++++++++++++----------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 9b0c2f814..6efd2de45 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1269,7 +1269,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map, true); } - if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) { update_obs_header(obsFile, pvt_solver->gps_utc_model); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 51aabe4f7..6e4ec6d1d 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -281,48 +281,51 @@ void Gnss_Sdr_Supl_Client::read_supl_data() gps_ephemeris_map.insert(std::pair(e->prn, gps_eph)); gps_eph_iterator = this->gps_ephemeris_map.find(e->prn); } - if (gps_time.valid) + if (gps_eph_iterator != gps_ephemeris_map.end()) { - gps_eph_iterator->second.WN = assist.time.gps_week; - /* TS 44.031: GPSTOW, range 0-604799.92, resolution 0.08 sec, 23-bit presentation */ - gps_eph_iterator->second.tow = static_cast(assist.time.gps_tow) * 0.08; + if (gps_time.valid) + { + gps_eph_iterator->second.WN = assist.time.gps_week; + /* TS 44.031: GPSTOW, range 0-604799.92, resolution 0.08 sec, 23-bit presentation */ + gps_eph_iterator->second.tow = static_cast(assist.time.gps_tow) * 0.08; + } + else + { + gps_eph_iterator->second.WN = 0; + gps_eph_iterator->second.tow = 0; + } + gps_eph_iterator->second.PRN = e->prn; + // SV navigation model + gps_eph_iterator->second.code_on_L2 = e->bits; + gps_eph_iterator->second.SV_accuracy = e->ura; // User Range Accuracy (URA) + gps_eph_iterator->second.SV_health = e->health; + gps_eph_iterator->second.IODC = static_cast(e->IODC); + // miss P flag (1 bit) + // miss SF1 Reserved (87 bits) + gps_eph_iterator->second.TGD = static_cast(e->tgd) * T_GD_LSB; + gps_eph_iterator->second.toc = static_cast(e->toc) * T_OC_LSB; + gps_eph_iterator->second.af0 = static_cast(e->AF0) * A_F0_LSB; + gps_eph_iterator->second.af1 = static_cast(e->AF1) * A_F1_LSB; + gps_eph_iterator->second.af2 = static_cast(e->AF2) * A_F2_LSB; + gps_eph_iterator->second.Crc = static_cast(e->Crc) * C_RC_LSB; + gps_eph_iterator->second.delta_n = static_cast(e->delta_n) * DELTA_N_LSB; + gps_eph_iterator->second.M_0 = static_cast(e->M0) * M_0_LSB; + gps_eph_iterator->second.Cuc = static_cast(e->Cuc) * C_UC_LSB; + gps_eph_iterator->second.ecc = static_cast(e->e) * ECCENTRICITY_LSB; + gps_eph_iterator->second.Cus = static_cast(e->Cus) * C_US_LSB; + gps_eph_iterator->second.sqrtA = static_cast(e->A_sqrt) * SQRT_A_LSB; + gps_eph_iterator->second.toe = static_cast(e->toe) * T_OE_LSB; + // miss fit interval flag (1 bit) + gps_eph_iterator->second.AODO = e->AODA * AODO_LSB; + gps_eph_iterator->second.Cic = static_cast(e->Cic) * C_IC_LSB; + gps_eph_iterator->second.OMEGA_0 = static_cast(e->OMEGA_0) * OMEGA_0_LSB; + gps_eph_iterator->second.Cis = static_cast(e->Cis) * C_IS_LSB; + gps_eph_iterator->second.i_0 = static_cast(e->i0) * I_0_LSB; + gps_eph_iterator->second.Crs = static_cast(e->Crs) * C_RS_LSB; + gps_eph_iterator->second.omega = static_cast(e->w) * OMEGA_LSB; + gps_eph_iterator->second.OMEGAdot = static_cast(e->OMEGA_dot) * OMEGA_DOT_LSB; + gps_eph_iterator->second.idot = static_cast(e->i_dot) * I_DOT_LSB; } - else - { - gps_eph_iterator->second.WN = 0; - gps_eph_iterator->second.tow = 0; - } - gps_eph_iterator->second.PRN = e->prn; - // SV navigation model - gps_eph_iterator->second.code_on_L2 = e->bits; - gps_eph_iterator->second.SV_accuracy = e->ura; // User Range Accuracy (URA) - gps_eph_iterator->second.SV_health = e->health; - gps_eph_iterator->second.IODC = static_cast(e->IODC); - // miss P flag (1 bit) - // miss SF1 Reserved (87 bits) - gps_eph_iterator->second.TGD = static_cast(e->tgd) * T_GD_LSB; - gps_eph_iterator->second.toc = static_cast(e->toc) * T_OC_LSB; - gps_eph_iterator->second.af0 = static_cast(e->AF0) * A_F0_LSB; - gps_eph_iterator->second.af1 = static_cast(e->AF1) * A_F1_LSB; - gps_eph_iterator->second.af2 = static_cast(e->AF2) * A_F2_LSB; - gps_eph_iterator->second.Crc = static_cast(e->Crc) * C_RC_LSB; - gps_eph_iterator->second.delta_n = static_cast(e->delta_n) * DELTA_N_LSB; - gps_eph_iterator->second.M_0 = static_cast(e->M0) * M_0_LSB; - gps_eph_iterator->second.Cuc = static_cast(e->Cuc) * C_UC_LSB; - gps_eph_iterator->second.ecc = static_cast(e->e) * ECCENTRICITY_LSB; - gps_eph_iterator->second.Cus = static_cast(e->Cus) * C_US_LSB; - gps_eph_iterator->second.sqrtA = static_cast(e->A_sqrt) * SQRT_A_LSB; - gps_eph_iterator->second.toe = static_cast(e->toe) * T_OE_LSB; - // miss fit interval flag (1 bit) - gps_eph_iterator->second.AODO = e->AODA * AODO_LSB; - gps_eph_iterator->second.Cic = static_cast(e->Cic) * C_IC_LSB; - gps_eph_iterator->second.OMEGA_0 = static_cast(e->OMEGA_0) * OMEGA_0_LSB; - gps_eph_iterator->second.Cis = static_cast(e->Cis) * C_IS_LSB; - gps_eph_iterator->second.i_0 = static_cast(e->i0) * I_0_LSB; - gps_eph_iterator->second.Crs = static_cast(e->Crs) * C_RS_LSB; - gps_eph_iterator->second.omega = static_cast(e->w) * OMEGA_LSB; - gps_eph_iterator->second.OMEGAdot = static_cast(e->OMEGA_dot) * OMEGA_DOT_LSB; - gps_eph_iterator->second.idot = static_cast(e->i_dot) * I_DOT_LSB; } } @@ -343,18 +346,21 @@ void Gnss_Sdr_Supl_Client::read_supl_data() gps_acq_map.insert(std::pair(e->prn, gps_acq_assist)); gps_acq_iterator = this->gps_acq_map.find(e->prn); } - // fill the acquisition assistance structure - gps_acq_iterator->second.PRN = e->prn; - gps_acq_iterator->second.tow = static_cast(assist.acq_time); - gps_acq_iterator->second.Doppler0 = static_cast(e->doppler0); - gps_acq_iterator->second.Doppler1 = static_cast(e->doppler1); - gps_acq_iterator->second.dopplerUncertainty = static_cast(e->d_win); - gps_acq_iterator->second.Code_Phase = static_cast(e->code_ph); - gps_acq_iterator->second.Code_Phase_int = static_cast(e->code_ph_int); - gps_acq_iterator->second.Code_Phase_window = static_cast(e->code_ph_win); - gps_acq_iterator->second.Azimuth = static_cast(e->az); - gps_acq_iterator->second.Elevation = static_cast(e->el); - gps_acq_iterator->second.GPS_Bit_Number = static_cast(e->bit_num); + if (gps_acq_iterator != gps_acq_map.end()) + { + // fill the acquisition assistance structure + gps_acq_iterator->second.PRN = e->prn; + gps_acq_iterator->second.tow = static_cast(assist.acq_time); + gps_acq_iterator->second.Doppler0 = static_cast(e->doppler0); + gps_acq_iterator->second.Doppler1 = static_cast(e->doppler1); + gps_acq_iterator->second.dopplerUncertainty = static_cast(e->d_win); + gps_acq_iterator->second.Code_Phase = static_cast(e->code_ph); + gps_acq_iterator->second.Code_Phase_int = static_cast(e->code_ph_int); + gps_acq_iterator->second.Code_Phase_window = static_cast(e->code_ph_win); + gps_acq_iterator->second.Azimuth = static_cast(e->az); + gps_acq_iterator->second.Elevation = static_cast(e->el); + gps_acq_iterator->second.GPS_Bit_Number = static_cast(e->bit_num); + } } } } From f0c6a7184a3183ee436eec4396aec0ca78c706d4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 8 Nov 2023 16:33:26 +0100 Subject: [PATCH 070/142] Generate RINEX and HAS outputs for GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a + Galileo E6B receiver --- src/algorithms/PVT/adapters/rtklib_pvt.cc | 4 ++ .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- src/algorithms/PVT/libs/rinex_printer.cc | 58 ++++++++++++++++++- src/algorithms/PVT/libs/rinex_printer.h | 1 + src/algorithms/PVT/libs/rtklib_solver.cc | 4 ++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 9bf6174ab..e03dcad5c 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -412,6 +412,10 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, { pvt_output_parameters.type_of_receiver = 107; // GPS L1 C/A + Galileo E6B } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (gal_E6_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count == 0)) + { + pvt_output_parameters.type_of_receiver = 108; // GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a + Galileo E6B + } // BeiDou B1I Receiver if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (gal_E6_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index fc79642ea..8e24687ba 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -434,7 +434,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, } // Initialize HAS simple printer - d_enable_has_messages = (((d_type_of_rx >= 100) && (d_type_of_rx < 107)) && (conf_.output_enabled)); + d_enable_has_messages = (((d_type_of_rx >= 100) && (d_type_of_rx < 109)) && (conf_.output_enabled)); if (d_enable_has_messages) { d_has_simple_printer = std::make_unique(); diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 6efd2de45..7b17a4295 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -724,6 +724,20 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons d_rinex_header_written = true; // do not write header anymore } break; + case 108: // GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a + Galileo E6B + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and + (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and + (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + { + const std::string gal_signal("1B 5X E6"); + const std::string gps_signal("1C L5"); + rinex_obs_header(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gps_signal, gal_signal); + rinex_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); + output_navfilename.push_back(navMixfilename); + log_rinex_nav(navMixFile, pvt_solver->gps_ephemeris_map, pvt_solver->galileo_ephemeris_map); + d_rinex_header_written = true; // do not write header anymore + } + break; case 500: // BDS B1I only if (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend()) { @@ -1237,7 +1251,33 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } } } - + break; + case 108: // GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a + Galileo E6B + if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + { + if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + { + // we have Galileo ephemeris, maybe from assistance + log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) + { + update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); + d_rinex_header_updated = true; + } + } + else + { + // we do not have galileo ephemeris, print only GPS data + log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) + { + update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); + d_rinex_header_updated = true; + } + } + } break; case 500: // BDS B1I only if (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend()) @@ -1374,6 +1414,16 @@ void Rinex_Printer::log_rinex_nav_gps_nav(int type_of_rx, const std::map> (); // d_has_obs_corr_map["L1 C/A"] = empty_map; From fcfc851aa562bdeaad5ab035dbe48efe124acd9e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 9 Nov 2023 08:53:29 +0100 Subject: [PATCH 071/142] Write HAS data file at PVT.output_path --- src/algorithms/PVT/adapters/rtklib_pvt.cc | 1 + .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- src/algorithms/PVT/libs/pvt_conf.h | 1 + src/algorithms/PVT/libs/rinex_printer.cc | 33 ++++++------------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index e03dcad5c..0e47e01f9 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -861,6 +861,7 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, pvt_output_parameters.xml_output_path = configuration->property(role + ".xml_output_path", default_output_path); pvt_output_parameters.nmea_output_file_path = configuration->property(role + ".nmea_output_file_path", default_output_path); pvt_output_parameters.rtcm_output_file_path = configuration->property(role + ".rtcm_output_file_path", default_output_path); + pvt_output_parameters.has_output_file_path = configuration->property(role + ".has_output_file_path", default_output_path); // Read PVT MONITOR Configuration pvt_output_parameters.monitor_enabled = configuration->property(role + ".enable_monitor", false); diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 8e24687ba..ca63c6f31 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -437,7 +437,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, d_enable_has_messages = (((d_type_of_rx >= 100) && (d_type_of_rx < 109)) && (conf_.output_enabled)); if (d_enable_has_messages) { - d_has_simple_printer = std::make_unique(); + d_has_simple_printer = std::make_unique(conf_.has_output_file_path); } else { diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index 517465350..80f4494d5 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -46,6 +46,7 @@ public: std::string kml_output_path = std::string("."); std::string xml_output_path = std::string("."); std::string rtcm_output_file_path = std::string("."); + std::string has_output_file_path = std::string("."); std::string udp_addresses; std::string udp_eph_addresses; std::string log_source_timetag_file; diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 7b17a4295..516403dbb 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1253,30 +1253,17 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons } break; case 108: // GPS L1 C/A + Galileo E1B + GPS L5 + Galileo E5a + Galileo E6B - if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) and + (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) and + (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) { - if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) - { - // we have Galileo ephemeris, maybe from assistance - log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) - { - update_obs_header(obsFile, pvt_solver->gps_utc_model); - update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); - d_rinex_header_updated = true; - } - } - else - { - // we do not have galileo ephemeris, print only GPS data - log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); - if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) - { - update_obs_header(obsFile, pvt_solver->gps_utc_model); - update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); - d_rinex_header_updated = true; - } - } + log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, true); + } + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + { + update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); + d_rinex_header_updated = true; } break; case 500: // BDS B1I only From 526d414789485e1081681bd3b1ce2a383dde68b7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 11 Nov 2023 00:14:32 +0100 Subject: [PATCH 072/142] Update local version of matio to 1.5.25 and Protocol Buffers to 25.0 --- CMakeLists.txt | 4 ++-- cmake/Modules/BuildProtobuf.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86373d868..f7af13ad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,8 +338,8 @@ set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.6.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.24") -set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "24.4") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.25") +set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "25.0") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake index 48418d608..5590943db 100644 --- a/cmake/Modules/BuildProtobuf.cmake +++ b/cmake/Modules/BuildProtobuf.cmake @@ -13,7 +13,7 @@ if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION) - set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "24.4") + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "25.0") endif() if(NOT GNSSSDR_BINARY_DIR) From 8f13192aa6d7d8dbf5dbc80030ba17cab2916cd8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Nov 2023 08:04:42 +0100 Subject: [PATCH 073/142] Update local version of matio to 1.5.26 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7af13ad1..5a297f0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,7 +338,7 @@ set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.6.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.25") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.26") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "25.0") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") From 7132ee720ad727f9a7db09048803f6f59a85d729 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 13:42:44 +0100 Subject: [PATCH 074/142] Remove useless casts --- src/algorithms/PVT/libs/an_packet_printer.cc | 16 +++++----- src/algorithms/PVT/libs/rtcm.cc | 16 +++++----- ...o_e5a_noncoherent_iq_acquisition_caf_cc.cc | 20 ++++++------- .../gnuradio_blocks/pcps_acquisition.cc | 2 +- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 6 ++-- .../adapters/file_source_base.cc | 2 +- .../four_bit_cpx_file_signal_source.cc | 2 +- .../adapters/nsr_file_signal_source.cc | 2 +- .../two_bit_cpx_file_signal_source.cc | 2 +- .../two_bit_packed_file_signal_source.cc | 2 +- .../adapters/zmq_signal_source.cc | 2 +- .../galileo_telemetry_decoder_gs.cc | 22 +++++++------- .../tracking/libs/tracking_discriminators.cc | 4 +-- .../beidou_dnav_navigation_message.cc | 2 +- .../system_parameters/galileo_fnav_message.cc | 2 +- .../system_parameters/galileo_inav_message.cc | 14 ++++----- .../glonass_gnav_navigation_message.cc | 30 +++++++++---------- .../gps_cnav_navigation_message.cc | 6 ++-- 18 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/algorithms/PVT/libs/an_packet_printer.cc b/src/algorithms/PVT/libs/an_packet_printer.cc index 72e7e8a9f..6618d6982 100644 --- a/src/algorithms/PVT/libs/an_packet_printer.cc +++ b/src/algorithms/PVT/libs/an_packet_printer.cc @@ -171,9 +171,9 @@ void An_Packet_Printer::update_sdr_gnss_packet(sdr_gnss_packet_t* _packet, const _packet->gps_satellites = num_gps_sats; _packet->galileo_satellites = num_gal_sats; _packet->microseconds = static_cast(elapsed_seconds.count() * 1.0e6); - _packet->latitude = static_cast(pvt->get_latitude()) * (M_PI / 180.0); - _packet->longitude = static_cast(pvt->get_longitude()) * (M_PI / 180.0); - _packet->height = static_cast(pvt->get_height()); + _packet->latitude = pvt->get_latitude() * (M_PI / 180.0); + _packet->longitude = pvt->get_longitude() * (M_PI / 180.0); + _packet->height = pvt->get_height(); _packet->velocity[0] = static_cast(pvt->get_rx_vel()[1]); _packet->velocity[1] = static_cast(pvt->get_rx_vel()[0]); _packet->velocity[2] = static_cast(-pvt->get_rx_vel()[2]); @@ -196,11 +196,11 @@ void An_Packet_Printer::update_sdr_gnss_packet(sdr_gnss_packet_t* _packet, const void An_Packet_Printer::encode_sdr_gnss_packet(sdr_gnss_packet_t* sdr_gnss_packet, an_packet_t* _packet) const { uint8_t offset = 0; - LSB_bytes_to_array(reinterpret_cast(&sdr_gnss_packet->nsvfix), offset, _packet->data, sizeof(sdr_gnss_packet->nsvfix)); + LSB_bytes_to_array(&sdr_gnss_packet->nsvfix, offset, _packet->data, sizeof(sdr_gnss_packet->nsvfix)); offset += sizeof(sdr_gnss_packet->nsvfix); - LSB_bytes_to_array(reinterpret_cast(&sdr_gnss_packet->gps_satellites), offset, _packet->data, sizeof(sdr_gnss_packet->gps_satellites)); + LSB_bytes_to_array(&sdr_gnss_packet->gps_satellites, offset, _packet->data, sizeof(sdr_gnss_packet->gps_satellites)); offset += sizeof(sdr_gnss_packet->gps_satellites); - LSB_bytes_to_array(reinterpret_cast(&sdr_gnss_packet->galileo_satellites), offset, _packet->data, sizeof(sdr_gnss_packet->galileo_satellites)); + LSB_bytes_to_array(&sdr_gnss_packet->galileo_satellites, offset, _packet->data, sizeof(sdr_gnss_packet->galileo_satellites)); offset += sizeof(sdr_gnss_packet->galileo_satellites); LSB_bytes_to_array(reinterpret_cast(&sdr_gnss_packet->microseconds), offset, _packet->data, sizeof(sdr_gnss_packet->microseconds)); offset += sizeof(sdr_gnss_packet->microseconds); @@ -218,9 +218,9 @@ void An_Packet_Printer::encode_sdr_gnss_packet(sdr_gnss_packet_t* sdr_gnss_packe offset += sizeof(sdr_gnss_packet->velocity[2]); for (auto& sat : sdr_gnss_packet->sats) { - LSB_bytes_to_array(reinterpret_cast(&sat.prn), offset, _packet->data, sizeof(sat.prn)); + LSB_bytes_to_array(&sat.prn, offset, _packet->data, sizeof(sat.prn)); offset += sizeof(sat.prn); - LSB_bytes_to_array(reinterpret_cast(&sat.snr), offset, _packet->data, sizeof(sat.snr)); + LSB_bytes_to_array(&sat.snr, offset, _packet->data, sizeof(sat.snr)); offset += sizeof(sat.snr); LSB_bytes_to_array(reinterpret_cast(&sat.doppler), offset, _packet->data, sizeof(sat.doppler)); offset += sizeof(sat.doppler); diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index 7f962d4f7..5854b4eb8 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -929,7 +929,7 @@ int32_t Rtcm::read_MT1005(const std::string& message, uint32_t& ref_id, double& const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + uint32_t read_message_length = Rtcm::bin_to_uint(message_bin.substr(index, 10)); index += 10; if (read_message_length != 19) { @@ -1601,7 +1601,7 @@ int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) co const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = Rtcm::bin_to_uint(message_bin.substr(index, 10)); index += 10; if (read_message_length != 61) @@ -1621,7 +1621,7 @@ int32_t Rtcm::read_MT1019(const std::string& message, Gps_Ephemeris& gps_eph) co } // Fill Gps Ephemeris with message data content - gps_eph.PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + gps_eph.PRN = Rtcm::bin_to_uint(message_bin.substr(index, 6)); index += 6; gps_eph.WN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); @@ -1835,7 +1835,7 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = Rtcm::bin_to_uint(message_bin.substr(index, 10)); index += 10; if (read_message_length != 45) // 360 bits = 45 bytes @@ -1855,7 +1855,7 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl } // Fill Gps Ephemeris with message data content - glonass_gnav_eph.i_satellite_slot_number = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + glonass_gnav_eph.i_satellite_slot_number = Rtcm::bin_to_uint(message_bin.substr(index, 6)); index += 6; glonass_gnav_eph.i_satellite_freq_channel = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 5)) - 7.0); @@ -2138,7 +2138,7 @@ int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph const uint32_t reserved_field_length = 6; uint32_t index = preamble_length + reserved_field_length; - const uint32_t read_message_length = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 10))); + const uint32_t read_message_length = Rtcm::bin_to_uint(message_bin.substr(index, 10)); index += 10; if (read_message_length != 62) @@ -2158,7 +2158,7 @@ int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph } // Fill Galileo Ephemeris with message data content - gal_eph.PRN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 6))); + gal_eph.PRN = Rtcm::bin_to_uint(message_bin.substr(index, 6)); index += 6; gal_eph.WN = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 12))); @@ -2233,7 +2233,7 @@ int32_t Rtcm::read_MT1045(const std::string& message, Galileo_Ephemeris& gal_eph gal_eph.BGD_E1E5a = static_cast(Rtcm::bin_to_int(message_bin.substr(index, 10))); index += 10; - gal_eph.E5a_HS = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); + gal_eph.E5a_HS = Rtcm::bin_to_uint(message_bin.substr(index, 2)); index += 2; gal_eph.E5a_DVS = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 1))); diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 69430cca8..1e0f945b5 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -613,15 +613,15 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1.0F - weighting_factor * static_cast((doppler_index - i))); } - d_CAF_vector[doppler_index] /= static_cast(1.0F + static_cast(CAF_bins_half + doppler_index) - weighting_factor * static_cast(CAF_bins_half) * ((static_cast(CAF_bins_half) + 1.0F) / 2.0F) - weighting_factor * static_cast(doppler_index) * (static_cast(doppler_index) + 1.0F) / 2.0F); // triangles = [n*(n+1)/2] + d_CAF_vector[doppler_index] /= 1.0F + static_cast(CAF_bins_half + doppler_index) - weighting_factor * static_cast(CAF_bins_half) * ((static_cast(CAF_bins_half) + 1.0F) / 2.0F) - weighting_factor * static_cast(doppler_index) * (static_cast(doppler_index) + 1.0F) / 2.0F; // triangles = [n*(n+1)/2] if (d_both_signal_components) { accum[0] = 0; for (int i = 0; i < CAF_bins_half + doppler_index + 1; i++) { - accum[0] += static_cast(d_CAF_vector_Q[i] * (1.0F - weighting_factor * static_cast(abs(doppler_index - i)))); + accum[0] += d_CAF_vector_Q[i] * (1.0F - weighting_factor * static_cast(abs(doppler_index - i))); } - accum[0] /= static_cast(1.0F + static_cast(CAF_bins_half + doppler_index) - weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F - weighting_factor * static_cast(doppler_index) * static_cast(doppler_index + 1) / 2.0F); // triangles = [n*(n+1)/2] + accum[0] /= 1.0F + static_cast(CAF_bins_half + doppler_index) - weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F - weighting_factor * static_cast(doppler_index) * static_cast(doppler_index + 1) / 2.0F; // triangles = [n*(n+1)/2] d_CAF_vector[doppler_index] += accum[0]; } } @@ -629,19 +629,19 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items for (int doppler_index = CAF_bins_half; doppler_index < d_num_doppler_bins - CAF_bins_half; doppler_index++) { d_CAF_vector[doppler_index] = 0; - for (int i = doppler_index - CAF_bins_half; i < static_cast(doppler_index + CAF_bins_half + 1); i++) + for (int i = doppler_index - CAF_bins_half; i < doppler_index + CAF_bins_half + 1; i++) { d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1.0F - weighting_factor * static_cast((doppler_index - i))); } - d_CAF_vector[doppler_index] /= static_cast(1.0F + 2.0F * static_cast(CAF_bins_half) - 2.0F * weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F); + d_CAF_vector[doppler_index] /= 1.0F + 2.0F * static_cast(CAF_bins_half) - 2.0F * weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F; if (d_both_signal_components) { accum[0] = 0; - for (int i = doppler_index - CAF_bins_half; i < static_cast(doppler_index + CAF_bins_half + 1); i++) + for (int i = doppler_index - CAF_bins_half; i < doppler_index + CAF_bins_half + 1; i++) { - accum[0] += static_cast(d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast((doppler_index - i)))); + accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast((doppler_index - i))); } - accum[0] /= static_cast(1.0F + 2.0F * static_cast(CAF_bins_half) - 2.0F * weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F); + accum[0] /= 1.0F + 2.0F * static_cast(CAF_bins_half) - 2.0F * weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1) / 2.0F; d_CAF_vector[doppler_index] += accum[0]; } } @@ -653,13 +653,13 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1.0F - weighting_factor * static_cast(abs(doppler_index - i))); } - d_CAF_vector[doppler_index] /= static_cast(1.0F + static_cast(CAF_bins_half) + static_cast(d_num_doppler_bins - doppler_index - 1) - weighting_factor * static_cast(CAF_bins_half) * (static_cast(CAF_bins_half) + 1.0F) / 2.0F - weighting_factor * static_cast(d_num_doppler_bins - doppler_index - 1) * static_cast(d_num_doppler_bins - doppler_index) / 2.0F); + d_CAF_vector[doppler_index] /= 1.0F + static_cast(CAF_bins_half) + static_cast(d_num_doppler_bins - doppler_index - 1) - weighting_factor * static_cast(CAF_bins_half) * (static_cast(CAF_bins_half) + 1.0F) / 2.0F - weighting_factor * (d_num_doppler_bins - doppler_index - 1) * static_cast(d_num_doppler_bins - doppler_index) / 2.0F; if (d_both_signal_components) { accum[0] = 0; for (int i = doppler_index - CAF_bins_half; i < static_cast(d_num_doppler_bins); i++) { - accum[0] += static_cast(d_CAF_vector_Q[i] * (1.0F - weighting_factor * static_cast(abs(doppler_index - i)))); + accum[0] += d_CAF_vector_Q[i] * (1.0F - weighting_factor * static_cast(abs(doppler_index - i))); } accum[0] /= static_cast(1.0F + static_cast(CAF_bins_half) + static_cast(d_num_doppler_bins - doppler_index - 1) - weighting_factor * static_cast(CAF_bins_half) * static_cast(CAF_bins_half + 1.0) / 2.0 - weighting_factor * static_cast(d_num_doppler_bins - doppler_index - 1) * static_cast(d_num_doppler_bins - doppler_index) / 2.0); d_CAF_vector[doppler_index] += accum[0]; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index ffafd28bf..4ac0fd221 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -258,7 +258,7 @@ void pcps_acquisition::init() d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(d_acq_parameters.doppler_max) - static_cast(-d_acq_parameters.doppler_max)) / static_cast(d_doppler_step))); + d_num_doppler_bins = static_cast(std::ceil(static_cast(2 * d_acq_parameters.doppler_max) / static_cast(d_doppler_step))); // Create the carrier Doppler wipeoff signals if (d_grid_doppler_wipeoffs.empty()) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index e21af5d08..9d194f7aa 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -1584,11 +1584,11 @@ void time2epoch(gtime_t t, double *ep) break; } } - ep[0] = 1970 + static_cast(days / 1461) * 4 + static_cast(mon / 12); + ep[0] = 1970 + days / 1461 * 4 + mon / 12; ep[1] = mon % 12 + 1; ep[2] = day + 1; - ep[3] = static_cast(sec / 3600); - ep[4] = static_cast(sec % 3600 / 60); + ep[3] = sec / 3600; + ep[4] = sec % 3600 / 60; ep[5] = sec % 60 + t.sec; } diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 55da2791c..974d4acac 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -383,7 +383,7 @@ size_t FileSourceBase::samplesToSkip() const size_t FileSourceBase::computeSamplesInFile() const { - auto n_samples = static_cast(samples()); + auto n_samples = samples(); // this could throw, but the existence of the file has been proven before we get here. const auto size = fs::file_size(filename()); diff --git a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc index cdc1dfc8b..7052f0a4c 100644 --- a/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/four_bit_cpx_file_signal_source.cc @@ -69,7 +69,7 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource( std::tuple FourBitCpxFileSignalSource::itemTypeToSize() { auto is_complex = false; - auto item_size = size_t(sizeof(char)); // default + auto item_size = sizeof(char); // default if (item_type() == "byte") { diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc index c2463fc54..c86c11e76 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc @@ -40,7 +40,7 @@ NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configura std::tuple NsrFileSignalSource::itemTypeToSize() { auto is_complex = false; - auto item_size = size_t(sizeof(char)); // default + auto item_size = sizeof(char); // default if (item_type() == "byte") { diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc index 7bf1cb831..1350bded2 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc @@ -43,7 +43,7 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource( std::tuple TwoBitCpxFileSignalSource::itemTypeToSize() { auto is_complex = false; - auto item_size = size_t(sizeof(char)); // default + auto item_size = sizeof(char); // default if (item_type() == "byte") { diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index ebcb95d96..57e6e7768 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -49,7 +49,7 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource( std::tuple TwoBitPackedFileSignalSource::itemTypeToSize() { auto is_complex_t = false; - auto item_size = size_t(sizeof(char)); // default + auto item_size = sizeof(char); // default if (item_type() == "byte") { diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index bc8616ccd..caa4a9b9c 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -43,7 +43,7 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, { LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; // work around gnuradio interface const-deficiency - d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, const_cast(endpoint.data()), timeout_ms, pass_tags, hwm); + d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm); // work around another bug. GNU Radio passes tags through the ZMQ block // unconditionally if pass_tags is true, but that flag controls protocol more 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 227bf8e05..e597555aa 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 @@ -1100,7 +1100,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { // TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay d_TOW_at_Preamble_ms = static_cast(d_inav_nav.get_TOW5() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; d_inav_nav.set_TOW5_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1111,7 +1111,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // timetag debug if (d_valid_timetag == true) { - int decoder_delay_ms = static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + int decoder_delay_ms = GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; int rx_tow_at_preamble = d_current_timetag.tow_ms - decoder_delay_ms; if (rx_tow_at_preamble < 0) { @@ -1126,7 +1126,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { // TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay d_TOW_at_Preamble_ms = static_cast(d_inav_nav.get_TOW6() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; d_inav_nav.set_TOW6_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1137,7 +1137,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // timetag debug if (d_valid_timetag == true) { - int decoder_delay_ms = static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + int decoder_delay_ms = GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; int rx_tow_at_preamble = d_current_timetag.tow_ms - decoder_delay_ms; if (rx_tow_at_preamble < 0) { @@ -1151,7 +1151,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( { // TOW_0 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay d_TOW_at_Preamble_ms = static_cast(d_inav_nav.get_TOW0() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; d_inav_nav.set_TOW0_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1162,7 +1162,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // timetag debug if (d_valid_timetag == true) { - int decoder_delay_ms = static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + int decoder_delay_ms = GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms; int rx_tow_at_preamble = d_current_timetag.tow_ms - decoder_delay_ms; if (rx_tow_at_preamble < 0) { @@ -1195,7 +1195,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( if (d_fnav_nav.is_TOW1_set() == true) { d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.get_TOW1() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS; d_fnav_nav.set_TOW1_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1207,7 +1207,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( else if (d_fnav_nav.is_TOW2_set() == true) { d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.get_TOW2() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS; d_fnav_nav.set_TOW2_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1219,7 +1219,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( else if (d_fnav_nav.is_TOW3_set() == true) { d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.get_TOW3() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS; d_fnav_nav.set_TOW3_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1231,7 +1231,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( else if (d_fnav_nav.is_TOW4_set() == true) { d_TOW_at_Preamble_ms = static_cast(d_fnav_nav.get_TOW4() * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (d_required_symbols + 1) * GALILEO_FNAV_CODES_PER_SYMBOL * GALILEO_E5A_CODE_PERIOD_MS; d_fnav_nav.set_TOW4_flag(false); if (d_there_are_e6_channels && !d_valid_timetag) { @@ -1262,7 +1262,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( int rx_tow_at_preamble = d_current_timetag.tow_ms; uint32_t predicted_tow_at_preamble_ms = 1000 * (rx_tow_at_preamble / 1000); // floor to integer number of seconds d_TOW_at_Preamble_ms = predicted_tow_at_preamble_ms; - d_TOW_at_current_symbol_ms = predicted_tow_at_preamble_ms + static_cast((d_required_symbols + 1) * d_PRN_code_period_ms); + d_TOW_at_current_symbol_ms = predicted_tow_at_preamble_ms + (d_required_symbols + 1) * d_PRN_code_period_ms; if (d_E6_TOW_set == false) { std::cout << " Sat PRN " << d_satellite.get_PRN() << " E6 TimeTag TOW at preamble: " << predicted_tow_at_preamble_ms diff --git a/src/algorithms/tracking/libs/tracking_discriminators.cc b/src/algorithms/tracking/libs/tracking_discriminators.cc index cc9a38c98..a596376a6 100644 --- a/src/algorithms/tracking/libs/tracking_discriminators.cc +++ b/src/algorithms/tracking/libs/tracking_discriminators.cc @@ -54,7 +54,7 @@ double fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2, double { const float dot = prompt_s1.real() * prompt_s2.real() + prompt_s1.imag() * prompt_s2.imag(); const float cross = prompt_s1.real() * prompt_s2.imag() - prompt_s2.real() * prompt_s1.imag(); - return static_cast(gr::fast_atan2f(cross, dot) / (t2 - t1)); + return gr::fast_atan2f(cross, dot) / (t2 - t1); } @@ -85,7 +85,7 @@ double fll_diff_atan(gr_complex prompt_s1, gr_complex prompt_s2, double t1, doub */ double pll_four_quadrant_atan(gr_complex prompt_s1) { - return static_cast(gr::fast_atan2f(prompt_s1.imag(), prompt_s1.real())); + return gr::fast_atan2f(prompt_s1.imag(), prompt_s1.real()); } diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index 78e9570dc..f1a0fc1b1 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -492,7 +492,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s d_eccentricity_msb = static_cast(read_navigation_unsigned(subframe_bits, D2_E_MSB)); d_eccentricity_msb_bits = (read_navigation_unsigned(subframe_bits, D2_E_MSB)); // Adjust for lsb in next page (shift number of lsb to the left) - d_eccentricity_msb = static_cast((static_cast(d_eccentricity_msb) << 22U)); + d_eccentricity_msb = static_cast(d_eccentricity_msb) << 22U; d_eccentricity_msb_bits = d_eccentricity_msb_bits << 22U; // Set system flags for message reception diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index e4fe4a50a..1d313ceed 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -60,7 +60,7 @@ bool Galileo_Fnav_Message::CRC_test(const std::bitset frame_bits(std::string(bits.to_string())); + boost::dynamic_bitset frame_bits(bits.to_string()); std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); diff --git a/src/core/system_parameters/galileo_inav_message.cc b/src/core/system_parameters/galileo_inav_message.cc index 3c946b487..850f2ffb9 100644 --- a/src/core/system_parameters/galileo_inav_message.cc +++ b/src/core/system_parameters/galileo_inav_message.cc @@ -54,7 +54,7 @@ bool Galileo_Inav_Message::CRC_test(const std::bitset& // using boost::dynamic_bitset. // ToDo: Use boost::dynamic_bitset for all the bitset operations in this class - boost::dynamic_bitset frame_bits(std::string(bits.to_string())); + boost::dynamic_bitset frame_bits(bits.to_string()); std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); @@ -162,7 +162,7 @@ int64_t Galileo_Inav_Message::read_navigation_signed(const std::bitset& bits, const std::vector>& parameter) const { bool value; - if (static_cast(static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first])) == 1) + if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first]) == 1) { value = true; } @@ -989,15 +989,15 @@ int32_t Galileo_Inav_Message::page_jk_decoder(const char* data_jk) ai2_5 = ai2_5 * AI2_5_LSB; DLOG(INFO) << "ai2_5= " << ai2_5; // Ionospheric disturbance flag - Region1_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION1_5_BIT)); + Region1_flag_5 = read_navigation_bool(data_jk_bits, REGION1_5_BIT); DLOG(INFO) << "Region1_flag_5= " << Region1_flag_5; - Region2_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION2_5_BIT)); + Region2_flag_5 = read_navigation_bool(data_jk_bits, REGION2_5_BIT); DLOG(INFO) << "Region2_flag_5= " << Region2_flag_5; - Region3_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION3_5_BIT)); + Region3_flag_5 = read_navigation_bool(data_jk_bits, REGION3_5_BIT); DLOG(INFO) << "Region3_flag_5= " << Region3_flag_5; - Region4_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION4_5_BIT)); + Region4_flag_5 = read_navigation_bool(data_jk_bits, REGION4_5_BIT); DLOG(INFO) << "Region4_flag_5= " << Region4_flag_5; - Region5_flag_5 = static_cast(read_navigation_bool(data_jk_bits, REGION5_5_BIT)); + Region5_flag_5 = read_navigation_bool(data_jk_bits, REGION5_5_BIT); DLOG(INFO) << "Region5_flag_5= " << Region5_flag_5; BGD_E1E5a_5 = static_cast(read_navigation_signed(data_jk_bits, BGD_E1_E5A_5_BIT)); BGD_E1E5a_5 = BGD_E1E5a_5 * BGD_E1_E5A_5_LSB; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 94ddd9073..586f795b2 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -292,7 +292,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame if (flag_ephemeris_str_1 == true) { gnav_ephemeris.d_B_n = static_cast(read_navigation_unsigned(string_bits, B_N)); - gnav_ephemeris.d_P_2 = static_cast(read_navigation_bool(string_bits, P2)); + gnav_ephemeris.d_P_2 = read_navigation_bool(string_bits, P2); gnav_ephemeris.d_t_b = static_cast(read_navigation_unsigned(string_bits, T_B)) * 15 * 60; gnav_ephemeris.d_VYn = static_cast(read_navigation_signed(string_bits, Y_N_DOT)) * TWO_N20; gnav_ephemeris.d_AYn = static_cast(read_navigation_signed(string_bits, Y_N_DOT_DOT)) * TWO_N30; @@ -308,10 +308,10 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame // --- It is string 3 ---------------------------------------------- if (flag_ephemeris_str_2 == true) { - gnav_ephemeris.d_P_3 = static_cast(read_navigation_bool(string_bits, P3)); + gnav_ephemeris.d_P_3 = read_navigation_bool(string_bits, P3); gnav_ephemeris.d_gamma_n = static_cast(read_navigation_signed(string_bits, GAMMA_N)) * TWO_N40; gnav_ephemeris.d_P = static_cast(read_navigation_unsigned(string_bits, P)); - gnav_ephemeris.d_l3rd_n = static_cast(read_navigation_bool(string_bits, EPH_L_N)); + gnav_ephemeris.d_l3rd_n = read_navigation_bool(string_bits, EPH_L_N); gnav_ephemeris.d_VZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT)) * TWO_N20; gnav_ephemeris.d_AZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT_DOT)) * TWO_N30; gnav_ephemeris.d_Zn = static_cast(read_navigation_signed(string_bits, Z_N)) * TWO_N11; @@ -328,7 +328,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_ephemeris.d_tau_n = static_cast(read_navigation_signed(string_bits, TAU_N)) * TWO_N30; gnav_ephemeris.d_Delta_tau_n = static_cast(read_navigation_signed(string_bits, DELTA_TAU_N)) * TWO_N30; gnav_ephemeris.d_E_n = static_cast(read_navigation_unsigned(string_bits, E_N)); - gnav_ephemeris.d_P_4 = static_cast(read_navigation_bool(string_bits, P4)); + gnav_ephemeris.d_P_4 = read_navigation_bool(string_bits, P4); gnav_ephemeris.d_F_T = static_cast(read_navigation_unsigned(string_bits, F_T)); gnav_ephemeris.d_N_T = static_cast(read_navigation_unsigned(string_bits, N_T)); gnav_ephemeris.d_n = static_cast(read_navigation_unsigned(string_bits, N)); @@ -352,7 +352,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_utc_model.d_tau_c = static_cast(read_navigation_signed(string_bits, TAU_C)) * TWO_N31; gnav_utc_model.d_N_4 = static_cast(read_navigation_unsigned(string_bits, N_4)); gnav_utc_model.d_tau_gps = static_cast(read_navigation_signed(string_bits, TAU_GPS)) * TWO_N30; - gnav_ephemeris.d_l5th_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_ephemeris.d_l5th_n = read_navigation_bool(string_bits, ALM_L_N); flag_utc_model_str_5 = true; @@ -402,7 +402,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame return 0; } - gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = read_navigation_bool(string_bits, C_N); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; @@ -423,7 +423,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A = static_cast(read_navigation_signed(string_bits, DELTA_T_N_A)) * TWO_N9; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast(read_navigation_signed(string_bits, DELTA_T_DOT_N_A)) * TWO_N14; gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A = static_cast(read_navigation_unsigned(string_bits, H_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = read_navigation_bool(string_bits, ALM_L_N); // Set satellite information for redundancy purposes if (gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A > 24) @@ -452,7 +452,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame return 0; } - gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = read_navigation_bool(string_bits, C_N); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; @@ -473,7 +473,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A = static_cast(read_navigation_signed(string_bits, DELTA_T_N_A)) * TWO_N9; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast(read_navigation_signed(string_bits, DELTA_T_DOT_N_A)) * TWO_N14; gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A = static_cast(read_navigation_unsigned(string_bits, H_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = read_navigation_bool(string_bits, ALM_L_N); // Set satellite information for redundancy purposes if (gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A > 24) @@ -497,7 +497,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame return 0; } - gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = read_navigation_bool(string_bits, C_N); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; @@ -518,7 +518,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A = static_cast(read_navigation_signed(string_bits, DELTA_T_N_A)) * TWO_N9; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast(read_navigation_signed(string_bits, DELTA_T_DOT_N_A)) * TWO_N14; gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A = static_cast(read_navigation_unsigned(string_bits, H_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = read_navigation_bool(string_bits, ALM_L_N); // Set satellite information for redundancy purposes if (gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A > 24) @@ -541,7 +541,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame { return 0; } - gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = read_navigation_bool(string_bits, C_N); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; @@ -562,7 +562,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A = static_cast(read_navigation_signed(string_bits, DELTA_T_N_A)) * TWO_N9; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast(read_navigation_signed(string_bits, DELTA_T_DOT_N_A)) * TWO_N14; gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A = static_cast(read_navigation_unsigned(string_bits, H_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = read_navigation_bool(string_bits, ALM_L_N); // Set satellite information for redundancy purposes if (gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A > 24) @@ -592,7 +592,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame { return 0; } - gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = read_navigation_bool(string_bits, C_N); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_tau_n_A = static_cast(read_navigation_unsigned(string_bits, TAU_N_A)) * TWO_N18; @@ -613,7 +613,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A = static_cast(read_navigation_signed(string_bits, DELTA_T_N_A)) * TWO_N9; gnav_almanac[i_alm_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast(read_navigation_signed(string_bits, DELTA_T_DOT_N_A)) * TWO_N14; gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A = static_cast(read_navigation_unsigned(string_bits, H_N_A)); - gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + gnav_almanac[i_alm_satellite_slot_number - 1].d_l_n = read_navigation_bool(string_bits, ALM_L_N); // Set satellite information for redundancy purposes if (gnav_almanac[i_alm_satellite_slot_number - 1].d_H_n_A > 24) diff --git a/src/core/system_parameters/gps_cnav_navigation_message.cc b/src/core/system_parameters/gps_cnav_navigation_message.cc index 62268fb18..a644f7f2a 100644 --- a/src/core/system_parameters/gps_cnav_navigation_message.cc +++ b/src/core/system_parameters/gps_cnav_navigation_message.cc @@ -113,7 +113,7 @@ void Gps_CNAV_Navigation_Message::decode_page(const std::bitset(read_navigation_bool(data_bits, CNAV_ALERT_FLAG)); + alert_flag = read_navigation_bool(data_bits, CNAV_ALERT_FLAG); ephemeris_record.alert_flag = alert_flag; page_type = static_cast(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE)); @@ -145,8 +145,8 @@ void Gps_CNAV_Navigation_Message::decode_page(const std::bitset(read_navigation_signed(data_bits, CNAV_OMEGA)); ephemeris_record.omega *= CNAV_OMEGA_LSB; - ephemeris_record.integrity_status_flag = static_cast(read_navigation_bool(data_bits, CNAV_INTEGRITY_FLAG)); - ephemeris_record.l2c_phasing_flag = static_cast(read_navigation_bool(data_bits, CNAV_L2_PHASING_FLAG)); + ephemeris_record.integrity_status_flag = read_navigation_bool(data_bits, CNAV_INTEGRITY_FLAG); + ephemeris_record.l2c_phasing_flag = read_navigation_bool(data_bits, CNAV_L2_PHASING_FLAG); b_flag_ephemeris_1 = true; break; From f739eb698c740d55154fd3c7cbf1faa156b0abec Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 13:44:41 +0100 Subject: [PATCH 075/142] Reset color when printing GPS CNAV messages in the terminal --- .../gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index 2c0ab7083..f8ad72108 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -264,7 +264,7 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << " with CN0=" << std::setprecision(2) << current_synchro_data.CN0_dB_hz - << std::setprecision(default_precision) << " dB-Hz" << std::endl; + << std::setprecision(default_precision) << " dB-Hz" << TEXT_RESET << std::endl; } if (d_CNAV_Message.have_new_iono() == true) { From 7cfdcd3ae150998ce4c0930cbead014e333137a4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 14:29:41 +0100 Subject: [PATCH 076/142] Fix compiler warning, avoid using std::strncat --- src/algorithms/PVT/libs/rtcm.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 2fe68299c..338c36a8d 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -587,16 +587,24 @@ private: inline bool decode_header() { - char header[header_length + 1] = ""; - std::strncat(header, data_.data(), header_length); + std::string header(data_.data(), header_length); if (header[0] != 'G' || header[1] != 'S') { return false; } - char header2_[header_length - 1] = ""; - std::strncat(header2_, data_.data() + 2, header_length - 2); - body_length_ = std::atoi(header2_); + auto header2 = header.substr(2); + try + { + body_length_ = std::stoi(header2); + } + catch (const std::exception& e) + { + // invalid stoi conversion + body_length_ = 0; + return false; + } + if (body_length_ == 0) { return false; @@ -612,11 +620,11 @@ private: inline void encode_header() { - char header[header_length + 1] = ""; std::stringstream ss; ss << "GS" << std::setw(4) << std::max(std::min(static_cast(body_length_), static_cast(max_body_length)), 0); - std::copy_n(ss.str().c_str(), header_length + 1, header); - std::copy_n(header, header_length, data_.data()); + std::string header = ss.str(); + header.resize(header_length, ' '); + std::copy(header.begin(), header.end(), data_.begin()); } private: From ce14845bbb73896944e923b676d718254dbefb4e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 14:32:19 +0100 Subject: [PATCH 077/142] Fix validation of GPS navigation data (fix due to @tractoan). Closes: #737 --- docs/CHANGELOG.md | 1 + src/core/system_parameters/gps_navigation_message.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 930a5c59c..b17d9b6f7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -65,6 +65,7 @@ All notable changes to GNSS-SDR will be documented in this file. signal). - The estimated CN0 value is now printed in the terminal when navigation data is succesfully decoded. +- Fixed GPS navigation message satellite validation. ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index b9a007a3f..d65520720 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -514,9 +514,9 @@ bool Gps_Navigation_Message::satellite_validation() // First Step: // check Issue Of Ephemeris Data (IODE IODC..) to find a possible interrupted reception // and check if the data have been filled (!=0) - if (d_TOW_SF1 != 0.0 and d_TOW_SF2 != 0.0 and d_TOW_SF3 != 0.0) + if (d_TOW_SF1 != 0.0 && d_TOW_SF2 != 0.0 && d_TOW_SF3 != 0.0) { - if (d_IODE_SF2 == d_IODE_SF3 and d_IODC == d_IODE_SF2 and d_IODC != -1.0) + if (d_IODE_SF2 == d_IODE_SF3 && (d_IODC & 0xFF) == d_IODE_SF2 && d_IODE_SF2 != -1.0) { flag_data_valid = true; b_valid_ephemeris_set_flag = true; From 5842f72f5270f15d7774558fb7d29bd7c30e0bf0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 15:12:16 +0100 Subject: [PATCH 078/142] This cast is required in some environments --- src/algorithms/signal_source/adapters/zmq_signal_source.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index caa4a9b9c..bc8616ccd 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -43,7 +43,7 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, { LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; // work around gnuradio interface const-deficiency - d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm); + d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, const_cast(endpoint.data()), timeout_ms, pass_tags, hwm); // work around another bug. GNU Radio passes tags through the ZMQ block // unconditionally if pass_tags is true, but that flag controls protocol more From dd4478135a1297d3d691f4c470dffed3d95f90e4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 14:21:07 +0100 Subject: [PATCH 079/142] Remove useless casts --- src/algorithms/libs/gps_l2c_signal_replica.cc | 2 +- src/algorithms/libs/gps_l5_signal_replica.cc | 4 ++-- src/tests/unit-tests/arithmetic/complex_carrier_test.cc | 4 ++-- ...galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ..._e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ..._pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc | 2 +- ...eo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ...alileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc | 8 ++++---- .../acquisition/galileo_e5b_pcps_acquisition_test.cc | 2 +- .../acquisition/galileo_e6_pcps_acquisition_test.cc | 2 +- .../gps_l1_ca_pcps_acquisition_gsoc2013_test.cc | 2 +- .../gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc | 2 +- .../gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc | 2 +- .../gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc | 2 +- .../signal-processing-blocks/adapter/adapter_test.cc | 4 ++-- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/algorithms/libs/gps_l2c_signal_replica.cc b/src/algorithms/libs/gps_l2c_signal_replica.cc index 5be9e632e..c536be0af 100644 --- a/src/algorithms/libs/gps_l2c_signal_replica.cc +++ b/src/algorithms/libs/gps_l2c_signal_replica.cc @@ -24,7 +24,7 @@ uint32_t gps_l2c_m_shift(uint32_t x) { - return static_cast((x >> 1U) xor ((x & 1U) * 0445112474U)); + return ((x >> 1U) xor ((x & 1U) * 0445112474U)); } diff --git a/src/algorithms/libs/gps_l5_signal_replica.cc b/src/algorithms/libs/gps_l5_signal_replica.cc index 75ce0c9bc..09a6ac798 100644 --- a/src/algorithms/libs/gps_l5_signal_replica.cc +++ b/src/algorithms/libs/gps_l5_signal_replica.cc @@ -210,7 +210,7 @@ void gps_l5i_code_gen_complex_sampled(own::span> dest, uint3 // === Digitizing ================================================== // --- Make index array to read L5 code values --------------------- - codeValueIndex = static_cast(std::ceil(ts * static_cast(i + 1.0F) / tc)) - 1; + codeValueIndex = static_cast(std::ceil(ts * (i + 1.0F) / tc)) - 1; // --- Make the digitized version of the L5I code ------------------ if (i == samplesPerCode - 1) @@ -282,7 +282,7 @@ void gps_l5q_code_gen_complex_sampled(own::span> dest, uint3 // === Digitizing ================================================== // --- Make index array to read L5 code values --------------------- - codeValueIndex = static_cast(std::ceil(ts * static_cast(i + 1.0F) / tc)) - 1; + codeValueIndex = static_cast(std::ceil(ts * (i + 1.0F) / tc)) - 1; // --- Make the digitized version of the L5Q code ------------------ if (i == samplesPerCode - 1) diff --git a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc index 88ab2d6d9..19a4ba37c 100644 --- a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc +++ b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc @@ -32,7 +32,7 @@ TEST(ComplexCarrierTest, StandardComplexImplementation) auto* output = new std::complex[FLAGS_size_carrier_test]; const double _f = 2000.0; const double _fs = 2000000.0; - const auto phase_step = static_cast((TWO_PI * _f) / _fs); + const auto phase_step = (TWO_PI * _f) / _fs; double phase = 0.0; std::chrono::time_point start, end; @@ -72,7 +72,7 @@ TEST(ComplexCarrierTest, C11ComplexImplementation) std::vector> output(FLAGS_size_carrier_test); const double _f = 2000.0; const double _fs = 2000000.0; - const auto phase_step = static_cast((TWO_PI * _f) / _fs); + const auto phase_step = (TWO_PI * _f) / _fs; double phase = 0.0; std::chrono::time_point start, end; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index 8dbc5a45d..103778f60 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -387,7 +387,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (static_cast(gnss_synchro.Acq_delay_samples) - 5) * 1023.0 / static_cast(fs_in * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (static_cast(gnss_synchro.Acq_delay_samples) - 5) * 1023.0 / (fs_in * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index 380f3bcb9..db50b891d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -387,7 +387,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index 991896a5c..5204b859b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -501,7 +501,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 4ab73ca01..093121afa 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -389,7 +389,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 07d909d84..d90e8b0e9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -467,19 +467,19 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::process_message() switch (sat) { case 0: - delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); break; case 1: - delay_error_chips = std::abs(static_cast(expected_delay_chips1) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips1) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz1 - gnss_synchro.Acq_doppler_hz); break; case 2: - delay_error_chips = std::abs(static_cast(expected_delay_chips2) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips2) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz2 - gnss_synchro.Acq_doppler_hz); break; case 3: - delay_error_chips = std::abs(static_cast(expected_delay_chips3) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips3) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz3 - gnss_synchro.Acq_doppler_hz); break; default: // case 3 diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc index 27dab121a..c74b99d29 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc @@ -264,7 +264,7 @@ void GalileoE5bPcpsAcquisitionTest::process_message() { if (message == 1) { - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); // The term -5 is here to correct the additional delay introduced by the FIR filter /* diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc index 82cfb7c98..497ced58f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc @@ -264,7 +264,7 @@ void GalileoE6PcpsAcquisitionTest::process_message() { if (message == 1) { - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * GALILEO_E6_B_CODE_LENGTH_CHIPS / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * GALILEO_E6_B_CODE_LENGTH_CHIPS / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); // The term -5 is here to correct the additional delay introduced by the FIR filter /* diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index 2c2191f1e..70015c2d5 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -388,7 +388,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 7e4ef8df8..40f735c05 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -388,7 +388,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index 21ff4678e..92a8e19ff 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -490,7 +490,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index a8e988210..20e737c94 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -382,7 +382,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index 26ff99a38..68b3d6a3d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -347,9 +347,9 @@ TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(gr_complex))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), iSample.real()); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), iSample.imag()); i++; } } From b751b4b8a1232fa8284f95a7cccbe74214a51262 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 14:23:30 +0100 Subject: [PATCH 080/142] Remove useless casts --- .../signal-processing-blocks/adapter/adapter_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index 68b3d6a3d..f4c6aaa44 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -373,9 +373,9 @@ TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(lv_16sc_t))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), iSample.real()); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), iSample.imag()); i++; } } From 0a438ec7266433c3771059c787961fa21b688187 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 16:08:56 +0100 Subject: [PATCH 081/142] Avoid shadowed variables --- docs/CHANGELOG.md | 5 +++++ src/algorithms/PVT/libs/rinex_printer.cc | 1 - .../telemetry_decoder/libs/viterbi_decoder_sbas.cc | 7 ++++--- .../telemetry_decoder/libs/viterbi_decoder_sbas.h | 2 +- src/core/system_parameters/galileo_has_data.cc | 8 ++++---- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b17d9b6f7..162df725f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -31,6 +31,11 @@ All notable changes to GNSS-SDR will be documented in this file. - `geohash`, an [encoded geographic location](https://en.wikipedia.org/wiki/Geohash). +### Improvements in Maintainability + +- Removed useless casts and shadowed variables, improving source code + readability. + ### Improvements in Portability: - Updated local `cpu_features` library to v0.9.0. diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 516403dbb..8f3042830 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -11309,7 +11309,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { lineObs += satsys_gal->second; diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc index 116215ad0..7972e708c 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc @@ -423,9 +423,10 @@ int Viterbi_Decoder_Sbas::parity_counter(int symbol, int length) // prev helper class -Viterbi_Decoder_Sbas::Prev::Prev(int states, int t) : num_states(states), - t(t), - refcount(1) +Viterbi_Decoder_Sbas::Prev::Prev(int states, + int tt) : num_states(states), + t(tt), + refcount(1) { state = std::vector(num_states); v_bit = std::vector(num_states); diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h index cf119e7fe..0f0a213df 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h @@ -56,7 +56,7 @@ private: { public: int num_states; - Prev(int states, int t); + Prev(int states, int tt); Prev(const Prev& prev); Prev& operator=(const Prev& other); ~Prev(); diff --git a/src/core/system_parameters/galileo_has_data.cc b/src/core/system_parameters/galileo_has_data.cc index 2e722f64a..cf52b9a99 100644 --- a/src/core/system_parameters/galileo_has_data.cc +++ b/src/core/system_parameters/galileo_has_data.cc @@ -602,10 +602,10 @@ float Galileo_HAS_data::get_code_bias_m(const std::string& signal, int PRN) cons if (!code_bias.empty() && !targeted_system.empty()) { std::vector systems = this->get_systems_string(); - auto Nsys = systems.size(); + auto Nsys_ = systems.size(); auto nsys_index = std::distance(systems.cbegin(), std::find(systems.cbegin(), systems.cend(), targeted_system)); - if (static_cast(nsys_index) < Nsys) + if (static_cast(nsys_index) < Nsys_) { std::vector signals = get_signals_in_mask(static_cast(nsys_index)); auto sig_index = std::distance(signals.cbegin(), std::find(signals.cbegin(), signals.cend(), signal)); @@ -678,10 +678,10 @@ float Galileo_HAS_data::get_phase_bias_cycle(const std::string& signal, int PRN) if (!phase_bias.empty() && !targeted_system.empty()) { std::vector systems = this->get_systems_string(); - auto Nsys = systems.size(); + auto Nsys_ = systems.size(); auto nsys_index = std::distance(systems.cbegin(), std::find(systems.cbegin(), systems.cend(), targeted_system)); - if (static_cast(nsys_index) < Nsys) + if (static_cast(nsys_index) < Nsys_) { std::vector signals = get_signals_in_mask(static_cast(nsys_index)); auto sig_index = std::distance(signals.cbegin(), std::find(signals.cbegin(), signals.cend(), signal)); From 49eb161d9034c42e9218d17f424719024457de2b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 24 Nov 2023 14:00:53 +0100 Subject: [PATCH 082/142] Add -fsanitize=undefined to ASAN build --- cmake/Modules/GnsssdrBuildTypes.cmake | 4 ++-- .../volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/GnsssdrBuildTypes.cmake b/cmake/Modules/GnsssdrBuildTypes.cmake index ddb12df6b..0e3507a1b 100644 --- a/cmake/Modules/GnsssdrBuildTypes.cmake +++ b/cmake/Modules/GnsssdrBuildTypes.cmake @@ -191,9 +191,9 @@ endif() # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING "Flags used by the C++ compiler during Address Sanitized builds." FORCE) - set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING "Flags used by the C compiler during Address Sanitized builds." FORCE) set(CMAKE_EXE_LINKER_FLAGS_ASAN "-W" CACHE STRING diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake index b828082f8..16cb6117e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkBuildTypes.cmake @@ -253,9 +253,9 @@ endif() # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + set(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING "Flags used by the C++ compiler during Address Sanitized builds." FORCE) - set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING + set(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING "Flags used by the C compiler during Address Sanitized builds." FORCE) mark_as_advanced( CMAKE_CXX_FLAGS_ASAN From caef6acdd4fba6973ab7795e64dbc25b152498a7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 24 Nov 2023 22:04:24 +0100 Subject: [PATCH 083/142] Adjust number of decimal places displayed in terminal --- docs/CHANGELOG.md | 5 +++++ .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 17 ++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 162df725f..dadd11630 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -71,6 +71,11 @@ All notable changes to GNSS-SDR will be documented in this file. - The estimated CN0 value is now printed in the terminal when navigation data is succesfully decoded. - Fixed GPS navigation message satellite validation. +- Latitude and longitude are now reported in the terminal with six decimal + places (the sixth decimal place worths up to 0.11 m), instead of the + overkilling nine (the ninth decimal place worths up to 110 microns). + Similarly, height in meters is now reported with two decimal places instead of + three, and velocity in m/s also with two decimal places instead of three. ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index ca63c6f31..7c14b6350 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2403,22 +2403,17 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item std::cout << TEXT_BOLD_GREEN << "Position at " << time_solution << UTC_solution_str - << " using " << d_user_pvt_solver->get_num_valid_observations() - << std::fixed << std::setprecision(9) - << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() - << std::fixed << std::setprecision(3) - << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]" << TEXT_RESET << '\n'; - - std::cout << std::setprecision(ss); + << " using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " + << std::fixed << std::setprecision(6) << d_user_pvt_solver->get_latitude() + << " [deg], Long = " << d_user_pvt_solver->get_longitude() << " [deg], Height = " + << std::fixed << std::setprecision(2) << d_user_pvt_solver->get_height() << std::setprecision(ss) << " [m]" << TEXT_RESET << std::endl; DLOG(INFO) << "RX clock offset: " << d_user_pvt_solver->get_time_offset_s() << "[s]"; std::cout << TEXT_BOLD_GREEN - << "Velocity: " << std::fixed << std::setprecision(3) + << "Velocity: " << std::fixed << std::setprecision(2) << "East: " << d_user_pvt_solver->get_rx_vel()[0] << " [m/s], North: " << d_user_pvt_solver->get_rx_vel()[1] - << " [m/s], Up = " << d_user_pvt_solver->get_rx_vel()[2] << " [m/s]" << TEXT_RESET << '\n'; - - std::cout << std::setprecision(ss); + << " [m/s], Up = " << d_user_pvt_solver->get_rx_vel()[2] << std::setprecision(ss) << " [m/s]" << TEXT_RESET << std::endl; DLOG(INFO) << "RX clock drift: " << d_user_pvt_solver->get_clock_drift_ppm() << " [ppm]"; // boost::posix_time::ptime p_time; From 5ef12c8244dbaeb3dde837bef5a827b68caf3e09 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Nov 2023 14:21:28 +0100 Subject: [PATCH 084/142] CI: improve python version handling --- .github/workflows/main.yml | 43 ++++++++++++-------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc1fb280f..11b50e04a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,19 +40,13 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + check-latest: true - name: install dependencies run: | brew update - rm /usr/local/bin/2to3 || true - rm /usr/local/bin/idle3 || true - rm /usr/local/bin/pydoc3 || true - rm /usr/local/bin/python3 || true - rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true brew install ninja hdf5 automake armadillo lapack \ gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -69,19 +63,13 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + check-latest: true - name: install dependencies run: | brew update - rm /usr/local/bin/2to3 || true - rm /usr/local/bin/idle3 || true - rm /usr/local/bin/pydoc3 || true - rm /usr/local/bin/python3 || true - rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -117,19 +105,13 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + check-latest: true - name: install dependencies run: | brew update - rm /usr/local/bin/2to3 || true - rm /usr/local/bin/idle3 || true - rm /usr/local/bin/pydoc3 || true - rm /usr/local/bin/python3 || true - rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \ log4cpp openssl pugixml protobuf pip3 install mako @@ -195,6 +177,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.12' + check-latest: true - name: Install dependencies run: | python -m pip install --upgrade pip From 132f85079aca8f865663ee3cc4af951d4afbc4ef Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 26 Nov 2023 08:57:35 +0100 Subject: [PATCH 085/142] Pass msg by reference isntead of by value --- src/algorithms/PVT/libs/rtcm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 338c36a8d..23d10db71 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -810,7 +810,7 @@ private: inline void write(const Rtcm_Message& msg) { io_context_.post( - [this, msg]() { + [this, &msg]() { bool write_in_progress = !write_msgs_.empty(); write_msgs_.push_back(msg); if (!write_in_progress) From 7c9118a33fcaf7c1d73e0d42a403a4e906a86b8f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 26 Nov 2023 10:18:58 +0100 Subject: [PATCH 086/142] Fix building with latest GNU Radio --- cmake/Modules/FindGNURADIO.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 9d6926e36..5ce37cba6 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -406,7 +406,7 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) if("#include " STREQUAL "${_file_line}") set(_uses_log4cpp TRUE) endif() - if("#include " STREQUAL "${_file_line}") + if("#include " STREQUAL "${_file_line}") set(_uses_spdlog TRUE) endif() endforeach() From 0f42dbdea49c5bc75a10b185a45557a97f2e8b2a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 26 Nov 2023 10:55:48 +0100 Subject: [PATCH 087/142] Revert "CI: improve python version handling" This reverts commit 5ef12c8244dbaeb3dde837bef5a827b68caf3e09. --- .github/workflows/main.yml | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 11b50e04a..bc1fb280f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,13 +40,19 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - check-latest: true - name: install dependencies run: | brew update + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true brew install ninja hdf5 automake armadillo lapack \ gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -63,13 +69,19 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - check-latest: true - name: install dependencies run: | brew update + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -105,13 +117,19 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - check-latest: true - name: install dependencies run: | brew update + rm /usr/local/bin/2to3 || true + rm /usr/local/bin/idle3 || true + rm /usr/local/bin/pydoc3 || true + rm /usr/local/bin/python3 || true + rm /usr/local/bin/python3-config || true + rm /usr/local/bin/2to3-3.11 || true + rm /usr/local/bin/idle3.11 || true + rm /usr/local/bin/pydoc3.11 || true + rm /usr/local/bin/python3.11 || true + rm /usr/local/bin/python3.11-config || true brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \ log4cpp openssl pugixml protobuf pip3 install mako @@ -177,7 +195,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.12' - check-latest: true - name: Install dependencies run: | python -m pip install --upgrade pip From cfb6f283d42c39735044e3bbca93f5a0534c00d9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 27 Nov 2023 13:41:55 +0100 Subject: [PATCH 088/142] Fix some performance inefficiencies detected by Coverity Scan --- .../acquisition/adapters/beidou_b1i_pcps_acquisition.h | 2 +- .../acquisition/adapters/beidou_b3i_pcps_acquisition.h | 2 +- .../adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h | 2 +- .../adapters/galileo_e1_pcps_ambiguous_acquisition.h | 2 +- .../galileo_e1_pcps_ambiguous_acquisition_fpga.h | 2 +- .../galileo_e1_pcps_cccwsr_ambiguous_acquisition.h | 2 +- .../galileo_e1_pcps_quicksync_ambiguous_acquisition.h | 2 +- .../galileo_e1_pcps_tong_ambiguous_acquisition.h | 2 +- .../galileo_e5a_noncoherent_iq_acquisition_caf.h | 2 +- .../acquisition/adapters/galileo_e5a_pcps_acquisition.h | 2 +- .../adapters/galileo_e5a_pcps_acquisition_fpga.h | 2 +- .../acquisition/adapters/galileo_e5b_pcps_acquisition.h | 2 +- .../adapters/galileo_e5b_pcps_acquisition_fpga.h | 2 +- .../acquisition/adapters/galileo_e6_pcps_acquisition.h | 2 +- .../adapters/glonass_l1_ca_pcps_acquisition.h | 2 +- .../adapters/glonass_l2_ca_pcps_acquisition.h | 2 +- .../acquisition/adapters/gps_l1_ca_pcps_acquisition.h | 2 +- .../adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h | 2 +- .../adapters/gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../adapters/gps_l1_ca_pcps_assisted_acquisition.h | 2 +- .../adapters/gps_l1_ca_pcps_opencl_acquisition.h | 2 +- .../adapters/gps_l1_ca_pcps_quicksync_acquisition.h | 2 +- .../adapters/gps_l1_ca_pcps_tong_acquisition.h | 2 +- .../acquisition/adapters/gps_l2_m_pcps_acquisition.h | 2 +- .../adapters/gps_l2_m_pcps_acquisition_fpga.h | 2 +- .../acquisition/adapters/gps_l5i_pcps_acquisition.h | 2 +- .../acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h | 2 +- .../galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc | 2 +- .../gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc | 2 +- .../gnuradio_blocks/pcps_assisted_acquisition_cc.cc | 2 +- .../gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc | 2 +- .../gnuradio_blocks/pcps_opencl_acquisition_cc.cc | 2 +- .../gnuradio_blocks/pcps_quicksync_acquisition_cc.cc | 2 +- .../gnuradio_blocks/pcps_tong_acquisition_cc.cc | 2 +- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 2 +- .../gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 4 ++-- .../glonass_l1_ca_telemetry_decoder_gs.cc | 5 +++-- .../glonass_l2_ca_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc | 3 ++- .../gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc | 5 +++-- .../gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc | 3 ++- .../tracking/gnuradio_blocks/dll_pll_veml_tracking.cc | 2 +- .../gnuradio_blocks/dll_pll_veml_tracking_fpga.cc | 2 +- .../galileo_e1_tcp_connector_tracking_cc.cc | 4 ++-- .../glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc | 4 ++-- .../glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 4 ++-- .../gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc | 4 ++-- .../glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc | 4 ++-- .../glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 4 ++-- .../gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc | 4 ++-- .../gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc | 5 +++-- .../gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc | 4 ++-- .../gps_l1_ca_tcp_connector_tracking_cc.cc | 4 ++-- .../signal-processing-blocks/pvt/rinex_printer_test.cc | 9 +++++---- 58 files changed, 88 insertions(+), 78 deletions(-) diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index b56489784..a5a659369 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -97,7 +97,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index 1e5b082bf..ccbaf8c53 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -96,7 +96,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h index 9d0ed9abe..7903dff58 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h @@ -93,7 +93,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h index ec2e2299e..995c2570a 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h @@ -96,7 +96,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 597d9975a..0352d4dbd 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -122,7 +122,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h index 284b5872a..fb53e690d 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h @@ -94,7 +94,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h index 78b8a582f..7ba948513 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h @@ -94,7 +94,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! * \brief Set statistics threshold of PCPS algorithm diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h index 250f8508c..33390e134 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h @@ -94,7 +94,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! * \brief Set statistics threshold of TONG algorithm diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index 2a5fa33a2..66323eb11 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -94,7 +94,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h index 0a300e883..2b0f35050 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h @@ -87,7 +87,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index a33f6738e..f57d5d3b0 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -122,7 +122,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h index 48c2bd4d2..76de8b140 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h @@ -118,7 +118,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index 33545bd2b..34abc3ba6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -121,7 +121,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h index 21e2e166f..2902177a7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h @@ -96,7 +96,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h index 938fe0021..84999e6df 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h @@ -98,7 +98,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h index 3927bd4f2..6d0f68eb4 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -97,7 +97,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h index 6ad39ab03..5c79bd7de 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -102,7 +102,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h index 01ef4e245..f59db4494 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h @@ -96,7 +96,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index f187d77c0..57786c570 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -123,7 +123,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h index 099c38528..2745218ef 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h @@ -95,7 +95,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h index 6f73fd97e..880d94281 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h @@ -93,7 +93,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h index be692b317..f10cbdaa5 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h @@ -96,7 +96,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h index b7c7a119b..2a7ba680f 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h @@ -94,7 +94,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_cc_->set_channel_fsm(channel_fsm); + acquisition_cc_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h index 8a3627f81..5f9e41615 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h @@ -98,7 +98,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index d105ea7e2..2003ab5a7 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -98,7 +98,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h index 820329821..0578ae793 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h @@ -97,7 +97,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_->set_channel_fsm(channel_fsm); + acquisition_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index c68cd7bda..3a6beaf7e 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -125,7 +125,7 @@ public: inline void set_channel_fsm(std::weak_ptr channel_fsm) override { channel_fsm_ = channel_fsm; - acquisition_fpga_->set_channel_fsm(channel_fsm); + acquisition_fpga_->set_channel_fsm(channel_fsm_); } /*! diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 1e0f945b5..98861361b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -730,7 +730,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); return_value = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index e123424d6..17d697fed 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -381,7 +381,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index a1941a060..270238767 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -566,7 +566,7 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); return_value = 1; // Number of Gnss_Synchro objects produced } break; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index 56f4b56b3..3d919f87f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -427,7 +427,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } break; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 8498b7c27..e16d184a3 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -403,7 +403,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc index 0d364bdd6..2f0e3662a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc @@ -765,7 +765,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 44dcb4c73..39bac577c 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -507,7 +507,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, auto** out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 9563f3af6..f072dcd6a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -403,7 +403,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); noutput_items = 1; // Number of Gnss_Synchro objects produced } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index d3c9269e0..5a060c3d1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -232,7 +232,7 @@ void read_results(std::vector *results, std::string if (single_kernel_result.size() == 3) { - volk_gnsssdr_test_results_t kernel_result; + volk_gnsssdr_test_results_t kernel_result{}; kernel_result.name = std::string(single_kernel_result[0]); kernel_result.config_name = std::string(single_kernel_result[0]); kernel_result.best_arch_u = std::string(single_kernel_result[1]); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index 6798a2e17..0edbfee36 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -36,6 +36,7 @@ #include // for setprecision #include // for cout #include // for shared_ptr, make_shared +#include // for std::move #define CRC_ERROR_LIMIT 8 @@ -702,8 +703,8 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + *out[0] = std::move(current_symbol); return 1; } return 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index dcd4609d0..a1fd40555 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -35,6 +35,7 @@ #include // for setprecision #include // for cout #include // for shared_ptr, make_shared +#include // for std::move #define CRC_ERROR_LIMIT 8 @@ -726,8 +727,8 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + *out[0] = std::move(current_symbol); return 1; } return 0; 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 e597555aa..fbaaaa84f 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 @@ -1399,8 +1399,8 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( LOG(WARNING) << "Exception writing navigation data dump file " << e.what(); } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + *out[0] = std::move(current_symbol); return 1; } return 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index 3d6aacbcc..b2cc50cf8 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include // for std::setprecision #include // for cout #include // for shared_ptr, make_shared +#include // for std::move #define CRC_ERROR_LIMIT 6 @@ -525,8 +526,8 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + *out[0] = std::move(current_symbol); return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index 2340b59ff..473e5eb73 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include // for std::setprecision #include // for cout #include // for shared_ptr, make_shared +#include // for std::move #define CRC_ERROR_LIMIT 6 @@ -528,8 +529,8 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + *out[0] = std::move(current_symbol); return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index bf8b9ba21..178eb8bd4 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -36,6 +36,7 @@ #include // for setprecision #include // for cout #include // for shared_ptr +#include // for std::move #include #ifdef COMPILER_HAS_ROTL @@ -659,8 +660,8 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ } } - // 3. Make the output (copy the object contents to the GNU Radio reserved memory) - *out[0] = current_symbol; + // 3. Make the output (move the object contents to the GNU Radio reserved memory) + *out[0] = std::move(current_symbol); return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index 60b33d5b7..b745738da 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -35,6 +35,7 @@ #include // for setprecision #include // for cout #include // for shared_ptr, make_shared +#include // for std::move gps_l2c_telemetry_decoder_gs_sptr @@ -368,6 +369,6 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( } // 3. Make the output (copy the object contents to the GNURadio reserved memory) - out[0] = current_synchro_data; + out[0] = std::move(current_synchro_data); return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index f8ad72108..d664551ea 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include // for std::exception #include // for std::setprecision #include // for std::cout +#include // for std::move gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf) @@ -383,8 +384,8 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u } } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - out[0] = current_synchro_data; + // 3. Make the output (move the object contents to the GNURadio reserved memory) + out[0] = std::move(current_synchro_data); return 1; } return 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc index f1ec40229..9a15fd2b6 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc @@ -25,6 +25,7 @@ #include // for abs #include // for exception #include // for operator<<, setw +#include // for std::move // logging levels #define EVENT 2 // logs important events which don't occur every block @@ -470,7 +471,7 @@ int sbas_l1_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // UPDATE GNSS SYNCHRO DATA // actually the SBAS telemetry decoder doesn't support ranging current_symbol.Flag_valid_word = false; // indicate to observable block that this synchro object isn't valid for pseudorange computation - out[0] = current_symbol; + out[0] = std::move(current_symbol); consume_each(1); // tell scheduler input items consumed return 1; // tell scheduler output items produced } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 1d367d70e..a824f80ef 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -2066,7 +2066,6 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) current_synchro_data.Tracking_sample_counter = this->nitems_read(0); current_synchro_data.Flag_valid_symbol_output = !loss_of_lock; current_synchro_data.Flag_PLL_180_deg_phase_locked = d_Flag_PLL_180_deg_phase_locked; - *out[0] = current_synchro_data; // generate new tag associated with gnss-synchro object @@ -2088,6 +2087,7 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_timetag_waiting = false; } + *out[0] = std::move(current_synchro_data); return 1; } return 0; 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 923fc8fa0..8e70694ec 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 @@ -2015,7 +2015,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un current_synchro_data.Tracking_sample_counter = d_sample_counter_next; // d_sample_counter; current_synchro_data.Flag_valid_symbol_output = !loss_of_lock; current_synchro_data.Flag_PLL_180_deg_phase_locked = d_Flag_PLL_180_deg_phase_locked; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); return 1; } return 0; diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index 4b6a44d14..d40c99783 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -291,7 +291,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); d_sample_counter = d_sample_counter + static_cast(samples_offset); // count for the processed samples d_pull_in = false; consume_each(samples_offset); // shift input to perform alignment with local replica @@ -438,7 +438,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri current_synchro_data.Signal[2] = '\0'; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index d3531eac8..32e0a2e2f 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -575,7 +575,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * TWO_PI; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -811,7 +811,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index c7dc7c22c..99108ee19 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -578,7 +578,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * TWO_PI; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -813,7 +813,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index 4962899df..61e9e9feb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -518,7 +518,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -637,7 +637,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index bbba59cbf..6274a0b26 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -574,7 +574,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * TWO_PI; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -806,7 +806,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index 410e42599..f88f217c4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -575,7 +575,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * TWO_PI; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -810,7 +810,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_correlation_length_samples); } current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index a1afb3c84..56b892474 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -520,7 +520,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); consume_each(samples_offset); // shift input to perform alignment with local replica return 1; } @@ -639,7 +639,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { // MULTIPLEXED FILE RECORDING - Record results to file diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc index 1b6e7f2f6..9898ad178 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc @@ -30,6 +30,7 @@ #include #include #include +#include gps_l1_ca_dll_pll_tracking_gpu_cc_sptr @@ -344,7 +345,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); d_sample_counter += static_cast(samples_offset); // count for the processed samples d_pull_in = false; consume_each(samples_offset); // shift input to perform alignment with local replica @@ -479,7 +480,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index 6faf12488..df97429eb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -634,7 +634,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); // Kalman filter initialization reset kf_P_x = kf_P_x_ini; // Update Kalman states based on acquisition information @@ -811,7 +811,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ // assign the GNU Radio block output data current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index f646d7512..fb94fc2de 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -319,7 +319,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(samples_offset); current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); d_sample_counter_seconds = d_sample_counter_seconds + (static_cast(samples_offset) / static_cast(d_fs_in)); d_sample_counter = d_sample_counter + static_cast(samples_offset); // count for the processed samples d_pull_in = false; @@ -468,7 +468,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib current_synchro_data.Signal[2] = '\0'; current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); if (d_dump) { diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 8885e7367..68f029c1c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -21,6 +21,7 @@ #include "rtklib_solver.h" #include #include +#include class RinexPrinterTest : public ::testing::Test @@ -296,9 +297,9 @@ TEST_F(RinexPrinterTest, MixedObsHeader) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 106, false, false); - pvt_solution->galileo_ephemeris_map[1] = eph_gal; + pvt_solution->galileo_ephemeris_map[1] = std::move(eph_gal); - pvt_solution->gps_ephemeris_map[1] = eph_gps; + pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps); std::map gnss_observables_map; Gnss_Synchro gs{}; @@ -603,8 +604,8 @@ TEST_F(RinexPrinterTest, GpsObsLogDualBand) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 7, false, false); - pvt_solution->gps_ephemeris_map[1] = eph; - pvt_solution->gps_cnav_ephemeris_map[1] = eph_cnav; + pvt_solution->gps_ephemeris_map[1] = std::move(eph); + pvt_solution->gps_cnav_ephemeris_map[1] = std::move(eph_cnav); std::map gnss_observables_map; Gnss_Synchro gs1 = Gnss_Synchro(); From 1690563acdec6e4673b9504294e4374fe531e9ed Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 27 Nov 2023 14:44:45 +0100 Subject: [PATCH 089/142] Fix: bugprone-use-after-move --- src/algorithms/data_type_adapter/adapters/byte_to_short.cc | 2 +- src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc index 7bb206bc3..43e9d119b 100644 --- a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc +++ b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc @@ -26,7 +26,7 @@ ByteToShort::ByteToShort(const ConfigurationInterface* configuration, unsigned int out_streams) : role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams), - dump_(configuration->property(role + ".dump", false)) + dump_(configuration->property(role_ + ".dump", false)) { const std::string default_input_item_type("byte"); const std::string default_output_item_type("short"); diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index eb1c8affd..1d4e2f386 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -32,7 +32,7 @@ FreqXlatingFirFilter::FreqXlatingFirFilter(const ConfigurationInterface* configu : role_(std::move(role)), in_streams_(in_streams), out_streams_(out_streams), - dump_(configuration->property(role + ".dump", false)) + dump_(configuration->property(role_ + ".dump", false)) { const std::string default_input_item_type("gr_complex"); const std::string default_output_item_type("gr_complex"); From f28ed4f45f2b0adacd7c2b0cebcacdad8caafb88 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 27 Nov 2023 15:28:02 +0100 Subject: [PATCH 090/142] Fix data race condition detected by Coverity Scan --- src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 4ac0fd221..5aa106bf3 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -871,6 +871,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) // Called by gnuradio to enable drivers, etc for i/o devices. bool pcps_acquisition::start() { + gr::thread::scoped_lock lk(d_setlock); d_sample_counter = 0ULL; calculate_threshold(); return true; @@ -1017,7 +1018,7 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), { Gnss_Synchro current_synchro_data = d_monitor_queue.front(); d_monitor_queue.pop(); - *out[i] = current_synchro_data; + *out[i] = std::move(current_synchro_data); } return num_gnss_synchro_objects; } From 15c6108fe439be5ba3e0a1234bbc30c052bd50ce Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 27 Nov 2023 15:47:59 +0100 Subject: [PATCH 091/142] Fix data race condition detected by Coverity Scan --- .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 1 + .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc | 2 ++ 2 files changed, 3 insertions(+) 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 fbaaaa84f..a7ed36787 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 @@ -918,6 +918,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // check if there is a problem with the telemetry of the current satellite if (d_sent_tlm_failed_msg == false) { + gr::thread::scoped_lock lock(d_setlock); if ((d_symbol_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) { const int message = 1; // bad telemetry diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 178eb8bd4..2229adc6c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -464,6 +464,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ // check if there is a problem with the telemetry of the current satellite if (d_stat < 2 && d_sent_tlm_failed_msg == false) { + gr::thread::scoped_lock lock(d_setlock); if ((d_sample_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) { const int message = 1; // bad telemetry @@ -551,6 +552,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ if (d_CRC_error_counter > 2) { DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; + gr::thread::scoped_lock lock(d_setlock); d_flag_frame_sync = false; d_stat = 0; d_TOW_at_current_symbol_ms = 0; From 9034ce44cb8d51f1b34aa2bd2e2715bb4ccbd8d5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 09:48:59 +0100 Subject: [PATCH 092/142] Fix data race conditions detected by Coverity Scan --- .../gnuradio_blocks/gr_complex_ip_packet_source.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc index d5659d0dc..ae557e2d6 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc @@ -164,6 +164,7 @@ bool Gr_Complex_Ip_Packet_Source::start() // open the ethernet device if (open() == true) { + gr::thread::scoped_lock guard(d_setlock); // start pcap capture thread d_pcap_thread = new boost::thread( #if HAS_GENERIC_LAMBDA @@ -181,6 +182,7 @@ bool Gr_Complex_Ip_Packet_Source::start() bool Gr_Complex_Ip_Packet_Source::stop() { std::cout << "gr_complex_ip_packet_source STOP\n"; + gr::thread::scoped_lock guard(d_setlock); if (descr != nullptr) { pcap_breakloop(descr); @@ -294,11 +296,11 @@ void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char * const u_char *udp_payload = (reinterpret_cast(uh) + sizeof(gr_udp_header)); if (fifo_items <= (FIFO_SIZE - payload_length_bytes)) { + gr::thread::scoped_lock guard(d_setlock); int aligned_write_items = FIFO_SIZE - fifo_write_ptr; if (aligned_write_items >= payload_length_bytes) { // write all in a single memcpy - gr::thread::scoped_lock guard(d_setlock); memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], payload_length_bytes); // size in bytes fifo_write_ptr += payload_length_bytes; if (fifo_write_ptr == FIFO_SIZE) @@ -310,7 +312,6 @@ void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char * else { // two step wrap write - gr::thread::scoped_lock guard(d_setlock); memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], aligned_write_items); // size in bytes fifo_write_ptr = payload_length_bytes - aligned_write_items; memcpy(&fifo_buff[0], &udp_payload[aligned_write_items], fifo_write_ptr); // size in bytes From 2b708c2e4af85038e293d27421ce6d227b3309e8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 09:50:11 +0100 Subject: [PATCH 093/142] Fix wrong API usage --- src/utils/front-end-cal/main.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 5d7122686..f8469e0b3 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -596,8 +596,16 @@ int main(int argc, char** argv) for (auto& it : f_if_estimation_Hz_map) { mean_f_if_Hz += it.second; - mean_fs_Hz += f_fs_estimation_Hz_map.find(it.first)->second; - mean_osc_err_ppm += f_ppm_estimation_Hz_map.find(it.first)->second; + const auto est_Hz = f_fs_estimation_Hz_map.find(it.first); + if (est_Hz != f_fs_estimation_Hz_map.cend()) + { + mean_fs_Hz += est_Hz->second; + } + const auto est_ppm = f_ppm_estimation_Hz_map.find(it.first); + if (est_ppm != f_ppm_estimation_Hz_map.cend()) + { + mean_osc_err_ppm += est_ppm->second; + } } mean_f_if_Hz /= n_elements; From 3c24b564c95528a5cf6772ddb9d7c950523f3ee7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 11:05:18 +0100 Subject: [PATCH 094/142] Better variable names --- src/utils/front-end-cal/main.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index f8469e0b3..4915b35b5 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -596,10 +596,10 @@ int main(int argc, char** argv) for (auto& it : f_if_estimation_Hz_map) { mean_f_if_Hz += it.second; - const auto est_Hz = f_fs_estimation_Hz_map.find(it.first); - if (est_Hz != f_fs_estimation_Hz_map.cend()) + const auto est_fs = f_fs_estimation_Hz_map.find(it.first); + if (est_fs != f_fs_estimation_Hz_map.cend()) { - mean_fs_Hz += est_Hz->second; + mean_fs_Hz += est_fs->second; } const auto est_ppm = f_ppm_estimation_Hz_map.find(it.first); if (est_ppm != f_ppm_estimation_Hz_map.cend()) From 73100a7b645aae50fd71a84676a568565f5f44d0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 12:01:16 +0100 Subject: [PATCH 095/142] Fix data race condition --- .../galileo_telemetry_decoder_gs.cc | 28 +++++++++++-------- .../galileo_telemetry_decoder_gs.h | 1 + .../gps_l1_ca_telemetry_decoder_gs.cc | 27 +++++++++++------- .../gps_l1_ca_telemetry_decoder_gs.h | 1 + 4 files changed, 36 insertions(+), 21 deletions(-) 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 a7ed36787..04c4fc61b 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 @@ -853,6 +853,22 @@ void galileo_telemetry_decoder_gs::set_channel(int32_t channel) } +void galileo_telemetry_decoder_gs::check_tlm_separation() +{ + gr::thread::scoped_lock lock(d_setlock); + if (d_sent_tlm_failed_msg == false) + { + if ((d_symbol_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) + { + const int message = 1; // bad telemetry + DLOG(INFO) << "Wrong tlm sync in sat " << this->d_satellite; + this->message_port_pub(pmt::mp("telemetry_to_trk"), pmt::make_any(message)); + d_sent_tlm_failed_msg = true; + } + } +} + + int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -916,17 +932,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( d_flag_preamble = false; // check if there is a problem with the telemetry of the current satellite - if (d_sent_tlm_failed_msg == false) - { - gr::thread::scoped_lock lock(d_setlock); - if ((d_symbol_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) - { - const int message = 1; // bad telemetry - DLOG(INFO) << "sent msg sat " << this->d_satellite; - this->message_port_pub(pmt::mp("telemetry_to_trk"), pmt::make_any(message)); - d_sent_tlm_failed_msg = true; - } - } + check_tlm_separation(); // ******* frame sync ****************** int32_t corr_value = 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h index f571fea86..9cf5c81e0 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h @@ -80,6 +80,7 @@ private: galileo_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf, int frame_type); + void check_tlm_separation(); void msg_handler_read_galileo_tow_map(const pmt::pmt_t &msg); void deinterleaver(int32_t rows, int32_t cols, const float *in, float *out); void decode_INAV_word(float *page_part_symbols, int32_t frame_length, double cn0); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 2229adc6c..c094fa1bc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -428,6 +428,21 @@ void gps_l1_ca_telemetry_decoder_gs::reset() } +void gps_l1_ca_telemetry_decoder_gs::check_tlm_separation() +{ + gr::thread::scoped_lock lock(d_setlock); + if (d_stat < 2 && d_sent_tlm_failed_msg == false) + { + if ((d_sample_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) + { + const int message = 1; // bad telemetry + this->message_port_pub(pmt::mp("telemetry_to_trk"), pmt::make_any(message)); + d_sent_tlm_failed_msg = true; + } + } +} + + int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -461,17 +476,9 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ d_sample_counter++; // count for the processed symbols consume_each(1); d_flag_preamble = false; + // check if there is a problem with the telemetry of the current satellite - if (d_stat < 2 && d_sent_tlm_failed_msg == false) - { - gr::thread::scoped_lock lock(d_setlock); - if ((d_sample_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame) - { - const int message = 1; // bad telemetry - this->message_port_pub(pmt::mp("telemetry_to_trk"), pmt::make_any(message)); - d_sent_tlm_failed_msg = true; - } - } + check_tlm_separation(); // ******* frame sync ****************** switch (d_stat) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h index 07bfdeee2..2be8cd597 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h @@ -73,6 +73,7 @@ private: gps_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf); + void check_tlm_separation(); bool gps_word_parityCheck(uint32_t gpsword); bool decode_subframe(double cn0, bool flag_invert); From 346cd8f9ac52cae89082bca6f7385fb047b95268 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 12:26:13 +0100 Subject: [PATCH 096/142] Fix data race condition --- src/core/receiver/gnss_flowgraph.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index d5505b4f9..0770b305d 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -491,6 +491,7 @@ int GNSSFlowgraph::connect_desktop_flowgraph() } // Activate acquisition in enabled channels + std::lock_guard lock(signal_list_mutex_); for (int i = 0; i < channels_count_; i++) { LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); From 1818c889837c9e8f2c3982d6a0e3701f1cdf3c9f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 28 Nov 2023 18:06:41 +0100 Subject: [PATCH 097/142] Fix data race conditions and performance inefficiencies, update CHANGELOG --- docs/CHANGELOG.md | 9 + .../gr_complex_ip_packet_source.cc | 2 +- .../gps_l1_ca_telemetry_decoder_gs.cc | 188 +++++++++--------- .../gps_l1_ca_telemetry_decoder_gs.h | 1 + src/core/receiver/file_configuration.cc | 8 +- 5 files changed, 111 insertions(+), 97 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index dadd11630..a4348315e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,10 @@ All notable changes to GNSS-SDR will be documented in this file. ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) +### Improvements in Efficiency: + +- Fixed some performance inefficiencies detected by Coverity Scan. + ### Improvements in Interoperability: - Added a new PVT configuration boolean flag (`flag_geohash_log_out`) that @@ -41,6 +45,7 @@ All notable changes to GNSS-SDR will be documented in this file. - Updated local `cpu_features` library to v0.9.0. - `volk_gnsssdr`: fix syntax for Python 3.12 without breaking backward compatibility with Python 2.7. +- Fixed linking against latest GNU Radio version. ### Improvements in Repeatability: @@ -54,6 +59,10 @@ All notable changes to GNSS-SDR will be documented in this file. `PVT.kf_system_ecef_pos_sd_m=0.01`, in [m]; and `PVT.kf_system_ecef_vel_sd_ms=0.001`, in [m/s]. +### Improvements in Scalability: + +- Fixed some potential data race conditions detected by Coverity Scan. + ### Improvements in Usability: - The Galileo E1B Reduced CED parameters usage has been set to `false` by diff --git a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc index ae557e2d6..722fc9b1a 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/gr_complex_ip_packet_source.cc @@ -260,6 +260,7 @@ void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char * // eth frame parameters // **** UDP RAW PACKET DECODER **** + gr::thread::scoped_lock guard(d_setlock); if ((packet[12] == 0x08) & (packet[13] == 0x00)) // IP FRAME { // retrieve the position of the ip header @@ -296,7 +297,6 @@ void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char * const u_char *udp_payload = (reinterpret_cast(uh) + sizeof(gr_udp_header)); if (fifo_items <= (FIFO_SIZE - payload_length_bytes)) { - gr::thread::scoped_lock guard(d_setlock); int aligned_write_items = FIFO_SIZE - fifo_write_ptr; if (aligned_write_items >= payload_length_bytes) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index c094fa1bc..fe04d5369 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -443,6 +443,100 @@ void gps_l1_ca_telemetry_decoder_gs::check_tlm_separation() } +void gps_l1_ca_telemetry_decoder_gs::frame_synchronization(const Gnss_Synchro ¤t_gs) +{ + gr::thread::scoped_lock lock(d_setlock); + switch (d_stat) + { + case 0: // no preamble information + { + // correlate with preamble + int32_t corr_value = 0; + if (d_symbol_history.size() >= d_required_symbols) + { + // ******* preamble correlation ******** + for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) + { + if (d_symbol_history[i] < 0.0) // symbols clipping + { + corr_value -= d_preamble_samples[i]; + } + else + { + corr_value += d_preamble_samples[i]; + } + } + } + if (abs(corr_value) >= d_samples_per_preamble) + { + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (corr_value < 0) + { + d_flag_PLL_180_deg_phase_locked = true; + } + else + { + d_flag_PLL_180_deg_phase_locked = false; + } + DLOG(INFO) << "Preamble detection for GPS L1 satellite " << this->d_satellite; + d_prev_GPS_frame_4bytes = 0; + if (decode_subframe(current_gs.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_last_valid_preamble = d_sample_counter; + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << " Frame sync SAT " << this->d_satellite; + } + d_stat = 1; // preamble acquired + } + } + d_flag_TOW_set = false; + break; + } + case 1: // preamble acquired + { + if (d_sample_counter >= d_preamble_index + static_cast(d_preamble_period_symbols)) + { + DLOG(INFO) << "Preamble received for SAT " << this->d_satellite << "d_sample_counter=" << d_sample_counter << "\n"; + // call the decoder + // 0. fetch the symbols into an array + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) + + if (decode_subframe(current_gs.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_last_valid_preamble = d_sample_counter; + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << " Frame sync SAT " << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + if (d_CRC_error_counter > 2) + { + DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; + d_CRC_error_counter = 0; + d_flag_TOW_set = false; + } + } + } + break; + } + } +} + + int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -480,98 +574,8 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ // check if there is a problem with the telemetry of the current satellite check_tlm_separation(); - // ******* frame sync ****************** - switch (d_stat) - { - case 0: // no preamble information - { - // correlate with preamble - int32_t corr_value = 0; - if (d_symbol_history.size() >= d_required_symbols) - { - // ******* preamble correlation ******** - for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) - { - if (d_symbol_history[i] < 0.0) // symbols clipping - { - corr_value -= d_preamble_samples[i]; - } - else - { - corr_value += d_preamble_samples[i]; - } - } - } - if (abs(corr_value) >= d_samples_per_preamble) - { - d_preamble_index = d_sample_counter; // record the preamble sample stamp - if (corr_value < 0) - { - d_flag_PLL_180_deg_phase_locked = true; - } - else - { - d_flag_PLL_180_deg_phase_locked = false; - } - DLOG(INFO) << "Preamble detection for GPS L1 satellite " << this->d_satellite; - d_prev_GPS_frame_4bytes = 0; - if (decode_subframe(current_symbol.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) - { - d_CRC_error_counter = 0; - d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) - gr::thread::scoped_lock lock(d_setlock); - d_last_valid_preamble = d_sample_counter; - if (!d_flag_frame_sync) - { - d_flag_frame_sync = true; - DLOG(INFO) << " Frame sync SAT " << this->d_satellite; - } - d_stat = 1; // preamble acquired - } - } - d_flag_TOW_set = false; - break; - } - case 1: // preamble acquired - { - if (d_sample_counter >= d_preamble_index + static_cast(d_preamble_period_symbols)) - { - DLOG(INFO) << "Preamble received for SAT " << this->d_satellite << "d_sample_counter=" << d_sample_counter << "\n"; - // call the decoder - // 0. fetch the symbols into an array - d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) - - if (decode_subframe(current_symbol.CN0_dB_hz, d_flag_PLL_180_deg_phase_locked)) - { - d_CRC_error_counter = 0; - d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) - gr::thread::scoped_lock lock(d_setlock); - d_last_valid_preamble = d_sample_counter; - if (!d_flag_frame_sync) - { - d_flag_frame_sync = true; - DLOG(INFO) << " Frame sync SAT " << this->d_satellite; - } - } - else - { - d_CRC_error_counter++; - if (d_CRC_error_counter > 2) - { - DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; - gr::thread::scoped_lock lock(d_setlock); - d_flag_frame_sync = false; - d_stat = 0; - d_TOW_at_current_symbol_ms = 0; - d_TOW_at_Preamble_ms = 0; - d_CRC_error_counter = 0; - d_flag_TOW_set = false; - } - } - } - break; - } - } + // frame sync + frame_synchronization(current_symbol); // 2. Add the telemetry decoder information if (d_flag_preamble == true) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h index 2be8cd597..8b00d51ce 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h @@ -74,6 +74,7 @@ private: gps_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf); void check_tlm_separation(); + void frame_synchronization(const Gnss_Synchro ¤t_gs); bool gps_word_parityCheck(uint32_t gpsword); bool decode_subframe(double cn0, bool flag_invert); diff --git a/src/core/receiver/file_configuration.cc b/src/core/receiver/file_configuration.cc index 659895934..3c34d54bc 100644 --- a/src/core/receiver/file_configuration.cc +++ b/src/core/receiver/file_configuration.cc @@ -84,7 +84,7 @@ bool FileConfiguration::property(std::string property_name, bool default_value) return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -139,7 +139,7 @@ uint16_t FileConfiguration::property(std::string property_name, uint16_t default return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -150,7 +150,7 @@ int16_t FileConfiguration::property(std::string property_name, int16_t default_v return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -172,7 +172,7 @@ double FileConfiguration::property(std::string property_name, double default_val return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } From 4a8c58f6ba9acd933c9719015c28a8822bfdd6cf Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 29 Nov 2023 21:34:59 +0100 Subject: [PATCH 098/142] Fix performance inefficiencies detected by Coverity Scan --- .../gnuradio_blocks/hybrid_observables_gs.cc | 2 +- .../telemetry_decoder/libs/tlm_crc_stats.cc | 2 +- .../tracking/gnuradio_blocks/kf_tracking.cc | 2 +- .../tracking/libs/bayesian_estimation.cc | 10 +++++----- .../tracking/libs/nonlinear_tracking.cc | 8 ++++---- src/core/monitor/serdes_gnss_synchro.h | 2 +- src/core/receiver/file_configuration.cc | 12 ++++++------ src/core/receiver/gnss_block_factory.cc | 8 ++++---- src/core/receiver/gnss_flowgraph.cc | 10 +++++----- src/core/receiver/in_memory_configuration.cc | 18 +++++++++--------- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 8569dde24..3ce0ed6e9 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -768,7 +768,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused) { n_valid++; } - epoch_data[n] = interpolated_gnss_synchro; + epoch_data[n] = std::move(interpolated_gnss_synchro); } if (d_T_rx_TOW_set) { diff --git a/src/algorithms/telemetry_decoder/libs/tlm_crc_stats.cc b/src/algorithms/telemetry_decoder/libs/tlm_crc_stats.cc index 2a57d55ac..4d6b9d9e6 100644 --- a/src/algorithms/telemetry_decoder/libs/tlm_crc_stats.cc +++ b/src/algorithms/telemetry_decoder/libs/tlm_crc_stats.cc @@ -44,7 +44,7 @@ bool Tlm_CRC_Stats::set_channel(int32_t channel) { std::string dump_filename_ = d_dump_crc_stats_filename.substr(d_dump_crc_stats_filename.find_last_of('/') + 1); dump_path = d_dump_crc_stats_filename.substr(0, d_dump_crc_stats_filename.find_last_of('/')); - d_dump_crc_stats_filename = dump_filename_; + d_dump_crc_stats_filename = std::move(dump_filename_); } else { diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc index eb21fe31f..2a7900f20 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc @@ -2075,7 +2075,7 @@ int kf_tracking::general_work(int noutput_items __attribute__((unused)), gr_vect { current_synchro_data.fs = static_cast(d_trk_parameters.fs_in); current_synchro_data.Tracking_sample_counter = d_sample_counter; - *out[0] = current_synchro_data; + *out[0] = std::move(current_synchro_data); return 1; } return 0; diff --git a/src/algorithms/tracking/libs/bayesian_estimation.cc b/src/algorithms/tracking/libs/bayesian_estimation.cc index e0536e50f..1823efcb3 100644 --- a/src/algorithms/tracking/libs/bayesian_estimation.cc +++ b/src/algorithms/tracking/libs/bayesian_estimation.cc @@ -29,7 +29,7 @@ */ #include "bayesian_estimation.h" - +#include Bayesian_estimator::Bayesian_estimator() : kappa_prior(0), @@ -122,10 +122,10 @@ void Bayesian_estimator::update_sequential(const arma::vec& data) Psi_est = Psi_posterior / (nu_posterior + ny + 1); } - mu_prior = mu_posterior; + mu_prior = std::move(mu_posterior); kappa_prior = kappa_posterior; nu_prior = nu_posterior; - Psi_prior = Psi_posterior; + Psi_prior = std::move(Psi_posterior); } @@ -161,10 +161,10 @@ void Bayesian_estimator::update_sequential(const arma::vec& data, const arma::ve Psi_est = Psi_posterior / (nu_posterior + ny + 1); } - mu_prior = mu_posterior; + mu_prior = std::move(mu_posterior); kappa_prior = kappa_posterior; nu_prior = nu_posterior; - Psi_prior = Psi_posterior; + Psi_prior = std::move(Psi_posterior); } diff --git a/src/algorithms/tracking/libs/nonlinear_tracking.cc b/src/algorithms/tracking/libs/nonlinear_tracking.cc index d4f5609db..200c22f5d 100644 --- a/src/algorithms/tracking/libs/nonlinear_tracking.cc +++ b/src/algorithms/tracking/libs/nonlinear_tracking.cc @@ -104,8 +104,8 @@ void CubatureFilter::predict_sequential(const arma::vec& x_post, const arma::mat P_x_pred = P_x_pred / static_cast(np) - x_pred * x_pred.t() + noise_covariance; // Store predicted mean and error covariance - x_pred_out = x_pred; - P_x_pred_out = P_x_pred; + x_pred_out = std::move(x_pred); + P_x_pred_out = std::move(P_x_pred); } @@ -270,8 +270,8 @@ void UnscentedFilter::predict_sequential(const arma::vec& x_post, const arma::ma P_x_pred = P_x_pred + noise_covariance; // Store predicted mean and error covariance - x_pred_out = x_pred; - P_x_pred_out = P_x_pred; + x_pred_out = std::move(x_pred); + P_x_pred_out = std::move(P_x_pred); } diff --git a/src/core/monitor/serdes_gnss_synchro.h b/src/core/monitor/serdes_gnss_synchro.h index 35bbed909..9f45df031 100644 --- a/src/core/monitor/serdes_gnss_synchro.h +++ b/src/core/monitor/serdes_gnss_synchro.h @@ -73,7 +73,7 @@ public: { observables.Clear(); std::string data; - for (auto gs : vgs) + for (const auto& gs : vgs) { gnss_sdr::GnssSynchro* obs = observables.add_observable(); char c = gs.System; diff --git a/src/core/receiver/file_configuration.cc b/src/core/receiver/file_configuration.cc index 3c34d54bc..5e8fff282 100644 --- a/src/core/receiver/file_configuration.cc +++ b/src/core/receiver/file_configuration.cc @@ -95,7 +95,7 @@ int64_t FileConfiguration::property(std::string property_name, int64_t default_v return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -106,7 +106,7 @@ uint64_t FileConfiguration::property(std::string property_name, uint64_t default return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -117,7 +117,7 @@ int FileConfiguration::property(std::string property_name, int default_value) co return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -128,7 +128,7 @@ unsigned int FileConfiguration::property(std::string property_name, unsigned int return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -161,7 +161,7 @@ float FileConfiguration::property(std::string property_name, float default_value return overrided_->property(property_name, default_value); } const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } @@ -178,7 +178,7 @@ double FileConfiguration::property(std::string property_name, double default_val void FileConfiguration::set_property(std::string property_name, std::string value) { - overrided_->set_property(property_name, value); + overrided_->set_property(std::move(property_name), std::move(value)); } diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index e1a6d3f15..5742bca83 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -192,16 +192,16 @@ auto const item_prop = ".item_type"s; // "item_type" property template std::unique_ptr dynamic_unique_cast(std::unique_ptr&& p) { - std::unique_ptr result; - if (To* cast = dynamic_cast(p.get())) { - result.reset(cast); + std::unique_ptr result(cast); p.release(); // NOLINT(bugprone-unused-return-value) + return result; } - return result; + return std::unique_ptr(nullptr); } + auto findRole(ConfigurationInterface const* configuration, std::string const& base, int ID) -> std::string { auto role = base + std::to_string(ID); diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 0770b305d..1c913a8fc 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -2190,7 +2190,7 @@ void GNSSFlowgraph::set_signals_list() if (!tmp_set.empty()) { - available_galileo_prn = tmp_set; + available_galileo_prn = std::move(tmp_set); } } @@ -2230,7 +2230,7 @@ void GNSSFlowgraph::set_signals_list() if (!tmp_set.empty()) { - available_gps_prn = tmp_set; + available_gps_prn = std::move(tmp_set); } } @@ -2270,7 +2270,7 @@ void GNSSFlowgraph::set_signals_list() if (!tmp_set.empty()) { - available_sbas_prn = tmp_set; + available_sbas_prn = std::move(tmp_set); } } @@ -2310,7 +2310,7 @@ void GNSSFlowgraph::set_signals_list() if (!tmp_set.empty()) { - available_glonass_prn = tmp_set; + available_glonass_prn = std::move(tmp_set); } } @@ -2350,7 +2350,7 @@ void GNSSFlowgraph::set_signals_list() if (!tmp_set.empty()) { - available_beidou_prn = tmp_set; + available_beidou_prn = std::move(tmp_set); } } diff --git a/src/core/receiver/in_memory_configuration.cc b/src/core/receiver/in_memory_configuration.cc index df46b0053..b3cde9946 100644 --- a/src/core/receiver/in_memory_configuration.cc +++ b/src/core/receiver/in_memory_configuration.cc @@ -47,63 +47,63 @@ std::string InMemoryConfiguration::property(std::string property_name, std::stri bool InMemoryConfiguration::property(std::string property_name, bool default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } int64_t InMemoryConfiguration::property(std::string property_name, int64_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } uint64_t InMemoryConfiguration::property(std::string property_name, uint64_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } int32_t InMemoryConfiguration::property(std::string property_name, int32_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } uint32_t InMemoryConfiguration::property(std::string property_name, uint32_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } uint16_t InMemoryConfiguration::property(std::string property_name, uint16_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } int16_t InMemoryConfiguration::property(std::string property_name, int16_t default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } float InMemoryConfiguration::property(std::string property_name, float default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } double InMemoryConfiguration::property(std::string property_name, double default_value) const { const std::string empty; - return converter_->convert(property(property_name, empty), default_value); + return converter_->convert(property(std::move(property_name), empty), default_value); } From 0fd604db63caa9cea4a41bb10431dff03fb3b7d0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 29 Nov 2023 21:35:12 +0100 Subject: [PATCH 099/142] Fix performance inefficiencies detected by Coverity Scan --- .../acquisition/adapters/beidou_b1i_pcps_acquisition.h | 1 + .../acquisition/adapters/beidou_b3i_pcps_acquisition.h | 3 ++- .../adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h | 3 ++- .../adapters/galileo_e1_pcps_ambiguous_acquisition.h | 3 ++- .../adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h | 3 ++- .../adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h | 3 ++- .../galileo_e1_pcps_quicksync_ambiguous_acquisition.h | 4 +++- .../adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h | 4 +++- .../adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h | 3 ++- .../acquisition/adapters/galileo_e5a_pcps_acquisition.h | 3 ++- .../acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h | 3 ++- .../acquisition/adapters/galileo_e5b_pcps_acquisition.h | 3 ++- .../acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h | 3 ++- .../acquisition/adapters/galileo_e6_pcps_acquisition.h | 3 ++- .../acquisition/adapters/glonass_l1_ca_pcps_acquisition.h | 3 ++- .../acquisition/adapters/glonass_l2_ca_pcps_acquisition.h | 3 ++- .../acquisition/adapters/gps_l1_ca_pcps_acquisition.h | 3 ++- .../adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h | 3 ++- .../acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h | 3 ++- .../adapters/gps_l1_ca_pcps_assisted_acquisition.h | 3 ++- .../acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h | 3 ++- .../adapters/gps_l1_ca_pcps_quicksync_acquisition.h | 3 ++- .../acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h | 3 ++- .../acquisition/adapters/gps_l2_m_pcps_acquisition.h | 3 ++- .../acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h | 3 ++- .../acquisition/adapters/gps_l5i_pcps_acquisition.h | 3 ++- .../acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h | 3 ++- 27 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index a5a659369..7a3b3a310 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -30,6 +30,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index ccbaf8c53..105f3e45c 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -29,6 +29,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -95,7 +96,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h index 7903dff58..7548d1274 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h @@ -24,6 +24,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -92,7 +93,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h index 995c2570a..aea4c2d99 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h @@ -27,6 +27,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -95,7 +96,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 0352d4dbd..db9f10bf1 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -25,6 +25,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -121,7 +122,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h index fb53e690d..ee0e56abb 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h @@ -24,6 +24,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -93,7 +94,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h index 7ba948513..8eb96a5e0 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h @@ -24,6 +24,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -93,9 +94,10 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } + /*! * \brief Set statistics threshold of PCPS algorithm */ diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h index 33390e134..7d9245148 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h @@ -24,6 +24,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -93,9 +94,10 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } + /*! * \brief Set statistics threshold of TONG algorithm */ diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index 66323eb11..4a5655080 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -29,6 +29,7 @@ #include "gnss_synchro.h" #include #include +#include #include /** \addtogroup Acquisition @@ -93,7 +94,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h index 2b0f35050..a2194a729 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h @@ -25,6 +25,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -86,7 +87,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index f57d5d3b0..8cebfc042 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -25,6 +25,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -121,7 +122,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h index 76de8b140..940dac140 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h @@ -26,6 +26,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -117,7 +118,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index 34abc3ba6..f42720a92 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -26,6 +26,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -120,7 +121,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h index 2902177a7..a3fe58ca2 100644 --- a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h @@ -27,6 +27,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -95,7 +96,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h index 84999e6df..7a30d725d 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h @@ -29,6 +29,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -97,7 +98,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h index 6d0f68eb4..5cce50b40 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -28,6 +28,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -96,7 +97,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h index 5c79bd7de..0fd769bce 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -31,6 +31,7 @@ #include #include #include +#include /** \addtogroup Acquisition * Classes for GNSS signal acquisition @@ -101,7 +102,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h index f59db4494..c5e27ece5 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h @@ -25,6 +25,7 @@ #include "pcps_acquisition_fine_doppler_cc.h" #include #include +#include #include /** \addtogroup Acquisition @@ -95,7 +96,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 57786c570..c3f38a8b7 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -28,6 +28,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -122,7 +123,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h index 2745218ef..6a2cfde4c 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h @@ -25,6 +25,7 @@ #include "pcps_assisted_acquisition_cc.h" #include #include +#include #include /** \addtogroup Acquisition @@ -94,7 +95,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h index 880d94281..331f8c84b 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h @@ -24,6 +24,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -92,7 +93,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h index f10cbdaa5..c148fa6c0 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h @@ -26,6 +26,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -95,7 +96,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h index 2a7ba680f..336a1f1f9 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h @@ -25,6 +25,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -93,7 +94,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_cc_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h index 5f9e41615..f485ccd1b 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h @@ -28,6 +28,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -97,7 +98,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index 2003ab5a7..c72328be6 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -29,6 +29,7 @@ #include // for size_t #include // for weak_ptr #include // for string +#include /** \addtogroup Acquisition * \{ */ @@ -97,7 +98,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h index 0578ae793..6230e7a57 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h @@ -28,6 +28,7 @@ #include #include #include +#include /** \addtogroup Acquisition * \{ */ @@ -96,7 +97,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 3a6beaf7e..ee4d193a2 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -28,6 +28,7 @@ #include #include #include +#include #include /** \addtogroup Acquisition @@ -124,7 +125,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_fpga_->set_channel_fsm(channel_fsm_); } From 1a270281c0e93e8e26825f5a97c385e911e44371 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 29 Nov 2023 21:51:14 +0100 Subject: [PATCH 100/142] Add missing include --- src/algorithms/tracking/libs/nonlinear_tracking.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/tracking/libs/nonlinear_tracking.cc b/src/algorithms/tracking/libs/nonlinear_tracking.cc index 200c22f5d..676eac9c7 100644 --- a/src/algorithms/tracking/libs/nonlinear_tracking.cc +++ b/src/algorithms/tracking/libs/nonlinear_tracking.cc @@ -27,6 +27,7 @@ */ #include "nonlinear_tracking.h" +#include /***************** CUBATURE KALMAN FILTER *****************/ From 699050baaf97e0082ee9a6e0f42c1b910cebf560 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 29 Nov 2023 23:45:38 +0100 Subject: [PATCH 101/142] Fix performance inefficiencies detected by Coverity Scan --- src/algorithms/PVT/libs/rtcm.h | 2 +- .../acquisition/adapters/beidou_b1i_pcps_acquisition.h | 2 +- .../adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc | 2 +- .../adapters/gps_l1_ca_pcps_assisted_acquisition.cc | 2 +- .../adapters/gps_l1_ca_pcps_quicksync_acquisition.cc | 2 +- .../acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc | 2 +- .../observables/gnuradio_blocks/hybrid_observables_gs.cc | 2 +- .../tracking/gnuradio_blocks/dll_pll_veml_tracking.cc | 4 ++-- .../tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc | 2 +- src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc | 6 +++--- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 23d10db71..c7011eec3 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -647,7 +647,7 @@ private: inline void join(const std::shared_ptr& participant) { participants_.insert(participant); - for (auto msg : recent_msgs_) + for (const auto& msg : recent_msgs_) { participant->deliver(msg); } diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index 7a3b3a310..9e0a37ac7 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -97,7 +97,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) override { - channel_fsm_ = channel_fsm; + channel_fsm_ = std::move(channel_fsm); acquisition_->set_channel_fsm(channel_fsm_); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc index 0ba02b62c..ffe4ca5d2 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -55,7 +55,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( acq_parameters.fs_in = fs_in_; acq_parameters.samples_per_chip = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD_S * static_cast(acq_parameters.fs_in))); acq_parameters.dump = dump_; - dump_filename_ = configuration->property(role_ + ".dump_filename", default_dump_filename); + dump_filename_ = configuration->property(role_ + ".dump_filename", std::move(default_dump_filename)); acq_parameters.dump_filename = dump_filename_; if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc index 9c9dfd7e3..98fb0b9c6 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc @@ -46,7 +46,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( { const std::string default_item_type("gr_complex"); std::string default_dump_filename = "./data/acquisition.dat"; - dump_filename_ = configuration->property(role_ + ".dump_filename", default_dump_filename); + dump_filename_ = configuration->property(role_ + ".dump_filename", std::move(default_dump_filename)); item_type_ = configuration->property(role_ + ".item_type", default_item_type); int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc index ee09ec085..db6451541 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc @@ -99,7 +99,7 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( max_dwells_ = 2; } - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); + dump_filename_ = configuration_->property(role_ + ".dump_filename", std::move(default_dump_filename)); bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc index bc31812fb..7dca40c3a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc @@ -61,7 +61,7 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( item_type_ = configuration_->property(role_ + ".item_type", default_item_type); int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); + dump_filename_ = configuration_->property(role_ + ".dump_filename", std::move(default_dump_filename)); if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 270238767..28624f346 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -84,7 +84,7 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 3ce0ed6e9..a9bc19407 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -113,7 +113,7 @@ hybrid_observables_gs::hybrid_observables_gs(const Obs_Conf &conf_) { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index a824f80ef..5ac5f6d62 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -574,7 +574,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { @@ -1572,7 +1572,7 @@ int32_t dll_pll_veml_tracking::save_matfile() const // WRITE MAT FILE mat_t *matfp; matvar_t *matvar; - std::string filename = dump_filename_; + std::string filename = std::move(dump_filename_); filename.erase(filename.length() - 4, 4); filename.append(".mat"); matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); 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 8e70694ec..68df0ec82 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 @@ -1209,7 +1209,7 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() const // WRITE MAT FILE mat_t *matfp; matvar_t *matvar; - std::string filename = dump_filename_; + std::string filename = std::move(dump_filename_); filename.erase(filename.length() - 4, 4); filename.append(".mat"); matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc index 2a7900f20..dd50b4547 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc @@ -564,7 +564,7 @@ kf_tracking::kf_tracking(const Kf_Conf &conf_) { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { @@ -911,7 +911,7 @@ void kf_tracking::update_kf_narrow_integration_time() Qnew += d_F * d_Q * d_F.t(); d_Q = d_F * d_Q * d_F.t(); } - d_Q = Qnew; + d_Q = std::move(Qnew); // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz d_F = {{1.0, 0.0, d_beta * Ti, d_beta * TiTi / 2.0}, @@ -1629,7 +1629,7 @@ int32_t kf_tracking::save_matfile() const // WRITE MAT FILE mat_t *matfp; matvar_t *matvar; - std::string filename = dump_filename_; + std::string filename = std::move(dump_filename_); filename.erase(filename.length() - 4, 4); filename.append(".mat"); matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); From 9c4090f71aa8cdc8bb7d067fdcc9ae5f4d0278bb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 30 Nov 2023 08:57:30 +0100 Subject: [PATCH 102/142] Fix use of auto that caused a copy --- src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 7c14b6350..1795671a6 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -498,7 +498,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, std::ostringstream os; #ifdef HAS_PUT_TIME time_t when = std::time(nullptr); - auto const tm = *std::localtime(&when); + const auto& tm = *std::localtime(&when); os << std::put_time(&tm, "%z"); #endif std::string utc_diff_str = os.str(); // in ISO 8601 format: "+HHMM" or "-HHMM" From bd1f9e5ad978d25925ed8d9061b7217cca33f036 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 30 Nov 2023 09:48:04 +0100 Subject: [PATCH 103/142] Fix performance inefficiencies detected by Coverity Scan --- src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- .../conditioner/adapters/array_signal_conditioner.cc | 2 +- .../conditioner/adapters/signal_conditioner.cc | 2 +- .../signal_source/adapters/file_source_base.cc | 10 +++++----- .../signal_source/adapters/gen_signal_source.cc | 2 +- .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 4 ++-- .../libs/acquisition_dump_reader.cc | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 1795671a6..80b41440a 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -227,7 +227,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc index 206d76793..02471e8a5 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc @@ -73,7 +73,7 @@ void ArraySignalConditioner::disconnect(gr::top_block_sptr top_block) // data_type_adapt_->disconnect(top_block); in_filt_->disconnect(top_block); - res_->disconnect(top_block); + res_->disconnect(std::move(top_block)); connected_ = false; } diff --git a/src/algorithms/conditioner/adapters/signal_conditioner.cc b/src/algorithms/conditioner/adapters/signal_conditioner.cc index ba724abb0..871ed0a51 100644 --- a/src/algorithms/conditioner/adapters/signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/signal_conditioner.cc @@ -101,7 +101,7 @@ void SignalConditioner::disconnect(gr::top_block_sptr top_block) data_type_adapt_->disconnect(top_block); in_filt_->disconnect(top_block); - res_->disconnect(top_block); + res_->disconnect(std::move(top_block)); connected_ = false; } diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 974d4acac..220f65191 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -186,11 +186,11 @@ void FileSourceBase::connect(gr::top_block_sptr top_block) // DUMP if (sink()) { - top_block->connect(output, 0, sink(), 0); + top_block->connect(std::move(output), 0, sink(), 0); DLOG(INFO) << "connected output to file sink"; } - post_connect_hook(top_block); + post_connect_hook(std::move(top_block)); } @@ -219,7 +219,7 @@ void FileSourceBase::disconnect(gr::top_block_sptr top_block) // VALVE if (valve()) { - top_block->disconnect(input, 0, valve(), 0); + top_block->disconnect(std::move(input), 0, valve(), 0); DLOG(INFO) << "disconnected source to valve"; output = valve(); @@ -234,11 +234,11 @@ void FileSourceBase::disconnect(gr::top_block_sptr top_block) // DUMP if (sink()) { - top_block->disconnect(output, 0, sink(), 0); + top_block->disconnect(std::move(output), 0, sink(), 0); DLOG(INFO) << "disconnected output to file sink"; } - post_disconnect_hook(top_block); + post_disconnect_hook(std::move(top_block)); } diff --git a/src/algorithms/signal_source/adapters/gen_signal_source.cc b/src/algorithms/signal_source/adapters/gen_signal_source.cc index db403234c..a87f77b12 100644 --- a/src/algorithms/signal_source/adapters/gen_signal_source.cc +++ b/src/algorithms/signal_source/adapters/gen_signal_source.cc @@ -70,7 +70,7 @@ void GenSignalSource::disconnect(gr::top_block_sptr top_block) filter_->get_left_block(), 0); signal_generator_->disconnect(top_block); - filter_->disconnect(top_block); + filter_->disconnect(std::move(top_block)); connected_ = false; } 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 04c4fc61b..690715725 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 @@ -393,7 +393,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in if (page_part_bits[0] == 1) { // DECODE COMPLETE WORD (even + odd) and TEST CRC - d_inav_nav.split_page(page_String, d_flag_even_word_arrived); + d_inav_nav.split_page(std::move(page_String), d_flag_even_word_arrived); if (d_inav_nav.get_flag_CRC_test() == true) { if (d_band == '1') @@ -421,7 +421,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in else { // STORE HALF WORD (even page) - d_inav_nav.split_page(page_String, d_flag_even_word_arrived); + d_inav_nav.split_page(std::move(page_String), d_flag_even_word_arrived); d_flag_even_word_arrived = 1; } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index 07b5ff7a4..6ba023893 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -209,7 +209,7 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, } d_num_doppler_bins = static_cast(ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))); std::vector > mag_aux(d_num_doppler_bins, std::vector(d_samples_per_code)); - mag = mag_aux; + mag = std::move(mag_aux); d_dump_filename = d_basename + "_ch_" + std::to_string(channel) + "_" + std::to_string(execution) + "_sat_" + std::to_string(d_sat) + ".mat"; for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { From 0b4d525feb37d937fd4799203beb89d42684bddf Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 30 Nov 2023 13:18:56 +0100 Subject: [PATCH 104/142] Add GCC 14 to FindGFORTRAN.cmake --- cmake/Modules/FindGFORTRAN.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindGFORTRAN.cmake b/cmake/Modules/FindGFORTRAN.cmake index 5e4d2885d..a6eb38a53 100644 --- a/cmake/Modules/FindGFORTRAN.cmake +++ b/cmake/Modules/FindGFORTRAN.cmake @@ -20,7 +20,7 @@ if(DEFINED ENV{GFORTRAN_ROOT}) ) endif() -set(GCC_MAJOR_SERIES 13 12 11 10 9 8 7 6 5) +set(GCC_MAJOR_SERIES 14 13 12 11 10 9 8 7 6 5) set(GCC4_SERIES 4.9.1 4.9 4.8.3 4.8.1 4.7.2 4.7 4.8.2 4.8 4.7 4.6 4.5 4.4.4 4.4) set(GCC_SERIES ${GCC_MAJOR_SERIES} ${GCC4_SERIES}) From 4b60f8a7f2d836419914af82e53400ed4b2dc872 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Dec 2023 10:19:39 +0100 Subject: [PATCH 105/142] Fix performance inefficiencies detected by Coverity Scan --- src/algorithms/PVT/libs/rinex_printer.cc | 2 +- .../signal_source/adapters/file_source_base.cc | 2 +- .../control-plane/file_configuration_test.cc | 7 ++++--- .../control-plane/gnss_block_factory_test.cc | 3 ++- .../control-plane/gnss_flowgraph_test.cc | 9 +++++---- .../filter/fir_filter_test.cc | 3 ++- .../filter/notch_filter_lite_test.cc | 3 ++- .../pvt/rinex_printer_test.cc | 16 ++++++++-------- src/utils/front-end-cal/front_end_cal.cc | 8 ++++---- 9 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 8f3042830..92098517f 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -5651,7 +5651,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.E1B_DVS); - std::string SVhealth_str = E5B_HS + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); + std::string SVhealth_str = std::move(E5B_HS) + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); line += Rinex_Printer::doub2for(static_cast(SVhealth), 18, 2); line += std::string(1, ' '); diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 220f65191..6efa7cdbc 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -171,7 +171,7 @@ void FileSourceBase::connect(gr::top_block_sptr top_block) // VALVE if (valve()) { - top_block->connect(input, 0, valve(), 0); + top_block->connect(std::move(input), 0, valve(), 0); DLOG(INFO) << "connected source to valve"; output = valve(); diff --git a/src/tests/unit-tests/control-plane/file_configuration_test.cc b/src/tests/unit-tests/control-plane/file_configuration_test.cc index 5b2036234..4b09f1096 100644 --- a/src/tests/unit-tests/control-plane/file_configuration_test.cc +++ b/src/tests/unit-tests/control-plane/file_configuration_test.cc @@ -19,6 +19,7 @@ #include "file_configuration.h" #include "gnss_sdr_make_unique.h" #include +#include TEST(FileConfigurationTest, OverridedProperties) @@ -31,7 +32,7 @@ TEST(FileConfigurationTest, OverridedProperties) std::string value = configuration->property("NotThere", default_value); EXPECT_STREQ("default_value", value.c_str()); configuration->set_property("NotThere", "Yes!"); - value = configuration->property("NotThere", default_value); + value = configuration->property("NotThere", std::move(default_value)); EXPECT_STREQ("Yes!", value.c_str()); } @@ -40,7 +41,7 @@ TEST(FileConfigurationTest, LoadFromNonExistentFile) { std::unique_ptr configuration = std::make_unique("./i_dont_exist.conf"); std::string default_value = "default_value"; - std::string value = configuration->property("whatever.whatever", default_value); + std::string value = configuration->property("whatever.whatever", std::move(default_value)); EXPECT_STREQ("default_value", value.c_str()); } @@ -51,6 +52,6 @@ TEST(FileConfigurationTest, PropertyDoesNotExist) std::string filename = path + "data/config_file_sample.txt"; std::unique_ptr configuration = std::make_unique(filename); std::string default_value = "default_value"; - std::string value = configuration->property("whatever.whatever", default_value); + std::string value = configuration->property("whatever.whatever", std::move(default_value)); EXPECT_STREQ("default_value", value.c_str()); } diff --git a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc index 89352892b..9ce4f0469 100644 --- a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc @@ -32,6 +32,7 @@ #include "tracking_interface.h" #include #include +#include #include TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) @@ -40,7 +41,7 @@ TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) configuration->set_property("SignalSource.implementation", "File_Signal_Source"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - configuration->set_property("SignalSource.filename", filename); + configuration->set_property("SignalSource.filename", std::move(filename)); std::shared_ptr> queue = std::make_shared>(); // Example of a factory as a shared_ptr std::shared_ptr factory = std::make_shared(); diff --git a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc index 63cf9ea90..158f0ee27 100644 --- a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc @@ -28,6 +28,7 @@ #include "pass_through.h" #include "tracking_interface.h" #include +#include TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopOldNotation /*unused*/) @@ -42,7 +43,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopOldNotation /*unused*/ config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "1"); config->set_property("Channels.in_acquisition", "1"); @@ -76,7 +77,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStop /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "8"); config->set_property("Channels.in_acquisition", "1"); @@ -110,7 +111,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopGalileoE1B /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1B.count", "8"); config->set_property("Channels.in_acquisition", "1"); @@ -145,7 +146,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopHybrid /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "8"); config->set_property("Channels_1B.count", "8"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index a0d064dac..60987b0f2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -37,6 +37,7 @@ #include "interleaved_short_to_complex_short.h" #include #include +#include DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -311,7 +312,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "ibyte"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index db12b3bfc..1c77dc929 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -36,6 +36,7 @@ #include "notch_filter_lite.h" #include #include +#include DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -178,7 +179,7 @@ TEST_F(NotchFilterLiteTest, ConnectAndRunGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "gr_complex"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 68f029c1c..ea0aac0bd 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -149,12 +149,12 @@ TEST_F(RinexPrinterTest, GalileoObsHeader) auto pvt_solution = std::make_shared(rtk, conf, "filename", 4, false, false); auto eph = Galileo_Ephemeris(); eph.PRN = 1; - pvt_solution->galileo_ephemeris_map[1] = eph; + pvt_solution->galileo_ephemeris_map[1] = std::move(eph); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; - gnss_observables_map[1] = gs; + gnss_observables_map[1] = std::move(gs); auto rp = std::make_shared(); @@ -237,12 +237,12 @@ TEST_F(RinexPrinterTest, GlonassObsHeader) auto pvt_solution = std::make_shared(rtk, conf, "filename", 28, false, false); auto eph = Glonass_Gnav_Ephemeris(); eph.PRN = 1; - pvt_solution->glonass_gnav_ephemeris_map[1] = eph; + pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; - gnss_observables_map[1] = gs; + gnss_observables_map[1] = std::move(gs); auto rp = std::make_shared(3); @@ -305,7 +305,7 @@ TEST_F(RinexPrinterTest, MixedObsHeader) Gnss_Synchro gs{}; gs.PRN = 1; gnss_observables_map[1] = gs; - gnss_observables_map[2] = gs; + gnss_observables_map[2] = std::move(gs); auto rp = std::make_shared(); @@ -369,15 +369,15 @@ TEST_F(RinexPrinterTest, MixedObsHeaderGpsGlo) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 26, false, false); - pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo; + pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph_glo); - pvt_solution->gps_ephemeris_map[1] = eph_gps; + pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; gnss_observables_map[1] = gs; - gnss_observables_map[2] = gs; + gnss_observables_map[2] = std::move(gs); auto rp = std::make_shared(); diff --git a/src/utils/front-end-cal/front_end_cal.cc b/src/utils/front-end-cal/front_end_cal.cc index 8150fcfce..9c527d10e 100644 --- a/src/utils/front-end-cal/front_end_cal.cc +++ b/src/utils/front-end-cal/front_end_cal.cc @@ -86,8 +86,8 @@ int FrontEndCal::Get_SUPL_Assist() LOG(INFO) << "SUPL RRLP GPS assistance enabled!"; std::string default_acq_server = "supl.nokia.com"; std::string default_eph_server = "supl.google.com"; - supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); - supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); + supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", std::move(default_acq_server)); + supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", std::move(default_eph_server)); supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); @@ -97,7 +97,7 @@ int FrontEndCal::Get_SUPL_Assist() std::string default_ci = "0x31b0"; try { - supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC", default_lac)); + supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC", std::move(default_lac))); } catch (boost::bad_lexical_cast &) { @@ -105,7 +105,7 @@ int FrontEndCal::Get_SUPL_Assist() } try { - supl_ci = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_CI", default_ci)); + supl_ci = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_CI", std::move(default_ci))); } catch (boost::bad_lexical_cast &) { From 4f36210536a16dd89870c3e26a598c11dfd06efb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Dec 2023 10:20:52 +0100 Subject: [PATCH 106/142] Fix warnings --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 19 ++++++++++--------- src/algorithms/libs/rtklib/rtklib_stream.cc | 14 +++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 9d194f7aa..de9bcccb7 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -2983,7 +2983,7 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time, const pcvs_t *pcvs) { pcv_t *pcv; - char buff[MAXANT] = ""; + char buff[MAXANT + 1] = ""; char *types[2]; char *p; int i; @@ -3730,12 +3730,12 @@ int savenav(const char *file, const nav_t *nav) } auto id = satno2id(nav->eph[i].sat); fprintf(fp, - "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," + "%s,%d,%d,%d,%d,%lld,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n", id.data(), nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva, - nav->eph[i].svh, static_cast(nav->eph[i].toe.time), - static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), + nav->eph[i].svh, static_cast(nav->eph[i].toe.time), + static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd, nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc, @@ -3751,11 +3751,11 @@ int savenav(const char *file, const nav_t *nav) } auto id = satno2id(nav->geph[i].sat); fprintf(fp, - "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," + "%s,%d,%d,%d,%d,%d,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n", id.data(), nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh, - nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), - static_cast(nav->geph[i].tof.time), + nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), + static_cast(nav->geph[i].tof.time), nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2], nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2], @@ -5016,7 +5016,7 @@ int rtk_uncompress(const char *file, char *uncfile) int stat = 0; char *p; char cmd[2048] = ""; - char tmpfile[1024] = ""; + char tmpfile[1025] = ""; char buff[1024]; char *fname; char *dir = const_cast(""); @@ -5157,7 +5157,7 @@ int expath(const char *path, char *paths[], int nmax) int i; int j; int n = 0; - char tmp[1024] = ""; + char tmp[1025] = ""; struct dirent *d; DIR *dp; const char *file = path; @@ -5230,6 +5230,7 @@ int expath(const char *path, char *paths[], int nmax) } std::strncpy(paths[i], paths[j], 1024); std::strncpy(paths[j], tmp, 1024); + paths[j][1023] = '\0'; } } } diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index e9a29cf3f..3cb647ad6 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -81,7 +81,8 @@ serial_t *openserial(const char *path, int mode, char *msg) char *p; char parity = 'N'; char dev[128]; - char port[128]; + char port[128] = ""; + port[127] = '\0'; char fctr[64] = ""; const speed_t bs[] = { @@ -105,7 +106,7 @@ serial_t *openserial(const char *path, int mode, char *msg) } else if (strlen(path) < 128) { - std::strncpy(port, path, 128); + std::strncpy(port, path, 127); port[127] = '\0'; } @@ -124,7 +125,6 @@ serial_t *openserial(const char *path, int mode, char *msg) return nullptr; } parity = static_cast(toupper(static_cast(parity))); - std::string s_aux = "/dev/"s + std::string(port); s_aux.resize(128, '\0'); int n = s_aux.length(); @@ -705,7 +705,7 @@ void syncfile(file_t *file1, file_t *file2) void decodetcppath(const char *path, char *addr, char *port, char *user, char *passwd, char *mntpnt, char *str) { - char buff[MAXSTRPATH] = ""; + char buff[MAXSTRPATH + 1] = ""; char *p; char *q; @@ -1827,7 +1827,7 @@ int statentrip(ntrip_t *ntrip) void decodeftppath(const char *path, char *addr, char *file, char *user, char *passwd, int *topts) { - char buff[MAXSTRPATH] = ""; + char buff[MAXSTRPATH + 1] = ""; char *p; char *q; @@ -1896,7 +1896,7 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, p = buff; } - std::strncpy(addr, p, 1024); + std::strncpy(addr, p, 1023); addr[1023] = '\0'; } @@ -2254,7 +2254,7 @@ int stropen(stream_t *stream, int type, int mode, const char *path) stream->mode = mode; if (strlen(path) < MAXSTRPATH) { - std::strncpy(stream->path, path, MAXSTRPATH); + std::strncpy(stream->path, path, MAXSTRPATH - 1); stream->path[MAXSTRPATH - 1] = '\0'; } stream->inb = stream->inr = stream->outb = stream->outr = 0; From 1a4e5f43afd2692e32b2e9b897cab142f7e58c2c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Dec 2023 11:53:54 +0100 Subject: [PATCH 107/142] Fix warnings --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index de9bcccb7..512d3958c 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -3730,12 +3730,12 @@ int savenav(const char *file, const nav_t *nav) } auto id = satno2id(nav->eph[i].sat); fprintf(fp, - "%s,%d,%d,%d,%d,%lld,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," + "%s,%d,%d,%d,%d,%ld,%ld,%ld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n", id.data(), nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva, - nav->eph[i].svh, static_cast(nav->eph[i].toe.time), - static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), + nav->eph[i].svh, static_cast(nav->eph[i].toe.time), + static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd, nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc, @@ -3751,11 +3751,11 @@ int savenav(const char *file, const nav_t *nav) } auto id = satno2id(nav->geph[i].sat); fprintf(fp, - "%s,%d,%d,%d,%d,%d,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," + "%s,%d,%d,%d,%d,%d,%ld,%ld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n", id.data(), nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh, - nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), - static_cast(nav->geph[i].tof.time), + nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), + static_cast(nav->geph[i].tof.time), nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2], nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2], @@ -5016,7 +5016,8 @@ int rtk_uncompress(const char *file, char *uncfile) int stat = 0; char *p; char cmd[2048] = ""; - char tmpfile[1025] = ""; + char tmpfile[1024] = ""; + tmpfile[1023] = '\0'; char buff[1024]; char *fname; char *dir = const_cast(""); @@ -5067,6 +5068,7 @@ int rtk_uncompress(const char *file, char *uncfile) std::strncpy(uncfile, tmpfile, 1024); uncfile[p - tmpfile] = '\0'; std::strncpy(buff, tmpfile, 1024); + buff[1023] = '\0'; fname = buff; if ((p = strrchr(buff, '/'))) { @@ -5157,7 +5159,8 @@ int expath(const char *path, char *paths[], int nmax) int i; int j; int n = 0; - char tmp[1025] = ""; + char tmp[1024] = ""; + tmp[1023] = '\0'; struct dirent *d; DIR *dp; const char *file = path; @@ -5222,7 +5225,6 @@ int expath(const char *path, char *paths[], int nmax) if (strlen(paths[i]) < 1025) { std::strncpy(tmp, paths[i], 1024); - tmp[1023] = '\0'; } else { From 1685c896eae5e00b2053f17e3825e96730f69167 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Dec 2023 13:35:31 +0100 Subject: [PATCH 108/142] Fix annotation rate for KML, GPX, GeoJSON, and NMEA --- docs/CHANGELOG.md | 10 ++++++++++ src/algorithms/PVT/libs/pvt_conf.h | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a4348315e..648aa380a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -85,6 +85,16 @@ All notable changes to GNSS-SDR will be documented in this file. overkilling nine (the ninth decimal place worths up to 110 microns). Similarly, height in meters is now reported with two decimal places instead of three, and velocity in m/s also with two decimal places instead of three. +- Fixed the rate at which KLM, GPX, GeoJSON, and NMEA annotations are made. The + rate is now set by `PVT.output_rate_ms` (`500` ms by default), and can be + particularized by `PVT.kml_rate_ms`, `PVT.gpx_rate_ms`, `PVT.geojson_rate_ms`, + and `PVT.nmea_rate_ms`. Those values should be multiples of + `PVT.output_rate_ms`, or the least common multiple will be taken. + +See the definitions of concepts and metrics at +https://gnss-sdr.org/design-forces/ + +  ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index 80f4494d5..37d9b5aac 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -56,13 +56,13 @@ public: int32_t output_rate_ms = 0; int32_t display_rate_ms = 0; - int32_t kml_rate_ms = 1000; - int32_t gpx_rate_ms = 1000; - int32_t geojson_rate_ms = 1000; - int32_t nmea_rate_ms = 1000; + int32_t kml_rate_ms = 20; + int32_t gpx_rate_ms = 20; + int32_t geojson_rate_ms = 20; + int32_t nmea_rate_ms = 20; int32_t rinex_version = 0; int32_t rinexobs_rate_ms = 0; - int32_t an_rate_ms = 1000; + int32_t an_rate_ms = 20; int32_t max_obs_block_rx_clock_offset_ms = 40; int udp_port = 0; int udp_eph_port = 0; From 4afee8b7be401a4174e90f5a12524b4d173b8fdc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Dec 2023 12:51:33 +0100 Subject: [PATCH 109/142] Avoid memory illegal access detected by Coverity Scan --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 512d3958c..f216e1344 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -5225,6 +5225,7 @@ int expath(const char *path, char *paths[], int nmax) if (strlen(paths[i]) < 1025) { std::strncpy(tmp, paths[i], 1024); + tmp[1023] = '\0'; } else { From a152226f50d8268b3c1976fbbbfa9dadbc4f52e8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Dec 2023 12:54:28 +0100 Subject: [PATCH 110/142] Fix potenctial data race condition --- src/algorithms/channel/adapters/channel.cc | 7 +++++++ src/algorithms/channel/adapters/channel.h | 2 +- src/core/interfaces/channel_interface.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 69b84ca0c..444eef958 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -212,6 +212,13 @@ gr::basic_block_sptr Channel::get_right_block() } +Gnss_Signal Channel::get_signal() +{ + std::lock_guard lk(mx_); + return gnss_signal_; +} + + void Channel::set_signal(const Gnss_Signal& gnss_signal) { std::lock_guard lk(mx_); diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index a8e80123a..834cc5cd7 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -84,7 +84,7 @@ public: inline std::string role() override { return role_; } inline std::string implementation() override { return std::string("Channel"); } //!< Returns "Channel" inline size_t item_size() override { return 2 * sizeof(float); } - inline Gnss_Signal get_signal() const override { return gnss_signal_; } + Gnss_Signal get_signal() override; void start_acquisition() override; //!< Start the State Machine void stop_channel() override; //!< Stop the State Machine void set_signal(const Gnss_Signal& gnss_signal_) override; //!< Sets the channel GNSS signal diff --git a/src/core/interfaces/channel_interface.h b/src/core/interfaces/channel_interface.h index da0da3ccc..9224ed0e3 100644 --- a/src/core/interfaces/channel_interface.h +++ b/src/core/interfaces/channel_interface.h @@ -49,7 +49,7 @@ public: virtual gr::basic_block_sptr get_right_block_acq() = 0; virtual gr::basic_block_sptr get_left_block() = 0; virtual gr::basic_block_sptr get_right_block() = 0; - virtual Gnss_Signal get_signal() const = 0; + virtual Gnss_Signal get_signal() = 0; virtual void start_acquisition() = 0; virtual void assist_acquisition_doppler(double Carrier_Doppler_hz) = 0; virtual void stop_channel() = 0; From 15ddddf7c58492d441325ee4492ae024cfde9b1b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Dec 2023 13:01:08 +0100 Subject: [PATCH 111/142] Fix potenctial data race condition --- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc | 9 ++++++++- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index fe04d5369..bd72d4cde 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -537,6 +537,13 @@ void gps_l1_ca_telemetry_decoder_gs::frame_synchronization(const Gnss_Synchro &c } +bool gps_l1_ca_telemetry_decoder_gs::is_PLL_180_deg_phase_locked() +{ + gr::thread::scoped_lock lock(d_setlock); + return d_flag_PLL_180_deg_phase_locked; +} + + int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -613,7 +620,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ d_nav_msg_packet.nav_message = ""; } - if (d_flag_PLL_180_deg_phase_locked == true) + if (is_PLL_180_deg_phase_locked()) { // correct the accumulated phase for the Costas loop phase shift, if required current_symbol.Carrier_phase_rads += GNSS_PI; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h index 8b00d51ce..5939163bc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h @@ -75,6 +75,7 @@ private: void check_tlm_separation(); void frame_synchronization(const Gnss_Synchro ¤t_gs); + bool is_PLL_180_deg_phase_locked(); bool gps_word_parityCheck(uint32_t gpsword); bool decode_subframe(double cn0, bool flag_invert); From 3ad02f6dc1ab1f5b6835272e0ceae619486eb194 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Dec 2023 13:31:29 +0100 Subject: [PATCH 112/142] Update volk_gnsssdr_option_helpers --- .../apps/volk_gnsssdr_option_helpers.cc | 251 ++++++++++++------ .../apps/volk_gnsssdr_option_helpers.h | 36 ++- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 3 +- 3 files changed, 199 insertions(+), 91 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc index 84d09aa3d..752359499 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc @@ -15,70 +15,118 @@ #include // for pair -/* - * Option type - */ -option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)()) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - callback(callback) { option_type = VOID_CALLBACK; } +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)()) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + callback(t_callback) +{ + option_type = VOID_CALLBACK; +} -option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(int)) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - callback((void (*)())callback) { option_type = INT_CALLBACK; } -option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(float)) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - callback((void (*)())callback) { option_type = FLOAT_CALLBACK; } +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(int)) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + callback((void (*)())t_callback) +{ + option_type = INT_CALLBACK; +} -option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(bool)) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - callback((void (*)())callback) { option_type = BOOL_CALLBACK; } -option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(std::string)) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - callback((void (*)())callback) { option_type = STRING_CALLBACK; } +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(float)) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + callback((void (*)())t_callback) +{ + option_type = FLOAT_CALLBACK; +} -option_t::option_t(std::string longform, std::string shortform, std::string msg, std::string printval) - : longform("--" + longform), - shortform("-" + shortform), - msg(msg), - printval(printval) { option_type = STRING; } + +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(bool)) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + callback((void (*)())t_callback) +{ + option_type = BOOL_CALLBACK; +} + + +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(std::string)) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + callback((void (*)())t_callback) +{ + option_type = STRING_CALLBACK; +} + + +option_t::option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + std::string t_printval) + : longform("--" + t_longform), + shortform("-" + t_shortform), + msg(t_msg), + printval(t_printval) +{ + option_type = STRING; +} /* * Option List */ -option_list::option_list(std::string program_name) : program_name(program_name) +option_list::option_list(std::string program_name) : d_program_name(program_name) { - { - internal_list = std::vector(); - } + d_internal_list = std::vector(); } -void option_list::add(const option_t &opt) { internal_list.push_back(opt); } -void option_list::parse(int argc, char **argv) +void option_list::add(const option_t& opt) { d_internal_list.push_back(opt); } + + +void option_list::parse(int argc, char** argv) { for (int arg_number = 0; arg_number < argc; ++arg_number) { - for (std::vector::iterator this_option = internal_list.begin(); - this_option != internal_list.end(); + for (std::vector::iterator this_option = d_internal_list.begin(); + this_option != d_internal_list.end(); this_option++) { + int int_val = INT_MIN; if (this_option->longform == std::string(argv[arg_number]) || this_option->shortform == std::string(argv[arg_number])) { + if (d_present_options.count(this_option->longform) == 0) + { + d_present_options.insert( + std::pair(this_option->longform, 1)); + } + else + { + d_present_options[this_option->longform] += 1; + } switch (this_option->option_type) { case VOID_CALLBACK: @@ -87,54 +135,94 @@ void option_list::parse(int argc, char **argv) case INT_CALLBACK: try { - int int_val = std::stoi(argv[++arg_number]); + int_val = atoi(argv[++arg_number]); ((void (*)(int))this_option->callback)(int_val); } - catch (std::exception &exc) + catch (std::exception& exc) { - std::cout << "An int option can only receive a number\n"; + std::cout << "An int option can only receive a number" + << std::endl; throw std::exception(); }; break; case FLOAT_CALLBACK: try { - int int_val = std::stof(argv[++arg_number]); - ((void (*)(float))this_option->callback)(int_val); + double double_val = atof(argv[++arg_number]); + ((void (*)(float))this_option->callback)(double_val); } - catch (std::exception &exc) + catch (std::exception& exc) { - std::cout << "A float option can only receive a number\n"; + std::cout << "A float option can only receive a number" + << std::endl; throw std::exception(); }; break; case BOOL_CALLBACK: try { - bool int_val = (bool)std::stoi(argv[++arg_number]); + if (arg_number == (argc - 1)) + { // this is the last arg + int_val = 1; + } + else + { // sneak a look at the next arg since it's present + char* next_arg = argv[arg_number + 1]; + if ((strncmp(next_arg, "-", 1) == 0) || + (strncmp(next_arg, "--", 2) == 0)) + { + // the next arg is actually an arg, the bool is just + // present, set to true + int_val = 1; + } + else if (strncmp(next_arg, "true", 4) == 0) + { + int_val = 1; + } + else if (strncmp(next_arg, "false", 5) == 0) + { + int_val = 0; + } + else + { + // we got a number or a string. + // convert it to a number and depend on the catch to + // report an error condition + int_val = (bool)atoi(argv[++arg_number]); + } + } + } + catch (std::exception& e) + { + int_val = INT_MIN; + }; + if (int_val == INT_MIN) + { + std::cout + << "option: '" << argv[arg_number - 1] + << "' -> received an unknown value. Boolean " + "options should receive one of '0', '1', 'true', 'false'." + << std::endl; + throw std::exception(); + } + else if (int_val) + { ((void (*)(bool))this_option->callback)(int_val); } - catch (std::exception &exc) - { - std::cout << "A bool option can only receive 0 or 1\n"; - throw std::exception(); - }; break; case STRING_CALLBACK: try { - ((void (*)(std::string))this_option->callback)(argv[++arg_number]); + ((void (*)(std::string))this_option->callback)( + argv[++arg_number]); } - catch (std::exception &exc) + catch (std::exception& exc) { throw std::exception(); }; break; case STRING: - std::cout << this_option->printval << '\n'; - break; - default: - this_option->callback(); + std::cout << this_option->printval << std::endl; break; } } @@ -142,17 +230,31 @@ void option_list::parse(int argc, char **argv) if (std::string("--help") == std::string(argv[arg_number]) || std::string("-h") == std::string(argv[arg_number])) { + d_present_options.insert(std::pair("--help", 1)); help(); } } } + +bool option_list::present(std::string option_name) +{ + if (d_present_options.count("--" + option_name)) + { + return true; + } + else + { + return false; + } +} + void option_list::help() { - std::cout << program_name << '\n'; - std::cout << " -h [ --help ] \t\tDisplay this help message\n"; - for (std::vector::iterator this_option = internal_list.begin(); - this_option != internal_list.end(); + std::cout << d_program_name << std::endl; + std::cout << " -h [ --help ] \t\tdisplay this help message" << std::endl; + for (std::vector::iterator this_option = d_internal_list.begin(); + this_option != d_internal_list.end(); this_option++) { std::string help_line(" "); @@ -165,24 +267,11 @@ void option_list::help() help_line += this_option->shortform + " [ " + this_option->longform + " ]"; } - switch (help_line.size() / 8) + while (help_line.size() < 32) { - case 0: - help_line += "\t\t\t\t"; - break; - case 1: - help_line += "\t\t\t"; - break; - case 2: - help_line += "\t\t"; - break; - case 3: - help_line += "\t"; - break; - default: - break; + help_line += " "; } help_line += this_option->msg; - std::cout << help_line << '\n'; + std::cout << help_line << std::endl; } -} +} \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h index cc481b4a8..6a30eaaaa 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h @@ -29,12 +29,30 @@ typedef enum class option_t { public: - option_t(std::string longform, std::string shortform, std::string msg, void (*callback)()); - option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(int)); - option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(float)); - option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(bool)); - option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(std::string)); - option_t(std::string longform, std::string shortform, std::string msg, std::string printval); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)()); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(int)); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(float)); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(bool)); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + void (*t_callback)(std::string)); + option_t(std::string t_longform, + std::string t_shortform, + std::string t_msg, + std::string t_printval); std::string longform; std::string shortform; @@ -48,6 +66,7 @@ class option_list { public: explicit option_list(std::string program_name); + bool present(std::string option_name); void add(const option_t &opt); @@ -56,8 +75,9 @@ public: void help(); private: - std::string program_name; - std::vector internal_list; + std::string d_program_name; + std::vector d_internal_list; + std::map d_present_options; }; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 5a060c3d1..f4d248f79 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -81,8 +81,7 @@ int main(int argc, char *argv[]) for (int arg_number = 0; arg_number < argc; ++arg_number) { - if (std::string("--help") == std::string(argv[arg_number]) || - std::string("-h") == std::string(argv[arg_number])) + if (profile_options.present("help")) { return 0; } From e836d8f4714cee90deda7b506851c9582344010e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Dec 2023 10:10:40 +0100 Subject: [PATCH 113/142] Fix more defects detected by Coverity Scan --- .../apps/volk_gnsssdr_option_helpers.cc | 14 +++++++------- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 2 +- .../volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc | 6 +++--- .../control-plane/in_memory_configuration_test.cc | 5 +++-- ...e5a_pcps_acquisition_gsoc2014_gensource_test.cc | 2 +- .../filter/fir_filter_test.cc | 4 ++-- .../pvt/rinex_printer_test.cc | 8 ++++---- .../sources/file_signal_source_test.cc | 5 +++-- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc index 752359499..f88da8bd7 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.cc @@ -21,7 +21,7 @@ option_t::option_t(std::string t_longform, void (*t_callback)()) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), + msg(std::move(t_msg)), callback(t_callback) { option_type = VOID_CALLBACK; @@ -34,7 +34,7 @@ option_t::option_t(std::string t_longform, void (*t_callback)(int)) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), + msg(std::move(t_msg)), callback((void (*)())t_callback) { option_type = INT_CALLBACK; @@ -47,7 +47,7 @@ option_t::option_t(std::string t_longform, void (*t_callback)(float)) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), + msg(std::move(t_msg)), callback((void (*)())t_callback) { option_type = FLOAT_CALLBACK; @@ -60,7 +60,7 @@ option_t::option_t(std::string t_longform, void (*t_callback)(bool)) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), + msg(std::move(t_msg)), callback((void (*)())t_callback) { option_type = BOOL_CALLBACK; @@ -73,7 +73,7 @@ option_t::option_t(std::string t_longform, void (*t_callback)(std::string)) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), + msg(std::move(t_msg)), callback((void (*)())t_callback) { option_type = STRING_CALLBACK; @@ -86,8 +86,8 @@ option_t::option_t(std::string t_longform, std::string t_printval) : longform("--" + t_longform), shortform("-" + t_shortform), - msg(t_msg), - printval(t_printval) + msg(std::move(t_msg)), + printval(std::move(t_printval)) { option_type = STRING; } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index f4d248f79..27715f406 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) if (!dry_run) { if (config_file != "") - write_results(&results, false, config_file); + write_results(&results, false, std::move(config_file)); else write_results(&results, false); } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc index c0105fb21..274d2fd48 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc @@ -33,8 +33,8 @@ int main(int argc, char* argv[]) std::string def_kernel_regex = ""; volk_gnsssdr_test_params_t test_params(def_tol, def_scalar, def_vlen, def_iter, - def_benchmark_mode, def_kernel_regex); - std::vector test_cases = init_test_list(test_params); + def_benchmark_mode, std::move(def_kernel_regex)); + std::vector test_cases = init_test_list(std::move(test_params)); std::vector results; if (argc > 1) { @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) } // Generate XML results - print_qa_xml(results, qa_failures.size()); + print_qa_xml(std::move(results), qa_failures.size()); // Summarize QA results std::cerr << "Kernel QA finished: " << qa_failures.size() << " failures out of " diff --git a/src/tests/unit-tests/control-plane/in_memory_configuration_test.cc b/src/tests/unit-tests/control-plane/in_memory_configuration_test.cc index 4691bc0a0..a51ef89b1 100644 --- a/src/tests/unit-tests/control-plane/in_memory_configuration_test.cc +++ b/src/tests/unit-tests/control-plane/in_memory_configuration_test.cc @@ -18,6 +18,7 @@ #include "configuration_interface.h" #include "gnss_sdr_make_unique.h" #include "in_memory_configuration.h" +#include TEST(InMemoryConfiguration, IsPresent) { @@ -35,7 +36,7 @@ TEST(InMemoryConfiguration, StoreAndRetrieve) auto configuration = std::make_unique(); configuration->set_property("Foo.property1", "value"); std::string default_value = "default_value"; - std::string value = configuration->property("Foo.property1", default_value); + std::string value = configuration->property("Foo.property1", std::move(default_value)); EXPECT_STREQ("value", value.c_str()); } @@ -45,7 +46,7 @@ TEST(InMemoryConfiguration, NoStoringAndRetrieve) // std::shared_ptr configuration = std::make_shared(); auto configuration = std::make_unique(); std::string default_value = "default_value"; - std::string value = configuration->property("Foo.property1", default_value); + std::string value = configuration->property("Foo.property1", std::move(default_value)); EXPECT_STREQ("default_value", value.c_str()); } diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index d90e8b0e9..33d60383e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -225,7 +225,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_1() config = std::make_shared(); - config->set_property("Channel.signal", signal); + config->set_property("Channel.signal", std::move(signal)); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in)); config->set_property("SignalSource.fs_hz", std::to_string(fs_in)); config->set_property("SignalSource.item_type", "gr_complex"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index 60987b0f2..ec1b783ef 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -267,7 +267,7 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "ishort"); config2->set_property("Test_Source.repeat", "true"); @@ -357,7 +357,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "ibyte"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index ea0aac0bd..754bae627 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -796,8 +796,8 @@ TEST_F(RinexPrinterTest, MixedObsLog) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 9, false, false); - pvt_solution->gps_ephemeris_map[1] = eph_gps; - pvt_solution->galileo_ephemeris_map[1] = eph_gal; + pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps); + pvt_solution->galileo_ephemeris_map[1] = std::move(eph_gal); std::map gnss_observables_map; Gnss_Synchro gs1 = Gnss_Synchro(); @@ -922,8 +922,8 @@ TEST_F(RinexPrinterTest, MixedObsLogGpsGlo) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 26, false, false); - pvt_solution->gps_ephemeris_map[1] = eph_gps; - pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo; + pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps); + pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph_glo); std::map gnss_observables_map; Gnss_Synchro gs1 = Gnss_Synchro(); diff --git a/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc b/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc index 2057811f4..f07f02835 100644 --- a/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/sources/file_signal_source_test.cc @@ -22,6 +22,7 @@ #include #include #include +#include TEST(FileSignalSource, Instantiate) { @@ -32,7 +33,7 @@ TEST(FileSignalSource, Instantiate) config->set_property("Test.sampling_frequency", "0"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config->set_property("Test.filename", filename); + config->set_property("Test.filename", std::move(filename)); config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); @@ -57,5 +58,5 @@ TEST(FileSignalSource, InstantiateFileNotExists) // connect doesn't matter, since the exception should be thrown sooner than any connections auto top = gr::make_top_block("GNSSUnitTest"); auto uptr = std::make_shared(config.get(), "Test", 0, 1, queue.get()); - EXPECT_THROW({ uptr->connect(top); }, std::exception); + EXPECT_THROW({ uptr->connect(std::move(top)); }, std::exception); } From 906d7173816541fd216444f23b9c23f1a589214d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Dec 2023 11:42:30 +0100 Subject: [PATCH 114/142] Fix more defects detected by Coverity Scan --- .../volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index 2257e51f0..10697e7a1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -20,8 +20,8 @@ #include // for numeric_limits #include // for map #include // for random_device, default_random_engine, uniform_real_distribution -#include // for vector - +#include +#include // for vector template void random_values(T *buf, unsigned int n, std::default_random_engine &e1) @@ -946,14 +946,14 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, if (puppet_master_name == "NULL") { - results->back().config_name = name; + results->back().config_name = std::move(name); } else { - results->back().config_name = puppet_master_name; + results->back().config_name = std::move(puppet_master_name); } - results->back().best_arch_a = best_arch_a; - results->back().best_arch_u = best_arch_u; + results->back().best_arch_a = std::move(best_arch_a); + results->back().best_arch_u = std::move(best_arch_u); return fail_global; } From e286a0d807b3e99ee58337fc8b04faacb2e9e9cd Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Dec 2023 14:33:23 +0100 Subject: [PATCH 115/142] Fix more defects detected by Coverity Scan --- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 2 +- .../volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc | 3 +-- .../libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h | 9 +++++---- .../pvt/serdes_monitor_pvt_test.cc | 3 ++- .../telemetry_decoder/galileo_fnav_inav_decoder_test.cc | 3 ++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 27715f406..2c52adf65 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -47,7 +47,7 @@ void set_benchmark(bool val) { test_params.set_benchmark(val); } void set_tolerance(float val) { test_params.set_tol(val); } void set_vlen(int val) { test_params.set_vlen((unsigned int)val); } void set_iter(int val) { test_params.set_iter((unsigned int)val); } -void set_substr(std::string val) { test_params.set_regex(val); } +void set_substr(std::string val) { test_params.set_regex(std::move(val)); } bool update_mode = false; void set_update(bool val) { update_mode = val; } bool dry_run = false; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index 10697e7a1..c4aeb1a5e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -20,8 +20,7 @@ #include // for numeric_limits #include // for map #include // for random_device, default_random_engine, uniform_real_distribution -#include -#include // for vector +#include // for vector template void random_values(T *buf, unsigned int n, std::default_random_engine &e1) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h index 878c73659..1bfd1c991 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.h @@ -19,6 +19,7 @@ #include // for NULL #include // for map #include // for string, basic_string +#include // for move #include // for vector @@ -69,14 +70,14 @@ private: public: // ctor volk_gnsssdr_test_params_t(float tol, lv_32fc_t scalar, unsigned int vlen, unsigned int iter, - bool benchmark_mode, std::string kernel_regex) : _tol(tol), _scalar(scalar), _vlen(vlen), _iter(iter), _benchmark_mode(benchmark_mode), _kernel_regex(kernel_regex){}; + bool benchmark_mode, std::string kernel_regex) : _tol(tol), _scalar(scalar), _vlen(vlen), _iter(iter), _benchmark_mode(benchmark_mode), _kernel_regex(std::move(kernel_regex)){}; // setters void set_tol(float tol) { _tol = tol; }; void set_scalar(lv_32fc_t scalar) { _scalar = scalar; }; void set_vlen(unsigned int vlen) { _vlen = vlen; }; void set_iter(unsigned int iter) { _iter = iter; }; void set_benchmark(bool benchmark) { _benchmark_mode = benchmark; }; - void set_regex(std::string regex) { _kernel_regex = regex; }; + void set_regex(std::string regex) { _kernel_regex = std::move(regex); }; // getters float tol() { return _tol; }; lv_32fc_t scalar() { return _scalar; }; @@ -103,10 +104,10 @@ public: volk_gnsssdr_test_params_t test_parameters() { return _test_parameters; }; // normal ctor volk_gnsssdr_test_case_t(volk_gnsssdr_func_desc_t desc, void (*kernel_ptr)(), std::string name, - volk_gnsssdr_test_params_t test_parameters) : _desc(desc), _kernel_ptr(kernel_ptr), _name(name), _test_parameters(test_parameters), _puppet_master_name("NULL"){}; + volk_gnsssdr_test_params_t test_parameters) : _desc(desc), _kernel_ptr(kernel_ptr), _name(std::move(name)), _test_parameters(std::move(test_parameters)), _puppet_master_name("NULL"){}; // ctor for puppets volk_gnsssdr_test_case_t(volk_gnsssdr_func_desc_t desc, void (*kernel_ptr)(), std::string name, - std::string puppet_master_name, volk_gnsssdr_test_params_t test_parameters) : _desc(desc), _kernel_ptr(kernel_ptr), _name(name), _test_parameters(test_parameters), _puppet_master_name(puppet_master_name){}; + std::string puppet_master_name, volk_gnsssdr_test_params_t test_parameters) : _desc(desc), _kernel_ptr(kernel_ptr), _name(std::move(name)), _test_parameters(std::move(test_parameters)), _puppet_master_name(std::move(puppet_master_name)){}; }; /************************************************ diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc index 5cfca59d5..881bb60d8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc @@ -17,6 +17,7 @@ #include "serdes_galileo_eph.h" #include "serdes_monitor_pvt.h" #include +#include TEST(Serdes_Monitor_Pvt_Test, Simpletest) { @@ -41,7 +42,7 @@ TEST(Serdes_Monitor_Pvt_Test, GalileoEphemerisSerdes) eph->tow = true_tow; Serdes_Galileo_Eph gal_serdes = Serdes_Galileo_Eph(); - std::string serialized_data = gal_serdes.createProtobuffer(eph); + std::string serialized_data = gal_serdes.createProtobuffer(std::move(eph)); gnss_sdr::GalileoEphemeris ephgal; ephgal.ParseFromString(serialized_data); diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc index 61b4d60ef..1a73517bf 100644 --- a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc @@ -28,6 +28,7 @@ #include // for std::back_inserter #include #include +#include class Galileo_FNAV_INAV_test : public ::testing::Test @@ -102,7 +103,7 @@ public: if (page_part_bits[0] == 1) { // DECODE COMPLETE WORD (even + odd) and TEST CRC - INAV_decoder.split_page(page_String, flag_even_word_arrived); + INAV_decoder.split_page(std::move(page_String), flag_even_word_arrived); if (INAV_decoder.get_flag_CRC_test() == true) { crc_ok = true; From 9c95aeb07f8e82112cfb831e8d95b05a28bc2b1c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 13 Dec 2023 22:12:29 +0100 Subject: [PATCH 116/142] Avoid deprecation warnings when VOLK >= 3.1 Bump CMake max version to 3.28 Do not leak build system paths when cross-compiling. Fixes OpenEmbedded QA warning volk_gnsssdr: Fix 64-bit integer testing CI: Fix for Python 3.12 --- .github/workflows/main.yml | 27 +++--- CMakeLists.txt | 2 +- docs/CHANGELOG.md | 4 + .../gnuradio_blocks/CMakeLists.txt | 8 ++ ...o_e5a_noncoherent_iq_acquisition_caf_cc.cc | 15 ++- .../galileo_pcps_8ms_acquisition_cc.cc | 8 +- .../volk_gnsssdr/CMakeLists.txt | 2 +- .../volk_gnsssdr_16ic_rotatorpuppet_16ic.h | 16 ++-- .../volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h | 92 +++++++++---------- .../volk_gnsssdr/lib/CMakeLists.txt | 38 +++++--- .../volk_gnsssdr/lib/qa_utils.cc | 4 +- 11 files changed, 129 insertions(+), 87 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc1fb280f..5206c6d31 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,11 +48,10 @@ jobs: rm /usr/local/bin/pydoc3 || true rm /usr/local/bin/python3 || true rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true + rm /usr/local/bin/2to3-3.1* || true + rm /usr/local/bin/idle3.1* || true + rm /usr/local/bin/pydoc3.1* || true + rm /usr/local/bin/python3.1* || true brew install ninja hdf5 automake armadillo lapack \ gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -77,11 +76,10 @@ jobs: rm /usr/local/bin/pydoc3 || true rm /usr/local/bin/python3 || true rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true + rm /usr/local/bin/2to3-3.1* || true + rm /usr/local/bin/idle3.1* || true + rm /usr/local/bin/pydoc3.1* || true + rm /usr/local/bin/python3.1* || true brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -125,11 +123,10 @@ jobs: rm /usr/local/bin/pydoc3 || true rm /usr/local/bin/python3 || true rm /usr/local/bin/python3-config || true - rm /usr/local/bin/2to3-3.11 || true - rm /usr/local/bin/idle3.11 || true - rm /usr/local/bin/pydoc3.11 || true - rm /usr/local/bin/python3.11 || true - rm /usr/local/bin/python3.11-config || true + rm /usr/local/bin/2to3-3.1* || true + rm /usr/local/bin/idle3.1* || true + rm /usr/local/bin/pydoc3.1* || true + rm /usr/local/bin/python3.1* || true brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \ log4cpp openssl pugixml protobuf pip3 install mako diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a297f0ae..ab0c1bc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # Build type can still be overridden by setting -DCMAKE_BUILD_TYPE= set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") -cmake_minimum_required(VERSION 2.8.12...3.27) +cmake_minimum_required(VERSION 2.8.12...3.28) project(gnss-sdr CXX C) set(GNSSSDR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Allows to be a sub-project diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 648aa380a..ca209027e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -46,6 +46,10 @@ All notable changes to GNSS-SDR will be documented in this file. - `volk_gnsssdr`: fix syntax for Python 3.12 without breaking backward compatibility with Python 2.7. - Fixed linking against latest GNU Radio version. +- Make use of new API if linking against VOLK >= 3.1. +- Fixed undefined behaviour in `volk_gnsssdr` arising from incompatibility + between complex numbers in C and C++. +- Now build system paths are not leaked when cross-compiling. ### Improvements in Repeatability: diff --git a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt index 9ecdf6cdb..fdeb3981e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt @@ -101,6 +101,14 @@ if(ENABLE_OPENCL) ) endif() +if(VOLK_VERSION) + if(VOLK_VERSION VERSION_GREATER 3.0.99) + target_compile_definitions(acquisition_gr_blocks + PRIVATE -DVOLK_EQUAL_OR_GREATER_31=1 + ) + endif() +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(acquisition_gr_blocks diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 98861361b..7851aff79 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -184,10 +184,16 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_local_code(std::complex 1) { // DATA CODE B: First replica is inverted (0,1,1) +#if VOLK_EQUAL_OR_GREATER_31 + auto minus_one = gr_complex(-1, 0); + volk_32fc_s32fc_multiply2_32fc(&(d_fft_if->get_inbuf())[0], + &codeI[0], &minus_one, + d_samples_per_code); +#else volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[0], &codeI[0], gr_complex(-1, 0), d_samples_per_code); - +#endif d_fft_if->execute(); // We need the FFT of local code // Conjugate the local code @@ -196,9 +202,16 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_local_code(std::complexget_inbuf())[0], + &codeQ[0], &minus_one, + d_samples_per_code); +#else volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[0], &codeQ[0], gr_complex(-1, 0), d_samples_per_code); +#endif d_fft_if->execute(); // We need the FFT of local code // Conjugate the local code diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index 17d697fed..7dad27c45 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -124,10 +124,16 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_code_A.data(), d_fft_if->get_outbuf(), d_fft_size); // code B: two replicas of a primary code; the second replica is inverted. +#if VOLK_EQUAL_OR_GREATER_31 + auto minus_one = gr_complex(-1, 0); + volk_32fc_s32fc_multiply2_32fc(&(d_fft_if->get_inbuf())[d_samples_per_code], + &code[d_samples_per_code], &minus_one, + d_samples_per_code); +#else volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[d_samples_per_code], &code[d_samples_per_code], gr_complex(-1, 0), d_samples_per_code); - +#endif d_fft_if->execute(); // We need the FFT of local code // Conjugate the local code diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 89594968b..a65a33172 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -8,7 +8,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.8.12...3.27) +cmake_minimum_required(VERSION 2.8.12...3.28) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h index 75bcdb87e..a7d26e9b5 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_rotatorpuppet_16ic.h @@ -37,7 +37,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_generic(lv_16sc_t* outVe phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_GENERIC */ @@ -53,7 +53,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_generic_reload(lv_16sc_t phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_GENERIC */ @@ -69,7 +69,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_a_sse3(lv_16sc_t* outVec phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_SSE3 */ @@ -85,7 +85,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_a_sse3_reload(lv_16sc_t* phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_SSE3 */ @@ -101,7 +101,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_u_sse3(lv_16sc_t* outVec phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_SSE3 */ @@ -117,7 +117,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_u_sse3_reload(lv_16sc_t* phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_SSE3 */ @@ -133,7 +133,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_neon(lv_16sc_t* outVecto phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_NEON */ @@ -149,7 +149,7 @@ static inline void volk_gnsssdr_16ic_rotatorpuppet_16ic_neon_reload(lv_16sc_t* o phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad)); lv_32fc_t phase_inc[1]; phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad)); - volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(outVector, inVector, phase_inc[0], phase, num_points); + volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(outVector, inVector, &phase_inc[0], phase, num_points); } #endif /* LV_HAVE_NEON */ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h index 81e5bd7aa..1d6d0ac05 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_s32fc_x2_rotator_16ic.h @@ -27,7 +27,7 @@ * * Dispatcher Prototype * \code - * void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points); + * void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points); * \endcode * * \b Inputs @@ -51,7 +51,7 @@ #ifdef LV_HAVE_GENERIC -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { unsigned int i = 0; lv_16sc_t tmp16; @@ -61,7 +61,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(lv_16sc_t* ou tmp16 = *inVector++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *outVector++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; // Regenerate phase if (i % 512 == 0) { @@ -81,7 +81,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic(lv_16sc_t* ou #ifdef LV_HAVE_GENERIC -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { unsigned int ROTATOR_RELOAD = 512; unsigned int n = 0; @@ -95,7 +95,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(lv_16s tmp16 = *inVector++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *outVector++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } // Regenerate phase // printf("Phase before regeneration %i: %f,%f Modulus: %f\n", n,lv_creal(*phase),lv_cimag(*phase), cabsf(*phase)); @@ -111,7 +111,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(lv_16s tmp16 = *inVector++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *outVector++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -121,7 +121,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_generic_reload(lv_16s #ifdef LV_HAVE_SSE3 #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { const unsigned int sse_iters = num_points / 4; unsigned int number; @@ -129,13 +129,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(lv_16sc_t* out __m128i c1, c2, result; __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_inc[2]; - two_phase_inc[0] = phase_inc * phase_inc; - two_phase_inc[1] = phase_inc * phase_inc; + two_phase_inc[0] = *phase_inc * *phase_inc; + two_phase_inc[1] = *phase_inc * *phase_inc; two_phase_inc_reg = _mm_load_ps((float*)two_phase_inc); __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_acc[2]; two_phase_acc[0] = (*phase); - two_phase_acc[1] = (*phase) * phase_inc; + two_phase_acc[1] = (*phase) * *phase_inc; two_phase_acc_reg = _mm_load_ps((float*)two_phase_acc); const lv_16sc_t* _in = inVector; @@ -213,7 +213,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(lv_16sc_t* out tmp16 = *_in++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -223,7 +223,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3(lv_16sc_t* out #ifdef LV_HAVE_SSE3 #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { const unsigned int sse_iters = num_points / 4; const unsigned int ROTATOR_RELOAD = 512; @@ -233,13 +233,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(lv_16sc __m128i c1, c2, result; __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_inc[2]; - two_phase_inc[0] = phase_inc * phase_inc; - two_phase_inc[1] = phase_inc * phase_inc; + two_phase_inc[0] = *phase_inc * *phase_inc; + two_phase_inc[1] = *phase_inc * *phase_inc; two_phase_inc_reg = _mm_load_ps((float*)two_phase_inc); __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_acc[2]; two_phase_acc[0] = (*phase); - two_phase_acc[1] = (*phase) * phase_inc; + two_phase_acc[1] = (*phase) * *phase_inc; two_phase_acc_reg = _mm_load_ps((float*)two_phase_acc); const lv_16sc_t* _in = inVector; @@ -367,7 +367,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(lv_16sc tmp16 = *_in++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -377,7 +377,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_a_sse3_reload(lv_16sc #ifdef LV_HAVE_SSE3 #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { const unsigned int sse_iters = num_points / 4; unsigned int number; @@ -385,13 +385,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(lv_16sc_t* out __m128i c1, c2, result; __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_inc[2]; - two_phase_inc[0] = phase_inc * phase_inc; - two_phase_inc[1] = phase_inc * phase_inc; + two_phase_inc[0] = *phase_inc * *phase_inc; + two_phase_inc[1] = *phase_inc * *phase_inc; two_phase_inc_reg = _mm_load_ps((float*)two_phase_inc); __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_acc[2]; two_phase_acc[0] = (*phase); - two_phase_acc[1] = (*phase) * phase_inc; + two_phase_acc[1] = (*phase) * *phase_inc; two_phase_acc_reg = _mm_load_ps((float*)two_phase_acc); const lv_16sc_t* _in = inVector; @@ -470,7 +470,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(lv_16sc_t* out tmp16 = *_in++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -480,7 +480,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3(lv_16sc_t* out #ifdef LV_HAVE_SSE3 #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { const unsigned int sse_iters = num_points / 4; unsigned int ROTATOR_RELOAD = 512; @@ -490,13 +490,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(lv_16sc __m128i c1, c2, result; __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_inc[2]; - two_phase_inc[0] = phase_inc * phase_inc; - two_phase_inc[1] = phase_inc * phase_inc; + two_phase_inc[0] = *phase_inc * *phase_inc; + two_phase_inc[1] = *phase_inc * *phase_inc; two_phase_inc_reg = _mm_load_ps((float*)two_phase_inc); __VOLK_ATTR_ALIGNED(16) lv_32fc_t two_phase_acc[2]; two_phase_acc[0] = (*phase); - two_phase_acc[1] = (*phase) * phase_inc; + two_phase_acc[1] = (*phase) * *phase_inc; two_phase_acc_reg = _mm_load_ps((float*)two_phase_acc); const lv_16sc_t* _in = inVector; @@ -624,7 +624,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(lv_16sc tmp16 = *_in++; tmp32 = lv_cmake((float)lv_creal(tmp16), (float)lv_cimag(tmp16)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32)), (int16_t)rintf(lv_cimag(tmp32))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -634,7 +634,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_u_sse3_reload(lv_16sc #ifdef LV_HAVE_NEON #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { unsigned int i = 0; const unsigned int neon_iters = num_points / 4; @@ -642,13 +642,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVe lv_32fc_t tmp32_; float arg_phase0 = cargf(*phase); - float arg_phase_inc = cargf(phase_inc); + float arg_phase_inc = cargf(*phase_inc); float phase_est = 0.0; const lv_16sc_t* _in = inVector; lv_16sc_t* _out = outVector; - lv_32fc_t ___phase4 = phase_inc * phase_inc * phase_inc * phase_inc; + lv_32fc_t ___phase4 = *phase_inc * *phase_inc * *phase_inc * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t __phase4_real[4] = {lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4)}; __VOLK_ATTR_ALIGNED(16) @@ -657,9 +657,9 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVe float32x4_t _phase4_real = vld1q_f32(__phase4_real); float32x4_t _phase4_imag = vld1q_f32(__phase4_imag); - lv_32fc_t phase2 = (lv_32fc_t)(*phase) * phase_inc; - lv_32fc_t phase3 = phase2 * phase_inc; - lv_32fc_t phase4 = phase3 * phase_inc; + lv_32fc_t phase2 = (lv_32fc_t)(*phase) * *phase_inc; + lv_32fc_t phase3 = phase2 * *phase_inc; + lv_32fc_t phase4 = phase3 * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t __phase_real[4] = {lv_creal((*phase)), lv_creal(phase2), lv_creal(phase3), lv_creal(phase4)}; @@ -737,9 +737,9 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVe // printf("Estimated phase: %f\n\n", cos(phase_est)); *phase = lv_cmake(cos(phase_est), sin(phase_est)); - phase2 = (lv_32fc_t)(*phase) * phase_inc; - phase3 = phase2 * phase_inc; - phase4 = phase3 * phase_inc; + phase2 = (lv_32fc_t)(*phase) * *phase_inc; + phase3 = phase2 * *phase_inc; + phase4 = phase3 * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t ____phase_real[4] = {lv_creal((*phase)), lv_creal(phase2), lv_creal(phase3), lv_creal(phase4)}; @@ -760,7 +760,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVe tmp16_ = *_in++; tmp32_ = lv_cmake((float32_t)lv_creal(tmp16_), (float32_t)lv_cimag(tmp16_)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32_)), (int16_t)rintf(lv_cimag(tmp32_))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } @@ -770,7 +770,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon(lv_16sc_t* outVe #ifdef LV_HAVE_NEON #include -static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points) +static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t* outVector, const lv_16sc_t* inVector, const lv_32fc_t* phase_inc, lv_32fc_t* phase, unsigned int num_points) { unsigned int i = 0; const unsigned int neon_iters = num_points / 4; @@ -782,13 +782,13 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t lv_32fc_t tmp32_; float arg_phase0 = cargf(*phase); - float arg_phase_inc = cargf(phase_inc); + float arg_phase_inc = cargf(*phase_inc); float phase_est = 0.0; const lv_16sc_t* _in = inVector; lv_16sc_t* _out = outVector; - lv_32fc_t ___phase4 = phase_inc * phase_inc * phase_inc * phase_inc; + lv_32fc_t ___phase4 = *phase_inc * *phase_inc * *phase_inc * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t __phase4_real[4] = {lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4)}; __VOLK_ATTR_ALIGNED(16) @@ -797,9 +797,9 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t float32x4_t _phase4_real = vld1q_f32(__phase4_real); float32x4_t _phase4_imag = vld1q_f32(__phase4_imag); - lv_32fc_t phase2 = (lv_32fc_t)(*phase) * phase_inc; - lv_32fc_t phase3 = phase2 * phase_inc; - lv_32fc_t phase4 = phase3 * phase_inc; + lv_32fc_t phase2 = (lv_32fc_t)(*phase) * *phase_inc; + lv_32fc_t phase3 = phase2 * *phase_inc; + lv_32fc_t phase4 = phase3 * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t __phase_real[4] = {lv_creal((*phase)), lv_creal(phase2), lv_creal(phase3), lv_creal(phase4)}; @@ -877,9 +877,9 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t phase_est = arg_phase0 + (n + 1) * ROTATOR_RELOAD * 4 * arg_phase_inc; // printf("Estimated phase: %f\n\n", cos(phase_est)); *phase = lv_cmake(cos(phase_est), sin(phase_est)); - phase2 = (lv_32fc_t)(*phase) * phase_inc; - phase3 = phase2 * phase_inc; - phase4 = phase3 * phase_inc; + phase2 = (lv_32fc_t)(*phase) * *phase_inc; + phase3 = phase2 * *phase_inc; + phase4 = phase3 * *phase_inc; __VOLK_ATTR_ALIGNED(16) float32_t ____phase_real[4] = {lv_creal((*phase)), lv_creal(phase2), lv_creal(phase3), lv_creal(phase4)}; @@ -954,7 +954,7 @@ static inline void volk_gnsssdr_16ic_s32fc_x2_rotator_16ic_neon_reload(lv_16sc_t tmp16_ = *_in++; tmp32_ = lv_cmake((float32_t)lv_creal(tmp16_), (float32_t)lv_cimag(tmp16_)) * (*phase); *_out++ = lv_cmake((int16_t)rintf(lv_creal(tmp32_)), (int16_t)rintf(lv_cimag(tmp32_))); - (*phase) *= phase_inc; + (*phase) *= *phase_inc; } } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index f22441f69..8bfd62614 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -372,14 +372,18 @@ if(MSVC) set(cmake_c_compiler_version "Microsoft Visual Studio 14.0") endif() else() - execute_process(COMMAND ${CMAKE_C_COMPILER} --version - OUTPUT_VARIABLE cmake_c_compiler_version - ) + if(NOT CMAKE_CROSSCOMPILING) + execute_process(COMMAND ${CMAKE_C_COMPILER} --version + OUTPUT_VARIABLE cmake_c_compiler_version + ) + endif() endif() if(NOT GRCBTU) set(GRCBTU "") endif() -set(COMPILER_INFO "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n") +if(NOT CMAKE_CROSSCOMPILING) + set(COMPILER_INFO "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n") +endif() foreach(machine_name ${available_machines}) # generate machine source @@ -396,7 +400,9 @@ foreach(machine_name ${available_machines}) if(NOT (CMAKE_GENERATOR STREQUAL Xcode)) message(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}") endif() - set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n") + if(NOT CMAKE_CROSSCOMPILING) + set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n") + endif() if(${machine_name}_flags AND NOT MSVC) set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}") endif() @@ -407,11 +413,15 @@ foreach(machine_name ${available_machines}) endforeach() # Convert to a C string to compile and display properly -string(STRIP "${cmake_c_compiler_version}" cmake_c_compiler_version) -string(STRIP ${COMPILER_INFO} COMPILER_INFO) -message(STATUS "Compiler Version: ${cmake_c_compiler_version}") -string(REPLACE "\n" " \\n" cmake_c_compiler_version ${cmake_c_compiler_version}) -string(REPLACE "\n" " \\n" COMPILER_INFO ${COMPILER_INFO}) +if(NOT CMAKE_CROSSCOMPILING) + string(STRIP "${cmake_c_compiler_version}" cmake_c_compiler_version) + string(REPLACE "\n" " \\n" cmake_c_compiler_version ${cmake_c_compiler_version}) + message(STATUS "Compiler Version: ${cmake_c_compiler_version}") + string(STRIP ${COMPILER_INFO} COMPILER_INFO) + string(REPLACE "\n" " \\n" COMPILER_INFO ${COMPILER_INFO}) +else() + set(cmake_c_compiler_version "") +endif() ######################################################################## @@ -481,8 +491,12 @@ endif() message(STATUS "Loading version ${VERSION} into constants...") # double escape for windows backslash path separators -string(REPLACE "\\" "\\\\" prefix "${prefix}") -string(REPLACE "${CMAKE_SOURCE_DIR}" "$BUILD_DIR" COMPILER_INFO "${COMPILER_INFO}") +if(NOT CMAKE_CROSSCOMPILING) + string(REPLACE "\\" "\\\\" prefix "${prefix}") + string(REPLACE "${CMAKE_SOURCE_DIR}" "$BUILD_DIR" COMPILER_INFO "${COMPILER_INFO}") +else() + set(prefix "") +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/constants.c.in diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index c4aeb1a5e..9c961cee0 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -483,12 +483,12 @@ bool icompare(t *in1, t *in2, unsigned int vlen, unsigned int tol) int print_max_errs = 10; for (unsigned int i = 0; i < vlen; i++) { - if (((unsigned int)abs(int(((t *)(in1))[i]) - int(((t *)(in2))[i]))) > tol) + if (((uint64_t)abs(int64_t(((t *)(in1))[i]) - int64_t(((t *)(in2))[i]))) > tol) { fail = true; if (print_max_errs-- > 0) { - std::cout << "offset " << i << " in1: " << static_cast(t(((t *)(in1))[i])) << " in2: " << static_cast(t(((t *)(in2))[i])); + std::cout << "offset " << i << " in1: " << static_cast(t(((t *)(in1))[i])) << " in2: " << static_cast(t(((t *)(in2))[i])); std::cout << " tolerance was: " << tol << '\n'; } } From 071f78202de6698c0513a50fad75b4b510f37f55 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 13 Dec 2023 22:38:01 +0100 Subject: [PATCH 117/142] CI: update checkouts --- .github/workflows/citation.yml | 2 +- .github/workflows/gnss-sdr_archs.yml | 4 ++-- .github/workflows/volk_gnsssdr_android.yml | 2 +- .github/workflows/volk_gnsssdr_archs.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/citation.yml b/.github/workflows/citation.yml index fdab6859e..9de637fed 100644 --- a/.github/workflows/citation.yml +++ b/.github/workflows/citation.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Validate CITATION.cff uses: dieghernan/cff-validator@main # Upload artifact in case of failure diff --git a/.github/workflows/gnss-sdr_archs.yml b/.github/workflows/gnss-sdr_archs.yml index e2ee8c1b5..6ba71fb64 100644 --- a/.github/workflows/gnss-sdr_archs.yml +++ b/.github/workflows/gnss-sdr_archs.yml @@ -40,8 +40,8 @@ jobs: # compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } steps: - - uses: actions/checkout@v3.1.0 - - uses: uraimo/run-on-arch-action@v2.5.0 + - uses: actions/checkout@v4 + - uses: uraimo/run-on-arch-action@v2.6.0 name: Test in non-x86 container continue-on-error: ${{ contains(fromJson('["ppc64le", "s390x"]'), matrix.arch) }} id: test diff --git a/.github/workflows/volk_gnsssdr_android.yml b/.github/workflows/volk_gnsssdr_android.yml index 69a04edfc..04a33c3d4 100644 --- a/.github/workflows/volk_gnsssdr_android.yml +++ b/.github/workflows/volk_gnsssdr_android.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Update repositories run: sudo apt update - name: Install dependencies diff --git a/.github/workflows/volk_gnsssdr_archs.yml b/.github/workflows/volk_gnsssdr_archs.yml index edc0721b1..0e3489647 100644 --- a/.github/workflows/volk_gnsssdr_archs.yml +++ b/.github/workflows/volk_gnsssdr_archs.yml @@ -44,8 +44,8 @@ jobs: compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } steps: - - uses: actions/checkout@v3.1.0 - - uses: uraimo/run-on-arch-action@v2.5.0 + - uses: actions/checkout@v4 + - uses: uraimo/run-on-arch-action@v2.6.0 name: Build in non-x86 container # continue-on-error: ${{ contains(fromJson('["ppc64le", "s390x"]'), matrix.arch) }} id: build From 8b512d997bd3a340a64a08ffb507fe210a6d32f2 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 20 Dec 2023 16:32:40 +0100 Subject: [PATCH 118/142] Remove the EZDMA driver, fix time reporting when using the FPGA, and include minor fixes for the dynamic bit selection, the AD9361 FPGA signal source, and the FPGA acquisition sampling factor parameter --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 2 +- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 1 + .../galileo_e5a_pcps_acquisition_fpga.cc | 2 +- .../galileo_e5a_pcps_acquisition_fpga.h | 1 + .../galileo_e5b_pcps_acquisition_fpga.cc | 2 +- .../galileo_e5b_pcps_acquisition_fpga.h | 1 + .../gps_l1_ca_pcps_acquisition_fpga.cc | 2 +- .../gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../gps_l2_m_pcps_acquisition_fpga.cc | 2 +- .../adapters/gps_l2_m_pcps_acquisition_fpga.h | 1 + .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 2 +- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 2 +- .../acquisition/libs/acq_conf_fpga.cc | 4 +- .../acquisition/libs/acq_conf_fpga.h | 2 +- .../adapters/ad9361_fpga_signal_source.cc | 32 ++-- .../adapters/ad9361_fpga_signal_source.h | 6 +- .../signal_source/libs/CMakeLists.txt | 9 +- .../signal_source/libs/ad9361_manager.cc | 10 +- .../libs/fpga_dynamic_bit_selection.cc | 143 ++++++++++-------- .../libs/fpga_dynamic_bit_selection.h | 19 ++- src/core/libs/gnss_sdr_fpga_sample_counter.cc | 2 +- 21 files changed, 138 insertions(+), 109 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 20efd8ae3..87e4c2d06 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -44,7 +44,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( out_streams_(out_streams), acquire_pilot_(configuration->property(role + ".acquire_pilot", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index db9f10bf1..09829267c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -182,6 +182,7 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: + static const uint32_t downsampling_factor_default = 4; static const uint32_t fpga_buff_num = 0; // L1/E1 band static const uint32_t fpga_blk_exp = 13; // default block exponent diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index d049ccd37..f3c041952 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 8cebfc042..12d38bf34 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -189,6 +189,7 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: + static const uint32_t downsampling_factor_default = 1; static const uint32_t fpga_buff_num = 1; // L5/E5a band static const uint32_t fpga_blk_exp = 13; // default block exponent diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc index 4ec2c5341..83996b5c8 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role_, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS); if (FLAGS_doppler_max != 0) { acq_parameters_.doppler_max = FLAGS_doppler_max; diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index f42720a92..8ae54e46a 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -188,6 +188,7 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: + static const uint32_t downsampling_factor_default = 1; static const uint32_t fpga_buff_num = 1; // E5b band static const uint32_t fpga_blk_exp = 13; // default block exponent diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 0b9ae0b9a..cc2713d24 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS); DLOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index c3f38a8b7..cfc483cda 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -186,7 +186,7 @@ public: private: static const uint32_t NUM_PRNs = 32; - + static const uint32_t downsampling_factor_default = 4; static const uint32_t fpga_buff_num = 0; // L1/E1 band static const uint32_t fpga_blk_exp = 10; // default block exponent diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index c74f1275b..ecce4df4c 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -43,7 +43,7 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index c72328be6..19acec8cb 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -150,6 +150,7 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: + static const uint32_t downsampling_factor_default = 1; static const uint32_t fpga_buff_num = 0; // L2 band static const uint32_t fpga_blk_exp = 13; // default block exponent diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index ebd701840..a96bf531d 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -44,7 +44,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_buff_num, fpga_blk_exp, downsampling_factor_default, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index ee4d193a2..497ab9b90 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -186,7 +186,7 @@ public: private: static const uint32_t NUM_PRNs = 32; - + static const uint32_t downsampling_factor_default = 1; static const uint32_t fpga_buff_num = 1; // L5/E5a band static const uint32_t fpga_blk_exp = 13; // default block exponent diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc index ac68a92ad..5c1e9e0c2 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.cc +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -23,7 +23,7 @@ #include void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configuration, - const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips) + const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, uint32_t downsampling_factor_default, double chip_rate, double code_length_chips) { // sampling frequency const int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", fs_in); @@ -33,7 +33,7 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura doppler_max = configuration->property(role + ".doppler_max", doppler_max); // downsampling factor - downsampling_factor = configuration->property(role + ".downsampling_factor", downsampling_factor); + downsampling_factor = configuration->property(role + ".downsampling_factor", downsampling_factor_default); fs_in = fs_in / downsampling_factor; diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.h b/src/algorithms/acquisition/libs/acq_conf_fpga.h index c24cbb031..11a2c7856 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.h +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.h @@ -35,7 +35,7 @@ class Acq_Conf_Fpga public: Acq_Conf_Fpga() = default; - void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips); + void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, uint32_t downsampling_factor_default, double chip_rate, double code_length_chips); /* PCPS Acquisition configuration */ std::string device_name = "uio0"; diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 0caa240f0..312c45c8f 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -73,7 +73,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con tx_bandwidth_(configuration->property(role + ".tx_bandwidth", static_cast(500000))), Fpass_(configuration->property(role + ".Fpass", static_cast(0.0))), Fstop_(configuration->property(role + ".Fstop", static_cast(0.0))), - num_freq_bands_(2), + num_input_files_(1), dma_buff_offset_pos_(0), in_stream_(in_stream), out_stream_(out_stream), @@ -95,16 +95,14 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con { const double seconds_to_skip = configuration->property(role + ".seconds_to_skip", 0.0); const size_t header_size = configuration->property(role + ".header_size", 0); - const int num_ch_rx1 = configuration->property("Channels_1C.count", 0) + - configuration->property("Channels_1B.count", 0); - const int num_ch_rx2 = (configuration->property("Channels_L2.count", 0) > 0) ? configuration->property("Channels_L2.count", 0) : configuration->property("Channels_L5.count", 0) + configuration->property("Channels_5X.count", 0); - // number of frequency bands - if (num_ch_rx2 == 0) - { - num_freq_bands_ = 1; - } + const bool enable_rx1_band((configuration->property("Channels_1C.count", 0) > 0) || + (configuration->property("Channels_1B.count", 0) > 0)); + const bool enable_rx2_band((configuration->property("Channels_L2.count", 0) > 0) || + (configuration->property("Channels_L5.count", 0) > 0) || + (configuration->property("Channels_5X.count", 0) > 0)); + const uint32_t num_freq_bands = ((enable_rx1_band == true) and (enable_rx2_band == true)) ? 2 : 1; if (freq0_ == 0) { // use ".freq0" @@ -132,6 +130,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con if (filename0_.empty()) { + num_input_files_ = 2; filename0_ = configuration->property(role + ".filename0", empty_string); filename1_ = configuration->property(role + ".filename1", empty_string); } @@ -141,7 +140,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con // if more than one input file are specified then the DMA transfer the samples to both the L1 and the L2/L5 frequency channels. if (filename1_.empty()) { - if (num_ch_rx1 != 0) + if (enable_rx1_band) { dma_buff_offset_pos_ = 2; } @@ -427,14 +426,14 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con return; } - buffer_monitor_fpga = std::make_shared(device_io_name_buffer_monitor, num_freq_bands_, dump_, dump_filename); + buffer_monitor_fpga = std::make_shared(device_io_name_buffer_monitor, num_freq_bands, dump_, dump_filename); thread_buffer_monitor = std::thread([&] { run_buffer_monitor_process(); }); } // dynamic bits selection if (enable_dynamic_bit_selection_) { - dynamic_bit_selection_fpga = std::make_shared(num_freq_bands_); + dynamic_bit_selection_fpga = std::make_shared(enable_rx1_band, enable_rx2_band); thread_dynamic_bit_selection = std::thread([&] { run_dynamic_bit_selection_process(); }); } @@ -559,7 +558,8 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0_, cons } } - // skip the initial samples if needed + // skip the initial samples if neededsrc/algorithms/signal_source/libs/ad9361_manager.cc + uint64_t bytes_to_skeep = samples_to_skip * item_size; try { @@ -607,7 +607,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0_, cons // if only one frequency band is used then clear the samples corresponding to the unused frequency band uint32_t dma_index = 0; - if (num_freq_bands_ == 1) + if (num_input_files_ == 1) { // if only one file is enabled then clear the samples corresponding to the frequency band that is not used. for (int index0 = 0; index0 < (nread_elements); index0 += 2) @@ -660,7 +660,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0_, cons } // read filename 1 (if enabled) - if (num_freq_bands_ > 1) + if (num_input_files_ > 1) { dma_index = 0; try @@ -781,7 +781,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0_, cons std::cerr << "Exception closing file " << filename0_ << '\n'; } - if (num_freq_bands_ > 1) + if (num_input_files_ > 1) { try { diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h index a78b1aa00..bedd25ad5 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h @@ -23,11 +23,7 @@ #include "concurrent_queue.h" #include "fpga_buffer_monitor.h" -#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture #include "fpga_dma-proxy.h" -#else -#include "fpga_ezdma.h" -#endif #include "fpga_dynamic_bit_selection.h" #include "fpga_switch.h" #include "gnss_block_interface.h" @@ -145,7 +141,7 @@ private: float Fpass_; float Fstop_; - uint32_t num_freq_bands_; + uint32_t num_input_files_; uint32_t dma_buff_offset_pos_; uint32_t in_stream_; uint32_t out_stream_; diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 92da88664..a5d582116 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -19,13 +19,8 @@ if(ENABLE_FPGA OR ENABLE_AD9361) set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_dynamic_bit_selection.h) set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_buffer_monitor.cc) set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_buffer_monitor.h) - if(ARCH_64BITS) - set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_dma-proxy.cc) - set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_dma-proxy.h) - else() - set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_ezdma.cc) - set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_ezdma.h) - endif() + set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_dma-proxy.cc) + set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_dma-proxy.h) endif() diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc index ccf02220f..4e0e49aeb 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.cc +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -337,6 +337,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_, struct iio_channel *rx_chan0; // stream channel 0 struct iio_channel *rx_chan1; // stream channel 1 struct iio_channel *chn; // phy channel + struct iio_channel *lo_chn; // phy channel int ret; @@ -419,12 +420,12 @@ bool config_ad9361_rx_local(uint64_t bandwidth_, } // Configure LO channel std::cout << "* Acquiring " << RX_DEV_A << " LO RX channel 0\n"; - if (!get_lo_chan(ad9361_phy, RX, 0, &chn)) + if (!get_lo_chan(ad9361_phy, RX, 0, &lo_chn)) { std::cout << "RX LO channel 0not found\n"; throw std::runtime_error("RX LO channel 0not found"); } - wr_ch_lli(chn, "frequency", freq0_); + wr_ch_lli(lo_chn, "frequency", freq0_); if (enable_ad9361_b) { @@ -485,7 +486,10 @@ bool config_ad9361_rx_local(uint64_t bandwidth_, if (rx2_enable_) { iio_channel_enable(rx_chan1); - ad9361_fmcomms5_multichip_sync(ctx, FIXUP_INTERFACE_TIMING | CHECK_SAMPLE_RATES); + if (enable_ad9361_b) + { + ad9361_fmcomms5_multichip_sync(ctx, FIXUP_INTERFACE_TIMING | CHECK_SAMPLE_RATES); + } } if (!rx1_enable_ and !rx2_enable_) { diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index c897e40f5..d71056582 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -26,38 +26,24 @@ #include // for cout #include // for mmap -Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(uint32_t num_freq_bands) - : d_num_freq_bands(num_freq_bands) +Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(bool enable_rx1_band, bool enable_rx2_band) + : d_enable_rx1_band(enable_rx1_band), d_enable_rx2_band(enable_rx2_band) { - d_map_base = std::vector(d_num_freq_bands); - d_device_descriptors = std::vector(d_num_freq_bands); - d_shift_out_bits = std::vector(d_num_freq_bands); - for (uint32_t k = 0; k < d_num_freq_bands; k++) + if (d_enable_rx1_band) { - // find the uio device file corresponding to the dynamic bit selector 0 module. - std::string device_name; - if (find_uio_dev_file_name(device_name, dyn_bit_sel_device_name, 0) < 0) - { - std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; - return; - } - // dynamic bits selection corresponding to frequency band 1 - if ((d_device_descriptors[k] = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) - { - LOG(WARNING) << "Cannot open deviceio" << device_name; - } - d_map_base[k] = reinterpret_cast(mmap(nullptr, FPGA_PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptors[k], 0)); + open_device(&d_map_base_freq_band_1, d_dev_descr_freq_band_1, 0); - if (d_map_base[k] == reinterpret_cast(-1)) - { - LOG(WARNING) << "Cannot map the FPGA dynamic bit selection module in frequency band 1 into tracking memory"; - std::cout << "Could not map dynamic bit selection memory corresponding to frequency band 1.\n"; - } + // init bit selection corresponding to frequency band 1 + d_shift_out_bits_freq_band_1 = shift_out_bits_default; + d_map_base_freq_band_1[0] = d_shift_out_bits_freq_band_1; + } + if (d_enable_rx2_band) + { + open_device(&d_map_base_freq_band_2, d_dev_descr_freq_band_2, 1); - // init bit selection corresopnding to frequency band 1 - d_shift_out_bits[k] = shift_out_bits_default; - d_map_base[k][0] = d_shift_out_bits[k]; + // init bit selection corresponding to frequency band 1 + d_shift_out_bits_freq_band_2 = shift_out_bits_default; + d_map_base_freq_band_2[0] = d_shift_out_bits_freq_band_2; } DLOG(INFO) << "Dynamic bit selection FPGA class created"; } @@ -65,48 +51,87 @@ Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(uint32_t num_freq_bands) Fpga_dynamic_bit_selection::~Fpga_dynamic_bit_selection() { - close_devices(); + if (d_enable_rx1_band) + { + close_device(d_map_base_freq_band_1, d_dev_descr_freq_band_1); + } + if (d_enable_rx2_band) + { + close_device(d_map_base_freq_band_2, d_dev_descr_freq_band_2); + } } void Fpga_dynamic_bit_selection::bit_selection() { - for (uint32_t k = 0; k < d_num_freq_bands; k++) + if (d_enable_rx1_band) { - // estimated signal power - uint32_t rx_signal_power = d_map_base[k][1]; + bit_selection_per_rf_band(d_map_base_freq_band_1, d_shift_out_bits_freq_band_1); + } - // dynamic bit selection - if (rx_signal_power > Power_Threshold_High) - { - if (d_shift_out_bits[k] < shift_out_bit_max) - { - d_shift_out_bits[k] = d_shift_out_bits[k] + 1; - } - } - else if (rx_signal_power < Power_Threshold_Low) - { - if (d_shift_out_bits[k] > shift_out_bits_min) - { - d_shift_out_bits[k] = d_shift_out_bits[k] - 1; - } - } - - // update bit selection corresopnding to frequency band 1 - d_map_base[k][0] = d_shift_out_bits[k]; + if (d_enable_rx2_band) + { + bit_selection_per_rf_band(d_map_base_freq_band_2, d_shift_out_bits_freq_band_2); } } - -void Fpga_dynamic_bit_selection::close_devices() +void Fpga_dynamic_bit_selection::open_device(volatile unsigned **d_map_base, int &d_dev_descr, int freq_band) { - for (uint32_t k = 0; k < d_num_freq_bands; k++) + // find the uio device file corresponding to the dynamic bit selector 0 module. + std::string device_name; + if (find_uio_dev_file_name(device_name, dyn_bit_sel_device_name, freq_band) < 0) { - auto *aux = const_cast(d_map_base[k]); - if (munmap(static_cast(aux), FPGA_PAGE_SIZE) == -1) - { - std::cout << "Failed to unmap memory uio\n"; - } - close(d_device_descriptors[k]); + std::cerr << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; + std::cout << "Cannot find the FPGA uio device file corresponding to device name " << dyn_bit_sel_device_name << '\n'; + return; + } + // dynamic bits selection corresponding to frequency band 1 + if ((d_dev_descr = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << device_name; + std::cout << "Cannot open deviceio" << device_name << std::endl; + } + *d_map_base = reinterpret_cast(mmap(nullptr, FPGA_PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_dev_descr, 0)); + + if (*d_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA dynamic bit selection module in frequency band 1 into tracking memory"; + std::cout << "Could not map dynamic bit selection memory corresponding to frequency band 1.\n"; } } + +void Fpga_dynamic_bit_selection::bit_selection_per_rf_band(volatile unsigned *d_map_base, uint32_t shift_out_bits) +{ + // estimated signal power + uint32_t rx_signal_power = d_map_base[1]; + + // dynamic bit selection + if (rx_signal_power > Power_Threshold_High) + { + if (shift_out_bits < shift_out_bit_max) + { + shift_out_bits = shift_out_bits + 1; + } + } + else if (rx_signal_power < Power_Threshold_Low) + { + if (shift_out_bits > shift_out_bits_min) + { + shift_out_bits = shift_out_bits - 1; + } + } + + // update bit selection corresopnding to frequency band 1 + d_map_base[0] = shift_out_bits; +} + +void Fpga_dynamic_bit_selection::close_device(volatile unsigned *d_map_base, int &d_dev_descr) +{ + auto *aux = const_cast(d_map_base); + if (munmap(static_cast(aux), FPGA_PAGE_SIZE) == -1) + { + std::cout << "Failed to unmap memory uio\n"; + } + close(d_dev_descr); +} diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h index f5454e299..3f4b73a5a 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.h @@ -43,7 +43,7 @@ public: /*! * \brief Constructor */ - explicit Fpga_dynamic_bit_selection(uint32_t num_freq_bands); + explicit Fpga_dynamic_bit_selection(bool enable_rx1_band, bool enable_rx2_band); /*! * \brief Destructor @@ -69,13 +69,18 @@ private: static const uint32_t Power_Threshold_High = 9000; static const uint32_t Power_Threshold_Low = 3000; - void close_devices(void); + void open_device(volatile unsigned **d_map_base, int &d_dev_descr, int freq_band); + void bit_selection_per_rf_band(volatile unsigned *d_map_base, uint32_t shift_out_bits); + void close_device(volatile unsigned *d_map_base, int &d_dev_descr); - std::vector d_map_base; - std::vector d_device_descriptors; - std::vector d_shift_out_bits; - - uint32_t d_num_freq_bands; // number of frequency bands + volatile unsigned *d_map_base_freq_band_1; + volatile unsigned *d_map_base_freq_band_2; + int d_dev_descr_freq_band_1; + int d_dev_descr_freq_band_2; + uint32_t d_shift_out_bits_freq_band_1; + uint32_t d_shift_out_bits_freq_band_2; + bool d_enable_rx1_band; + bool d_enable_rx2_band; }; diff --git a/src/core/libs/gnss_sdr_fpga_sample_counter.cc b/src/core/libs/gnss_sdr_fpga_sample_counter.cc index 6aa5c44a8..d67ea3b37 100644 --- a/src/core/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/core/libs/gnss_sdr_fpga_sample_counter.cc @@ -206,7 +206,7 @@ int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__(( out[0].Channel_ID = -1; out[0].fs = fs; - if ((sample_counter - last_sample_counter) > samples_per_report) + if ((sample_counter - last_sample_counter) >= samples_per_report) { last_sample_counter = sample_counter; From 3df8b9e83f80b92e3ad408094db250a898c5e576 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 20 Dec 2023 17:01:24 +0100 Subject: [PATCH 119/142] remove EZDMA files --- .../signal_source/libs/fpga_ezdma.cc | 68 ------------------- .../signal_source/libs/fpga_ezdma.h | 64 ----------------- 2 files changed, 132 deletions(-) delete mode 100644 src/algorithms/signal_source/libs/fpga_ezdma.cc delete mode 100644 src/algorithms/signal_source/libs/fpga_ezdma.h diff --git a/src/algorithms/signal_source/libs/fpga_ezdma.cc b/src/algorithms/signal_source/libs/fpga_ezdma.cc deleted file mode 100644 index cb8f5497e..000000000 --- a/src/algorithms/signal_source/libs/fpga_ezdma.cc +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * \file fpga_edma.cc - * \brief FPGA DMA control using the ezdma (See https://github.com/jeremytrimble/ezdma). - * \author Marc Majoral, mmajoral(at)cttc.es - * - * ----------------------------------------------------------------------------- - * - * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. - * This file is part of GNSS-SDR. - * - * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) - * SPDX-License-Identifier: GPL-3.0-or-later - * - * ----------------------------------------------------------------------------- - */ -#include "fpga_ezdma.h" -#include -#include // for std::cerr -#include - -int Fpga_DMA::DMA_open() -{ - tx_fd = open("/dev/loop_tx", O_WRONLY); - if (tx_fd < 1) - { - return tx_fd; - } - // note: a problem was identified with the DMA: when switching from tx to rx or rx to tx mode - // the DMA transmission may hang. This problem will be fixed soon. - // for the moment this problem can be avoided by closing and opening the DMA a second time - if (close(tx_fd) < 0) - { - std::cerr << "Error closing loop device " << '\n'; - return -1; - } - // open the DMA a second time - tx_fd = open("/dev/loop_tx", O_WRONLY); - if (tx_fd < 1) - { - std::cerr << "Cannot open loop device\n"; - // stop the receiver - return tx_fd; - } - return 0; -} - - -int8_t *Fpga_DMA::get_buffer_address() -{ - return buffer; -} - - -int Fpga_DMA::DMA_write(int nbytes) const -{ - const int num_bytes_sent = write(tx_fd, buffer, nbytes); - if (num_bytes_sent != nbytes) - { - return -1; - } - return 0; -} - - -int Fpga_DMA::DMA_close() const -{ - return close(tx_fd); -} diff --git a/src/algorithms/signal_source/libs/fpga_ezdma.h b/src/algorithms/signal_source/libs/fpga_ezdma.h deleted file mode 100644 index 801d2a6b7..000000000 --- a/src/algorithms/signal_source/libs/fpga_ezdma.h +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file fpga_ezdma.h - * \brief FPGA DMA control using the ezdma (See https://github.com/jeremytrimble/ezdma). - * \author Marc Majoral, mmajoral(at)cttc.es - * - * ----------------------------------------------------------------------------- - * - * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. - * This file is part of GNSS-SDR. - * - * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) - * SPDX-License-Identifier: GPL-3.0-or-later - * - * ----------------------------------------------------------------------------- - */ - - -#ifndef GNSS_SDR_FPGA_EDMA_H -#define GNSS_SDR_FPGA_EDMA_H - -#include // for std::int8_t - -/*! - * \brief Class that controls the switch DMA in the FPGA - */ -class Fpga_DMA -{ -public: - /*! - * \brief Default constructor. - */ - Fpga_DMA() = default; - - /*! - * \brief Default destructor. - */ - ~Fpga_DMA() = default; - - /*! - * \brief Open the DMA device driver. - */ - int DMA_open(void); - - /*! - * \brief Obtain DMA buffer address. - */ - int8_t *get_buffer_address(void); // NOLINT(readability-make-member-function-const) - - /*! - * \brief Transfer DMA data - */ - int DMA_write(int nbytes) const; - - /*! - * \brief Close the DMA device driver - */ - int DMA_close(void) const; - -private: - static const uint32_t DMA_MAX_BUFFER_SIZE = 4 * 16384; // 4-channel 16384-sample buffers - int8_t buffer[DMA_MAX_BUFFER_SIZE]; - int tx_fd; -}; -#endif // GNSS_SDR_FPGA_EDMA_H From dfbdd4bc76f5e7dd8c89a22bba262ab008f31d8d Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 20 Dec 2023 18:01:40 +0100 Subject: [PATCH 120/142] fix comment --- .../signal_source/adapters/ad9361_fpga_signal_source.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 312c45c8f..488c80ead 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -558,8 +558,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0_, cons } } - // skip the initial samples if neededsrc/algorithms/signal_source/libs/ad9361_manager.cc - + // skip the initial samples if needed uint64_t bytes_to_skeep = samples_to_skip * item_size; try { From d8fabdb4acc6ddbd0ff2fb563ea50c6c57e0c0c6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 10:18:12 +0100 Subject: [PATCH 121/142] Add [[maybe_unused]] to silence warnings --- src/algorithms/signal_source/libs/ad9361_manager.cc | 2 +- src/algorithms/signal_source/libs/ad936x_iio_custom.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc index 4e0e49aeb..977cc17df 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.cc +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -157,7 +157,7 @@ void cfg_ad9361_streaming_ch(struct stream_cfg *cfg, iio_channel *chn) int setup_filter(const std::string &filter_source_, uint64_t bandwidth_, uint64_t sample_rate_, uint64_t freq_, const std::string &rf_port_select_, - struct iio_device *ad9361_phy_dev, struct iio_channel *rx_chan, struct iio_channel *chn, int chid, std::string filter_filename_, float Fpass_, float Fstop_) + struct iio_device *ad9361_phy_dev, struct iio_channel *rx_chan, struct iio_channel *chn, int chid, std::string filter_filename_, [[maybe_unused]] float Fpass_, [[maybe_unused]] float Fstop_) { int ret; if (filter_source_ == "Off") diff --git a/src/algorithms/signal_source/libs/ad936x_iio_custom.cc b/src/algorithms/signal_source/libs/ad936x_iio_custom.cc index e487d29b5..23474891c 100644 --- a/src/algorithms/signal_source/libs/ad936x_iio_custom.cc +++ b/src/algorithms/signal_source/libs/ad936x_iio_custom.cc @@ -805,7 +805,7 @@ double ad936x_iio_custom::get_rx_gain(int ch_num) } -bool ad936x_iio_custom::calibrate(int ch, double bw_hz) +bool ad936x_iio_custom::calibrate([[maybe_unused]] int ch, [[maybe_unused]] double bw_hz) { if (check_device() == false) return false; // todo From 4916c6c8e8b7ad8a6ce915540c3ab9bdd752a625 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 13:57:41 +0100 Subject: [PATCH 122/142] Fix member initializations, potential data race conditions, and minor performance issues detected by Coverity Scan Never throw from main --- src/algorithms/PVT/libs/rinex_printer.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 3 +- .../acquisition/libs/acq_conf_fpga.cc | 3 +- .../signal_source/libs/ad9361_manager.cc | 4 +- .../libs/fpga_dynamic_bit_selection.cc | 8 +- .../dll_pll_veml_tracking_fpga.cc | 5 +- .../gps_l1_ca_gaussian_tracking_cc.cc | 9 +- .../tracking/libs/fpga_multicorrelator.cc | 14 +- src/core/receiver/gnss_flowgraph.cc | 1 + ...e1_pcps_ambiguous_acquisition_test_fpga.cc | 7 +- .../gps_l1_ca_pcps_acquisition_test_fpga.cc | 6 +- .../filter/fir_filter_test.cc | 2 +- .../filter/notch_filter_test.cc | 3 +- .../filter/pulse_blanking_filter_test.cc | 3 +- src/utils/front-end-cal/main.cc | 682 +++++++++--------- src/utils/rinex-tools/obsdiff.cc | 43 +- 16 files changed, 438 insertions(+), 357 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 92098517f..6c2d322d5 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -5651,7 +5651,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.E1B_DVS); - std::string SVhealth_str = std::move(E5B_HS) + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); + std::string SVhealth_str = std::move(E5B_HS) + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::move(E1B_DVS) + std::move(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); line += Rinex_Printer::doub2for(static_cast(SVhealth), 18, 2); line += std::string(1, ' '); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index d0c0c3849..92ec51781 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -33,6 +33,7 @@ #include // for uint32_t #include // for shared_ptr #include // for string +#include // for move /** \addtogroup Acquisition * \{ */ @@ -118,7 +119,7 @@ public: */ inline void set_channel_fsm(std::weak_ptr channel_fsm) { - d_channel_fsm = channel_fsm; + d_channel_fsm = std::move(channel_fsm); } /*! diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc index 5c1e9e0c2..838ab3ae6 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.cc +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -21,6 +21,7 @@ #include #include #include +#include void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t sel_queue_fpga, uint32_t blk_exp, uint32_t downsampling_factor_default, double chip_rate, double code_length_chips) @@ -58,7 +59,7 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; throw std::exception(); } - device_name = device_io_name; + device_name = std::move(device_io_name); // exclusion limit excludelimit = static_cast(1 + ceil((1.0 / chip_rate) * static_cast(fs_in))); diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc index 977cc17df..7e7e3fa74 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.cc +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -450,7 +450,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_, { return false; } - if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq1_, rf_port_select_, ad9361_phy_B, rx_chan1, chn, 0, filter_filename_, Fpass_, Fstop_) == -1) + if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq1_, rf_port_select_, ad9361_phy_B, rx_chan1, chn, 0, std::move(filter_filename_), Fpass_, Fstop_) == -1) { return false; } @@ -472,7 +472,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_, std::cout << rx_stream_dev_a << " channel 1 not found\n"; throw std::runtime_error(rx_stream_dev_a + "RX channel 1 not found"); } - if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq0_, rf_port_select_, ad9361_phy, rx_chan1, chn, 1, filter_filename_, Fpass_, Fstop_) == -1) + if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq0_, rf_port_select_, ad9361_phy, rx_chan1, chn, 1, std::move(filter_filename_), Fpass_, Fstop_) == -1) { return false; } diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index d71056582..e5725881e 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -29,6 +29,12 @@ Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(bool enable_rx1_band, bool enable_rx2_band) : d_enable_rx1_band(enable_rx1_band), d_enable_rx2_band(enable_rx2_band) { + d_map_base_freq_band_1 = nullptr; + d_map_base_freq_band_2 = nullptr; + d_dev_descr_freq_band_1 = 0; + d_dev_descr_freq_band_2 = 0; + d_shift_out_bits_freq_band_1 = 0; + d_shift_out_bits_freq_band_2 = 0; if (d_enable_rx1_band) { open_device(&d_map_base_freq_band_1, d_dev_descr_freq_band_1, 0); @@ -41,7 +47,7 @@ Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(bool enable_rx1_band, boo { open_device(&d_map_base_freq_band_2, d_dev_descr_freq_band_2, 1); - // init bit selection corresponding to frequency band 1 + // init bit selection corresponding to frequency band 2 d_shift_out_bits_freq_band_2 = shift_out_bits_default; d_map_base_freq_band_2[0] = d_shift_out_bits_freq_band_2; } 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 68df0ec82..070f0d46f 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 @@ -446,7 +446,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { @@ -1383,6 +1383,7 @@ void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) d_acquisition_gnss_synchro = p_gnss_synchro; if (p_gnss_synchro->PRN > 0) { + gr::thread::scoped_lock lock(d_setlock); // A set_gnss_synchro command with a valid PRN is received when the system is going to run acquisition with that PRN. // We can use this command to pre-initialize tracking parameters and variables before the actual acquisition process takes place. // In this way we minimize the latency between acquisition and tracking once the acquisition has been made. @@ -1527,8 +1528,8 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { case 1: // Pull-in { - d_worker_is_done = false; boost::mutex::scoped_lock lock(d_mutex); + d_worker_is_done = false; while (!d_worker_is_done) { d_m_condition.wait(lock); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index df97429eb..6c8e82231 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -308,10 +308,6 @@ void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking() sys = std::string(1, d_acquisition_gnss_synchro->System); - // DEBUG OUTPUT - std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; - // enable tracking d_pull_in = true; d_enable_tracking = true; @@ -319,6 +315,10 @@ void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking() LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; + + gr::thread::scoped_lock l(d_setlock); + std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; + LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; } @@ -776,6 +776,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { + gr::thread::scoped_lock l(d_setlock); std::cout << "Loss of lock in channel " << d_channel << "!\n"; LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 0269ed25d..99f5f778c 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -57,20 +57,26 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, d_Prompt_Data(nullptr), d_shifts_chips(nullptr), d_prompt_data_shift(nullptr), - d_rem_code_phase_chips(0), - d_code_phase_step_chips(0), - d_rem_carrier_phase_in_rad(0), - d_phase_step_rad(0), + d_rem_code_phase_chips(0.0), + d_code_phase_step_chips(0.0), + d_code_phase_rate_step_chips(0.0), + d_rem_carrier_phase_in_rad(0.0), + d_phase_step_rad(0.0), + d_carrier_phase_rate_step_rad(0.0), d_code_length_samples(code_length_chips * code_samples_per_chip), d_n_correlators(n_correlators), d_device_descriptor(0), d_map_base(nullptr), d_correlator_length_samples(0), d_code_phase_step_chips_num(0), + d_code_phase_rate_step_chips_num(0), d_rem_carr_phase_rad_int(0), d_phase_step_rad_int(0), + d_carrier_phase_rate_step_rad_int(0), d_ca_codes(ca_codes), d_data_codes(data_codes), + d_secondary_code_0_length(0), + d_secondary_code_1_length(0), d_track_pilot(track_pilot), d_secondary_code_enabled(false) { diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 1c913a8fc..47e35bfbd 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -2097,6 +2097,7 @@ void GNSSFlowgraph::set_configuration(const std::shared_ptr lock(signal_list_mutex_); for (int i = 0; i < channels_count_; i++) { if (channels_state_[i] == 1) diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc index 3206fdc67..714810fd7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc @@ -91,6 +91,7 @@ GalileoE1PcpsAmbiguousAcquisitionTestFpga::GalileoE1PcpsAmbiguousAcquisitionTest doppler_max = 5000; doppler_step = 100; + nsamples_to_transfer = 0; } @@ -280,7 +281,7 @@ public: } private: - bool acquisition_successful; + bool acquisition_successful{}; }; @@ -310,7 +311,7 @@ bool GalileoE1PcpsAmbiguousAcquisitionTestFpga::acquire_signal() args.scaling_factor = DMA_SIGNAL_SCALING_FACTOR; std::string file = "data/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - args.file = file; // DMA file configuration + args.file = std::move(file); // DMA file configuration // instantiate the FPGA switch and set the // switch position to DMA. @@ -348,7 +349,7 @@ bool GalileoE1PcpsAmbiguousAcquisitionTestFpga::acquire_signal() args.nsamples_tx = nsamples_to_transfer; // run the acquisition. The acquisition must run in a separate thread because it is a blocking function - args_acq.acquisition = acquisition; + args_acq.acquisition = std::move(acquisition); if (pthread_create(&thread_acquisition, nullptr, handler_acquisition_galileo_e1_pcps_ambiguous_acq_test, reinterpret_cast(&args_acq)) < 0) { diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index eb5d8fe2a..4bc54fba4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -279,7 +279,7 @@ public: } private: - bool acquisition_successful; + bool acquisition_successful{}; }; @@ -309,7 +309,7 @@ bool GpsL1CaPcpsAcquisitionTestFpga::acquire_signal() args.scaling_factor = DMA_SIGNAL_SCALING_FACTOR; std::string file = "data/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - args.file = file; // DMA file configuration + args.file = std::move(file); // DMA file configuration // instantiate the FPGA switch and set the // switch position to DMA. @@ -347,7 +347,7 @@ bool GpsL1CaPcpsAcquisitionTestFpga::acquire_signal() args.nsamples_tx = nsamples_to_transfer; // run the acquisition. The acquisition must run in a separate thread because it is a blocking function - args_acq.acquisition = acquisition; + args_acq.acquisition = std::move(acquisition); if (pthread_create(&thread_acquisition, nullptr, handler_acquisition_gps_l1_acq_test, reinterpret_cast(&args_acq)) < 0) { diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index ec1b783ef..97b27f51c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -224,7 +224,7 @@ TEST_F(FirFilterTest, ConnectAndRunGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "gr_complex"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc index 36c7346a2..cf4cde035 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef GR_GREATER_38 #include #else @@ -177,7 +178,7 @@ TEST_F(NotchFilterTest, ConnectAndRunGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "gr_complex"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc index 63038b5f1..4cb3c5c43 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef GR_GREATER_38 #include #else @@ -176,7 +177,7 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRunGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "gr_complex"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 4915b35b5..972e4a21e 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -269,18 +269,26 @@ static time_t utc_time(int week, int64_t tow) int main(int argc, char** argv) { - const std::string intro_help( - std::string("\n RTL-SDR E4000 RF front-end center frequency and sampling rate calibration tool that uses GPS signals\n") + - "Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)\n" + - "This program comes with ABSOLUTELY NO WARRANTY;\n" + - "See COPYING file to see a copy of the General Public License\n \n"); + try + { + const std::string intro_help( + std::string("\n RTL-SDR E4000 RF front-end center frequency and sampling rate calibration tool that uses GPS signals\n") + + "Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)\n" + + "This program comes with ABSOLUTELY NO WARRANTY;\n" + + "See COPYING file to see a copy of the General Public License\n \n"); - gflags::SetUsageMessage(intro_help); - google::SetVersionString(FRONT_END_CAL_VERSION); - gflags::ParseCommandLineFlags(&argc, &argv, true); - - std::cout << "Initializing... Please wait.\n"; + gflags::SetUsageMessage(intro_help); + google::SetVersionString(FRONT_END_CAL_VERSION); + gflags::ParseCommandLineFlags(&argc, &argv, true); + std::cout << "Initializing... Please wait.\n"; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + std::cout << "front-end-cal program ended.\n"; + return 1; + } google::InitGoogleLogging(argv[0]); if (FLAGS_log_dir.empty()) { @@ -292,358 +300,390 @@ int main(int argc, char** argv) } else { - const fs::path p(FLAGS_log_dir); - if (!fs::exists(p)) + try { - std::cout << "The path " - << FLAGS_log_dir - << " does not exist, attempting to create it" - << '\n'; - fs::create_directory(p); + const fs::path p(FLAGS_log_dir); + if (!fs::exists(p)) + { + std::cout << "The path " + << FLAGS_log_dir + << " does not exist, attempting to create it" + << '\n'; + errorlib::error_code ec; + if (!fs::create_directory(p, ec)) + { + std::cerr << "Could not create the " << FLAGS_log_dir << " folder. Front-end-cal program ended.\n"; + gflags::ShutDownCommandLineFlags(); + return 1; + } + } + std::cout << "Logging with be done at " + << FLAGS_log_dir << '\n'; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + std::cerr << "Could not create the " << FLAGS_log_dir << " folder. Front-end-cal program ended.\n"; + gflags::ShutDownCommandLineFlags(); + return 1; } - std::cout << "Logging with be done at " - << FLAGS_log_dir << '\n'; } // 0. Instantiate the FrontEnd Calibration class - FrontEndCal front_end_cal; - - // 1. Load configuration parameters from config file - std::shared_ptr configuration = std::make_shared(FLAGS_config_file); - front_end_cal.set_configuration(configuration); - - // 2. Get SUPL information from server: Ephemeris record, assistance info and TOW try { - if (front_end_cal.get_ephemeris() == true) - { - std::cout << "SUPL data received OK!\n"; - } - else - { - std::cout << "Failure connecting to SUPL server\n"; - } - } - catch (const boost::exception& e) - { - std::cout << "Failure connecting to SUPL server\n"; - } + FrontEndCal front_end_cal; - // 3. Capture some front-end samples to hard disk - try - { - if (front_end_capture(configuration)) - { - std::cout << "Front-end RAW samples captured\n"; - } - else - { - std::cout << "Failure capturing front-end samples\n"; - } - } - catch (const boost::bad_lexical_cast& e) - { - std::cout << "Exception caught while capturing samples (bad lexical cast)\n"; - } - catch (const std::exception& e) - { - std::cout << "Exception caught while capturing samples: " << e.what() << '\n'; - } - catch (...) - { - std::cout << "Unexpected exception\n"; - } + // 1. Load configuration parameters from config file + std::shared_ptr configuration = std::make_shared(FLAGS_config_file); + front_end_cal.set_configuration(configuration); - // 4. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) - gr::top_block_sptr top_block; - top_block = gr::make_top_block("Acquisition test"); - - // Satellite signal definition - gnss_synchro = Gnss_Synchro(); - gnss_synchro.Channel_ID = 0; - gnss_synchro.System = 'G'; - std::string signal = "1C"; - signal.copy(gnss_synchro.Signal, 2, 0); - gnss_synchro.PRN = 1; - - int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); - configuration->set_property("Acquisition.max_dwells", "10"); - - auto acquisition = std::make_shared(configuration.get(), "Acquisition", 1, 1); - - acquisition->set_channel(1); - acquisition->set_gnss_synchro(&gnss_synchro); - acquisition->set_threshold(configuration->property("Acquisition.threshold", 2.0)); - acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); - acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); - - gr::block_sptr source; - source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); -#if GNURADIO_USES_STD_POINTERS - std::shared_ptr msg_rx; -#else - boost::shared_ptr msg_rx; -#endif - try - { - msg_rx = FrontEndCal_msg_rx_make(); - } - catch (const std::exception& e) - { - std::cout << "Failure connecting the message port system: " << e.what() << '\n'; - exit(0); - } - - try - { - acquisition->connect(top_block); - top_block->connect(source, 0, acquisition->get_left_block(), 0); - top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - catch (const std::exception& e) - { - std::cout << "Failure connecting the GNU Radio blocks: " << e.what() << '\n'; - } - - // 5. Run the flowgraph - // Get visible GPS satellites (positive acquisitions with Doppler measurements) - // Compute Doppler estimations - - // todo: Fix the front-end cal to support new channel internal message system (no more external queues) - std::map doppler_measurements_map; - std::map cn0_measurements_map; - - std::thread ch_thread; - - // record startup time - std::chrono::time_point start; - std::chrono::time_point end; - std::chrono::duration elapsed_seconds{}; - start = std::chrono::system_clock::now(); - - bool start_msg = true; - - for (unsigned int PRN = 1; PRN < 33; PRN++) - { - gnss_synchro.PRN = PRN; - acquisition->set_gnss_synchro(&gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - acquisition->reset(); - stop = false; + // 2. Get SUPL information from server: Ephemeris record, assistance info and TOW try { - ch_thread = std::thread(wait_message); - } - catch (const std::exception& e) - { - LOG(INFO) << "Exception caught (thread resource error)"; - } - top_block->run(); - if (start_msg == true) - { - std::cout << "Searching for GPS Satellites in L1 band...\n"; - std::cout << "["; - start_msg = false; - } - if (!gnss_sync_vector.empty()) - { - std::cout << " " << PRN << " "; - double doppler_measurement_hz = 0; - for (auto& it : gnss_sync_vector) + if (front_end_cal.get_ephemeris() == true) { - doppler_measurement_hz += it.Acq_doppler_hz; + std::cout << "SUPL data received OK!\n"; + } + else + { + std::cout << "Failure connecting to SUPL server\n"; } - doppler_measurement_hz = doppler_measurement_hz / gnss_sync_vector.size(); - doppler_measurements_map.insert(std::pair(PRN, doppler_measurement_hz)); - } - else - { - std::cout << " . "; - } - try - { - channel_internal_queue.push(3); } catch (const boost::exception& e) { - LOG(INFO) << "Exception caught while pushing to the internal queue."; + std::cout << "Failure connecting to SUPL server\n"; } + + // 3. Capture some front-end samples to hard disk try { - ch_thread.join(); + if (front_end_capture(configuration)) + { + std::cout << "Front-end RAW samples captured\n"; + } + else + { + std::cout << "Failure capturing front-end samples\n"; + } + } + catch (const boost::bad_lexical_cast& e) + { + std::cout << "Exception caught while capturing samples (bad lexical cast)\n"; } catch (const std::exception& e) { - LOG(INFO) << "Exception caught while joining threads."; + std::cout << "Exception caught while capturing samples: " << e.what() << '\n'; } - gnss_sync_vector.clear(); + catch (...) + { + std::cout << "Unexpected exception\n"; + } + + // 4. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + + // Satellite signal definition + gnss_synchro = Gnss_Synchro(); + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(gnss_synchro.Signal, 2, 0); + gnss_synchro.PRN = 1; + + int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); + configuration->set_property("Acquisition.max_dwells", "10"); + + auto acquisition = std::make_shared(configuration.get(), "Acquisition", 1, 1); + + acquisition->set_channel(1); + acquisition->set_gnss_synchro(&gnss_synchro); + acquisition->set_threshold(configuration->property("Acquisition.threshold", 2.0)); + acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); + acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); + + gr::block_sptr source; + source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); #if GNURADIO_USES_STD_POINTERS - std::dynamic_pointer_cast(source)->seek(0, 0); + std::shared_ptr msg_rx; #else - boost::dynamic_pointer_cast(source)->seek(0, 0); + boost::shared_ptr msg_rx; #endif - std::cout.flush(); - } - std::cout << "]\n"; - - // report the elapsed time - end = std::chrono::system_clock::now(); - elapsed_seconds = end - start; - std::cout << "Total signal acquisition run time " - << elapsed_seconds.count() - << " [seconds]\n"; - - // 6. find TOW from SUPL assistance - double current_TOW = 0; - try - { - if (global_gps_ephemeris_map.size() > 0) + try { - std::map Eph_map; - Eph_map = global_gps_ephemeris_map.get_map_copy(); - current_TOW = Eph_map.begin()->second.tow; - - time_t t = utc_time(Eph_map.begin()->second.WN, static_cast(current_TOW)); - - std::cout << "Reference Time:\n"; - std::cout << " GPS Week: " << Eph_map.begin()->second.WN << '\n'; - std::cout << " GPS TOW: " << static_cast(current_TOW) << " " << static_cast(current_TOW) * 0.08 << '\n'; - std::cout << " ~ UTC: " << ctime(&t) << '\n'; - std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << '\n'; + msg_rx = FrontEndCal_msg_rx_make(); } - else + catch (const std::exception& e) { - std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!\n"; + std::cout << "Failure connecting the message port system: " << e.what() << '\n'; + exit(0); + } + + try + { + acquisition->connect(top_block); + top_block->connect(source, 0, acquisition->get_left_block(), 0); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the GNU Radio blocks: " << e.what() << '\n'; + } + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // Compute Doppler estimations + + // todo: Fix the front-end cal to support new channel internal message system (no more external queues) + std::map doppler_measurements_map; + std::map cn0_measurements_map; + + std::thread ch_thread; + + // record startup time + std::chrono::time_point start; + std::chrono::time_point end; + std::chrono::duration elapsed_seconds{}; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + for (unsigned int PRN = 1; PRN < 33; PRN++) + { + gnss_synchro.PRN = PRN; + acquisition->set_gnss_synchro(&gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + acquisition->reset(); + stop = false; + try + { + ch_thread = std::thread(wait_message); + } + catch (const std::exception& e) + { + LOG(INFO) << "Exception caught (thread resource error)"; + } + top_block->run(); + if (start_msg == true) + { + std::cout << "Searching for GPS Satellites in L1 band...\n"; + std::cout << "["; + start_msg = false; + } + if (!gnss_sync_vector.empty()) + { + std::cout << " " << PRN << " "; + double doppler_measurement_hz = 0; + for (auto& it : gnss_sync_vector) + { + doppler_measurement_hz += it.Acq_doppler_hz; + } + doppler_measurement_hz = doppler_measurement_hz / gnss_sync_vector.size(); + doppler_measurements_map.insert(std::pair(PRN, doppler_measurement_hz)); + } + else + { + std::cout << " . "; + } + try + { + channel_internal_queue.push(3); + } + catch (const boost::exception& e) + { + LOG(INFO) << "Exception caught while pushing to the internal queue."; + } + try + { + ch_thread.join(); + } + catch (const std::exception& e) + { + LOG(INFO) << "Exception caught while joining threads."; + } + gnss_sync_vector.clear(); +#if GNURADIO_USES_STD_POINTERS + std::dynamic_pointer_cast(source)->seek(0, 0); +#else + boost::dynamic_pointer_cast(source)->seek(0, 0); +#endif + std::cout.flush(); + } + std::cout << "]\n"; + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]\n"; + + // 6. find TOW from SUPL assistance + double current_TOW = 0; + try + { + if (global_gps_ephemeris_map.size() > 0) + { + std::map Eph_map; + Eph_map = global_gps_ephemeris_map.get_map_copy(); + current_TOW = Eph_map.begin()->second.tow; + + time_t t = utc_time(Eph_map.begin()->second.WN, static_cast(current_TOW)); + + std::cout << "Reference Time:\n"; + std::cout << " GPS Week: " << Eph_map.begin()->second.WN << '\n'; + std::cout << " GPS TOW: " << static_cast(current_TOW) << " " << static_cast(current_TOW) * 0.08 << '\n'; + std::cout << " ~ UTC: " << ctime(&t) << '\n'; + std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << '\n'; + } + else + { + std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!\n"; + gflags::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR Front-end calibration program ended.\n"; + return 0; + } + } + catch (const boost::exception& e) + { + std::cout << "Exception in getting Global ephemeris map\n"; gflags::ShutDownCommandLineFlags(); std::cout << "GNSS-SDR Front-end calibration program ended.\n"; return 0; } + + // Get user position from config file (or from SUPL using GSM Cell ID) + double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); + double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); + double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100); + + std::cout << "Reference location (defined in config file):\n"; + + std::cout << "Latitude=" << lat_deg << " [º]\n"; + std::cout << "Longitude=" << lon_deg << " [º]\n"; + std::cout << "Altitude=" << altitude_m << " [m]\n"; + + if (doppler_measurements_map.empty()) + { + std::cout << "Sorry, no GPS satellites detected in the front-end capture, please check the antenna setup...\n"; + gflags::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR Front-end calibration program ended.\n"; + return 0; + } + + std::map f_if_estimation_Hz_map; + std::map f_fs_estimation_Hz_map; + std::map f_ppm_estimation_Hz_map; + + std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Doppler analysis results:\n"; + + std::cout << "SV ID Measured [Hz] Predicted [Hz]\n"; + + for (auto& it : doppler_measurements_map) + { + try + { + double doppler_estimated_hz; + doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); + std::cout << " " << it.first << " " << it.second << " " << doppler_estimated_hz << '\n'; + // 7. Compute front-end IF and sampling frequency estimation + // Compare with the measurements and compute clock drift using FE model + double estimated_fs_Hz; + double estimated_f_if_Hz; + double f_osc_err_ppm; + front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it.second, fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm); + + f_if_estimation_Hz_map.insert(std::pair(it.first, estimated_f_if_Hz)); + f_fs_estimation_Hz_map.insert(std::pair(it.first, estimated_fs_Hz)); + f_ppm_estimation_Hz_map.insert(std::pair(it.first, f_osc_err_ppm)); + } + catch (const std::logic_error& e) + { + std::cout << "Logic error caught: " << e.what() << '\n'; + } + catch (const boost::lock_error& e) + { + std::cout << "Exception caught while reading ephemeris\n"; + } + catch (const std::exception& ex) + { + std::cout << " " << it.first << " " << it.second << " (Eph not found)\n"; + } + } + + // FINAL FE estimations + double mean_f_if_Hz = 0; + double mean_fs_Hz = 0; + double mean_osc_err_ppm = 0; + int n_elements = f_if_estimation_Hz_map.size(); + + for (auto& it : f_if_estimation_Hz_map) + { + mean_f_if_Hz += it.second; + const auto est_fs = f_fs_estimation_Hz_map.find(it.first); + if (est_fs != f_fs_estimation_Hz_map.cend()) + { + mean_fs_Hz += est_fs->second; + } + const auto est_ppm = f_ppm_estimation_Hz_map.find(it.first); + if (est_ppm != f_ppm_estimation_Hz_map.cend()) + { + mean_osc_err_ppm += est_ppm->second; + } + } + + mean_f_if_Hz /= n_elements; + mean_fs_Hz /= n_elements; + mean_osc_err_ppm /= n_elements; + + std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Parameters estimation for Elonics E4000 Front-End:\n"; + + std::cout << "Sampling frequency =" << mean_fs_Hz << " [Hz]\n"; + std::cout << "IF bias present in baseband=" << mean_f_if_Hz << " [Hz]\n"; + std::cout << "Reference oscillator error =" << mean_osc_err_ppm << " [ppm]\n"; + + std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) + << "Corrected Doppler vs. Predicted\n"; + std::cout << "SV ID Corrected [Hz] Predicted [Hz]\n"; + + for (auto& it : doppler_measurements_map) + { + try + { + double doppler_estimated_hz; + doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); + std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " " << doppler_estimated_hz << '\n'; + } + catch (const std::logic_error& e) + { + std::cout << "Logic error caught: " << e.what() << '\n'; + } + catch (const boost::lock_error& e) + { + std::cout << "Exception caught while reading ephemeris\n"; + } + catch (const std::exception& ex) + { + std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " (Eph not found)\n"; + } + } } - catch (const boost::exception& e) + catch (const std::exception& e) { - std::cout << "Exception in getting Global ephemeris map\n"; + std::cerr << "Exception: " << e.what(); gflags::ShutDownCommandLineFlags(); - std::cout << "GNSS-SDR Front-end calibration program ended.\n"; - return 0; + return 1; } - - // Get user position from config file (or from SUPL using GSM Cell ID) - double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); - double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); - double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100); - - std::cout << "Reference location (defined in config file):\n"; - - std::cout << "Latitude=" << lat_deg << " [º]\n"; - std::cout << "Longitude=" << lon_deg << " [º]\n"; - std::cout << "Altitude=" << altitude_m << " [m]\n"; - - if (doppler_measurements_map.empty()) + catch (...) { - std::cout << "Sorry, no GPS satellites detected in the front-end capture, please check the antenna setup...\n"; + std::cerr << "Unknown error\n"; gflags::ShutDownCommandLineFlags(); - std::cout << "GNSS-SDR Front-end calibration program ended.\n"; - return 0; - } - - std::map f_if_estimation_Hz_map; - std::map f_fs_estimation_Hz_map; - std::map f_ppm_estimation_Hz_map; - - std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Doppler analysis results:\n"; - - std::cout << "SV ID Measured [Hz] Predicted [Hz]\n"; - - for (auto& it : doppler_measurements_map) - { - try - { - double doppler_estimated_hz; - doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); - std::cout << " " << it.first << " " << it.second << " " << doppler_estimated_hz << '\n'; - // 7. Compute front-end IF and sampling frequency estimation - // Compare with the measurements and compute clock drift using FE model - double estimated_fs_Hz; - double estimated_f_if_Hz; - double f_osc_err_ppm; - front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it.second, fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm); - - f_if_estimation_Hz_map.insert(std::pair(it.first, estimated_f_if_Hz)); - f_fs_estimation_Hz_map.insert(std::pair(it.first, estimated_fs_Hz)); - f_ppm_estimation_Hz_map.insert(std::pair(it.first, f_osc_err_ppm)); - } - catch (const std::logic_error& e) - { - std::cout << "Logic error caught: " << e.what() << '\n'; - } - catch (const boost::lock_error& e) - { - std::cout << "Exception caught while reading ephemeris\n"; - } - catch (const std::exception& ex) - { - std::cout << " " << it.first << " " << it.second << " (Eph not found)\n"; - } - } - - // FINAL FE estimations - double mean_f_if_Hz = 0; - double mean_fs_Hz = 0; - double mean_osc_err_ppm = 0; - int n_elements = f_if_estimation_Hz_map.size(); - - for (auto& it : f_if_estimation_Hz_map) - { - mean_f_if_Hz += it.second; - const auto est_fs = f_fs_estimation_Hz_map.find(it.first); - if (est_fs != f_fs_estimation_Hz_map.cend()) - { - mean_fs_Hz += est_fs->second; - } - const auto est_ppm = f_ppm_estimation_Hz_map.find(it.first); - if (est_ppm != f_ppm_estimation_Hz_map.cend()) - { - mean_osc_err_ppm += est_ppm->second; - } - } - - mean_f_if_Hz /= n_elements; - mean_fs_Hz /= n_elements; - mean_osc_err_ppm /= n_elements; - - std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Parameters estimation for Elonics E4000 Front-End:\n"; - - std::cout << "Sampling frequency =" << mean_fs_Hz << " [Hz]\n"; - std::cout << "IF bias present in baseband=" << mean_f_if_Hz << " [Hz]\n"; - std::cout << "Reference oscillator error =" << mean_osc_err_ppm << " [ppm]\n"; - - std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) - << "Corrected Doppler vs. Predicted\n"; - std::cout << "SV ID Corrected [Hz] Predicted [Hz]\n"; - - for (auto& it : doppler_measurements_map) - { - try - { - double doppler_estimated_hz; - doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it.first, current_TOW, lat_deg, lon_deg, altitude_m); - std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " " << doppler_estimated_hz << '\n'; - } - catch (const std::logic_error& e) - { - std::cout << "Logic error caught: " << e.what() << '\n'; - } - catch (const boost::lock_error& e) - { - std::cout << "Exception caught while reading ephemeris\n"; - } - catch (const std::exception& ex) - { - std::cout << " " << it.first << " " << it.second - mean_f_if_Hz << " (Eph not found)\n"; - } + return 1; } gflags::ShutDownCommandLineFlags(); std::cout << "GNSS-SDR Front-end calibration program ended.\n"; + return 0; } diff --git a/src/utils/rinex-tools/obsdiff.cc b/src/utils/rinex-tools/obsdiff.cc index 60c74fe9f..0b156bb86 100644 --- a/src/utils/rinex-tools/obsdiff.cc +++ b/src/utils/rinex-tools/obsdiff.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include #if GNSSTK_USES_GPSTK_NAMESPACE @@ -673,7 +674,7 @@ void carrier_doppler_single_diff( { // 2. RMSE arma::vec err; - err = delta_measured_carrier_doppler_cycles; + err = std::move(delta_measured_carrier_doppler_cycles); arma::vec err2 = arma::square(err); double rmse = sqrt(arma::mean(err2)); @@ -865,7 +866,7 @@ void code_pseudorange_single_diff( // 2. RMSE arma::vec err; - err = delta_measured_obs; + err = std::move(delta_measured_obs); arma::vec err2 = arma::square(err); double rmse = sqrt(arma::mean(err2)); @@ -1014,7 +1015,7 @@ void coderate_phaserate_consistence( // 2. RMSE arma::vec err; - err = ratediff; + err = std::move(ratediff); arma::vec err2 = arma::square(err); double rmse = sqrt(arma::mean(err2)); @@ -1098,7 +1099,7 @@ void code_phase_diff( { // 2. RMSE arma::vec err; - err = code_minus_phase; + err = std::move(code_minus_phase); arma::vec err2 = arma::square(err); double rmse = sqrt(arma::mean(err2)); @@ -1727,22 +1728,42 @@ int main(int argc, char** argv) { std::cout << "Running RINEX observables difference tool...\n"; gflags::ParseCommandLineFlags(&argc, &argv, true); - if (FLAGS_single_diff) + try { - if (FLAGS_dupli_sat) + if (FLAGS_single_diff) { - RINEX_doublediff_dupli_sat(); + if (FLAGS_dupli_sat) + { + RINEX_doublediff_dupli_sat(); + } + else + { + RINEX_singlediff(); + } } else { - RINEX_singlediff(); + RINEX_doublediff(FLAGS_remove_rx_clock_error); } } - else + catch (const gnsstk::Exception& e) { - RINEX_doublediff(FLAGS_remove_rx_clock_error); + std::cerr << e; + gflags::ShutDownCommandLineFlags(); + return 1; + } + catch (const std::exception& e) + { + std::cerr << "Exception: " << e.what(); + gflags::ShutDownCommandLineFlags(); + return 1; + } + catch (...) + { + std::cerr << "Unknown error\n"; + gflags::ShutDownCommandLineFlags(); + return 1; } - gflags::ShutDownCommandLineFlags(); return 0; } From acf80198af5757f6464630071afd7935bd06e7d5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 13:58:31 +0100 Subject: [PATCH 123/142] Remove leftovers from building in the source directory --- .../volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index a65a33172..47c197ba7 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -539,6 +539,18 @@ install(EXPORT VOLK_GNSSSDR-export FILE VolkGnsssdrTargets.cmake NAMESPACE VolkGnsssdr:: DESTINATION ${CMAKE_MODULES_DIR}/volk_gnsssdr ) + +######################################################################## +# Remove leftovers in the source directory +######################################################################## +install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_arch_defs.py)") +install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_arch_defs.pyc)") +install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_kernel_defs.pyc)") +install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_machine_defs.pyc)") +install(CODE "file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/gen/__pycache__)") + + + ######################################################################## # Option to enable QA testing, on by default ######################################################################## From c498809bfb012ddf7b5b5737854c5da4bfbf3da1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 14:25:01 +0100 Subject: [PATCH 124/142] Better initialization for Fpga_dynamic_bit_selection constructor --- .../libs/fpga_dynamic_bit_selection.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index e5725881e..78a849008 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -27,14 +27,15 @@ #include // for mmap Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(bool enable_rx1_band, bool enable_rx2_band) - : d_enable_rx1_band(enable_rx1_band), d_enable_rx2_band(enable_rx2_band) + : d_map_base_freq_band_1(nullptr), + d_map_base_freq_band_2(nullptr), + d_dev_descr_freq_band_1(0), + d_dev_descr_freq_band_2(0), + d_shift_out_bits_freq_band_1(0), + d_shift_out_bits_freq_band_2(0), + d_enable_rx1_band(enable_rx1_band), + d_enable_rx2_band(enable_rx2_band) { - d_map_base_freq_band_1 = nullptr; - d_map_base_freq_band_2 = nullptr; - d_dev_descr_freq_band_1 = 0; - d_dev_descr_freq_band_2 = 0; - d_shift_out_bits_freq_band_1 = 0; - d_shift_out_bits_freq_band_2 = 0; if (d_enable_rx1_band) { open_device(&d_map_base_freq_band_1, d_dev_descr_freq_band_1, 0); From 9618918aee852dcf7a319bab24ec459d912bde5f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 14:46:27 +0100 Subject: [PATCH 125/142] Improve formatting consistency --- src/algorithms/signal_source/libs/fpga_dma-proxy.cc | 2 ++ .../signal_source/libs/fpga_dynamic_bit_selection.cc | 3 +++ src/algorithms/signal_source/libs/ppstcprx.cc | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/algorithms/signal_source/libs/fpga_dma-proxy.cc b/src/algorithms/signal_source/libs/fpga_dma-proxy.cc index 1e8881300..8ee7b411d 100644 --- a/src/algorithms/signal_source/libs/fpga_dma-proxy.cc +++ b/src/algorithms/signal_source/libs/fpga_dma-proxy.cc @@ -42,11 +42,13 @@ int Fpga_DMA::DMA_open() return 0; } + int8_t *Fpga_DMA::get_buffer_address() // NOLINT(readability-make-member-function-const) { return tx_channel.buf_ptr[0].buffer; } + int Fpga_DMA::DMA_write(int nbytes) const { int buffer_id = 0; diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index 78a849008..933d8b77f 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -82,6 +82,7 @@ void Fpga_dynamic_bit_selection::bit_selection() } } + void Fpga_dynamic_bit_selection::open_device(volatile unsigned **d_map_base, int &d_dev_descr, int freq_band) { // find the uio device file corresponding to the dynamic bit selector 0 module. @@ -108,6 +109,7 @@ void Fpga_dynamic_bit_selection::open_device(volatile unsigned **d_map_base, int } } + void Fpga_dynamic_bit_selection::bit_selection_per_rf_band(volatile unsigned *d_map_base, uint32_t shift_out_bits) { // estimated signal power @@ -133,6 +135,7 @@ void Fpga_dynamic_bit_selection::bit_selection_per_rf_band(volatile unsigned *d_ d_map_base[0] = shift_out_bits; } + void Fpga_dynamic_bit_selection::close_device(volatile unsigned *d_map_base, int &d_dev_descr) { auto *aux = const_cast(d_map_base); diff --git a/src/algorithms/signal_source/libs/ppstcprx.cc b/src/algorithms/signal_source/libs/ppstcprx.cc index 0855ad0b6..c23261aff 100644 --- a/src/algorithms/signal_source/libs/ppstcprx.cc +++ b/src/algorithms/signal_source/libs/ppstcprx.cc @@ -27,16 +27,19 @@ pps_tcp_rx::pps_tcp_rx() clientSd = -1; } + pps_tcp_rx::~pps_tcp_rx() { // TODO Auto-generated destructor stub } + void pps_tcp_rx::set_pps_samplestamp_queue(std::shared_ptr> queue) { Pps_queue = std::move(queue); } + bool pps_tcp_rx::send_cmd(std::string cmd) { if (is_connected == true) @@ -59,6 +62,8 @@ bool pps_tcp_rx::send_cmd(std::string cmd) } return true; } + + void pps_tcp_rx::receive_pps(std::string ip_address, int port) { // create a message buffer From 3338a8bc0cef67b77a7ff4c11dc95ff0559e8e94 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 14:52:41 +0100 Subject: [PATCH 126/142] CI: Workaround for macos-based jobs --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5206c6d31..bb0bd3724 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,6 +52,7 @@ jobs: rm /usr/local/bin/idle3.1* || true rm /usr/local/bin/pydoc3.1* || true rm /usr/local/bin/python3.1* || true + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install ninja hdf5 automake armadillo lapack \ gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -80,6 +81,7 @@ jobs: rm /usr/local/bin/idle3.1* || true rm /usr/local/bin/pydoc3.1* || true rm /usr/local/bin/python3.1* || true + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ gnuradio log4cpp openssl pugixml protobuf pip3 install mako @@ -127,6 +129,7 @@ jobs: rm /usr/local/bin/idle3.1* || true rm /usr/local/bin/pydoc3.1* || true rm /usr/local/bin/python3.1* || true + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \ log4cpp openssl pugixml protobuf pip3 install mako From 5d1057227d1ac63ed2e8d47d50a1c85bbb0f22b9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 15:33:30 +0100 Subject: [PATCH 127/142] Revert "Remove leftovers from building in the source directory" This reverts commit acf80198af5757f6464630071afd7935bd06e7d5. --- .../volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 47c197ba7..a65a33172 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -539,18 +539,6 @@ install(EXPORT VOLK_GNSSSDR-export FILE VolkGnsssdrTargets.cmake NAMESPACE VolkGnsssdr:: DESTINATION ${CMAKE_MODULES_DIR}/volk_gnsssdr ) - -######################################################################## -# Remove leftovers in the source directory -######################################################################## -install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_arch_defs.py)") -install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_arch_defs.pyc)") -install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_kernel_defs.pyc)") -install(CODE "file(REMOVE ${PROJECT_SOURCE_DIR}/gen/volk_gnsssdr_machine_defs.pyc)") -install(CODE "file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/gen/__pycache__)") - - - ######################################################################## # Option to enable QA testing, on by default ######################################################################## From a2f8758ac78eb707e8b01338fdb91b23165da0e8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 21 Dec 2023 17:56:32 +0100 Subject: [PATCH 128/142] Do not use __VOLK_VOLATILE in neon tests and other minor chores --- .../libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt | 4 ++-- .../gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc | 2 +- .../acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index 8bfd62614..2562bd90c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -224,9 +224,9 @@ check_c_source_compiles("#include \nint main(){ uint8_t *dest; uint8 if(neon_compile_result) set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) - check_c_source_compiles("#include \n int main(){__VOLK_ASM __VOLK_VOLATILE(\"vrev32.8 q0, q0\");}" + check_c_source_compiles("#include \n int main(){__VOLK_ASM(\"vrev32.8 q0, q0\");}" have_neonv7_result) - check_c_source_compiles("#include \n int main(){__VOLK_ASM __VOLK_VOLATILE(\"sub v1.4s,v1.4s,v1.4s\");}" + check_c_source_compiles("#include \n int main(){__VOLK_ASM(\"sub v1.4s,v1.4s,v1.4s\");}" have_neonv8_result) if(NOT have_neonv7_result) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index 6c8e82231..710c244e7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -746,6 +746,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ d_rem_code_phase_chips = d_code_freq_chips * (d_rem_code_phase_samples / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### + gr::thread::scoped_lock l(d_setlock); if (d_cn0_estimation_counter < FLAGS_cn0_samples) { // fill buffer with prompt correlator output values @@ -776,7 +777,6 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { - gr::thread::scoped_lock l(d_setlock); std::cout << "Loss of lock in channel " << d_channel << "!\n"; LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 4bc54fba4..60db2ec9b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -90,6 +90,7 @@ GpsL1CaPcpsAcquisitionTestFpga::GpsL1CaPcpsAcquisitionTestFpga() doppler_max = 5000; doppler_step = 100; + nsamples_to_transfer = 0; } From 6b9ad0332babbd384be39020dff37ea50dfd05d6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 22 Dec 2023 10:33:59 +0100 Subject: [PATCH 129/142] Fix data race condition --- .../tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index 710c244e7..d51557441 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -609,7 +609,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder Gnss_Synchro current_synchro_data = Gnss_Synchro(); - + gr::thread::scoped_lock l(d_setlock); if (d_enable_tracking == true) { // Fill the acquisition data @@ -746,7 +746,6 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__ d_rem_code_phase_chips = d_code_freq_chips * (d_rem_code_phase_samples / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### - gr::thread::scoped_lock l(d_setlock); if (d_cn0_estimation_counter < FLAGS_cn0_samples) { // fill buffer with prompt correlator output values From 7d6d62dbc6e5e486584352760aa22618fbc14c8d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 1 Jan 2024 14:23:42 +0100 Subject: [PATCH 130/142] Fix data race condition --- .../tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index d51557441..0b8c3bb84 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -235,6 +235,7 @@ Gps_L1_Ca_Gaussian_Tracking_cc::Gps_L1_Ca_Gaussian_Tracking_cc( void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking() { + gr::thread::scoped_lock l(d_setlock); /* * correct the code phase according to the delay between acq and trk */ @@ -316,7 +317,6 @@ void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking() << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; - gr::thread::scoped_lock l(d_setlock); std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; } From 76f2cc411a04faaa346b13ffde03bebb5c51fbca Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 1 Jan 2024 17:33:15 +0100 Subject: [PATCH 131/142] Enable building using macOS Sonoma --- CMakeLists.txt | 27 +++++++++++++++++---------- README.md | 23 +++++++++++++++++------ docs/CHANGELOG.md | 3 ++- src/tests/CMakeLists.txt | 8 ++++++-- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab0c1bc3e..798bb746d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2023 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2024 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause ################################################################################ @@ -911,6 +911,11 @@ if((Boost_VERSION_STRING VERSION_GREATER 1.71) AND (Boost_VERSION_STRING VERSION endif() endif() +# Workaround for macOS Sonoma +if((CMAKE_CXX_STANDARD EQUAL 17) AND ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND ("${DARWIN_VERSION}" VERSION_GREATER "22.99"))) + add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION=1) +endif() + # Fix for Boost Asio < 1.70 when using Clang in macOS if(Boost_VERSION_STRING VERSION_LESS 1.70.0) # Check if we have std::string_view @@ -1823,7 +1828,7 @@ endif() # Check that BLAS (Basic Linear Algebra Subprograms) is found in the system # See https://www.netlib.org/blas/ ################################################################################ -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND ("${DARWIN_VERSION}" VERSION_LESS "23")) # Avoid using the implementation that comes with the Accelerate framework include(AvoidAccelerate) else() @@ -1870,7 +1875,7 @@ endif() # Check that LAPACK (Linear Algebra PACKage) is found in the system # See https://www.netlib.org/lapack/ ################################################################################ -if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) +if(NOT((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND ("${DARWIN_VERSION}" VERSION_LESS "23"))) find_package(LAPACK) set_package_properties(LAPACK PROPERTIES URL "https://www.netlib.org/lapack/" @@ -1881,13 +1886,15 @@ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) endif() if(NOT LAPACK_FOUND) message(" The LAPACK library has not been found.") - message(" You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo yum install lapack-devel") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(" sudo zypper install lapack-devel") - else() - message(" sudo apt-get install liblapack-dev") + if(LINUX_DISTRIBUTION) + message(" You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum install lapack-devel") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(" sudo zypper install lapack-devel") + else() + message(" sudo apt-get install liblapack-dev") + endif() endif() message(FATAL_ERROR "LAPACK is required to build gnss-sdr") endif() diff --git a/README.md b/README.md index 7dfb672cd..467e925a8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ) [comment]: # ( -SPDX-FileCopyrightText: 2011-2021 Carles Fernandez-Prades +SPDX-FileCopyrightText: 2011-2024 Carles Fernandez-Prades ) @@ -799,7 +799,7 @@ Of course, you will also need a GPU that ## macOS GNSS-SDR can be built on macOS (or the former Mac OS X), starting from 10.9 -(Mavericks) and including 11 (Big Sur). If you still have not installed +(Mavericks) and including 14 (Sonoma). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools, which do not come by default in macOS versions older than Big Sur. If you are using an older @@ -830,12 +830,18 @@ In a terminal, type: ``` $ sudo port selfupdate $ sudo port upgrade outdated -$ sudo port install armadillo boost cmake gnuradio gnutls lapack libad9361-iio libiio \ - matio pkgconfig protobuf3-cpp pugixml google-glog +gflags +$ sudo port install armadillo cmake pkgconfig protobuf3-cpp pugixml gnutls +$ sudo port install gnuradio +uhd +grc +zeromq +$ sudo port install boost matio libad9361-iio libiio google-glog +gflags $ sudo port install py311-mako $ sudo port install doxygen +docs ``` +For macOS versions older than Sonoma, you will also need LAPACK: +``` +$ sudo port install lapack +``` + You also might need to activate a Python installation. The list of installed versions can be retrieved with: @@ -846,7 +852,7 @@ $ port select --list python and you can activate a certain version by typing: ``` -$ sudo port select --set python python37 +$ sudo port select --set python python311 ``` ### Homebrew @@ -871,13 +877,18 @@ Install the required dependencies: ``` $ brew update && brew upgrade -$ brew install armadillo cmake hdf5 gflags glog gnuradio lapack libmatio log4cpp \ +$ brew install armadillo cmake hdf5 gflags glog gnuradio libmatio log4cpp \ openssl pkg-config protobuf pugixml $ pip3 install mako $ brew install --cask mactex # when completed, restart Terminal $ brew install graphviz doxygen ``` +For macOS versions older than Sonoma, you will also need LAPACK: +``` +$ brew install lapack +``` + ### Other package managers GNU Radio and other dependencies can also be installed using other package diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ca209027e..97191e00c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ) [comment]: # ( -SPDX-FileCopyrightText: 2011-2023 Carles Fernandez-Prades +SPDX-FileCopyrightText: 2011-2024 Carles Fernandez-Prades ) @@ -50,6 +50,7 @@ All notable changes to GNSS-SDR will be documented in this file. - Fixed undefined behaviour in `volk_gnsssdr` arising from incompatibility between complex numbers in C and C++. - Now build system paths are not leaked when cross-compiling. +- Enabled building using macOS Sonoma and `arm64` processor architecture. ### Improvements in Repeatability: diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 53cc054d9..fbb815b78 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2020 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2024 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause @@ -408,6 +408,10 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) set(GNSSTK_FLAGS "-DCMAKE_CXX_FLAGS:STRING=-w") # Fix for clang in aarch64 endif() if(CMAKE_VERSION VERSION_GREATER 3.17.0) + set(GNSSTK_CXX_STANDARD 17) + if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND ("${DARWIN_VERSION}" VERSION_GREATER_EQUAL "14")) + set(GNSSTK_CXX_STANDARD 14) + endif() ExternalProject_Add(gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION} GIT_REPOSITORY https://github.com/SGL-UT/gnsstk GIT_TAG v${GNSSSDR_GNSSTK_LOCAL_VERSION} @@ -420,7 +424,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install -DBUILD_EXT=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_STANDARD=17 + -DCMAKE_CXX_STANDARD=${GNSSTK_CXX_STANDARD} -DCMAKE_CXX_EXTENSIONS=ON -DCMAKE_C_STANDARD=11 -DCMAKE_C_EXTENSIONS=ON From 5b257a677868062da4a59151231de5490a09454e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 1 Jan 2024 21:04:07 +0100 Subject: [PATCH 132/142] Fix formatting --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 467e925a8..7e9fd62d9 100644 --- a/README.md +++ b/README.md @@ -838,6 +838,7 @@ $ sudo port install doxygen +docs ``` For macOS versions older than Sonoma, you will also need LAPACK: + ``` $ sudo port install lapack ``` @@ -885,6 +886,7 @@ $ brew install graphviz doxygen ``` For macOS versions older than Sonoma, you will also need LAPACK: + ``` $ brew install lapack ``` From 61d7573eb66480f5036876839617bf8ce8aeec9c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 2 Jan 2024 14:04:53 +0100 Subject: [PATCH 133/142] Remove duplicate dependencies when linking --- cmake/Modules/RemoveDuplicates.cmake | 20 ++++++++++++++++++++ src/main/CMakeLists.txt | 2 ++ src/tests/CMakeLists.txt | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 cmake/Modules/RemoveDuplicates.cmake diff --git a/cmake/Modules/RemoveDuplicates.cmake b/cmake/Modules/RemoveDuplicates.cmake new file mode 100644 index 000000000..94b12b0fb --- /dev/null +++ b/cmake/Modules/RemoveDuplicates.cmake @@ -0,0 +1,20 @@ +# GNSS-SDR is a Global Navigation Satellite System software-defined receiver. +# This file is part of GNSS-SDR. +# +# SPDX-FileCopyrightText: 2024 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-License-Identifier: BSD-3-Clause + +# Usage: +# include(RemoveDuplicates) +# remove_duplicate_linked_libraries(my_target) + +if(DEFINED __INCLUDED_REMOVE_DUPLICATE_LINKED_LIBRARIES_MODULE) + return() +endif() +set(__INCLUDED_REMOVE_DUPLICATE_LINKED_LIBRARIES_MODULE TRUE) + +function(remove_duplicate_linked_libraries target_name) + get_target_property(LINK_LIBRARIES ${target_name} LINK_LIBRARIES) + list(REMOVE_DUPLICATES LINK_LIBRARIES) + set_target_properties(${target_name} PROPERTIES LINK_LIBRARIES "${LINK_LIBRARIES}") +endfunction() \ No newline at end of file diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 2895d5973..05b96fd5f 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -60,6 +60,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") target_link_libraries(gnss-sdr PRIVATE "-lc++") endif() endif() +include(RemoveDuplicates) +remove_duplicate_linked_libraries(gnss-sdr) if(ENABLE_STRIP) set_target_properties(gnss-sdr PROPERTIES LINK_FLAGS "-s") diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fbb815b78..94ae13246 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(unit-tests/signal-processing-blocks/libs) add_subdirectory(system-tests/libs) +include(RemoveDuplicates) ################################################################################ # Google Test - https://github.com/google/googletest @@ -645,6 +646,7 @@ if(ENABLE_UNIT_TESTING) target_compile_definitions(run_tests PRIVATE -DGNSSTK_OLDER_THAN_9=1) endif() endif() + remove_duplicate_linked_libraries(run_tests) if(ENABLE_STRIP) set_target_properties(run_tests PROPERTIES LINK_FLAGS "-s") endif() @@ -767,6 +769,7 @@ if(ENABLE_FPGA) target_include_directories(gps_l1_ca_dll_pll_tracking_test_fpga INTERFACE ${GNSSSDR_SOURCE_DIR}/src/tests/common-files ) + remove_duplicate_linked_libraries(gps_l1_ca_dll_pll_tracking_test_fpga) install(TARGETS gps_l1_ca_dll_pll_tracking_test_fpga RUNTIME DESTINATION bin COMPONENT "fpga-test" @@ -856,6 +859,7 @@ if(ENABLE_SYSTEM_TESTING) ) if(NOT ENABLE_PACKAGING) add_system_test(ttff) + remove_duplicate_linked_libraries(ttff) endif() if(ENABLE_SYSTEM_TESTING_EXTRA) @@ -877,6 +881,7 @@ if(ENABLE_SYSTEM_TESTING) ) endif() endif() + remove_duplicate_linked_libraries(position_test) if(NOT GNSSSIMULATOR_FOUND OR ENABLE_GNSS_SIM_INSTALL) if(NOT CMAKE_CROSSCOMPILING) add_dependencies(position_test gnss-sim) @@ -937,7 +942,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) PRIVATE ${GNSSSDR_SOURCE_DIR}/src/algorithms/libs ) - + remove_duplicate_linked_libraries(flowgraph_test) add_test(flowgraph_test flowgraph_test) set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) @@ -992,7 +997,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) if(ENABLE_FPGA) target_compile_definitions(gnss_block_test PRIVATE -DENABLE_FPGA=1) endif() - + remove_duplicate_linked_libraries(gnss_block_test) add_test(gnss_block_test gnss_block_test) set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) @@ -1029,7 +1034,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) core_receiver algorithms_libs ) - + remove_duplicate_linked_libraries(gnuradio_block_test) add_test(gnuradio_block_test gnuradio_block_test) set_property(TEST gnuradio_block_test PROPERTY TIMEOUT 30) @@ -1063,7 +1068,7 @@ target_include_directories(matio_test INTERFACE ${GNSSSDR_SOURCE_DIR}/src/tests/common-files ) - +remove_duplicate_linked_libraries(matio_test) add_test(matio_test matio_test) set_property(TEST matio_test PROPERTY TIMEOUT 30) @@ -1112,6 +1117,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) -DPMT_USES_BOOST_ANY=1 ) endif() + remove_duplicate_linked_libraries(acq_test) add_test(acq_test acq_test) if(USE_GENERIC_LAMBDAS) @@ -1207,7 +1213,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) -DPMT_USES_BOOST_ANY=1 ) endif() - + remove_duplicate_linked_libraries(trk_test) add_test(trk_test trk_test) set_property(TEST trk_test PROPERTY TIMEOUT 30) @@ -1238,7 +1244,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) algorithms_libs core_receiver ) - + remove_duplicate_linked_libraries(control_thread_test) add_test(control_thread_test control_thread_test) set_property(TEST control_thread_test PROPERTY TIMEOUT 30) From c16440fb35f2df196e3a9bdc344fec838c481794 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 2 Jan 2024 18:20:54 +0100 Subject: [PATCH 134/142] Update changelog --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 97191e00c..6f5ca432b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -45,7 +45,7 @@ All notable changes to GNSS-SDR will be documented in this file. - Updated local `cpu_features` library to v0.9.0. - `volk_gnsssdr`: fix syntax for Python 3.12 without breaking backward compatibility with Python 2.7. -- Fixed linking against latest GNU Radio version. +- Fixed linking against GNU Radio v3.10.9.1. - Make use of new API if linking against VOLK >= 3.1. - Fixed undefined behaviour in `volk_gnsssdr` arising from incompatibility between complex numbers in C and C++. From 00f9a131d8bc8c4e0055b09383d366342bcef78d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 3 Jan 2024 09:14:55 +0100 Subject: [PATCH 135/142] Fix for old CMake versions --- cmake/Modules/RemoveDuplicates.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/RemoveDuplicates.cmake b/cmake/Modules/RemoveDuplicates.cmake index 94b12b0fb..446dedbae 100644 --- a/cmake/Modules/RemoveDuplicates.cmake +++ b/cmake/Modules/RemoveDuplicates.cmake @@ -14,7 +14,9 @@ endif() set(__INCLUDED_REMOVE_DUPLICATE_LINKED_LIBRARIES_MODULE TRUE) function(remove_duplicate_linked_libraries target_name) - get_target_property(LINK_LIBRARIES ${target_name} LINK_LIBRARIES) - list(REMOVE_DUPLICATES LINK_LIBRARIES) - set_target_properties(${target_name} PROPERTIES LINK_LIBRARIES "${LINK_LIBRARIES}") + if(CMAKE_VERSION VERSION_GREATER 3.5) + get_target_property(LINK_LIBRARIES ${target_name} LINK_LIBRARIES) + list(REMOVE_DUPLICATES LINK_LIBRARIES) + set_target_properties(${target_name} PROPERTIES LINK_LIBRARIES "${LINK_LIBRARIES}") + endif() endfunction() \ No newline at end of file From 8e1a7ce7899f6eda85368adc76eea067a5f53253 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 6 Jan 2024 10:44:15 +0100 Subject: [PATCH 136/142] Allow building of local Armadillo also in macOS Sonoma --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 798bb746d..348c2f2a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2061,7 +2061,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) IMPORTED_LOCATION_RELWITHDEBINFO ${ARMADILLO_STATIC_LIBRARY} IMPORTED_LOCATION_MINSIZEREL ${ARMADILLO_STATIC_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES ${GNSSSDR_BINARY_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include - INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN} ${ARMADILLO_STATIC_LIBRARY} + INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" "${LAPACK_LIBRARIES}" ${GFORTRAN} ${ARMADILLO_STATIC_LIBRARY} ) if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC) set_target_properties(Armadillo::armadillo PROPERTIES @@ -2069,7 +2069,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) IMPORTED_LOCATION_RELEASE ${binary_dir}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" "${LAPACK_LIBRARIES}" ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} ) endif() set_package_properties(Armadillo PROPERTIES From 0ce2e5b5d86641c61da2a149e7aa8f840b5d71ee Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Jan 2024 10:46:01 +0100 Subject: [PATCH 137/142] Fix building of local armadillo in some environments --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 348c2f2a1..afc81e834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2061,7 +2061,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) IMPORTED_LOCATION_RELWITHDEBINFO ${ARMADILLO_STATIC_LIBRARY} IMPORTED_LOCATION_MINSIZEREL ${ARMADILLO_STATIC_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES ${GNSSSDR_BINARY_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include - INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" "${LAPACK_LIBRARIES}" ${GFORTRAN} ${ARMADILLO_STATIC_LIBRARY} + INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES};${LAPACK_LIBRARIES};${GFORTRAN};${ARMADILLO_STATIC_LIBRARY}" ) if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC) set_target_properties(Armadillo::armadillo PROPERTIES @@ -2069,7 +2069,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) IMPORTED_LOCATION_RELEASE ${binary_dir}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" "${LAPACK_LIBRARIES}" ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES};${LAPACK_LIBRARIES};${GFORTRAN};${binary_dir}/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}" ) endif() set_package_properties(Armadillo PROPERTIES From 5d5cbc05ebbd22db580f861f30d680d121c7d8a2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Jan 2024 10:47:14 +0100 Subject: [PATCH 138/142] Fix Wshorten-64-to-32 warning --- .../gnuradio_blocks/direct_resampler_conditioner_cb.cc | 7 +------ .../gnuradio_blocks/direct_resampler_conditioner_cc.cc | 6 +----- .../gnuradio_blocks/direct_resampler_conditioner_cs.cc | 7 +------ 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc index ba08c7817..e0221ecc3 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cb.cc @@ -65,12 +65,7 @@ void direct_resampler_conditioner_cb::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int nreqd = std::max(static_cast(1), static_cast(static_cast(noutput_items + 1) * sample_freq_in() / sample_freq_out()) + history() - 1); - unsigned ninputs = ninput_items_required.size(); - - for (unsigned i = 0; i < ninputs; i++) - { - ninput_items_required[i] = nreqd; - } + std::fill(ninput_items_required.begin(), ninput_items_required.end(), nreqd); } diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc index f6f46b711..d3a9544a7 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc @@ -64,11 +64,7 @@ void direct_resampler_conditioner_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int nreqd = std::max(static_cast(1), static_cast(static_cast(noutput_items + 1) * sample_freq_in() / sample_freq_out()) + history() - 1); - unsigned ninputs = ninput_items_required.size(); - for (unsigned i = 0; i < ninputs; i++) - { - ninput_items_required[i] = nreqd; - } + std::fill(ninput_items_required.begin(), ninput_items_required.end(), nreqd); } diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc index 365728b01..8f8407343 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cs.cc @@ -66,12 +66,7 @@ void direct_resampler_conditioner_cs::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int nreqd = std::max(static_cast(1), static_cast(static_cast(noutput_items + 1) * sample_freq_in() / sample_freq_out()) + history() - 1); - unsigned ninputs = ninput_items_required.size(); - - for (unsigned i = 0; i < ninputs; i++) - { - ninput_items_required[i] = nreqd; - } + std::fill(ninput_items_required.begin(), ninput_items_required.end(), nreqd); } From 3697bc1dce8155bef42f6299a5092328f6ec24d6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 13 Jan 2024 12:07:06 +0100 Subject: [PATCH 139/142] Improve value reading in navigation message decoding More concise code, less branching, fix some Wshorten-64-to-32 warnings --- .../beidou_dnav_navigation_message.cc | 52 +++----------- .../system_parameters/galileo_fnav_message.cc | 35 ++-------- .../system_parameters/galileo_inav_message.cc | 67 +++++-------------- .../glonass_gnav_navigation_message.cc | 46 +++---------- .../gps_cnav_navigation_message.cc | 47 +++---------- .../gps_navigation_message.cc | 58 ++++------------ 6 files changed, 61 insertions(+), 244 deletions(-) diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index f1a0fc1b1..0444a3555 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -21,7 +21,7 @@ #include // for cos, sin, fmod, sqrt, atan2, fabs, floor #include // for string, operator<<, cout, ostream #include // for std::numeric_limits - +#include // for accumulate Beidou_Dnav_Navigation_Message::Beidou_Dnav_Navigation_Message() { @@ -30,9 +30,6 @@ Beidou_Dnav_Navigation_Message::Beidou_Dnav_Navigation_Message() for (uint32_t i = 1; i < 64; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); - } - for (uint32_t i = 1; i < 64; i++) - { almanacHealth[i] = 0; } } @@ -48,16 +45,7 @@ bool Beidou_Dnav_Navigation_Message::read_navigation_bool( const std::bitset& bits, const std::vector>& parameter) const { - bool value; - - if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) - { - value = true; - } - else - { - value = false; - } + bool value = bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first]; return value; } @@ -67,16 +55,11 @@ uint64_t Beidou_Dnav_Navigation_Message::read_navigation_unsigned( const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& param : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < param.second; j++) { - value <<= 1U; // shift left - if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) - { - value += 1U; // insert the bit - } + value = (value << 1U) | static_cast(bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - param.first - j]); } } return value; @@ -87,29 +70,12 @@ int64_t Beidou_Dnav_Navigation_Message::read_navigation_signed( const std::bitset& bits, const std::vector>& parameter) const { - int64_t value = 0; - const int32_t num_of_slices = parameter.size(); - - // read the MSB and perform the sign extension - if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) + int64_t value = bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] ? -1LL : 0LL; + for (const auto& param : parameter) { - value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable - } - else - { - value &= 0; - } - - for (int32_t i = 0; i < num_of_slices; i++) - { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < param.second; j++) { - value *= 2; // shift left the signed integer - value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) - if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value = (value << 1) | static_cast(bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - param.first - j]); } } return value; diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index 1d313ceed..5dea81898 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -282,16 +282,12 @@ void Galileo_Fnav_Message::decode_page(const std::string& data) uint64_t Galileo_Fnav_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int j = 0; j < parameter[i].second; j++) + for (int j = 0; j < p.second; j++) { value <<= 1U; // shift left - if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j]) == 1) - { - value += 1; // insert the bit - } + value |= static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - p.first - j]); } } return value; @@ -300,29 +296,12 @@ uint64_t Galileo_Fnav_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector>& parameter) const { - int64_t value = 0LL; - const int num_of_slices = parameter.size(); - - // read the MSB and perform the sign extension - if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first]) == 1) + int64_t value = (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) ? -1LL : 0LL; + for (const auto& p : parameter) { - value ^= 0x0FFFFFFFFFFFFFFF; // 64 bits variable - } - else - { - value &= 0; - } - - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value <<= 1; // shift left - value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) - if (static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j]) == 1) - { - value += 1; // insert the bit - } + value = (value << 1) | static_cast(bits[GALILEO_FNAV_DATA_FRAME_BITS - p.first - j]); } } return value; diff --git a/src/core/system_parameters/galileo_inav_message.cc b/src/core/system_parameters/galileo_inav_message.cc index 850f2ffb9..81c47c3bb 100644 --- a/src/core/system_parameters/galileo_inav_message.cc +++ b/src/core/system_parameters/galileo_inav_message.cc @@ -74,16 +74,12 @@ bool Galileo_Inav_Message::CRC_test(const std::bitset& uint64_t Galileo_Inav_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int j = 0; j < p.second; j++) { value <<= 1U; // shift left - if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1) - { - value += 1; // insert the bit - } + value |= static_cast(bits[GALILEO_DATA_JK_BITS - p.first - j]); } } return value; @@ -93,16 +89,12 @@ uint64_t Galileo_Inav_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector>& parameter) const { uint8_t value = 0; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int j = 0; j < p.second; j++) { value <<= 1; // shift left - if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1) - { - value += 1; // insert the bit - } + value |= static_cast(bits[GALILEO_DATA_JK_BITS - p.first - j]); } } return value; @@ -112,16 +104,12 @@ uint8_t Galileo_Inav_Message::read_octet_unsigned(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int j = 0; j < p.second; j++) { - value <<= 1U; // shift left - if (static_cast(bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j]) == 1) - { - value += 1ULL; // insert the bit - } + value <<= 1; // shift left + value |= static_cast(bits[GALILEO_PAGE_TYPE_BITS - p.first - j]); } } return value; @@ -130,29 +118,12 @@ uint64_t Galileo_Inav_Message::read_page_type_unsigned(const std::bitset& bits, const std::vector>& parameter) const { - int64_t value = 0LL; - const int32_t num_of_slices = parameter.size(); - - // read the MSB and perform the sign extension - if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first]) == 1) + int64_t value = (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) ? -1LL : 0LL; + for (const auto& p : parameter) { - value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable - } - else - { - value &= 0LL; - } - - for (int32_t i = 0; i < num_of_slices; i++) - { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value *= 2; // shift left the signed integer - value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) - if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1) - { - value += 1LL; // insert the bit - } + value = (value << 1) | static_cast(bits[GALILEO_DATA_JK_BITS - p.first - j]); } } return value; @@ -161,15 +132,7 @@ int64_t Galileo_Inav_Message::read_navigation_signed(const std::bitset& bits, const std::vector>& parameter) const { - bool value; - if (static_cast(bits[GALILEO_DATA_JK_BITS - parameter[0].first]) == 1) - { - value = true; - } - else - { - value = false; - } + bool value = bits[GALILEO_DATA_JK_BITS - parameter[0].first]; return value; } diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 586f795b2..9428875c4 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -156,16 +156,7 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset& bits, const std::vector>& parameter) const { - bool value; - - if (bits[GLONASS_GNAV_STRING_BITS - parameter[0].first] == 1) - { - value = true; - } - else - { - value = false; - } + bool value = bits[GLONASS_GNAV_STRING_BITS - parameter[0].first]; return value; } @@ -173,16 +164,11 @@ bool Glonass_Gnav_Navigation_Message::read_navigation_bool(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value <<= 1ULL; // shift left - if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1) - { - value += 1ULL; // insert the bit - } + value = (value << 1U) | static_cast(bits[GLONASS_GNAV_STRING_BITS - p.first - j]); } } return value; @@ -192,26 +178,14 @@ uint64_t Glonass_Gnav_Navigation_Message::read_navigation_unsigned(const std::bi int64_t Glonass_Gnav_Navigation_Message::read_navigation_signed(const std::bitset& bits, const std::vector>& parameter) const { int64_t value = 0LL; - int64_t sign = 0LL; - const int32_t num_of_slices = parameter.size(); - // read the MSB and perform the sign extension - if (bits[GLONASS_GNAV_STRING_BITS - parameter[0].first] == 1) + int64_t sign = (bits[GLONASS_GNAV_STRING_BITS - parameter[0].first] == 1) ? -1LL : 1LL; + + // const int32_t num_of_slices = parameter.size(); + for (const auto& p : parameter) { - sign = -1LL; - } - else - { - sign = 1LL; - } - for (int32_t i = 0; i < num_of_slices; i++) - { - for (int32_t j = 1; j < parameter[i].second; j++) + for (int32_t j = 1; j < p.second; j++) { - value <<= 1; // shift left - if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1) - { - value += 1LL; // insert the bit - } + value = (value << 1) + bits[GLONASS_GNAV_STRING_BITS - p.first - j]; } } return (sign * value); diff --git a/src/core/system_parameters/gps_cnav_navigation_message.cc b/src/core/system_parameters/gps_cnav_navigation_message.cc index a644f7f2a..9b9b2e907 100644 --- a/src/core/system_parameters/gps_cnav_navigation_message.cc +++ b/src/core/system_parameters/gps_cnav_navigation_message.cc @@ -36,16 +36,7 @@ Gps_CNAV_Navigation_Message::Gps_CNAV_Navigation_Message() bool Gps_CNAV_Navigation_Message::read_navigation_bool(const std::bitset& bits, const std::vector>& parameter) const { - bool value; - - if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first]) == 1) - { - value = true; - } - else - { - value = false; - } + bool value = bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first]; return value; } @@ -53,16 +44,11 @@ bool Gps_CNAV_Navigation_Message::read_navigation_bool(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value <<= 1ULL; // shift left - if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j]) == 1) - { - value += 1ULL; // insert the bit - } + value = (value << 1) | static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - p.first - j]); } } return value; @@ -71,29 +57,12 @@ uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(const std::bitset int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(const std::bitset& bits, const std::vector>& parameter) const { - int64_t value = 0LL; - const int32_t num_of_slices = parameter.size(); - - // read the MSB and perform the sign extension - if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first]) == 1) + int64_t value = (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) ? -1LL : 0LL; + for (const auto& p : parameter) { - value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable - } - else - { - value &= 0LL; - } - - for (int32_t i = 0; i < num_of_slices; i++) - { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value *= 2; // shift left the signed integer - value &= 0xFFFFFFFFFFFFFFFELL; // reset the corresponding bit (for the 64 bits variable) - if (static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j]) == 1) - { - value += 1LL; // insert the bit - } + value = (value << 1) | static_cast(bits[GPS_CNAV_DATA_PAGE_BITS - p.first - j]); } } return value; diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index d65520720..b17458da7 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -32,9 +32,6 @@ Gps_Navigation_Message::Gps_Navigation_Message() for (uint32_t i = 1; i < 33; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); - } - for (int32_t i = 1; i < 33; i++) - { almanacHealth[i] = 0; } } @@ -46,66 +43,35 @@ void Gps_Navigation_Message::print_gps_word_bytes(uint32_t GPS_word) const } -bool Gps_Navigation_Message::read_navigation_bool(const std::bitset& bits, const std::vector /*unused*/>& parameter) const +bool Gps_Navigation_Message::read_navigation_bool(const std::bitset& bits, const std::vector>& parameter) const { - bool value; - - if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[0].first]) == 1) - { - value = true; - } - else - { - value = false; - } + bool value = bits[GPS_SUBFRAME_BITS - parameter[0].first]; return value; } -uint64_t Gps_Navigation_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector /*unused*/>& parameter) const +uint64_t Gps_Navigation_Message::read_navigation_unsigned(const std::bitset& bits, const std::vector>& parameter) const { uint64_t value = 0ULL; - const int32_t num_of_slices = parameter.size(); - for (int32_t i = 0; i < num_of_slices; i++) + for (const auto& p : parameter) { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; ++j) { - value <<= 1; // shift left - if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[i].first - j]) == 1) - { - value += 1ULL; // insert the bit - } + value = (value << 1) | (bits.test(GPS_SUBFRAME_BITS - p.first - j) ? 1 : 0); } } return value; } -int64_t Gps_Navigation_Message::read_navigation_signed(const std::bitset& bits, const std::vector /*unused*/>& parameter) const +int64_t Gps_Navigation_Message::read_navigation_signed(const std::bitset& bits, const std::vector>& parameter) const { - int64_t value = 0LL; - const int32_t num_of_slices = parameter.size(); - - // read the MSB and perform the sign extension - if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[0].first]) == 1) + int64_t value = (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) ? -1LL : 0LL; + for (const auto& p : parameter) { - value ^= 0xFFFFFFFFFFFFFFFFLL; // 64 bits variable - } - else - { - value &= 0LL; - } - - for (int32_t i = 0; i < num_of_slices; i++) - { - for (int32_t j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < p.second; j++) { - value *= 2; // shift left the signed integer - value &= 0xFFFFFFFFFFFFFFFELL; // reset the corresponding bit (for the 64 bits variable) - if (static_cast(bits[GPS_SUBFRAME_BITS - parameter[i].first - j]) == 1) - { - value += 1LL; // insert the bit - } + value = (value << 1) | static_cast(bits[GPS_SUBFRAME_BITS - p.first - j]); } } return value; @@ -351,7 +317,7 @@ int32_t Gps_Navigation_Message::subframe_decoder(const char* subframe) default: break; - } // switch subframeID ... + } // switch subframeID return subframe_ID; } From 1909900b3620a1668ff0802f09223407981127ac Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 13 Jan 2024 12:09:06 +0100 Subject: [PATCH 140/142] CI: add libmatio to macos jobs --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bb0bd3724..183a871ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: rm /usr/local/bin/pydoc3.1* || true rm /usr/local/bin/python3.1* || true export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 - brew install ninja hdf5 automake armadillo lapack \ + brew install ninja hdf5 automake armadillo lapack libmatio \ gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako - name: configure @@ -82,8 +82,8 @@ jobs: rm /usr/local/bin/pydoc3.1* || true rm /usr/local/bin/python3.1* || true export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 - brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \ - gnuradio log4cpp openssl pugixml protobuf + brew install ninja pkg-config hdf5 automake armadillo lapack libmatio \ + gflags glog gnuradio log4cpp openssl pugixml protobuf pip3 install mako - name: configure run: cd build && cmake -GXcode .. From b22f64cc6c33b80eb92b527d52a8738855e62587 Mon Sep 17 00:00:00 2001 From: En Shih Date: Sat, 13 Jan 2024 23:43:41 +0800 Subject: [PATCH 141/142] Fix finding packages for homebrew on M1 macs --- cmake/Modules/AvoidAccelerate.cmake | 2 ++ cmake/Modules/FindGFLAGS.cmake | 3 +++ cmake/Modules/FindGLOG.cmake | 1 + cmake/Modules/FindGOOGLETEST.cmake | 2 ++ 4 files changed, 8 insertions(+) diff --git a/cmake/Modules/AvoidAccelerate.cmake b/cmake/Modules/AvoidAccelerate.cmake index e3d3b029a..5d052296d 100644 --- a/cmake/Modules/AvoidAccelerate.cmake +++ b/cmake/Modules/AvoidAccelerate.cmake @@ -27,6 +27,7 @@ find_library(BLAS_LIBRARIES /opt/local/lib/lapack /opt/local/lib/ /usr/local/opt/lapack/lib + /opt/homebrew/opt/lapack/lib NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -47,6 +48,7 @@ find_library(LAPACK_LIBRARIES ${BLAS_ROOT_USER_DEFINED}/lapack /opt/local/lib/lapack /usr/local/opt/lapack/lib + /opt/homebrew/opt/lapack/lib NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH diff --git a/cmake/Modules/FindGFLAGS.cmake b/cmake/Modules/FindGFLAGS.cmake index c662faad0..2649380c9 100644 --- a/cmake/Modules/FindGFLAGS.cmake +++ b/cmake/Modules/FindGFLAGS.cmake @@ -44,6 +44,7 @@ if(APPLE) ${GFLAGS_ROOT_USER_PROVIDED}/lib /usr/local/lib /opt/local/lib + /opt/homebrew/opt/gflags/lib ) else() find_path(GFlags_ROOT_DIR @@ -84,6 +85,7 @@ else() endif() if(GFlags_ROOT_DIR) + unset(GFlags_INCLUDE_DIRS CACHE) # We are testing only a couple of files in the include directories find_path(GFlags_INCLUDE_DIRS gflags/gflags.h @@ -93,6 +95,7 @@ if(GFlags_ROOT_DIR) /usr/include /usr/local/include /opt/local/include + /opt/homebrew/opt/gflags/include ) # Find the libraries diff --git a/cmake/Modules/FindGLOG.cmake b/cmake/Modules/FindGLOG.cmake index e0e775539..e483dfbe9 100644 --- a/cmake/Modules/FindGLOG.cmake +++ b/cmake/Modules/FindGLOG.cmake @@ -109,6 +109,7 @@ else() /usr/include/glog /usr/local/include/glog /opt/local/include/glog # default location in Macports + /opt/homebrew/opt/glog/include/glog ${GLOG_ROOT}/include/glog ) endif() diff --git a/cmake/Modules/FindGOOGLETEST.cmake b/cmake/Modules/FindGOOGLETEST.cmake index 1d27e5d30..cf47a7062 100644 --- a/cmake/Modules/FindGOOGLETEST.cmake +++ b/cmake/Modules/FindGOOGLETEST.cmake @@ -47,6 +47,7 @@ find_path(LIBGTEST_DEV_DIR /usr/include/gtest /usr/local/src/googletest/googletest /opt/local/src/gtest-1.7.0 + /opt/homebrew/opt/googletest/include/googletest/googletest ) find_path(GTEST_INCLUDE_DIRS @@ -57,6 +58,7 @@ find_path(GTEST_INCLUDE_DIRS /usr/include /usr/local/include /opt/local/src/gtest-1.7.0/include + /opt/homebrew/opt/googletest/include ) include(FindPackageHandleStandardArgs) From e9cea61b87d26bc892f5d01373b8e498c02fbb00 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 14 Jan 2024 08:41:03 +0100 Subject: [PATCH 142/142] Fix building of benchmarks with Xcode --- src/tests/benchmarks/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tests/benchmarks/CMakeLists.txt b/src/tests/benchmarks/CMakeLists.txt index 3ef8a4eb3..133174871 100644 --- a/src/tests/benchmarks/CMakeLists.txt +++ b/src/tests/benchmarks/CMakeLists.txt @@ -25,6 +25,11 @@ if(NOT benchmark_FOUND) "--build" "${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}" "--config" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> ) + if(CMAKE_GENERATOR STREQUAL Xcode) + set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" + "-configuration" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + ) + endif() if((CMAKE_VERSION VERSION_GREATER 3.12.0) AND NOT (CMAKE_GENERATOR STREQUAL Xcode)) set(BENCHMARK_PARALLEL_BUILD "--parallel 2")