From a35b90b4cb589de080828c31b93a50e278bb1ee0 Mon Sep 17 00:00:00 2001 From: Vladisslav P Date: Tue, 12 Jul 2022 05:28:49 +0300 Subject: [PATCH 01/44] glonass_lx_ca_dll_pll_c_aid_tracking better checks before enabling preamble_timestamp_samples message port connection 1. Check for message port presence both in trk and nav blocks 2. Check for configuration property Tracking_xG.extend_correlation_ms Signed-off-by: Vladisslav P --- src/algorithms/channel/adapters/channel.cc | 32 ++++++++++++++++++++-- src/algorithms/channel/adapters/channel.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 28376dfd8..adb392e9f 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -104,6 +104,9 @@ Channel::Channel(const ConfigurationInterface* configuration, gnss_signal_ = Gnss_Signal(signal_str); channel_msg_rx_ = channel_msg_receiver_make_cc(channel_fsm_, repeat_); + + glonass_extend_correlation_ms_ = 0; + glonass_extend_correlation_ms_ = configuration->property("Tracking_1G.extend_correlation_ms", 0) + configuration->property("Tracking_2G.extend_correlation_ms", 0); } @@ -128,7 +131,7 @@ void Channel::connect(gr::top_block_sptr top_block) // Message ports top_block->msg_connect(nav_->get_left_block(), pmt::mp("telemetry_to_trk"), trk_->get_right_block(), pmt::mp("telemetry_to_trk")); - if ((trk_->get_right_block()->name() == "glonass_l1_ca_dll_pll_c_aid_tracking_cc") || (trk_->get_right_block()->name() == "glonass_l2_ca_dll_pll_c_aid_tracking_cc")) + if (glonass_dll_pll_c_aid_tracking_check()) { top_block->msg_connect(nav_->get_left_block(), pmt::mp("preamble_timestamp_samples"), trk_->get_right_block(), pmt::mp("preamble_timestamp_samples")); } @@ -162,7 +165,7 @@ void Channel::disconnect(gr::top_block_sptr top_block) nav_->disconnect(top_block); top_block->msg_disconnect(nav_->get_left_block(), pmt::mp("telemetry_to_trk"), trk_->get_right_block(), pmt::mp("telemetry_to_trk")); - if ((trk_->get_right_block()->name() == "glonass_l1_ca_dll_pll_c_aid_tracking_cc") || (trk_->get_right_block()->name() == "glonass_l2_ca_dll_pll_c_aid_tracking_cc")) + if (glonass_dll_pll_c_aid_tracking_check()) { top_block->msg_disconnect(nav_->get_left_block(), pmt::mp("preamble_timestamp_samples"), trk_->get_right_block(), pmt::mp("preamble_timestamp_samples")); } @@ -270,3 +273,28 @@ void Channel::start_acquisition() } DLOG(INFO) << "Channel start_acquisition()"; } + +bool Channel::glonass_dll_pll_c_aid_tracking_check() +{ + if (glonass_extend_correlation_ms_) + { + const pmt::pmt_t nav_ports_out = nav_->get_left_block()->message_ports_out(); + const pmt::pmt_t trk_ports_in = trk_->get_right_block()->message_ports_in(); + const pmt::pmt_t symbol = pmt::mp("preamble_timestamp_samples"); + for (unsigned k = 0; k < pmt::length(nav_ports_out); k++) + { + if (pmt::vector_ref(nav_ports_out, k) == symbol) + { + for (unsigned j = 0; j < pmt::length(trk_ports_in); j++) + { + if (pmt::vector_ref(trk_ports_in, j) == symbol) + { + return true; + } + } + return false; + } + } + } + return false; +} diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index d43d1df42..b9d3dbfc6 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -96,6 +96,7 @@ public: inline std::shared_ptr telemetry() const { return nav_; } private: + bool glonass_dll_pll_c_aid_tracking_check(); std::shared_ptr channel_fsm_; std::shared_ptr acq_; std::shared_ptr trk_; @@ -109,6 +110,7 @@ private: bool connected_; bool repeat_; bool flag_enable_fpga_; + int glonass_extend_correlation_ms_; }; From c991f8f601da64ad119d0e462d03bb600efcdb4c Mon Sep 17 00:00:00 2001 From: Vladisslav P Date: Tue, 12 Jul 2022 06:48:24 +0300 Subject: [PATCH 02/44] Glonass: implement extended correlation for cshort blocks Signed-off-by: Vladisslav P --- .../glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 17 +++++++++-------- .../glonass_l1_ca_dll_pll_c_aid_tracking_sc.h | 2 +- .../glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 17 +++++++++-------- .../glonass_l2_ca_dll_pll_c_aid_tracking_sc.h | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) 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 6ca1c9030..27d62058a 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 @@ -85,7 +85,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(const p DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) // avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_samples = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -134,7 +134,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_pll_to_dll_assist_secs_Ti(0.0), d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), - d_preamble_timestamp_s(0.0), + d_preamble_timestamp_samples(0.0), d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), @@ -154,8 +154,8 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_dump(dump) { // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + this->message_port_register_in(pmt::mp("preamble_timestamp_samples")); + this->set_msg_handler(pmt::mp("preamble_timestamp_samples"), #if HAS_GENERIC_LAMBDA [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); #else @@ -209,7 +209,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() const double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect // Fd=(C/(C+Vr))*F - d_glonass_freq_ch = GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_FREQ_HZ * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_glonass_freq_ch = GLONASS_L1_CA_FREQ_HZ + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); const double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; // new chip and prn sequence periods based on acq Doppler d_code_freq_chips = radial_velocity * GLONASS_L1_CA_CODE_RATE_CPS; @@ -273,8 +273,8 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() // enable tracking d_pull_in = true; d_enable_tracking = true; - d_enable_extended_integration = true; - d_preamble_synchronized = true; + d_enable_extended_integration = false; + d_preamble_synchronized = false; LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples @@ -604,7 +604,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples - d_preamble_timestamp_samples) / static_cast(d_fs_in))); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -631,6 +631,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } // UPDATE INTEGRATION TIME CURRENT_INTEGRATION_TIME_S = static_cast(d_extend_correlation_ms) * GLONASS_L1_CA_CODE_PERIOD_S; + d_code_loop_filter.set_pdi(static_cast(CURRENT_INTEGRATION_TIME_S)); enable_dll_pll = true; } else diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h index 8c482ec92..999b1f7a2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -170,7 +170,7 @@ private: double d_pll_to_dll_assist_secs_Ti; double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; - double d_preamble_timestamp_s; + double d_preamble_timestamp_samples; int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; 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 ebd6894e6..b137f50eb 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 @@ -83,7 +83,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(const p DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) // avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_samples = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -132,7 +132,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_pll_to_dll_assist_secs_Ti(0.0), d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), - d_preamble_timestamp_s(0.0), + d_preamble_timestamp_samples(0.0), d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), @@ -152,8 +152,8 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_dump(dump) { // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + this->message_port_register_in(pmt::mp("preamble_timestamp_samples")); + this->set_msg_handler(pmt::mp("preamble_timestamp_samples"), #if HAS_GENERIC_LAMBDA [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); #else @@ -206,7 +206,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() const double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect // Fd=(C/(C+Vr))*F - d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (GLONASS_L2_CA_FREQ_HZ * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); const double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; // new chip and prn sequence periods based on acq Doppler d_code_freq_chips = radial_velocity * GLONASS_L2_CA_CODE_RATE_CPS; @@ -269,8 +269,8 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() // enable tracking d_pull_in = true; d_enable_tracking = true; - d_enable_extended_integration = true; - d_preamble_synchronized = true; + d_enable_extended_integration = false; + d_preamble_synchronized = false; d_acc_carrier_phase_initialized = false; LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz @@ -601,7 +601,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - const int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + const int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples - d_preamble_timestamp_samples) / static_cast(d_fs_in))); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -663,6 +663,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // perform basic (1ms) correlation // UPDATE INTEGRATION TIME CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + d_code_loop_filter.set_pdi(static_cast(CURRENT_INTEGRATION_TIME_S)); enable_dll_pll = true; } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h index 0902aa17a..ae9047f7b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h @@ -165,7 +165,7 @@ private: double d_pll_to_dll_assist_secs_Ti; double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; - double d_preamble_timestamp_s; + double d_preamble_timestamp_samples; int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; From a0c1c0a00182993b83f0543913bb044a8bc1d671 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Fri, 29 Jul 2022 15:11:28 -0600 Subject: [PATCH 03/44] improve string handling to avoid buffer overrun --- src/algorithms/libs/rtklib/rtklib.h | 40 +-- src/algorithms/libs/rtklib/rtklib_pntpos.cc | 5 +- src/algorithms/libs/rtklib/rtklib_ppp.cc | 5 +- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 293 ++++++---------- src/algorithms/libs/rtklib/rtklib_rtkcmn.h | 12 +- src/algorithms/libs/rtklib/rtklib_rtkpos.cc | 32 +- src/algorithms/libs/rtklib/rtklib_stream.cc | 354 +++++++++----------- 7 files changed, 300 insertions(+), 441 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 216183d48..4bb933d43 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -1109,26 +1109,26 @@ typedef struct typedef struct -{ /* file control type */ - FILE *fp; /* file pointer */ - FILE *fp_tag; /* file pointer of tag file */ - FILE *fp_tmp; /* temporary file pointer for swap */ - FILE *fp_tag_tmp; /* temporary file pointer of tag file for swap */ - char path[MAXSTRPATH]; /* file path */ - char openpath[MAXSTRPATH]; /* open file path */ - int mode; /* file mode */ - int timetag; /* time tag flag (0:off,1:on) */ - int repmode; /* replay mode (0:master,1:slave) */ - int offset; /* time offset (ms) for slave */ - gtime_t time; /* start time */ - gtime_t wtime; /* write time */ - unsigned int tick; /* start tick */ - unsigned int tick_f; /* start tick in file */ - unsigned int fpos; /* current file position */ - double start; /* start offset (s) */ - double speed; /* replay speed (time factor) */ - double swapintv; /* swap interval (hr) (0: no swap) */ - lock_t lock; /* lock flag */ +{ /* file control type */ + FILE *fp = nullptr; /* file pointer */ + FILE *fp_tag = nullptr; /* file pointer of tag file */ + FILE *fp_tmp = nullptr; /* temporary file pointer for swap */ + FILE *fp_tag_tmp = nullptr; /* temporary file pointer of tag file for swap */ + std::string path; /* file path */ + std::string openpath; /* open file path */ + int mode = 0; /* file mode */ + int timetag; /* time tag flag (0:off,1:on) */ + int repmode = 0; /* replay mode (0:master,1:slave) */ + int offset = 0; /* time offset (ms) for slave */ + gtime_t time = {}; /* start time */ + gtime_t wtime = {}; /* write time */ + unsigned int tick = 0; /* start tick */ + unsigned int tick_f = 0; /* start tick in file */ + unsigned int fpos = 0; /* current file position */ + double start = 0; /* start offset (s) */ + double speed = 0; /* replay speed (time factor) */ + double swapintv = 0; /* swap interval (hr) (0: no swap) */ + lock_t lock; /* lock flag */ } file_t; diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index abc3c2579..594815996 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -720,7 +720,6 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, obsd_t *obs_e; sol_t sol_e = {{0, 0}, {}, {}, {}, '0', '0', '0', 0.0, 0.0, 0.0}; char tstr[32]; - char name[16]; char msg_e[128]; double *rs_e; double *dts_e; @@ -819,8 +818,8 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, if (stat) { time2str(obs[0].time, tstr, 2); - satno2id(sat, name); - trace(2, "%s: %s excluded by raim\n", tstr + 11, name); + auto name = satno2id(sat); + trace(2, "%s: %s excluded by raim\n", tstr + 11, name.data()); } free(obs_e); free(rs_e); diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index 5e4280f41..ad2adcee2 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -747,7 +747,6 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) int j; int week; int nfreq = 1; - char id[32]; if (level <= 0 || !fp) { @@ -804,11 +803,11 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) { continue; } - satno2id(i + 1, id); + auto id = satno2id(i + 1); for (j = 0; j < nfreq; j++) { fprintf(fp, "$SAT,%d,%.3f,%s,%d,%.1f,%.1f,%.4f,%.4f,%d,%.0f,%d,%d,%d,%d,%d,%d\n", - week, tow, id, j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, + week, tow, id.data(), j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, ssat->resp[j], ssat->resc[j], ssat->vsat[j], ssat->snr[j] * 0.25, ssat->fix[j], ssat->slip[j] & 3, ssat->lock[j], ssat->outc[j], ssat->slipc[j], ssat->rejc[j]); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 81842d48a..3565aa3ef 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,7 +43,6 @@ #include #include - const double GPST0[] = {1980, 1, 6, 0, 0, 0}; /* gps time reference */ const double GST0[] = {1999, 8, 22, 0, 0, 0}; /* galileo system time reference */ const double BDT0[] = {2006, 1, 1, 0, 0, 0}; /* beidou time reference */ @@ -460,37 +459,50 @@ int satid2no(const char *id) * char *id O satellite id (Gnn,Rnn,Enn,Jnn,Cnn,Inn or nnn) * return : none *-----------------------------------------------------------------------------*/ -void satno2id(int sat, char *id) +std::string satno2id(int sat) { + std::ostringstream ss; + ss << std::setfill('0'); // all PRNs are 0-filled + std::string prefix; + int width = 2; + int prn; - char id_aux[16]; switch (satsys(sat, &prn)) { case SYS_GPS: - std::snprintf(id, sizeof(id_aux), "G%02d", prn - MINPRNGPS + 1); - return; + prefix = "G"; + prn = prn - MINPRNGPS + 1; + break; case SYS_GLO: - snprintf(id, sizeof(id_aux), "R%02d", prn - MINPRNGLO + 1); - return; + prefix = "R"; + prn = prn - MINPRNGLO + 1; + break; case SYS_GAL: - std::snprintf(id, sizeof(id_aux), "E%02d", prn - MINPRNGAL + 1); - return; + prefix = "E"; + prn = prn - MINPRNGAL + 1; + break; case SYS_QZS: - std::snprintf(id, sizeof(id_aux), "J%02d", prn - MINPRNQZS + 1); - return; + prefix = "J"; + prn = prn - MINPRNQZS + 1; + break; case SYS_BDS: - std::snprintf(id, sizeof(id_aux), "C%02d", prn - MINPRNBDS + 1); - return; + prefix = "C"; + prn = prn - MINPRNBDS + 1; + break; case SYS_IRN: - std::snprintf(id, sizeof(id_aux), "I%02d", prn - MINPRNIRN + 1); - return; + prefix = "I"; + prn = prn - MINPRNIRN + 1; + break; case SYS_LEO: - std::snprintf(id, sizeof(id_aux), "L%02d", prn - MINPRNLEO + 1); - return; + prefix = "L"; + prn = prn - MINPRNLEO + 1; + break; case SYS_SBS: - std::snprintf(id, sizeof(id_aux), "%03d", prn); - return; + width = 3; + break; } + ss << prefix << std::setw(width) << prn; + return ss.str(); } @@ -2833,9 +2845,9 @@ int readantex(const char *file, pcvs_t *pcvs) if (strstr(buff + 60, "TYPE / SERIAL NO")) { - strncpy(pcv.type, buff, 20); + strncpy(pcv.type, buff, 20); // MAXANT (64) pcv.type[20] = '\0'; - strncpy(pcv.code, buff + 20, 20); + strncpy(pcv.code, buff + 20, 20); // MAXANT (64) pcv.code[20] = '\0'; if (!strncmp(pcv.code + 3, " ", 8)) { @@ -3090,9 +3102,9 @@ void readpos(const char *file, const char *rcv, double *pos) { continue; } - // strncpy(stas[np], str, 15); This line triggers a warning. Replaced by: - memcpy(stas[np], str, 15 * sizeof(stas[np][0])); - stas[np++][15] = '\0'; + auto sta = stas[np++]; + std::strncpy(sta, str, 16); + sta[15] = '\0'; } fclose(fp); len = static_cast(strlen(rcv)); @@ -3700,7 +3712,6 @@ int savenav(const char *file, const nav_t *nav) { FILE *fp; int i; - char id[32]; trace(3, "savenav: file=%s\n", file); @@ -3715,12 +3726,12 @@ int savenav(const char *file, const nav_t *nav) { continue; } - satno2id(nav->eph[i].sat, id); + auto id = satno2id(nav->eph[i].sat); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.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, nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva, + 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].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, @@ -3736,11 +3747,11 @@ int savenav(const char *file, const nav_t *nav) { continue; } - satno2id(nav->geph[i].sat, id); + auto id = satno2id(nav->geph[i].sat); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n", - id, nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh, + 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].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], @@ -3841,7 +3852,7 @@ void freenav(nav_t *nav, int opt) // #ifdef TRACE // FILE *fp_trace = nullptr; /* file pointer of trace */ -char file_trace[1024]; /* trace file */ +std::string file_trace; /* trace file */ static int level_trace = 0; /* level of trace */ unsigned int tick_trace = 0; /* tick time at traceopen (ms) */ gtime_t time_trace = {0, 0.0}; /* time at traceopen */ @@ -3850,7 +3861,7 @@ pthread_mutex_t lock_trace; /* lock for trace */ void traceswap() { gtime_t time = utc2gpst(timeget()); - char path[1024]; + std::string path; rtk_lock(&lock_trace); @@ -3872,7 +3883,7 @@ void traceswap() fclose(fp_trace); } - if (!(fp_trace = fopen(path, "we"))) + if (!(fp_trace = fopen(path.data(), "we"))) { fp_trace = stderr; } @@ -3883,22 +3894,15 @@ void traceswap() void traceopen(const char *file) { gtime_t time = utc2gpst(timeget()); - char path[1024]; + std::string path; reppath(file, path, time, "", ""); - if (!*path || !(fp_trace = fopen(path, "we"))) + if (path.empty() or (fp_trace = fopen(path.data(), "we")) == nullptr) { fp_trace = stderr; } - if (strlen(file) < 1025) - { - std::strncpy(file_trace, file, 1024); - file_trace[1023] = '\0'; - } - else - { - trace(1, "file array is too long"); - } + + file_trace = file; tick_trace = tickget(); time_trace = time; initlock(&lock_trace); @@ -3912,7 +3916,7 @@ void traceclose() fclose(fp_trace); } fp_trace = nullptr; - file_trace[0] = '\0'; + file_trace.clear(); } @@ -3967,9 +3971,9 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // if (!fp_trace||level>level_trace) return; // for (i=0;in;i++) { // time2str(nav->eph[i].toe,s1,0); // time2str(nav->eph[i].ttr,s2,0); -// satno2id(nav->eph[i].sat,id); +// auto id = satno2id(nav->eph[i].sat); // fprintf(fp_trace,"(%3d) %-3s : %s %s %3d %3d %02x\n",i+1, -// id,s1,s2,nav->eph[i].iode,nav->eph[i].iodc,nav->eph[i].svh); +// id.data(),s1,s2,nav->eph[i].iode,nav->eph[i].iodc,nav->eph[i].svh); // } // fprintf(fp_trace,"(ion) %9.4e %9.4e %9.4e %9.4e\n",nav->ion_gps[0], // nav->ion_gps[1],nav->ion_gps[2],nav->ion_gps[3]); @@ -4005,9 +4009,9 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // for (i=0;ing;i++) { // time2str(nav->geph[i].toe,s1,0); // time2str(nav->geph[i].tof,s2,0); -// satno2id(nav->geph[i].sat,id); +// auto id = satno2id(nav->geph[i].sat); // fprintf(fp_trace,"(%3d) %-3s : %s %s %2d %2d %8.3f\n",i+1, -// id,s1,s2,nav->geph[i].frq,nav->geph[i].svh,nav->geph[i].taun*1e6); +// id.data(),s1,s2,nav->geph[i].frq,nav->geph[i].svh,nav->geph[i].taun*1e6); // } // } // extern void tracehnav(int level, const nav_t *nav) @@ -4019,14 +4023,14 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // for (i=0;ins;i++) { // time2str(nav->seph[i].t0,s1,0); // time2str(nav->seph[i].tof,s2,0); -// satno2id(nav->seph[i].sat,id); +// auto id = satno2id(nav->seph[i].sat); // fprintf(fp_trace,"(%3d) %-3s : %s %s %2d %2d\n",i+1, -// id,s1,s2,nav->seph[i].svh,nav->seph[i].sva); +// id.data(),s1,s2,nav->seph[i].svh,nav->seph[i].sva); // } // } // extern void tracepeph(int level, const nav_t *nav) // { -// char s[64],id[16]; +// char s[64]; // int i,j; // // if (!fp_trace||level>level_trace) return; @@ -4034,9 +4038,9 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // for (i=0;ine;i++) { // time2str(nav->peph[i].time,s,0); // for (j=0;jpeph[i].index,id, +// s,nav->peph[i].index,id.data(), // nav->peph[i].pos[j][0],nav->peph[i].pos[j][1], // nav->peph[i].pos[j][2],nav->peph[i].pos[j][3]*1e9, // nav->peph[i].std[j][0],nav->peph[i].std[j][1], @@ -4046,7 +4050,7 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // } // extern void tracepclk(int level, const nav_t *nav) // { -// char s[64],id[16]; +// char s[64]; // int i,j; // // if (!fp_trace||level>level_trace) return; @@ -4054,9 +4058,9 @@ void traceobs(int level __attribute__((unused)), const obsd_t *obs __attribute__ // for (i=0;inc;i++) { // time2str(nav->pclk[i].time,s,0); // for (j=0;jpclk[i].index,id, +// s,nav->pclk[i].index,id.data(), // nav->pclk[i].clk[j][0]*1e9,nav->pclk[i].std[j][0]*1e9); // } // } @@ -4114,69 +4118,31 @@ int execcmd(const char *cmd) * return : none * notes : not recursive. only one level *-----------------------------------------------------------------------------*/ -void createdir(const char *path) +void createdir(std::filesystem::path const& path) { - char buff[1024]; - char *p; - // tracet(3, "createdir: path=%s\n", path); + std::error_code ec; - if (strlen(path) < 1025) - { - std::strncpy(buff, path, 1024); - buff[1023] = '\0'; - } - else - { - trace(1, "path is too long"); - } - if (!(p = strrchr(buff, FILEPATHSEP))) - { - return; - } - *p = '\0'; - - if (mkdir(buff, 0777) != 0) - { - trace(1, "Error creating folder"); - } + auto created = std::filesystem::create_directory(path, ec); + if (not created) + { + trace(1, "Error creating folder: %s", path.c_str()); + } } /* replace string ------------------------------------------------------------*/ -int repstr(char *str, const char *pat, const char *rep) +int repstr(std::string &str, std::string const &pat, std::string const &rep) { - int len = static_cast(strlen(pat)); - char buff[1024]; - char *p; - char *q; - char *r; + int replaced = 0; - for (p = str, r = buff; *p; p = q + len) + auto pos = str.find(pat); + if (pos != std::string::npos) { - if (!(q = strstr(p, pat))) - { - break; - } - strncpy(r, p, q - p); - r += q - p; - r += std::snprintf(r, sizeof(buff), "%s", rep); - } - if (p <= str) - { - return 0; + str.replace(pos, pat.length(), rep); + replaced = 1; } - if (strlen(p) < 1025) - { - std::strncpy(r, p, 1024); - r[1023] = '\0'; - } - else - { - trace(1, "pat array is too long"); - } - std::strncpy(str, buff, 1024); - return 1; + return replaced; } @@ -4208,23 +4174,19 @@ int repstr(char *str, const char *pat, const char *rep) * %r -> rrrr : rover id * %b -> bbbb : base station id *-----------------------------------------------------------------------------*/ -int reppath(const char *path, char *rpath, gtime_t time, const char *rov, +int reppath(std::string const &path, std::string &rpath, gtime_t time, const char *rov, const char *base) { - double ep[6]; - double ep0[6] = {2000, 1, 1, 0, 0, 0}; - int week; - int dow; - int doy; int stat = 0; - char rep[64]; - std::strncpy(rpath, path, 1024); + rpath = path; + + // synctactic sugar; implements C++23 std::string::contains() + auto patFind = [](std::string const &s, std::string const &pat) -> bool { + auto pos = s.find(pat); + return pos != s.npos; + }; - if (!strstr(rpath, "%")) - { - return 0; - } if (*rov) { stat |= repstr(rpath, "%r", rov); @@ -4235,10 +4197,17 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, } if (time.time != 0) { + char rep[64]; // scratch space for replacement string + + double ep[6]; time2epoch(time, ep); - ep0[0] = ep[0]; - dow = static_cast(floor(time2gpst(time, &week) / 86400.0)); - doy = static_cast(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; + + int week = 0; + auto dow = static_cast(floor(time2gpst(time, &week) / 86400.0)); + + double ep0[6] = {ep[0], 1, 1, 0, 0, 0}; + auto doy = static_cast(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; + std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[3]) / 3) * 3); stat |= repstr(rpath, "%ha", rep); std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[3]) / 6) * 6); @@ -4270,78 +4239,18 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[4]) / 15) * 15); stat |= repstr(rpath, "%t", rep); } - else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") || - strstr(rpath, "%Y") || strstr(rpath, "%y") || strstr(rpath, "%m") || - strstr(rpath, "%d") || strstr(rpath, "%h") || strstr(rpath, "%M") || - strstr(rpath, "%S") || strstr(rpath, "%n") || strstr(rpath, "%W") || - strstr(rpath, "%D") || strstr(rpath, "%H") || strstr(rpath, "%t")) + else if (patFind(rpath, "%ha") || patFind(rpath, "%hb") || patFind(rpath, "%hc") || + patFind(rpath, "%Y") || patFind(rpath, "%y") || patFind(rpath, "%m") || + patFind(rpath, "%d") || patFind(rpath, "%h") || patFind(rpath, "%M") || + patFind(rpath, "%S") || patFind(rpath, "%n") || patFind(rpath, "%W") || + patFind(rpath, "%D") || patFind(rpath, "%H") || patFind(rpath, "%t")) { - return -1; /* no valid time */ + stat = -1; /* no valid time */ } return stat; } -/* replace keywords in file path and generate multiple paths ------------------- - * replace keywords in file path with date, time, rover and base station id - * generate multiple keywords-replaced paths - * args : char *path I file path (see below) - * char *rpath[] O file paths in which keywords replaced - * int nmax I max number of output file paths - * gtime_t ts I time start (gpst) - * gtime_t te I time end (gpst) - * char *rov I rover id string ("": not replaced) - * char *base I base station id string ("": not replaced) - * return : number of replaced file paths - * notes : see reppath() for replacements of keywords. - * minimum interval of time replaced is 900s. - *-----------------------------------------------------------------------------*/ -int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, - gtime_t te, const char *rov, const char *base) -{ - gtime_t time; - double tow; - double tint = 86400.0; - int i; - int n = 0; - int week; - - trace(3, "reppaths: path =%s nmax=%d rov=%s base=%s\n", path, nmax, rov, base); - - if (ts.time == 0 || te.time == 0 || timediff(ts, te) > 0.0) - { - return 0; - } - - if (strstr(path, "%S") || strstr(path, "%M") || strstr(path, "%t")) - { - tint = 900.0; - } - else if (strstr(path, "%h") || strstr(path, "%H")) - { - tint = 3600.0; - } - - tow = time2gpst(ts, &week); - time = gpst2time(week, floor(tow / tint) * tint); - - while (timediff(time, te) <= 0.0 && n < nmax) - { - reppath(path, rpath[n], time, rov, base); - if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) - { - n++; - } - time = timeadd(time, tint); - } - for (i = 0; i < n; i++) - { - trace(3, "reppaths: rpath=%s\n", rpath[i]); - } - return n; -} - - /* satellite carrier wave length ----------------------------------------------- * get satellite carrier wave lengths * args : int sat I satellite number diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h index ddf152a0d..2d46700c1 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h @@ -59,6 +59,7 @@ #define GNSS_SDR_RTKLIB_RTKCMN_H #include "rtklib.h" +#include #include #include @@ -102,7 +103,7 @@ void fatalerr(const char *format, ...); int satno(int sys, int prn); int satsys(int sat, int *prn); int satid2no(const char *id); -void satno2id(int sat, char *id); +std::string satno2id(int sat); int satexclude(int sat, int svh, const prcopt_t *opt); int testsnr(int base, int freq, double el, double snr, const snrmask_t *mask); unsigned char obs2code(const char *obs, int *freq); @@ -229,12 +230,9 @@ void traceobs(int level, const obsd_t *obs, int n); // void traceb (int level, const unsigned char *p, int n); int execcmd(const char *cmd); -void createdir(const char *path); -int repstr(char *str, const char *pat, const char *rep); -int reppath(const char *path, char *rpath, gtime_t time, const char *rov, - const char *base); -int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, - gtime_t te, const char *rov, const char *base); +void createdir(std::filesystem::path const& path); +int reppath(std::string const &path, std::string &rpath, gtime_t time, const char *rov, + const char *base); double satwavelen(int sat, int frq, const nav_t *nav); double geodist(const double *rs, const double *rr, double *e); double satazel(const double *pos, const double *e, double *azel); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 54bcaa802..1be140ad9 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -124,7 +124,7 @@ static gtime_t time_stat = {0, 0}; /* rtk status file time */ int rtkopenstat(const char *file, int level) { gtime_t time = utc2gpst(timeget()); - char path[1024]; + std::string path; trace(3, "rtkopenstat: file=%s level=%d\n", file, level); @@ -135,9 +135,9 @@ int rtkopenstat(const char *file, int level) reppath(file, path, time, "", ""); - if (!(fp_stat = fopen(path, "we"))) + if (!(fp_stat = fopen(path.data(), "we"))) { - trace(1, "rtkopenstat: file open error path=%s\n", path); + trace(1, "rtkopenstat: file open error path=%s\n", path.data()); return 0; } if (strlen(file) < 1025) @@ -191,7 +191,6 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) int est; int nfreq; int nf = NF_RTK(&rtk->opt); - char id[32]; if (statlevel <= 0 || !fp_stat) { @@ -264,11 +263,11 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) { continue; } - satno2id(i + 1, id); + auto id = satno2id(i + 1); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; fprintf(fp_stat, "$ION,%d,%.3f,%d,%s,%.1f,%.1f,%.4f,%.4f\n", week, tow, rtk->sol.stat, - id, ssat->azel[0] * R2D, ssat->azel[1] * R2D, rtk->x[j], xa[0]); + id.data(), ssat->azel[0] * R2D, ssat->azel[1] * R2D, rtk->x[j], xa[0]); } } /* tropospheric parameters */ @@ -306,11 +305,11 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) { continue; } - satno2id(i + 1, id); + auto id = satno2id(i + 1); for (j = 0; j < nfreq; j++) { fprintf(fp_stat, "$SAT,%d,%.3f,%s,%d,%.1f,%.1f,%.4f,%.4f,%d,%.0f,%d,%d,%d,%d,%d,%d\n", - week, tow, id, j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, + week, tow, id.data(), j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, ssat->resp[j], ssat->resc[j], ssat->vsat[j], ssat->snr[j] * 0.25, ssat->fix[j], ssat->slip[j] & 3, ssat->lock[j], ssat->outc[j], ssat->slipc[j], ssat->rejc[j]); @@ -323,7 +322,7 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) void swapsolstat() { gtime_t time = utc2gpst(timeget()); - char path[1024]; + std::string path; if (static_cast(time2gpst(time, nullptr) / INT_SWAP_STAT) == static_cast(time2gpst(time_stat, nullptr) / INT_SWAP_STAT)) @@ -341,12 +340,12 @@ void swapsolstat() fclose(fp_stat); } - if (!(fp_stat = fopen(path, "we"))) + if (!(fp_stat = fopen(path.data(), "we"))) { - trace(2, "swapsolstat: file open error path=%s\n", path); + trace(2, "swapsolstat: file open error path=%s\n", path.data()); return; } - trace(3, "swapsolstat: path=%s\n", path); + trace(3, "swapsolstat: path=%s\n", path.data()); } @@ -367,7 +366,6 @@ void outsolstat(rtk_t *rtk) int est; int nfreq; int nf = NF_RTK(&rtk->opt); - char id[32]; if (statlevel <= 0 || !fp_stat) { @@ -440,11 +438,11 @@ void outsolstat(rtk_t *rtk) { continue; } - satno2id(i + 1, id); + auto id = satno2id(i + 1); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; fprintf(fp_stat, "$ION,%d,%.3f,%d,%s,%.1f,%.1f,%.4f,%.4f\n", week, tow, rtk->sol.stat, - id, ssat->azel[0] * R2D, ssat->azel[1] * R2D, rtk->x[j], xa[0]); + id.data(), ssat->azel[0] * R2D, ssat->azel[1] * R2D, rtk->x[j], xa[0]); } } /* tropospheric parameters */ @@ -482,11 +480,11 @@ void outsolstat(rtk_t *rtk) { continue; } - satno2id(i + 1, id); + auto id = satno2id(i + 1); for (j = 0; j < nfreq; j++) { fprintf(fp_stat, "$SAT,%d,%.3f,%s,%d,%.1f,%.1f,%.4f,%.4f,%d,%.0f,%d,%d,%d,%d,%d,%d\n", - week, tow, id, j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, + week, tow, id.data(), j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, ssat->resp[j], ssat->resc[j], ssat->vsat[j], ssat->snr[j] * 0.25, ssat->fix[j], ssat->slip[j] & 3, ssat->lock[j], ssat->outc[j], ssat->slipc[j], ssat->rejc[j]); diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index c1ea5c56e..df50eef56 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include +using namespace std::string_literals; /* global options ------------------------------------------------------------*/ @@ -118,7 +120,7 @@ serial_t *openserial(const char *path, int mode, char *msg) } parity = static_cast(toupper(static_cast(parity))); - std::string s_aux = "/dev/" + std::string(port); + std::string s_aux = "/dev/"s + std::string(port); s_aux.resize(128, '\0'); int n = s_aux.length(); for (i = 0; i < n; i++) @@ -228,7 +230,6 @@ int stateserial(serial_t *serial) int openfile_(file_t *file, gtime_t time, char *msg) { FILE *fp; - char *rw; char tagpath[MAXSTRPATH + 4] = ""; char tagh[TIMETAGH_LEN + 1] = ""; @@ -238,8 +239,8 @@ int openfile_(file_t *file, gtime_t time, char *msg) file->tick = file->tick_f = tickget(); file->fpos = 0; - /* use stdin or stdout if file path is null */ - if (!*file->path) + /* use stdin or stdout if file path is empty */ + if (file->path.empty()) { file->fp = file->mode & STR_MODE_R ? stdin : stdout; return 1; @@ -250,37 +251,39 @@ int openfile_(file_t *file, gtime_t time, char *msg) /* create directory */ if ((file->mode & STR_MODE_W) && !(file->mode & STR_MODE_R)) { - createdir(file->openpath); + createdir(file->openpath.data()); } + + char const *mode; if (file->mode & STR_MODE_R) { - rw = const_cast("rb"); + mode = "rb"; } else { - rw = const_cast("wb"); + mode = "wb"; } - if (!(file->fp = fopen(file->openpath, rw))) + if (!(file->fp = fopen(file->openpath.data(), mode))) { std::snprintf(msg, MAXSTRMSG, "file open error"); tracet(1, "openfile: %s\n", msg); return 0; } - tracet(4, "openfile_: open file %s (%s)\n", file->openpath, rw); + tracet(4, "openfile_: open file %s (%s)\n", file->openpath.data(), mode); - std::snprintf(tagpath, MAXSTRPATH + 4, "%s.tag", file->openpath); + std::snprintf(tagpath, MAXSTRPATH + 4, "%s.tag", file->openpath.data()); if (file->timetag) { /* output/sync time-tag */ - if (!(file->fp_tag = fopen(tagpath, rw))) + if (!(file->fp_tag = fopen(tagpath, mode))) { std::snprintf(msg, MAXSTRMSG, "tag open error"); tracet(1, "openfile: %s\n", msg); fclose(file->fp); return 0; } - tracet(4, "openfile_: open tag file %s (%s)\n", tagpath, rw); + tracet(4, "openfile_: open tag file %s (%s)\n", tagpath, mode); if (file->mode & STR_MODE_R) { @@ -330,127 +333,128 @@ void closefile_(file_t *file) if (file->fp) { fclose(file->fp); + file->fp = nullptr; } if (file->fp_tag) { fclose(file->fp_tag); + file->fp_tag = nullptr; } if (file->fp_tmp) { fclose(file->fp_tmp); + file->fp_tmp = nullptr; } if (file->fp_tag_tmp) { fclose(file->fp_tag_tmp); + file->fp_tag_tmp = nullptr; } - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; } /* open file (path=filepath[::T[::+][::x]][::S=swapintv]) --------*/ -file_t *openfile(const char *path, int mode, char *msg) +file_t *openfile(std::string const &path, int mode, char *msg) { - file_t *file; - gtime_t time; - gtime_t time0 = {0, 0.0}; - double speed = 0.0; - double start = 0.0; - double swapintv = 0.0; - char *p; - int timetag = 0; - tracet(3, "openfile: path=%s mode=%d\n", path, mode); - if (!(mode & (STR_MODE_R | STR_MODE_W))) + if ((mode & (STR_MODE_R | STR_MODE_W)) == 0) { return nullptr; } + // Split the string by regular expression (in this case, the trivial "::" string) + std::regex re("::"); + auto first = std::sregex_token_iterator(path.begin(), path.end(), re, -1); + auto last = std::sregex_token_iterator(); + std::deque tokens(first, last); + + auto file = std::make_unique(); + + file->mode = mode; + file->path = tokens.front(); // first token is the path + tokens.pop_front(); + + /* file options */ - for (p = const_cast(path); (p = strstr(p, "::")); p += 2) - { /* file options */ - if (*(p + 2) == 'T') - { - timetag = 1; - } - else if (*(p + 2) == '+') - { - sscanf(p + 2, "+%lf", &start); - } - else if (*(p + 2) == 'x') - { - sscanf(p + 2, "x%lf", &speed); - } - else if (*(p + 2) == 'S') - { - sscanf(p + 2, "S=%lf", &swapintv); - } - } - if (start <= 0.0) + while (not tokens.empty()) { - start = 0.0; - } - if (swapintv <= 0.0) - { - swapintv = 0.0; + auto tag = tokens.front(); + tokens.pop_front(); + + // edge case that may not be possible, but I don't want to test for right now + if (tag.empty()) continue; + + if (tag == "T") + { + file->timetag = 1; + } + else if (tag[0] == '+') + { + double start = 0.0; + std::istringstream ss(tag); + ss.ignore(1, '+') >> start; + // do we care if there are extra characters? + + if (start < 0) + { + start = 0; + } + file->start = start; + } + else if (tag[0] == 'x') + { + double speed = 0.0; + std::istringstream ss(tag); + ss.ignore(1, 'x') >> speed; + // do we care if there are extra characters? + file->speed = speed; + } + else if (tag[0] == 'S') + { + double swapintv = 0.0; + std::istringstream ss(tag); + ss.ignore(1, 'S').ignore(1, '=') >> swapintv; + // do we care if there are extra characters? + if (swapintv < 0) swapintv = 0; + file->swapintv = swapintv; + } + else + { + // unexpected value ... not previously handled + } } - if (!(file = static_cast(malloc(sizeof(file_t))))) - { - return nullptr; - } - - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; - if (strlen(path) < MAXSTRPATH) - { - std::strncpy(file->path, path, MAXSTRPATH); - file->path[MAXSTRPATH - 1] = '\0'; - } - if ((p = strstr(file->path, "::"))) - { - *p = '\0'; - } - file->openpath[0] = '\0'; - file->mode = mode; - file->timetag = timetag; - file->repmode = 0; - file->offset = 0; - file->time = file->wtime = time0; - file->tick = file->tick_f = file->fpos = 0; - file->start = start; - file->speed = speed; - file->swapintv = swapintv; initlock(&file->lock); - time = utc2gpst(timeget()); + auto time = utc2gpst(timeget()); /* open new file */ - if (!openfile_(file, time, msg)) + if (!openfile_(file.get(), time, msg)) { - free(file); - return nullptr; + file.reset(); } - return file; + return file.release(); // ownership belongs to the caller now } /* close file ----------------------------------------------------------------*/ void closefile(file_t *file) { - if (!file) + if (file) { - return; + std::unique_ptr fileH(file); + tracet(3, "closefile: fp=%p \n", fileH->fp); + + closefile_(fileH.get()); } - tracet(3, "closefile: fp=%p \n", file->fp); - closefile_(file); - free(file); } /* open new swap file --------------------------------------------------------*/ void swapfile(file_t *file, gtime_t time, char *msg) { - char openpath[MAXSTRPATH]; + std::string openpath; tracet(3, "swapfile: fp=%p \n time=%s\n", file->fp, time_str(time, 0)); @@ -463,9 +467,9 @@ void swapfile(file_t *file, gtime_t time, char *msg) /* check path of new swap file */ reppath(file->path, openpath, time, "", ""); - if (!strcmp(openpath, file->openpath)) + if (openpath == file->openpath) { - tracet(2, "swapfile: no need to swap %s\n", openpath); + tracet(2, "swapfile: no need to swap %s\n", openpath.data()); return; } /* save file pointer to temporary pointer */ @@ -1739,7 +1743,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg) /* ntrip access via proxy server */ if (*proxyaddr) { - std::string s_aux = "http://" + std::string(tpath); + std::string s_aux = "http://"s + std::string(tpath); int n = s_aux.length(); if (n < 256) { @@ -1924,19 +1928,6 @@ gtime_t nextdltime(const int *topts, int stat) void *ftpthread(void *arg) { auto *ftp = static_cast(arg); - FILE *fp; - gtime_t time; - char remote[1024]; - char local[1024]; - char tmpfile[1024]; - char errfile[1024]; - char *p; - char cmd[2048]; - char env[1024] = ""; - char opt[1024]; - char *proxyopt = const_cast(""); - char *proto; - int ret; tracet(3, "ftpthread:\n"); @@ -1948,152 +1939,117 @@ void *ftpthread(void *arg) return nullptr; } /* replace keyword in file path and local path */ - time = timeadd(utc2gpst(timeget()), ftp->topts[0]); + auto time = timeadd(utc2gpst(timeget()), ftp->topts[0]); + + std::string remote; reppath(ftp->file, remote, time, "", ""); + auto remotePath = std::filesystem::path(remote); - if ((p = strrchr(remote, '/'))) - { - p++; - } - else - { - p = remote; - } - std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p); - int n = s_aux.length(); - if (n < 1024) - { - for (int i = 0; i < n; i++) - { - local[i] = s_aux[i]; - } - } + auto local = std::filesystem::path(localdir); + local /= remotePath.filename(); - std::string s_aux2 = std::string(local) + ".err"; - n = s_aux2.length(); - if (n < 1024) - { - for (int i = 0; i < n; i++) - { - errfile[i] = s_aux2[i]; - } - } + auto errfile = std::filesystem::path(local); + errfile.replace_extension("err"); /* if local file exist, skip download */ - std::strncpy(tmpfile, local, 1024); - tmpfile[1023] = '\0'; - if ((p = strrchr(tmpfile, '.')) && - (!strcmp(p, ".z") || !strcmp(p, ".gz") || !strcmp(p, ".zip") || - !strcmp(p, ".Z") || !strcmp(p, ".GZ") || !strcmp(p, ".ZIP"))) + auto tmpfile = local; + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) { - *p = '\0'; + if (tmpfile.extension() == ext) + { + tmpfile.replace_extension(""); + break; + } } - if ((fp = fopen(tmpfile, "rbe"))) + if (std::filesystem::exists(tmpfile)) { - fclose(fp); - std::strncpy(ftp->local, tmpfile, 1024); + std::strncpy(ftp->local, tmpfile.c_str(), 1024); ftp->local[1023] = '\0'; tracet(3, "ftpthread: file exists %s\n", ftp->local); ftp->state = 2; return nullptr; } + + std::string env; + /* proxy settings for wget (ref [2]) */ + auto proxyopt = std::string(); if (*proxyaddr) { - proto = ftp->proto ? const_cast("http") : const_cast("ftp"); - std::snprintf(env, sizeof(env), "set %s_proxy=http://%s & ", proto, proxyaddr); - proxyopt = const_cast("--proxy=on "); + auto proto = "ftp"s; + if (ftp->proto) proto = "http"s; + env = "set "s + proto + "_proxy=http://"s + std::string(proxyaddr) + " % "; + proxyopt = "--proxy=on "; } + /* download command (ref [2]) */ + auto cmd_str = std::string(); if (ftp->proto == 0) { /* ftp */ - s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) + - " --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) + - " -O \"" + std::string(local) + "\""; - int k = s_aux.length(); - if (k < 1024) - { - for (int i = 0; i < k; i++) - { - opt[i] = s_aux[i]; - } - } + auto opt_str = "--ftp-user="s + std::string(ftp->user) + " --ftp-password="s + std::string(ftp->passwd) + + " --glob=off --passive-ftp "s + proxyopt + "s-t 1 -T "s + std::to_string(FTP_TIMEOUT) + + " -O \"" + local.native() + "\""s; - s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + - "\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; - k = s_aux2.length(); - for (int i = 0; (i < k) && (i < 1024); i++) - { - cmd[i] = s_aux2[i]; - } + // TODO: this uses shell syntax; consider escaping paths + cmd_str = env + std::string(FTP_CMD) + " "s + opt_str + " "s + + "\"ftp://"s + std::string(ftp->addr) + "/"s + remotePath.native() + "\" 2> \""s + errfile.native() + "\"\n"s; } else { /* http */ - s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; - int l = s_aux.length(); - for (int i = 0; (i < l) && (i < 1024); i++) - { - opt[i] = s_aux[i]; - } + auto opt_str = proxyopt + " -t 1 -T "s + std::to_string(FTP_TIMEOUT) + " -O \""s + local.native() + "\""s; - s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + - "\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; - l = s_aux2.length(); - for (int i = 0; (i < l) && (i < 1024); i++) - { - cmd[i] = s_aux2[i]; - } + cmd_str = env + std::string(FTP_CMD) + " "s + opt_str + " "s + + "\"http://"s + std::string(ftp->addr) + "/"s + remotePath.native() + "\" 2> \""s + errfile.native() + "\"\n"; } /* execute download command */ - if ((ret = execcmd(cmd))) + std::error_code ec; // prevent exceptions + auto ret = execcmd(cmd_str.c_str()); + if ((ret != 0)) { - if (remove(local) != 0) + if (std::filesystem::remove(local, ec) == false) { - trace(1, "Error removing file"); + trace(1, "Error removing file %s", local.c_str()); } - tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd, ret); + tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd_str.data(), ret); ftp->error = ret; ftp->state = 3; return nullptr; } - if (remove(errfile) != 0) + if (std::filesystem::remove(errfile, ec) == false) { - trace(1, "Error removing file"); + trace(1, "Error removing file %s", errfile.c_str()); } /* uncompress downloaded file */ - if ((p = strrchr(local, '.')) && - (!strcmp(p, ".z") || !strcmp(p, ".gz") || !strcmp(p, ".zip") || - !strcmp(p, ".Z") || !strcmp(p, ".GZ") || !strcmp(p, ".ZIP"))) + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) { - if (rtk_uncompress(local, tmpfile)) + if (local.extension() == ext) { - if (remove(local) != 0) + char tmpfile_arg[1024]; + ret = rtk_uncompress(local.c_str(), tmpfile_arg); + if (ret != 0) // success { - trace(1, "Error removing file"); + if (std::filesystem::remove(local, ec) == false) + { + trace(1, "Error removing file %s", local.c_str()); + } + local = tmpfile_arg; } - if (strlen(tmpfile) < 1024) + else { - std::strncpy(local, tmpfile, 1024); - local[1023] = '\0'; + tracet(1, "file uncompact error: %s\n", local.c_str()); + ftp->error = 12; + ftp->state = 3; + return nullptr; } - } - else - { - tracet(1, "file uncompact error: %s\n", local); - ftp->error = 12; - ftp->state = 3; - return nullptr; + break; } } - if (strlen(local) < 1024) - { - std::strncpy(ftp->local, local, 1024); - ftp->local[1023] = '\0'; - } + std::strncpy(ftp->local, local.c_str(), 1024); + ftp->local[1023] = '\0'; ftp->state = 2; /* ftp completed */ - tracet(3, "ftpthread: complete cmd=%s\n", cmd); + tracet(3, "ftpthread: complete cmd=%s\n", cmd_str.data()); return nullptr; } From e45632f82745a5aee247bbd52be18870bceee828 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Fri, 29 Jul 2022 15:46:45 -0600 Subject: [PATCH 04/44] run clang-format on ALL the modified files this time --- src/algorithms/libs/rtklib/rtklib_ppp.cc | 2 +- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 14 +++++++------- src/algorithms/libs/rtklib/rtklib_rtkcmn.h | 6 +++--- src/algorithms/libs/rtklib/rtklib_stream.cc | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index ad2adcee2..ebd7ddc48 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -807,7 +807,7 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) for (j = 0; j < nfreq; j++) { fprintf(fp, "$SAT,%d,%.3f,%s,%d,%.1f,%.1f,%.4f,%.4f,%d,%.0f,%d,%d,%d,%d,%d,%d\n", - week, tow, id.data(), j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, + week, tow, id.data(), j + 1, ssat->azel[0] * R2D, ssat->azel[1] * R2D, ssat->resp[j], ssat->resc[j], ssat->vsat[j], ssat->snr[j] * 0.25, ssat->fix[j], ssat->slip[j] & 3, ssat->lock[j], ssat->outc[j], ssat->slipc[j], ssat->rejc[j]); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 3565aa3ef..12d2a8f0a 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -4118,15 +4118,15 @@ int execcmd(const char *cmd) * return : none * notes : not recursive. only one level *-----------------------------------------------------------------------------*/ -void createdir(std::filesystem::path const& path) +void createdir(std::filesystem::path const &path) { - std::error_code ec; + std::error_code ec; - auto created = std::filesystem::create_directory(path, ec); - if (not created) - { - trace(1, "Error creating folder: %s", path.c_str()); - } + auto created = std::filesystem::create_directory(path, ec); + if (not created) + { + trace(1, "Error creating folder: %s", path.c_str()); + } } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h index 2d46700c1..3f6b0f1c0 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h @@ -59,8 +59,8 @@ #define GNSS_SDR_RTKLIB_RTKCMN_H #include "rtklib.h" -#include #include +#include #include @@ -230,9 +230,9 @@ void traceobs(int level, const obsd_t *obs, int n); // void traceb (int level, const unsigned char *p, int n); int execcmd(const char *cmd); -void createdir(std::filesystem::path const& path); +void createdir(std::filesystem::path const &path); int reppath(std::string const &path, std::string &rpath, gtime_t time, const char *rov, - const char *base); + const char *base); double satwavelen(int sat, int frq, const nav_t *nav); double geodist(const double *rs, const double *rr, double *e); double satazel(const double *pos, const double *e, double *azel); diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index df50eef56..7ecf10dfa 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1976,9 +1976,9 @@ void *ftpthread(void *arg) auto proxyopt = std::string(); if (*proxyaddr) { - auto proto = "ftp"s; - if (ftp->proto) proto = "http"s; - env = "set "s + proto + "_proxy=http://"s + std::string(proxyaddr) + " % "; + auto proto = "ftp"s; + if (ftp->proto) proto = "http"s; + env = "set "s + proto + "_proxy=http://"s + std::string(proxyaddr) + " % "; proxyopt = "--proxy=on "; } @@ -2025,7 +2025,7 @@ void *ftpthread(void *arg) { if (local.extension() == ext) { - char tmpfile_arg[1024]; + char tmpfile_arg[1024]; ret = rtk_uncompress(local.c_str(), tmpfile_arg); if (ret != 0) // success { From d449d938851f1c80f98a7baeb57f9607333b42ef Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Fri, 29 Jul 2022 15:50:53 -0600 Subject: [PATCH 05/44] cpplint fixes --- src/algorithms/libs/rtklib/rtklib_rtkpos.cc | 1 + src/algorithms/libs/rtklib/rtklib_stream.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 1be140ad9..2e13bde39 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -37,6 +37,7 @@ #include "rtklib_tides.h" #include #include +#include #include static int resamb_WLNL(rtk_t *rtk __attribute((unused)), const obsd_t *obs __attribute((unused)), const int *sat __attribute((unused)), diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 7ecf10dfa..2869075dc 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -38,7 +38,9 @@ #include #include #include +#include #include +#include #include #include #include From 963b1cc63c192fedaeff9c5afefb3d6539efc59a Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Fri, 29 Jul 2022 16:10:07 -0600 Subject: [PATCH 06/44] address MacOS CI failures --- src/algorithms/libs/rtklib/rtklib.h | 4 ++-- src/algorithms/libs/rtklib/rtklib_stream.cc | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 4bb933d43..064d7aa0b 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -1108,7 +1108,7 @@ typedef struct } serial_t; -typedef struct +struct file_t { /* file control type */ FILE *fp = nullptr; /* file pointer */ FILE *fp_tag = nullptr; /* file pointer of tag file */ @@ -1129,7 +1129,7 @@ typedef struct double speed = 0; /* replay speed (time factor) */ double swapintv = 0; /* swap interval (hr) (0: no swap) */ lock_t lock; /* lock flag */ -} file_t; +}; typedef struct diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 2869075dc..5edd2e195 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -235,7 +236,7 @@ int openfile_(file_t *file, gtime_t time, char *msg) char tagpath[MAXSTRPATH + 4] = ""; char tagh[TIMETAGH_LEN + 1] = ""; - tracet(3, "openfile_: path=%s time=%s\n", file->path, time_str(time, 0)); + tracet(3, "openfile_: path=%s time=%s\n", file->path.data(), time_str(time, 0)); file->time = utc2gpst(timeget()); file->tick = file->tick_f = tickget(); @@ -331,7 +332,7 @@ int openfile_(file_t *file, gtime_t time, char *msg) /* close file ----------------------------------------------------------------*/ void closefile_(file_t *file) { - tracet(3, "closefile_: path=%s\n", file->path); + tracet(3, "closefile_: path=%s\n", file->path.data()); if (file->fp) { fclose(file->fp); @@ -358,7 +359,7 @@ void closefile_(file_t *file) /* open file (path=filepath[::T[::+][::x]][::S=swapintv]) --------*/ file_t *openfile(std::string const &path, int mode, char *msg) { - tracet(3, "openfile: path=%s mode=%d\n", path, mode); + tracet(3, "openfile: path=%s mode=%d\n", path.data(), mode); if ((mode & (STR_MODE_R | STR_MODE_W)) == 0) { From 9c773a9dda53bc2421d9babf399a9f9285ed035b Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Sun, 31 Jul 2022 13:45:17 -0600 Subject: [PATCH 07/44] clang-tidy compromise; fix some, silence some --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 2 +- src/algorithms/libs/rtklib/rtklib_stream.cc | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 12d2a8f0a..fe4cffdf9 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -3102,7 +3102,7 @@ void readpos(const char *file, const char *rcv, double *pos) { continue; } - auto sta = stas[np++]; + auto sta = stas[np++]; // NOLINT(readability-qualified-auto) std::strncpy(sta, str, 16); sta[15] = '\0'; } diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 5edd2e195..475aa8a9f 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1956,7 +1956,7 @@ void *ftpthread(void *arg) /* if local file exist, skip download */ auto tmpfile = local; - for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable { if (tmpfile.extension() == ext) { @@ -1980,7 +1980,7 @@ void *ftpthread(void *arg) if (*proxyaddr) { auto proto = "ftp"s; - if (ftp->proto) proto = "http"s; + if (ftp->proto) proto = "http"s; // NOLINT(readability-braces-around-statements): adding braces reduces readability env = "set "s + proto + "_proxy=http://"s + std::string(proxyaddr) + " % "; proxyopt = "--proxy=on "; } @@ -1991,18 +1991,18 @@ void *ftpthread(void *arg) { /* ftp */ auto opt_str = "--ftp-user="s + std::string(ftp->user) + " --ftp-password="s + std::string(ftp->passwd) + " --glob=off --passive-ftp "s + proxyopt + "s-t 1 -T "s + std::to_string(FTP_TIMEOUT) + - " -O \"" + local.native() + "\""s; + R"( -O ")" + local.native() + R"(")"s; // TODO: this uses shell syntax; consider escaping paths cmd_str = env + std::string(FTP_CMD) + " "s + opt_str + " "s + - "\"ftp://"s + std::string(ftp->addr) + "/"s + remotePath.native() + "\" 2> \""s + errfile.native() + "\"\n"s; + R"("ftp://)"s + std::string(ftp->addr) + "/"s + remotePath.native() + R"(" 2> ")"s + errfile.native() + "\"\n"s; } else { /* http */ auto opt_str = proxyopt + " -t 1 -T "s + std::to_string(FTP_TIMEOUT) + " -O \""s + local.native() + "\""s; cmd_str = env + std::string(FTP_CMD) + " "s + opt_str + " "s + - "\"http://"s + std::string(ftp->addr) + "/"s + remotePath.native() + "\" 2> \""s + errfile.native() + "\"\n"; + R"("http://)"s + std::string(ftp->addr) + "/"s + remotePath.native() + R"(" 2> ")"s + errfile.native() + "\"\n"; } /* execute download command */ std::error_code ec; // prevent exceptions @@ -2024,7 +2024,7 @@ void *ftpthread(void *arg) } /* uncompress downloaded file */ - for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable { if (local.extension() == ext) { @@ -2074,7 +2074,7 @@ ftp_t *openftp(const char *path, int type, char *msg) ftp->state = 0; ftp->proto = type; ftp->error = 0; - ftp->thread = 0; // NOLINT + ftp->thread = pthread_t(); ftp->local[0] = '\0'; /* decode ftp path */ From 01fccabf829ebec6793659053ad161c653c00225 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Sun, 31 Jul 2022 13:48:04 -0600 Subject: [PATCH 08/44] one of these days, I'll learn to format before commit --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 2 +- src/algorithms/libs/rtklib/rtklib_stream.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index fe4cffdf9..792bb46dc 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -3102,7 +3102,7 @@ void readpos(const char *file, const char *rcv, double *pos) { continue; } - auto sta = stas[np++]; // NOLINT(readability-qualified-auto) + auto sta = stas[np++]; // NOLINT(readability-qualified-auto) std::strncpy(sta, str, 16); sta[15] = '\0'; } diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 475aa8a9f..b12ae0d49 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1956,7 +1956,7 @@ void *ftpthread(void *arg) /* if local file exist, skip download */ auto tmpfile = local; - for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable { if (tmpfile.extension() == ext) { @@ -1980,7 +1980,7 @@ void *ftpthread(void *arg) if (*proxyaddr) { auto proto = "ftp"s; - if (ftp->proto) proto = "http"s; // NOLINT(readability-braces-around-statements): adding braces reduces readability + if (ftp->proto) proto = "http"s; // NOLINT(readability-braces-around-statements): adding braces reduces readability env = "set "s + proto + "_proxy=http://"s + std::string(proxyaddr) + " % "; proxyopt = "--proxy=on "; } @@ -2024,7 +2024,7 @@ void *ftpthread(void *arg) } /* uncompress downloaded file */ - for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable + for (auto ext : {".z", ".gz", ".zip", ".Z", ".GZ", ".ZIP"}) // NOLINT(readability-qualified-auto): auto decoration is less readable { if (local.extension() == ext) { From 32843a09f47379d3ad29c5acc4f96b97c7cfe11e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 3 Aug 2022 12:33:57 +0200 Subject: [PATCH 09/44] CI: add shellcheck work --- .github/workflows/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 268ec1b46..cc27accc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -182,6 +182,16 @@ jobs: run: cd build && ctest -C Release --exclude-regex volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: install dependencies + run: sudo apt install shellcheck + - name: check scripts + run: shellcheck src/utils/scripts/* + + REUSE-compliance: runs-on: ubuntu-latest steps: From 875b622cd18ee79f63b97b7f1abd80bef69cd529 Mon Sep 17 00:00:00 2001 From: "Alexander V. Joura" Date: Wed, 3 Aug 2022 19:01:36 +0300 Subject: [PATCH 10/44] 1. Added class name qualifiers for member function definitions 2. Synchronized member function signatures --- src/core/libs/gnss_sdr_supl_client.cc | 6 +++--- src/core/libs/gnss_sdr_supl_client.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 6bc814334..7b2571f6a 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -429,7 +429,7 @@ bool Gnss_Sdr_Supl_Client::load_gal_ephemeris_xml(const std::string& file_name) } -bool save_gal_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +bool Gnss_Sdr_Supl_Client::save_gal_ephemeris_map_xml(const std::string& file_name, std::map eph_map) { if (eph_map.empty() == false) { @@ -476,7 +476,7 @@ bool Gnss_Sdr_Supl_Client::load_cnav_ephemeris_xml(const std::string& file_name) } -bool save_cnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +bool Gnss_Sdr_Supl_Client::save_cnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) { if (eph_map.empty() == false) { @@ -523,7 +523,7 @@ bool Gnss_Sdr_Supl_Client::load_gnav_ephemeris_xml(const std::string& file_name) } -bool save_gnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) +bool Gnss_Sdr_Supl_Client::save_gnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map) { if (eph_map.empty() == false) { diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 0a73b4ead..33f5331b9 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -122,7 +122,7 @@ public: /*! * \brief Save GPS CNAV ephemeris map to XML file. */ - bool save_cnav_ephemeris_map_xml(const std::string file_name, + bool save_cnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map); /*! @@ -133,7 +133,7 @@ public: /*! * \brief Save Galileo ephemeris map to XML file. */ - bool save_gal_ephemeris_map_xml(const std::string file_name, + bool save_gal_ephemeris_map_xml(const std::string& file_name, std::map eph_map); /*! @@ -144,7 +144,7 @@ public: /*! * \brief Save GLONASS GNAV ephemeris map to XML file. */ - bool save_gnav_ephemeris_map_xml(const std::string file_name, + bool save_gnav_ephemeris_map_xml(const std::string &file_name, std::map eph_map); /*! From 2792aafe19585e676fe8dd7d62540131afcc7299 Mon Sep 17 00:00:00 2001 From: "Alexander V. Joura" Date: Wed, 3 Aug 2022 19:29:15 +0300 Subject: [PATCH 11/44] Using wrong ephemeris map for GLONASS satellites --- src/core/libs/gnss_sdr_supl_client.cc | 4 ++-- src/core/libs/gnss_sdr_supl_client.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 7b2571f6a..73905ee25 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -510,9 +510,9 @@ bool Gnss_Sdr_Supl_Client::load_gnav_ephemeris_xml(const std::string& file_name) { ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); - gps_cnav_ephemeris_map.clear(); + glonass_gnav_ephemeris_map.clear(); xml >> boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", this->glonass_gnav_ephemeris_map); - LOG(INFO) << "Loaded GLONASS ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites"; + LOG(INFO) << "Loaded GLONASS ephemeris map data with " << this->glonass_gnav_ephemeris_map.size() << " satellites"; } catch (std::exception& e) { diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 33f5331b9..b37b68da3 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -144,7 +144,7 @@ public: /*! * \brief Save GLONASS GNAV ephemeris map to XML file. */ - bool save_gnav_ephemeris_map_xml(const std::string &file_name, + bool save_gnav_ephemeris_map_xml(const std::string& file_name, std::map eph_map); /*! From daaa4799b6d37c25f639a19dc11794c22581e409 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Mon, 8 Aug 2022 21:12:38 -0600 Subject: [PATCH 12/44] maybe this is the last one --- src/algorithms/libs/rtklib/rtklib_stream.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index b12ae0d49..31dc197f1 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -386,7 +386,7 @@ file_t *openfile(std::string const &path, int mode, char *msg) tokens.pop_front(); // edge case that may not be possible, but I don't want to test for right now - if (tag.empty()) continue; + if (tag.empty()) continue; // NOLINT(readability-braces-around-statements) if (tag == "T") { From 7bd25aa9cc04b47d1f832c501cb10944fff7bb97 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Mon, 8 Aug 2022 23:50:39 -0600 Subject: [PATCH 13/44] penultimate clang-tidy compromise --- src/algorithms/libs/rtklib/rtklib_stream.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 31dc197f1..7752494cb 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -419,7 +419,7 @@ file_t *openfile(std::string const &path, int mode, char *msg) std::istringstream ss(tag); ss.ignore(1, 'S').ignore(1, '=') >> swapintv; // do we care if there are extra characters? - if (swapintv < 0) swapintv = 0; + if (swapintv < 0) swapintv = 0; // NOLINT(readability-braces-around-statements) file->swapintv = swapintv; } else From c1d68ffbb3b2006b315390343f1b416aee93366f Mon Sep 17 00:00:00 2001 From: Vlad P Date: Tue, 9 Aug 2022 20:49:15 +0300 Subject: [PATCH 14/44] glonass_lx_ca_dll_pll_c_aid_tracking better checks before enabling preamble_timestamp_samples message port connection 1. Check for message port presence both in trk and nav blocks 2. Check for configuration property Tracking_xG.extend_correlation_ms Signed-off-by: Vlad P --- src/algorithms/channel/adapters/channel.cc | 32 ++++++++++++++++++++-- src/algorithms/channel/adapters/channel.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 28376dfd8..adb392e9f 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -104,6 +104,9 @@ Channel::Channel(const ConfigurationInterface* configuration, gnss_signal_ = Gnss_Signal(signal_str); channel_msg_rx_ = channel_msg_receiver_make_cc(channel_fsm_, repeat_); + + glonass_extend_correlation_ms_ = 0; + glonass_extend_correlation_ms_ = configuration->property("Tracking_1G.extend_correlation_ms", 0) + configuration->property("Tracking_2G.extend_correlation_ms", 0); } @@ -128,7 +131,7 @@ void Channel::connect(gr::top_block_sptr top_block) // Message ports top_block->msg_connect(nav_->get_left_block(), pmt::mp("telemetry_to_trk"), trk_->get_right_block(), pmt::mp("telemetry_to_trk")); - if ((trk_->get_right_block()->name() == "glonass_l1_ca_dll_pll_c_aid_tracking_cc") || (trk_->get_right_block()->name() == "glonass_l2_ca_dll_pll_c_aid_tracking_cc")) + if (glonass_dll_pll_c_aid_tracking_check()) { top_block->msg_connect(nav_->get_left_block(), pmt::mp("preamble_timestamp_samples"), trk_->get_right_block(), pmt::mp("preamble_timestamp_samples")); } @@ -162,7 +165,7 @@ void Channel::disconnect(gr::top_block_sptr top_block) nav_->disconnect(top_block); top_block->msg_disconnect(nav_->get_left_block(), pmt::mp("telemetry_to_trk"), trk_->get_right_block(), pmt::mp("telemetry_to_trk")); - if ((trk_->get_right_block()->name() == "glonass_l1_ca_dll_pll_c_aid_tracking_cc") || (trk_->get_right_block()->name() == "glonass_l2_ca_dll_pll_c_aid_tracking_cc")) + if (glonass_dll_pll_c_aid_tracking_check()) { top_block->msg_disconnect(nav_->get_left_block(), pmt::mp("preamble_timestamp_samples"), trk_->get_right_block(), pmt::mp("preamble_timestamp_samples")); } @@ -270,3 +273,28 @@ void Channel::start_acquisition() } DLOG(INFO) << "Channel start_acquisition()"; } + +bool Channel::glonass_dll_pll_c_aid_tracking_check() +{ + if (glonass_extend_correlation_ms_) + { + const pmt::pmt_t nav_ports_out = nav_->get_left_block()->message_ports_out(); + const pmt::pmt_t trk_ports_in = trk_->get_right_block()->message_ports_in(); + const pmt::pmt_t symbol = pmt::mp("preamble_timestamp_samples"); + for (unsigned k = 0; k < pmt::length(nav_ports_out); k++) + { + if (pmt::vector_ref(nav_ports_out, k) == symbol) + { + for (unsigned j = 0; j < pmt::length(trk_ports_in); j++) + { + if (pmt::vector_ref(trk_ports_in, j) == symbol) + { + return true; + } + } + return false; + } + } + } + return false; +} diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index d43d1df42..b9d3dbfc6 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -96,6 +96,7 @@ public: inline std::shared_ptr telemetry() const { return nav_; } private: + bool glonass_dll_pll_c_aid_tracking_check(); std::shared_ptr channel_fsm_; std::shared_ptr acq_; std::shared_ptr trk_; @@ -109,6 +110,7 @@ private: bool connected_; bool repeat_; bool flag_enable_fpga_; + int glonass_extend_correlation_ms_; }; From aad50e44d4550577a91079442f9f8d26e1ed5c09 Mon Sep 17 00:00:00 2001 From: Vlad P Date: Tue, 9 Aug 2022 20:51:06 +0300 Subject: [PATCH 15/44] Glonass: implement extended correlation for cshort blocks Signed-off-by: Vlad P --- .../glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 17 +++++++++-------- .../glonass_l1_ca_dll_pll_c_aid_tracking_sc.h | 2 +- .../glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 17 +++++++++-------- .../glonass_l2_ca_dll_pll_c_aid_tracking_sc.h | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) 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 6ca1c9030..27d62058a 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 @@ -85,7 +85,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(const p DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) // avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_samples = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -134,7 +134,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_pll_to_dll_assist_secs_Ti(0.0), d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), - d_preamble_timestamp_s(0.0), + d_preamble_timestamp_samples(0.0), d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), @@ -154,8 +154,8 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_dump(dump) { // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + this->message_port_register_in(pmt::mp("preamble_timestamp_samples")); + this->set_msg_handler(pmt::mp("preamble_timestamp_samples"), #if HAS_GENERIC_LAMBDA [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); #else @@ -209,7 +209,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() const double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect // Fd=(C/(C+Vr))*F - d_glonass_freq_ch = GLONASS_L1_CA_FREQ_HZ + (GLONASS_L1_CA_FREQ_HZ * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_glonass_freq_ch = GLONASS_L1_CA_FREQ_HZ + (DFRQ1_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); const double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; // new chip and prn sequence periods based on acq Doppler d_code_freq_chips = radial_velocity * GLONASS_L1_CA_CODE_RATE_CPS; @@ -273,8 +273,8 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() // enable tracking d_pull_in = true; d_enable_tracking = true; - d_enable_extended_integration = true; - d_preamble_synchronized = true; + d_enable_extended_integration = false; + d_preamble_synchronized = false; LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples @@ -604,7 +604,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples - d_preamble_timestamp_samples) / static_cast(d_fs_in))); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -631,6 +631,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } // UPDATE INTEGRATION TIME CURRENT_INTEGRATION_TIME_S = static_cast(d_extend_correlation_ms) * GLONASS_L1_CA_CODE_PERIOD_S; + d_code_loop_filter.set_pdi(static_cast(CURRENT_INTEGRATION_TIME_S)); enable_dll_pll = true; } else diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h index 8c482ec92..999b1f7a2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -170,7 +170,7 @@ private: double d_pll_to_dll_assist_secs_Ti; double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; - double d_preamble_timestamp_s; + double d_preamble_timestamp_samples; int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; 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 ebd6894e6..b137f50eb 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 @@ -83,7 +83,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(const p DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) // avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(msg); + d_preamble_timestamp_samples = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -132,7 +132,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_pll_to_dll_assist_secs_Ti(0.0), d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), - d_preamble_timestamp_s(0.0), + d_preamble_timestamp_samples(0.0), d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), @@ -152,8 +152,8 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_dump(dump) { // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + this->message_port_register_in(pmt::mp("preamble_timestamp_samples")); + this->set_msg_handler(pmt::mp("preamble_timestamp_samples"), #if HAS_GENERIC_LAMBDA [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); #else @@ -206,7 +206,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() const double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect // Fd=(C/(C+Vr))*F - d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (GLONASS_L2_CA_FREQ_HZ * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); const double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; // new chip and prn sequence periods based on acq Doppler d_code_freq_chips = radial_velocity * GLONASS_L2_CA_CODE_RATE_CPS; @@ -269,8 +269,8 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() // enable tracking d_pull_in = true; d_enable_tracking = true; - d_enable_extended_integration = true; - d_preamble_synchronized = true; + d_enable_extended_integration = false; + d_preamble_synchronized = false; d_acc_carrier_phase_initialized = false; LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz @@ -601,7 +601,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at bool enable_dll_pll; if (d_enable_extended_integration == true) { - const int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + const int64_t symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples - d_preamble_timestamp_samples) / static_cast(d_fs_in))); if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -663,6 +663,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at // perform basic (1ms) correlation // UPDATE INTEGRATION TIME CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + d_code_loop_filter.set_pdi(static_cast(CURRENT_INTEGRATION_TIME_S)); enable_dll_pll = true; } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h index 0902aa17a..ae9047f7b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h @@ -165,7 +165,7 @@ private: double d_pll_to_dll_assist_secs_Ti; double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; - double d_preamble_timestamp_s; + double d_preamble_timestamp_samples; int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; From e429a96601fee8a39c5a858f0814597b192de3c1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 10 Aug 2022 12:14:52 +0200 Subject: [PATCH 16/44] Use boost::filesystem if std::filesystem is not available --- src/algorithms/libs/rtklib/CMakeLists.txt | 10 ++++++++++ src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 6 +++--- src/algorithms/libs/rtklib/rtklib_rtkcmn.h | 21 +++++++++++++++++++-- src/algorithms/libs/rtklib/rtklib_stream.cc | 16 ++++++++-------- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index ec7958c02..8bab07358 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -74,6 +74,16 @@ target_link_libraries(algorithms_libs_rtklib BLAS::BLAS ) +if(FILESYSTEM_FOUND) + target_compile_definitions(algorithms_libs_rtklib PUBLIC -DHAS_STD_FILESYSTEM=1) + if(find_experimental) + target_compile_definitions(algorithms_libs_rtklib PUBLIC -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1) + endif() + target_link_libraries(algorithms_libs_rtklib PUBLIC std::filesystem) +else() + target_link_libraries(algorithms_libs_rtklib PUBLIC Boost::filesystem Boost::system) +endif() + set_property(TARGET algorithms_libs_rtklib APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 792bb46dc..9cb21816a 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -4118,11 +4118,11 @@ int execcmd(const char *cmd) * return : none * notes : not recursive. only one level *-----------------------------------------------------------------------------*/ -void createdir(std::filesystem::path const &path) +void createdir(fs::path const &path) { - std::error_code ec; + errorlib::error_code ec; - auto created = std::filesystem::create_directory(path, ec); + auto created = fs::create_directory(path, ec); if (not created) { trace(1, "Error creating folder: %s", path.c_str()); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h index 3f6b0f1c0..d606d4d4e 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h @@ -60,9 +60,26 @@ #include "rtklib.h" #include -#include #include +#if HAS_STD_FILESYSTEM +#include +namespace errorlib = std; +#if HAS_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace fs = std::experimental::filesystem; +#else +#include +namespace fs = std::filesystem; +#endif +#else +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem +#include // for error_code +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif /* coordinate rotation matrix ------------------------------------------------*/ #define Rx(t, X) \ @@ -230,7 +247,7 @@ void traceobs(int level, const obsd_t *obs, int n); // void traceb (int level, const unsigned char *p, int n); int execcmd(const char *cmd); -void createdir(std::filesystem::path const &path); +void createdir(fs::path const &path); int reppath(std::string const &path, std::string &rpath, gtime_t time, const char *rov, const char *base); double satwavelen(int sat, int frq, const nav_t *nav); diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 7752494cb..6c7a10b02 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1946,12 +1946,12 @@ void *ftpthread(void *arg) std::string remote; reppath(ftp->file, remote, time, "", ""); - auto remotePath = std::filesystem::path(remote); + auto remotePath = fs::path(remote); - auto local = std::filesystem::path(localdir); + auto local = fs::path(localdir); local /= remotePath.filename(); - auto errfile = std::filesystem::path(local); + auto errfile = fs::path(local); errfile.replace_extension("err"); /* if local file exist, skip download */ @@ -1964,7 +1964,7 @@ void *ftpthread(void *arg) break; } } - if (std::filesystem::exists(tmpfile)) + if (fs::exists(tmpfile)) { std::strncpy(ftp->local, tmpfile.c_str(), 1024); ftp->local[1023] = '\0'; @@ -2005,11 +2005,11 @@ void *ftpthread(void *arg) R"("http://)"s + std::string(ftp->addr) + "/"s + remotePath.native() + R"(" 2> ")"s + errfile.native() + "\"\n"; } /* execute download command */ - std::error_code ec; // prevent exceptions + errorlib::error_code ec; // prevent exceptions auto ret = execcmd(cmd_str.c_str()); if ((ret != 0)) { - if (std::filesystem::remove(local, ec) == false) + if (fs::remove(local, ec) == false) { trace(1, "Error removing file %s", local.c_str()); } @@ -2018,7 +2018,7 @@ void *ftpthread(void *arg) ftp->state = 3; return nullptr; } - if (std::filesystem::remove(errfile, ec) == false) + if (fs::remove(errfile, ec) == false) { trace(1, "Error removing file %s", errfile.c_str()); } @@ -2032,7 +2032,7 @@ void *ftpthread(void *arg) ret = rtk_uncompress(local.c_str(), tmpfile_arg); if (ret != 0) // success { - if (std::filesystem::remove(local, ec) == false) + if (fs::remove(local, ec) == false) { trace(1, "Error removing file %s", local.c_str()); } From f79332bb7d195fbb8aaaced1e3e20877d5d84dd2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 10 Aug 2022 16:44:50 +0200 Subject: [PATCH 17/44] Fix building for compilers using C++11 (Debian 8, Centos 7) for std::string_literals --- src/algorithms/libs/rtklib/CMakeLists.txt | 1 + src/algorithms/libs/rtklib/rtklib_stream.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index 8bab07358..fae644536 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -68,6 +68,7 @@ endif() target_link_libraries(algorithms_libs_rtklib PRIVATE core_system_parameters + algorithms_libs Gflags::gflags Glog::glog LAPACK::LAPACK diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 6c7a10b02..76b77d0de 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -31,6 +31,7 @@ */ #include "rtklib_stream.h" +#include "gnss_sdr_string_literals.h" // for std::string_literals #include "rtklib_rtkcmn.h" #include "rtklib_solution.h" #include From d8de6bf20b8f95fea31bd8a5ea839184417c3a6d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 10 Aug 2022 23:27:40 +0200 Subject: [PATCH 18/44] Allow std::make_unique in C++11 --- src/algorithms/libs/rtklib/rtklib_stream.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 76b77d0de..106598524 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -31,6 +31,7 @@ */ #include "rtklib_stream.h" +#include "gnss_sdr_make_unique.h" // for std::make:unique in C++11 #include "gnss_sdr_string_literals.h" // for std::string_literals #include "rtklib_rtkcmn.h" #include "rtklib_solution.h" From b24141ca72e3eec495f855a141265e3ab8afde0a Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 10 Aug 2022 17:37:57 -0600 Subject: [PATCH 19/44] add ZMQ signal source --- CMakeLists.txt | 11 ++- cmake/Modules/FindGNURADIO.cmake | 3 +- .../signal_source/adapters/CMakeLists.txt | 14 +++- .../adapters/signal_source_base.cc | 57 ++++++++++++- .../adapters/signal_source_base.h | 12 ++- .../adapters/zmq_signal_source.cc | 79 +++++++++++++++++++ .../adapters/zmq_signal_source.h | 74 +++++++++++++++++ src/core/receiver/CMakeLists.txt | 6 +- src/core/receiver/gnss_block_factory.cc | 16 +++- 9 files changed, 264 insertions(+), 8 deletions(-) create mode 100644 src/algorithms/signal_source/adapters/zmq_signal_source.cc create mode 100644 src/algorithms/signal_source/adapters/zmq_signal_source.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ef72511df..89a4948d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,8 @@ option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Tele option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) +option(ENABLE_ZMQ "Enable GNU Radio ZeroMQ Messaging" OFF) + # Performance analysis tools option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) @@ -596,7 +598,7 @@ set_package_properties(VOLK PROPERTIES ################################################################################ # GNU Radio - https://www.gnuradio.org ################################################################################ -set(GR_REQUIRED_COMPONENTS RUNTIME PMT BLOCKS FFT FILTER ANALOG) +list(APPEND GR_REQUIRED_COMPONENTS RUNTIME PMT BLOCKS FFT FILTER ANALOG) find_package(UHD) set_package_properties(UHD PROPERTIES PURPOSE "Used for communication with front-ends of the USRP family." @@ -606,10 +608,14 @@ if(ENABLE_UHD) if(NOT UHD_FOUND) set(ENABLE_UHD OFF) else() - set(GR_REQUIRED_COMPONENTS ${GR_REQUIRED_COMPONENTS} UHD) + list(APPEND GR_REQUIRED_COMPONENTS UHD) endif() endif() +if(ENABLE_ZMQ) + list(APPEND GR_REQUIRED_COMPONENTS ZEROMQ) +endif() + find_package(GNURADIO) set_package_properties(GNURADIO PROPERTIES PURPOSE "Implements flowgraph scheduler, provides some processing blocks and classes to create new ones." @@ -3401,6 +3407,7 @@ add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.") add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.") add_feature_info(ENABLE_ARRAY ENABLE_ARRAY "Enables Raw_Array_Signal_Source and Array_Signal_Conditioner for using CTTC's antenna array. Requires gr-dbfcttc.") +add_feature_info(ENABLE_ZMQ ENABLE_ZMQ "Enables GNU Radio ZeroMQ message blocks.") add_feature_info(ENABLE_GPERFTOOLS ENABLE_GPERFTOOLS "Enables performance analysis. Requires Gperftools.") add_feature_info(ENABLE_GPROF ENABLE_GPROF "Enables performance analysis with 'gprof'.") add_feature_info(ENABLE_CLANG_TIDY ENABLE_CLANG_TIDY "Runs clang-tidy along with the compiler. Requires Clang.") diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 3df296cc5..e7a561018 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2011-2020 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2011-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause ######################################################################## @@ -193,6 +193,7 @@ gr_module(TRELLIS gnuradio-trellis gnuradio/trellis/api.h gnuradio-trellis) gr_module(UHD gnuradio-uhd gnuradio/uhd/api.h gnuradio-uhd) gr_module(VOCODER gnuradio-vocoder gnuradio/vocoder/api.h gnuradio-vocoder) gr_module(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet) +gr_module(ZEROMQ gnuradio-zeromq gnuradio/zeromq/api.h gnuradio-zeromq) list(REMOVE_DUPLICATES GNURADIO_ALL_INCLUDE_DIRS) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 227b11dcd..ab24d5fc1 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/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-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause @@ -84,6 +84,11 @@ if(ENABLE_UHD) set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} uhd_signal_source.h) endif() +if(ENABLE_ZMQ) + list(APPEND OPT_DRIVER_SOURCES zmq_signal_source.cc) + list(APPEND OPT_DRIVER_HEADERS zmq_signal_source.h) +endif() + set(SIGNAL_SOURCE_ADAPTER_SOURCES signal_source_base.cc @@ -192,6 +197,13 @@ if(ENABLE_UHD) ) endif() +if(ENABLE_ZMQ) + target_link_libraries(signal_source_adapters + PUBLIC + Gnuradio::zeromq + ) +endif() + if(ENABLE_OSMOSDR AND GROSMOSDR_FOUND) target_link_libraries(signal_source_adapters PUBLIC diff --git a/src/algorithms/signal_source/adapters/signal_source_base.cc b/src/algorithms/signal_source/adapters/signal_source_base.cc index 27a4edb33..582d96175 100644 --- a/src/algorithms/signal_source/adapters/signal_source_base.cc +++ b/src/algorithms/signal_source/adapters/signal_source_base.cc @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -37,6 +37,12 @@ size_t SignalSourceBase::getRfChannels() const return rfChannels_; } +gr::basic_block_sptr SignalSourceBase::get_left_block() +{ + LOG(WARNING) << "Trying to get signal source left block."; + return gr::basic_block_sptr(); +} + SignalSourceBase::SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl) : role_(std::move(role)), implementation_(std::move(impl)) { @@ -44,3 +50,52 @@ SignalSourceBase::SignalSourceBase(ConfigurationInterface const* configuration, // depending on the order of initialization, assign rfChannels_ in the body rfChannels_ = configuration->property(role_ + ".RF_channels"s, uint64_t(1U)); } + +size_t SignalSourceBase::decode_item_type(std::string const& item_type, bool* is_interleaved, bool throw_on_error) +{ + size_t item_size = 0; + + // The default is for samples not to be interleaved + if (is_interleaved) *is_interleaved = false; // NOLINT + + if (item_type == "gr_complex"s) + { + item_size = sizeof(gr_complex); + } + else if (item_type == "float"s) + { + item_size = sizeof(float); + } + else if (item_type == "short"s) + { + item_size = sizeof(int16_t); + } + else if (item_type == "ishort"s) + { + item_size = sizeof(int16_t); + if (is_interleaved) *is_interleaved = true; // NOLINT + } + else if (item_type == "byte"s) + { + item_size = sizeof(int8_t); + } + else if (item_type == "ibyte"s) + { + item_size = sizeof(int8_t); + if (is_interleaved) *is_interleaved = true; // NOLINT + } + else + { + if (throw_on_error) + { + throw std::invalid_argument(item_type + " is not a recognized item type"s); + } + else + { + LOG(WARNING) << item_type + << " unrecognized item type. Using gr_complex."; + item_size = sizeof(gr_complex); + } + } + return item_size; +} diff --git a/src/algorithms/signal_source/adapters/signal_source_base.h b/src/algorithms/signal_source/adapters/signal_source_base.h index ff168b4a2..45f03826a 100644 --- a/src/algorithms/signal_source/adapters/signal_source_base.h +++ b/src/algorithms/signal_source/adapters/signal_source_base.h @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -32,11 +32,21 @@ public: std::string implementation() final; size_t getRfChannels() const override; + gr::basic_block_sptr get_left_block() override; // non-sensical; implement once protected: //! Constructor SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl); + //! utility for decoding passed ".item_type" values + //! @param[in] item_type - user provided string, should be one of the known types + //! @param[out] is_interleaved - if non-null, the pointed to memory is updated with + //! whether the data is interleaved I/Q (e.g., ishort) + //! @param[in] throw_on_error - if true, throw an exception if the string does not + //! represent a known type + //! @return the size in bytes of the passed type + size_t decode_item_type(std::string const& item_type, bool* is_interleaved = nullptr, bool throw_on_error = false); + private: std::string const role_; std::string const implementation_; diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc new file mode 100644 index 000000000..66d931760 --- /dev/null +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -0,0 +1,79 @@ +/*! + * \file zmq_signal_source.cc + * \brief Signal source which reads from ZeroMQ. + * \author Jim Melton, 2022. jim.melton(at)sncorp.com + * + * ----------------------------------------------------------------------------- + * + * 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 "zmq_signal_source.h" +#include "configuration_interface.h" +#include "gnss_sdr_string_literals.h" + +using namespace std::string_literals; + +ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int /* in_stream [[maybe_unused]] */, + unsigned int /* out_stream [[maybe_unused]] */, + Concurrent_Queue* /* queue [[maybe_unused]] */) + : SignalSourceBase(configuration, role, "ZMQ_Signal_Source"s) // + , + d_item_size(decode_item_type(configuration->property(role + ".item_type"s, "gr_complex"s), nullptr, true)) +{ + auto vlen = configuration->property(role + ".vlen"s, 1); + auto pass_tags = configuration->property(role + ".pass_tags"s, false); + auto timeout_ms = configuration->property(role + ".timeout_ms"s, 100); + auto hwm = configuration->property(role + ".hwm"s, -1); + + // Each .endpointN must be specified + for (auto n = 0u; n < getRfChannels(); ++n) + { + auto property = role + ".endpoint"s + std::to_string(n); + auto endpoint = configuration->property(property, ""s); + if (not endpoint.empty()) + { + LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; + d_source_blocks.push_back(gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm)); + } + else + { + std::cerr + << "For ZMQ_Signal_Source " << role << ", the .endpointN property must be defined\n" + << "for all values of N from 0 to " << getRfChannels() - 1 << std::endl; + + throw std::invalid_argument(property + ": undefined"); + } + } +} + + +auto ZmqSignalSource::item_size() -> size_t { return d_item_size; } + +auto ZmqSignalSource::connect(gr::top_block_sptr /* top_block [[maybe_unused]] */) -> void +{ + // for now, nothing to connect +} + +auto ZmqSignalSource::disconnect(gr::top_block_sptr /* top_block [[maybe_unused]] */) -> void +{ + // for now, nothing to disconnect +} + +auto ZmqSignalSource::get_right_block() -> gr::basic_block_sptr +{ + return d_source_blocks.front(); +} + +auto ZmqSignalSource::get_right_block(int RF_channel) -> gr::basic_block_sptr +{ + return d_source_blocks.at(RF_channel); // throws std::out_of_range +} diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.h b/src/algorithms/signal_source/adapters/zmq_signal_source.h new file mode 100644 index 000000000..07b3ecace --- /dev/null +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.h @@ -0,0 +1,74 @@ +/*! + * \file zmq_signal_source.h + * \brief Signal source which reads from ZeroMQ. + * \author Jim Melton, 2022. jim.melton(at)sncorp.com + * + * ----------------------------------------------------------------------------- + * + * 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_ZMQ_SIGNAL_SOURCE_H +#define GNSS_SDR_ZMQ_SIGNAL_SOURCE_H + +#include "signal_source_base.h" +// +#include "concurrent_queue.h" +#include +#include + +/** \addtogroup Signal_Source + * \{ */ +/** \addtogroup Signal_Source_adapters + * \{ */ + +//! This class supports the following properties: +//! +//! .pass_tags - boolean flag if tags should be propagated (default false) +//! .timeout_ms - receive timeout, in milliseconds (default 100) +//! .hwm - ZMQ high water mark (default -1, ZMQ default) +//! .vlen - vector length of the input items (default 1, one item) +//! .endpointN - the ZMQ endpoint to be connected to (repeat for each channel) +//! +//! .item_type - data type of the samples (default "gr_complex") +//! +//! (probably should be abstracted to the base class) +//! +//! .dump - whether to archive input data +//! +//! .dump_filename - if dumping, path to file for output +//! + +class ZmqSignalSource : public SignalSourceBase +{ +public: + ZmqSignalSource(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_stream, + unsigned int out_stream, + Concurrent_Queue* queue); + + ~ZmqSignalSource() = default; + + size_t item_size() override; + + auto connect(gr::top_block_sptr top_block) -> void override; + auto disconnect(gr::top_block_sptr top_block) -> void override; + auto get_right_block() -> gr::basic_block_sptr override; + auto get_right_block(int RF_channel) -> gr::basic_block_sptr override; + +private: + std::vector d_source_blocks; + + size_t d_item_size; +}; + +/** \} */ +/** \} */ +#endif diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 65b1a2072..418ee72ab 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/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-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause @@ -112,6 +112,10 @@ if(ENABLE_ARRAY) target_compile_definitions(core_receiver PRIVATE -DRAW_ARRAY_DRIVER=1) endif() +if(ENABLE_ZMQ) + target_compile_definitions(core_receiver PRIVATE -DZEROMQ_DRIVER=1) +endif() + if(ENABLE_FLEXIBAND) target_compile_definitions(core_receiver PRIVATE -DFLEXIBAND_DRIVER=1) endif() diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 6a92df891..a2273f182 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -16,7 +16,7 @@ * 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-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -171,6 +171,10 @@ #include "flexiband_signal_source.h" #endif +#if ZEROMQ_DRIVER +#include "zmq_signal_source.h" +#endif + #if CUDA_GPU_ACCEL #include "gps_l1_ca_dll_pll_tracking_gpu.h" #endif @@ -799,6 +803,16 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #endif +#if ZEROMQ_DRIVER + else if (implementation == "ZMQ_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } +#endif + + // DATA TYPE ADAPTER ----------------------------------------------------------- else if (implementation == "Byte_To_Short") { From 2eae3ef43ad08cf80631431814ae95541b8ff4b0 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 10 Aug 2022 20:21:12 -0600 Subject: [PATCH 20/44] implement dump --- .../adapters/zmq_signal_source.cc | 58 +++++++++---------- .../adapters/zmq_signal_source.h | 15 +++-- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index 66d931760..e87064ff2 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -17,6 +17,7 @@ #include "zmq_signal_source.h" #include "configuration_interface.h" #include "gnss_sdr_string_literals.h" +#include using namespace std::string_literals; @@ -25,55 +26,52 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, unsigned int /* in_stream [[maybe_unused]] */, unsigned int /* out_stream [[maybe_unused]] */, Concurrent_Queue* /* queue [[maybe_unused]] */) - : SignalSourceBase(configuration, role, "ZMQ_Signal_Source"s) // - , - d_item_size(decode_item_type(configuration->property(role + ".item_type"s, "gr_complex"s), nullptr, true)) + : SignalSourceBase(configuration, role, "ZMQ_Signal_Source"s), + d_item_size(decode_item_type(configuration->property(role + ".item_type"s, "gr_complex"s), nullptr, true)), + d_dump_filename(configuration->property(role + ".dump_filename"s, "data/zmq_dump.dat"s)), + d_dump(configuration->property(role + ".dump"s, false)) { auto vlen = configuration->property(role + ".vlen"s, 1); auto pass_tags = configuration->property(role + ".pass_tags"s, false); auto timeout_ms = configuration->property(role + ".timeout_ms"s, 100); auto hwm = configuration->property(role + ".hwm"s, -1); - // Each .endpointN must be specified - for (auto n = 0u; n < getRfChannels(); ++n) - { - auto property = role + ".endpoint"s + std::to_string(n); - auto endpoint = configuration->property(property, ""s); - if (not endpoint.empty()) - { - LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; - d_source_blocks.push_back(gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm)); - } - else - { - std::cerr - << "For ZMQ_Signal_Source " << role << ", the .endpointN property must be defined\n" - << "for all values of N from 0 to " << getRfChannels() - 1 << std::endl; + auto property = role + ".endpoint"s; + auto endpoint = configuration->property(property, ""s); - throw std::invalid_argument(property + ": undefined"); - } + if (not endpoint.empty()) + { + LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; + d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm); + } + else + { + std::cerr << "For ZMQ_Signal_Source " << property << " must be defined" << std::endl; + throw std::invalid_argument(property + ": undefined"); } } auto ZmqSignalSource::item_size() -> size_t { return d_item_size; } -auto ZmqSignalSource::connect(gr::top_block_sptr /* top_block [[maybe_unused]] */) -> void +auto ZmqSignalSource::connect(gr::top_block_sptr top_block) -> void { - // for now, nothing to connect + if (d_dump) + { + d_dump_sink = gr::blocks::file_sink::make(item_size(), d_dump_filename.data()); + top_block->connect(d_source_block, 0, d_dump_sink, 0); + } } -auto ZmqSignalSource::disconnect(gr::top_block_sptr /* top_block [[maybe_unused]] */) -> void +auto ZmqSignalSource::disconnect(gr::top_block_sptr top_block) -> void { - // for now, nothing to disconnect + if (d_dump) + { + top_block->disconnect(d_dump_sink); + } } auto ZmqSignalSource::get_right_block() -> gr::basic_block_sptr { - return d_source_blocks.front(); -} - -auto ZmqSignalSource::get_right_block(int RF_channel) -> gr::basic_block_sptr -{ - return d_source_blocks.at(RF_channel); // throws std::out_of_range + return d_source_block; } diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.h b/src/algorithms/signal_source/adapters/zmq_signal_source.h index 07b3ecace..dc33c1c0e 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.h +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.h @@ -20,6 +20,7 @@ #include "signal_source_base.h" // #include "concurrent_queue.h" +#include // for dump #include #include @@ -30,18 +31,18 @@ //! This class supports the following properties: //! +//! .endpoint - the ZMQ endpoint to be connected to +//! .vlen - vector length of the input items (default 1, one item) +//! this must match the size of the publisher! //! .pass_tags - boolean flag if tags should be propagated (default false) //! .timeout_ms - receive timeout, in milliseconds (default 100) //! .hwm - ZMQ high water mark (default -1, ZMQ default) -//! .vlen - vector length of the input items (default 1, one item) -//! .endpointN - the ZMQ endpoint to be connected to (repeat for each channel) //! //! .item_type - data type of the samples (default "gr_complex") //! //! (probably should be abstracted to the base class) //! -//! .dump - whether to archive input data -//! +//! .dump - whether to archive input data //! .dump_filename - if dumping, path to file for output //! @@ -61,12 +62,14 @@ public: auto connect(gr::top_block_sptr top_block) -> void override; auto disconnect(gr::top_block_sptr top_block) -> void override; auto get_right_block() -> gr::basic_block_sptr override; - auto get_right_block(int RF_channel) -> gr::basic_block_sptr override; private: - std::vector d_source_blocks; + gr::zeromq::sub_source::sptr d_source_block; + gr::blocks::file_sink::sptr d_dump_sink; size_t d_item_size; + std::string d_dump_filename; + bool d_dump; }; /** \} */ From 4e9faa5793bdfdb6cc9e4e79f75a2d3911b7d031 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 10 Aug 2022 21:26:10 -0600 Subject: [PATCH 21/44] cpplint --- src/algorithms/signal_source/adapters/zmq_signal_source.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.h b/src/algorithms/signal_source/adapters/zmq_signal_source.h index dc33c1c0e..55b2d29b7 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.h +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.h @@ -23,6 +23,7 @@ #include // for dump #include #include +#include /** \addtogroup Signal_Source * \{ */ From 1473dc348603db64e96bb423114ac61eb9b5e682 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 10 Aug 2022 21:27:47 -0600 Subject: [PATCH 22/44] cmakelint --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89a4948d3..0f44f9e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -613,7 +613,7 @@ if(ENABLE_UHD) endif() if(ENABLE_ZMQ) - list(APPEND GR_REQUIRED_COMPONENTS ZEROMQ) + list(APPEND GR_REQUIRED_COMPONENTS ZEROMQ) endif() find_package(GNURADIO) From 09d8e3b9e981fab0d397ac2baf5bb4073a211393 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 10 Aug 2022 22:41:38 -0600 Subject: [PATCH 23/44] clang-tidy claims this is more correct --- src/algorithms/signal_source/adapters/signal_source_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/signal_source_base.cc b/src/algorithms/signal_source/adapters/signal_source_base.cc index 582d96175..130cd6476 100644 --- a/src/algorithms/signal_source/adapters/signal_source_base.cc +++ b/src/algorithms/signal_source/adapters/signal_source_base.cc @@ -40,7 +40,7 @@ size_t SignalSourceBase::getRfChannels() const gr::basic_block_sptr SignalSourceBase::get_left_block() { LOG(WARNING) << "Trying to get signal source left block."; - return gr::basic_block_sptr(); + return {}; } SignalSourceBase::SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl) From 5120de51a543931adabfaed636e31c35c000d9c8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 11 Aug 2022 15:23:26 +0200 Subject: [PATCH 24/44] Document new ZMQ_Signal_Source --- CMakeLists.txt | 6 +++--- docs/CHANGELOG.md | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f44f9e0a..9c38528a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Tele option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) -option(ENABLE_ZMQ "Enable GNU Radio ZeroMQ Messaging" OFF) +option(ENABLE_ZMQ "Enable GNU Radio ZeroMQ Messaging, requires gr-zeromq" OFF) # Performance analysis tools option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) @@ -613,7 +613,7 @@ if(ENABLE_UHD) endif() if(ENABLE_ZMQ) - list(APPEND GR_REQUIRED_COMPONENTS ZEROMQ) + list(APPEND GR_REQUIRED_COMPONENTS ZEROMQ) endif() find_package(GNURADIO) @@ -3407,7 +3407,7 @@ add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.") add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.") add_feature_info(ENABLE_ARRAY ENABLE_ARRAY "Enables Raw_Array_Signal_Source and Array_Signal_Conditioner for using CTTC's antenna array. Requires gr-dbfcttc.") -add_feature_info(ENABLE_ZMQ ENABLE_ZMQ "Enables GNU Radio ZeroMQ message blocks.") +add_feature_info(ENABLE_ZMQ ENABLE_ZMQ "Enables ZMQ_Signal_Source for GNU Radio ZeroMQ messages. Requires gr-zeromq.") add_feature_info(ENABLE_GPERFTOOLS ENABLE_GPERFTOOLS "Enables performance analysis. Requires Gperftools.") add_feature_info(ENABLE_GPROF ENABLE_GPROF "Enables performance analysis with 'gprof'.") add_feature_info(ENABLE_CLANG_TIDY ENABLE_CLANG_TIDY "Runs clang-tidy along with the compiler. Requires Clang.") diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a06529e00..aa1b51f4d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -78,6 +78,8 @@ All notable changes to GNSS-SDR will be documented in this file. - The new configuration parameter `Channels_XX.RF_channel_ID` allows to specify the signal source per channel group. - Allowed the CMake project to be a sub-project. +- Added a `ZMQ_Signal_Source` for working with streams of samples published via + [ZeroMQ](https://zeromq.org/). See the definitions of concepts and metrics at https://gnss-sdr.org/design-forces/ From 02260a7337280f4ad5f5b534479fbf0403addf58 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Aug 2022 12:11:54 +0200 Subject: [PATCH 25/44] Fix building of obsdiff in systems that use lib64 --- src/utils/rinex-tools/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/rinex-tools/CMakeLists.txt b/src/utils/rinex-tools/CMakeLists.txt index 7a3bdb598..94906c04c 100644 --- a/src/utils/rinex-tools/CMakeLists.txt +++ b/src/utils/rinex-tools/CMakeLists.txt @@ -13,10 +13,10 @@ if("${ARMADILLO_VERSION_STRING}" VERSION_GREATER "9.800" OR (NOT ARMADILLO_FOUND if(NOT GNSSTK_FOUND OR ENABLE_OWN_GNSSTK) include(GNUInstallDirs) if(GNSSTK_USES_GPSTK_NAMESPACE) - set(GNSSTK_LIBRARY ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(GNSSTK_LIBRARY ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}) set(GNSSTK_INCLUDE_DIR ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/include) else() - set(GNSSTK_LIBRARY ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(GNSSTK_LIBRARY ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_STATIC_LIBRARY_SUFFIX}) set(GNSSTK_INCLUDE_DIR ${GNSSSDR_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/include) endif() endif() From cd3be227984480232b25f9a22330251aef795cb8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Aug 2022 20:09:11 +0200 Subject: [PATCH 26/44] Fix error with C++14 (invalid conversion from const char* to char*) --- .../signal_source/adapters/zmq_signal_source.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index e87064ff2..a9cab6540 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -18,6 +18,7 @@ #include "configuration_interface.h" #include "gnss_sdr_string_literals.h" #include +#include using namespace std::string_literals; @@ -38,11 +39,12 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, auto property = role + ".endpoint"s; auto endpoint = configuration->property(property, ""s); + std::vector address(endpoint.c_str(), endpoint.c_str() + endpoint.size() + 1); - if (not endpoint.empty()) + if (!endpoint.empty()) { LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; - 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, address.data(), timeout_ms, pass_tags, hwm); } else { @@ -54,6 +56,7 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, auto ZmqSignalSource::item_size() -> size_t { return d_item_size; } + auto ZmqSignalSource::connect(gr::top_block_sptr top_block) -> void { if (d_dump) @@ -63,6 +66,7 @@ auto ZmqSignalSource::connect(gr::top_block_sptr top_block) -> void } } + auto ZmqSignalSource::disconnect(gr::top_block_sptr top_block) -> void { if (d_dump) @@ -71,6 +75,7 @@ auto ZmqSignalSource::disconnect(gr::top_block_sptr top_block) -> void } } + auto ZmqSignalSource::get_right_block() -> gr::basic_block_sptr { return d_source_block; From da120cfa2250a5dd8bcb7a473e202a7199081c71 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Aug 2022 21:24:38 +0200 Subject: [PATCH 27/44] Reorder CHANGELOG.md --- docs/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index aa1b51f4d..91db3563c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,6 +36,8 @@ All notable changes to GNSS-SDR will be documented in this file. and IGM05 (SSR Code Bias). Please note that the content of the HAS messages is **not** applied to the computed PVT solution. In the Galileo E6B-only receiver, HAS messages are decoded and reported. +- Added a `ZMQ_Signal_Source` for working with streams of samples published via + [ZeroMQ](https://zeromq.org/). ### Improvements in Maintainability: @@ -78,8 +80,6 @@ All notable changes to GNSS-SDR will be documented in this file. - The new configuration parameter `Channels_XX.RF_channel_ID` allows to specify the signal source per channel group. - Allowed the CMake project to be a sub-project. -- Added a `ZMQ_Signal_Source` for working with streams of samples published via - [ZeroMQ](https://zeromq.org/). See the definitions of concepts and metrics at https://gnss-sdr.org/design-forces/ From cd843787c852e1ab8b4861ecf77bc89306ee104c Mon Sep 17 00:00:00 2001 From: "Alexander V. Joura" Date: Mon, 15 Aug 2022 19:25:13 +0300 Subject: [PATCH 28/44] Wrong decoding of GLONASS navigation message parameter P1 in string #1 --- src/algorithms/PVT/libs/rtcm.cc | 9 +++++---- .../system_parameters/glonass_gnav_navigation_message.cc | 4 +++- .../unit-tests/signal-processing-blocks/pvt/rtcm_test.cc | 6 +++--- .../system-parameters/glonass_gnav_nav_message_test.cc | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index 6023f19ee..f799f81ee 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -1873,8 +1873,8 @@ int32_t Rtcm::read_MT1020(const std::string& message, Glonass_Gnav_Ephemeris& gl { } // Avoid compiler warning - glonass_gnav_eph.d_P_1 = static_cast(Rtcm::bin_to_uint(message_bin.substr(index, 2))); - glonass_gnav_eph.d_P_1 = (glonass_gnav_eph.d_P_1 + 1) * 15; + uint32_t P_1_tmp = Rtcm::bin_to_uint(message_bin.substr(index, 2)); + glonass_gnav_eph.d_P_1 = (P_1_tmp == 0) ? 0. : (P_1_tmp + 1) * 15; index += 2; glonass_gnav_eph.d_t_k += static_cast(Rtcm::bin_to_int(message_bin.substr(index, 5))) * 3600; @@ -5102,8 +5102,9 @@ int32_t Rtcm::set_DF105(uint32_t glonass_gnav_alm_health_ind) int32_t Rtcm::set_DF106(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - // Convert the value from (15, 30, 45, 60) to (00, 01, 10, 11) - const auto P_1 = static_cast(std::round(glonass_gnav_eph.d_P_1 / 15.0 - 1.0)); + // Convert the value from (0, 30, 45, 60) to (00, 01, 10, 11) + uint32_t P_1_tmp = std::round(glonass_gnav_eph.d_P_1 / 15.); + uint32_t P_1 = (P_1_tmp == 0) ? 0 : P_1_tmp - 1; DF106 = std::bitset<2>(P_1); return 0; } diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index d6469898d..3f1bcd12e 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -235,6 +235,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame { int32_t J = 0; d_frame_ID = 0U; + uint64_t P_1_tmp = 0; // Unpack bytes to bits const std::bitset string_bits(frame_string); @@ -252,7 +253,8 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame { case 1: // --- It is string 1 ----------------------------------------------- - gnav_ephemeris.d_P_1 = (static_cast(read_navigation_unsigned(string_bits, P1)) + 1) * 15; + P_1_tmp = read_navigation_unsigned(string_bits, P1); + gnav_ephemeris.d_P_1 = (P_1_tmp == 0) ? 0. : (P_1_tmp + 1) * 15; gnav_ephemeris.d_t_k = static_cast(read_navigation_unsigned(string_bits, T_K_HR)) * 3600 + static_cast(read_navigation_unsigned(string_bits, T_K_MIN)) * 60 + static_cast(read_navigation_unsigned(string_bits, T_K_SEC)) * 30; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc index 5e26a758e..a8434e645 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc @@ -274,13 +274,13 @@ TEST(RtcmTest, MT1020) Glonass_Gnav_Utc_Model gnav_utc_model_read = Glonass_Gnav_Utc_Model(); // Perform data read and print of special values types - gnav_ephemeris.d_P_1 = 15; + gnav_ephemeris.d_P_1 = 0.; // Bit distribution per fields - gnav_ephemeris.d_t_k = 7560; + gnav_ephemeris.d_t_k = 7560.; // Glonass signed values gnav_ephemeris.d_VXn = -0.490900039672852; // Bit distribution per fields dependent on other factors - gnav_ephemeris.d_t_b = 8100; + gnav_ephemeris.d_t_b = 8100.; // Binary flag representation gnav_ephemeris.d_P_3 = true; diff --git a/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc b/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc index 1f136f48e..1af57d484 100644 --- a/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc +++ b/src/tests/unit-tests/system-parameters/glonass_gnav_nav_message_test.cc @@ -76,10 +76,10 @@ TEST(GlonassGnavNavigationMessageTest, String1Decoder) Glonass_Gnav_Ephemeris gnav_ephemeris; // Fill out ephemeris values for truth - gnav_ephemeris.d_P_1 = 15; - gnav_ephemeris.d_t_k = 7560; + gnav_ephemeris.d_P_1 = 0.; + gnav_ephemeris.d_t_k = 7560.; gnav_ephemeris.d_VXn = -0.490900039672852; - gnav_ephemeris.d_AXn = 0; + gnav_ephemeris.d_AXn = 0.; gnav_ephemeris.d_Xn = -11025.6669921875; // Call target test method From 56ae0c043c39067034860da117d7bd85633c9bb4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 13:02:04 +0200 Subject: [PATCH 29/44] CMake: Improve spdlog handling --- CMakeLists.txt | 20 ++--- cmake/Modules/FindFMT.cmake | 76 ----------------- cmake/Modules/FindSPDLOG.cmake | 84 ------------------- src/algorithms/PVT/adapters/CMakeLists.txt | 8 -- src/algorithms/channel/libs/CMakeLists.txt | 8 -- .../conditioner/adapters/CMakeLists.txt | 8 -- .../gnuradio_blocks/CMakeLists.txt | 8 -- .../gnuradio_blocks/CMakeLists.txt | 8 -- src/algorithms/libs/CMakeLists.txt | 8 -- .../gnuradio_blocks/CMakeLists.txt | 8 -- .../signal_generator/adapters/CMakeLists.txt | 8 -- .../signal_source/libs/CMakeLists.txt | 8 -- .../gnuradio_blocks/CMakeLists.txt | 8 -- src/core/monitor/CMakeLists.txt | 8 -- .../libs/CMakeLists.txt | 8 -- 15 files changed, 5 insertions(+), 271 deletions(-) delete mode 100644 cmake/Modules/FindFMT.cmake delete mode 100644 cmake/Modules/FindSPDLOG.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c38528a6..4da409a50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,24 +645,14 @@ endif() # spdlog - https://github.com/gabime/spdlog ################################################################################ if(GNURADIO_USES_SPDLOG) - find_package(SPDLOG REQUIRED) - set_package_properties(SPDLOG PROPERTIES - PURPOSE "Required by GNU Radio." - TYPE REQUIRED - ) -endif() - - - -################################################################################ -# fmt - https://github.com/fmtlib/fmt -################################################################################ -if(GNURADIO_USES_SPDLOG) - find_package(FMT REQUIRED) - set_package_properties(FMT PROPERTIES + find_package(spdlog REQUIRED CONFIG) + set_package_properties(spdlog PROPERTIES + URL "https://github.com/gabime/spdlog" + DESCRIPTION "Very fast, header-only/compiled, C++ logging library" PURPOSE "Required by GNU Radio." TYPE REQUIRED ) + target_link_libraries(Gnuradio::runtime INTERFACE spdlog::spdlog) endif() diff --git a/cmake/Modules/FindFMT.cmake b/cmake/Modules/FindFMT.cmake deleted file mode 100644 index 49d091d8a..000000000 --- a/cmake/Modules/FindFMT.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# GNSS-SDR is a Global Navigation Satellite System software-defined receiver. -# This file is part of GNSS-SDR. -# -# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es -# SPDX-License-Identifier: BSD-3-Clause - -if(NOT COMMAND feature_summary) - include(FeatureSummary) -endif() - -# Locate header -find_path(FMT_INCLUDE_DIR fmt/core.h - HINTS ${FMT_ROOT_DIR}/include - PATHS - /usr/include - /usr/local/include - /opt/local/include -) - -# Locate library -find_library(FMT_LIBRARY NAMES fmt - HINTS ${FMT_ROOT_DIR}/lib ${FMT_ROOT_DIR}/lib64 - PATHS - /usr/lib - /usr/lib64 - /usr/lib/x86_64-linux-gnu - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/aarch64-linux-gnu - /usr/lib/mipsel-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/powerpc-linux-gnuspe - /usr/lib/hppa-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib/i386-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/x86_64-kfreebsd-gnu - /usr/lib/i386-kfreebsd-gnu - /usr/lib/m68k-linux-gnu - /usr/lib/sh4-linux-gnu - /usr/lib/sparc64-linux-gnu - /usr/lib/x86_64-linux-gnux32 - /usr/lib/alpha-linux-gnu - /usr/lib/riscv64-linux-gnu - /usr/local/lib - /usr/local/lib64 - /opt/local/lib -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FMT DEFAULT_MSG FMT_INCLUDE_DIR FMT_LIBRARY) - -set_package_properties(FMT PROPERTIES - URL "https://github.com/fmtlib/fmt" - DESCRIPTION "An open-source formatting library" -) - -# Add imported target. -if(FMT_FOUND) - set(FMT_INCLUDE_DIRS "${FMT_INCLUDE_DIR}") - - if(NOT TARGET fmt::fmt) - add_library(fmt::fmt UNKNOWN IMPORTED) - set_target_properties(fmt::fmt PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIRS}" - ) - set_property(TARGET fmt::fmt APPEND PROPERTY - IMPORTED_LOCATION "${FMT_LIBRARY}" - ) - endif() -endif() diff --git a/cmake/Modules/FindSPDLOG.cmake b/cmake/Modules/FindSPDLOG.cmake deleted file mode 100644 index ac53fc870..000000000 --- a/cmake/Modules/FindSPDLOG.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# GNSS-SDR is a Global Navigation Satellite System software-defined receiver. -# This file is part of GNSS-SDR. -# -# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es -# SPDX-License-Identifier: BSD-3-Clause - -if(NOT COMMAND feature_summary) - include(FeatureSummary) -endif() - -# Locate header -find_path(SPDLOG_INCLUDE_DIR spdlog/spdlog.h - HINTS ${SPDLOG_ROOT_DIR}/include - PATHS - /usr/include - /usr/local/include - /opt/local/include -) - -# Locate library -find_library(SPDLOG_LIBRARY NAMES spdlog spdlogd - HINTS ${SPDLOG_ROOT_DIR}/lib ${SPDLOG_ROOT_DIR}/lib64 - PATHS - /usr/lib - /usr/lib64 - /usr/lib/x86_64-linux-gnu - /usr/lib/i386-linux-gnu - /usr/lib/arm-linux-gnueabihf - /usr/lib/arm-linux-gnueabi - /usr/lib/aarch64-linux-gnu - /usr/lib/mipsel-linux-gnu - /usr/lib/mips-linux-gnu - /usr/lib/mips64el-linux-gnuabi64 - /usr/lib/powerpc-linux-gnu - /usr/lib/powerpc64-linux-gnu - /usr/lib/powerpc64le-linux-gnu - /usr/lib/powerpc-linux-gnuspe - /usr/lib/hppa-linux-gnu - /usr/lib/s390x-linux-gnu - /usr/lib/i386-gnu - /usr/lib/hppa-linux-gnu - /usr/lib/x86_64-kfreebsd-gnu - /usr/lib/i386-kfreebsd-gnu - /usr/lib/m68k-linux-gnu - /usr/lib/sh4-linux-gnu - /usr/lib/sparc64-linux-gnu - /usr/lib/x86_64-linux-gnux32 - /usr/lib/alpha-linux-gnu - /usr/lib/riscv64-linux-gnu - /usr/local/lib - /usr/local/lib64 - /opt/local/lib -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SPDLOG DEFAULT_MSG SPDLOG_INCLUDE_DIR SPDLOG_LIBRARY) - -set_package_properties(SPDLOG PROPERTIES - URL "https://github.com/gabime/spdlog" - DESCRIPTION "Very fast, header-only/compiled, C++ logging library" -) - -# Add imported target. -if(SPDLOG_FOUND) - set(SPDLOG_INCLUDE_DIRS "${SPDLOG_INCLUDE_DIR}") - - if(NOT TARGET spdlog::spdlog) - add_library(spdlog::spdlog UNKNOWN IMPORTED) - set_target_properties(spdlog::spdlog PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SPDLOG_INCLUDE_DIRS}" - ) - set_property(TARGET spdlog::spdlog APPEND PROPERTY - IMPORTED_LOCATION "${SPDLOG_LIBRARY}" - ) - endif() - - if(CMAKE_VERSION VERSION_GREATER 3.11.0) - target_compile_definitions(spdlog::spdlog INTERFACE -DSPDLOG_FMT_EXTERNAL=1) - else() - set_property(TARGET spdlog::spdlog APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS SPDLOG_FMT_EXTERNAL=1 - ) - endif() -endif() diff --git a/src/algorithms/PVT/adapters/CMakeLists.txt b/src/algorithms/PVT/adapters/CMakeLists.txt index 3cf70fe95..6b9ff33e6 100644 --- a/src/algorithms/PVT/adapters/CMakeLists.txt +++ b/src/algorithms/PVT/adapters/CMakeLists.txt @@ -39,14 +39,6 @@ if(USE_OLD_BOOST_MATH_COMMON_FACTOR) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(pvt_adapters - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(pvt_adapters diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index 90607d700..63e0d72d8 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -54,14 +54,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(channel_libs - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) diff --git a/src/algorithms/conditioner/adapters/CMakeLists.txt b/src/algorithms/conditioner/adapters/CMakeLists.txt index 265965e67..7c24d008e 100644 --- a/src/algorithms/conditioner/adapters/CMakeLists.txt +++ b/src/algorithms/conditioner/adapters/CMakeLists.txt @@ -42,14 +42,6 @@ target_link_libraries(conditioner_adapters Glog::glog ) -if(GNURADIO_USES_SPDLOG) - target_link_libraries(conditioner_adapters - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(conditioner_adapters PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt index a0e1f2ddc..5a05385c2 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt @@ -55,14 +55,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(data_type_gr_blocks - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - set_property(TARGET data_type_gr_blocks APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index c652131ea..5b1a6762a 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -55,14 +55,6 @@ if(LOG4CPP_FOUND) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(input_filter_gr_blocks - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(input_filter_gr_blocks PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index e8f0d6366..1e31cf4c3 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -119,14 +119,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(algorithms_libs - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(FILESYSTEM_FOUND) target_compile_definitions(algorithms_libs PUBLIC -DHAS_STD_FILESYSTEM=1) if(find_experimental) diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 7f6537ccf..225518612 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -37,14 +37,6 @@ target_link_libraries(obs_gr_blocks Gnuradio::pmt ) -if(GNURADIO_USES_SPDLOG) - target_link_libraries(obs_gr_blocks - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(obs_gr_blocks PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/signal_generator/adapters/CMakeLists.txt b/src/algorithms/signal_generator/adapters/CMakeLists.txt index e8486b326..c430af3c2 100644 --- a/src/algorithms/signal_generator/adapters/CMakeLists.txt +++ b/src/algorithms/signal_generator/adapters/CMakeLists.txt @@ -44,14 +44,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(signal_generator_adapters - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(signal_generator_adapters diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 34cb13e88..2823283b7 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -80,14 +80,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(signal_source_libs - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(ENABLE_FMCOMMS2 OR ENABLE_AD9361) target_link_libraries(signal_source_libs PUBLIC diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index d6bed4f97..c71184aa8 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -69,14 +69,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(telemetry_decoder_gr_blocks - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(telemetry_decoder_gr_blocks PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces diff --git a/src/core/monitor/CMakeLists.txt b/src/core/monitor/CMakeLists.txt index 4f6211a40..cfd2cdab3 100644 --- a/src/core/monitor/CMakeLists.txt +++ b/src/core/monitor/CMakeLists.txt @@ -73,14 +73,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(GNURADIO_USES_SPDLOG) - target_link_libraries(core_monitor - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(USE_BOOST_ASIO_IO_CONTEXT) target_compile_definitions(core_monitor PUBLIC diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt index 6740932fb..53545ef44 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt +++ b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt @@ -53,14 +53,6 @@ target_include_directories(signal_processing_testing_lib ${GNSSSDR_SOURCE_DIR}/src/tests/common-files ) -if(GNURADIO_USES_SPDLOG) - target_link_libraries(signal_processing_testing_lib - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) From 5186b737b745a6f59937e78da80127ee0b066501 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 13:14:59 +0200 Subject: [PATCH 30/44] CMake: remove leftovers --- src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt index ae521eeb9..9a7ea4e5d 100644 --- a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt @@ -50,14 +50,6 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() -if(NOT GNURADIO_USES_LOG4CPP) - target_link_libraries(resampler_gr_blocks - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(resampler_gr_blocks PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces From 8247021f328bea8824536ebd7a702efee052da0c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 14:11:06 +0200 Subject: [PATCH 31/44] CMake: Move log4cpp/spdlog handling to the GNURADIO cmake module --- CMakeLists.txt | 29 ------------------- cmake/Modules/FindGNURADIO.cmake | 17 +++++++++-- docs/CHANGELOG.md | 1 + .../gnuradio_blocks/CMakeLists.txt | 7 ----- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4da409a50..02f3096be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,35 +628,6 @@ endif() -################################################################################ -# Log4cpp - http://log4cpp.sourceforge.net/ -################################################################################ -if(GNURADIO_USES_LOG4CPP) - find_package(LOG4CPP) - set_package_properties(LOG4CPP PROPERTIES - PURPOSE "Required by GNU Radio." - TYPE REQUIRED - ) -endif() - - - -################################################################################ -# spdlog - https://github.com/gabime/spdlog -################################################################################ -if(GNURADIO_USES_SPDLOG) - find_package(spdlog REQUIRED CONFIG) - set_package_properties(spdlog PROPERTIES - URL "https://github.com/gabime/spdlog" - DESCRIPTION "Very fast, header-only/compiled, C++ logging library" - PURPOSE "Required by GNU Radio." - TYPE REQUIRED - ) - target_link_libraries(Gnuradio::runtime INTERFACE spdlog::spdlog) -endif() - - - ################################################################################ # Detect availability of std::filesystem and set C++ standard accordingly ################################################################################ diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index e7a561018..400885ede 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -411,10 +411,23 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) endif() endforeach() if(${_uses_log4cpp}) - set(GNURADIO_USES_LOG4CPP TRUE) + find_package(LOG4CPP) + set_package_properties(LOG4CPP PROPERTIES + PURPOSE "Required by GNU Radio." + TYPE REQUIRED + ) + target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp) endif() if(${_uses_spdlog}) - set(GNURADIO_USES_SPDLOG TRUE) + find_package(spdlog REQUIRED CONFIG) + set_package_properties(spdlog PROPERTIES + URL "https://github.com/gabime/spdlog" + DESCRIPTION "Very fast, header-only/compiled, C++ logging library" + PURPOSE "Required by GNU Radio." + TYPE REQUIRED + ) + target_link_libraries(Gnuradio::runtime INTERFACE spdlog::spdlog) + target_link_libraries(Gnuradio::blocks INTERFACE spdlog::spdlog) endif() endif() endif() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 91db3563c..512b55ccc 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -62,6 +62,7 @@ All notable changes to GNSS-SDR will be documented in this file. - The configuration options at building time `-DENABLE_OWN_GLOG`, `-DENABLE_OWN_ARMADILLO`, and `-DENABLE_OWN_GNSSTK` can now be switched `ON` and `OFF` without the need to start from an empty buiding folder. +- Improved CMake handling of the spdlog library used by GNU Radio >= 3.10. ### Improvements in Usability: diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index 5b1a6762a..c65727296 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -48,13 +48,6 @@ target_link_libraries(input_filter_gr_blocks Volk::volk ) -if(LOG4CPP_FOUND) - target_link_libraries(input_filter_gr_blocks - PRIVATE - Log4cpp::log4cpp - ) -endif() - target_include_directories(input_filter_gr_blocks PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces From e15faa7b670ae595082fc2aaa3fc05434820a5db Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 15:12:09 +0200 Subject: [PATCH 32/44] Fix for old CMake --- cmake/Modules/FindGNURADIO.cmake | 6 +++++- src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 400885ede..a8f0b2a90 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -416,7 +416,11 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) PURPOSE "Required by GNU Radio." TYPE REQUIRED ) - target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp) + if(CMAKE_VERSION VERSION_GREATER 3.0) + target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp) + else() + set(LOG4CPP_WITH_OLD_CMAKE TRUE) + endif() endif() if(${_uses_spdlog}) find_package(spdlog REQUIRED CONFIG) diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index c65727296..51113a267 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -53,6 +53,13 @@ target_include_directories(input_filter_gr_blocks ${GNSSSDR_SOURCE_DIR}/src/core/interfaces ) +if(LOG4CPP_WITH_OLD_CMAKE) + target_link_libraries(input_filter_gr_blocks + PRIVATE + Log4cpp::log4cpp + ) +endif() + if(GNURADIO_USES_STD_POINTERS) target_compile_definitions(input_filter_gr_blocks PUBLIC -DGNURADIO_USES_STD_POINTERS=1 From 1a4e9dc2740b6ad18e2dccc3e70e84ec074bfc8b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 15:13:15 +0200 Subject: [PATCH 33/44] Add missing include (fix building in fedora-rawhide) --- src/utils/front-end-cal/main.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 42d7a7601..5d7122686 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -60,6 +60,7 @@ #include #include // for ctime #include +#include // for std::setiosflags, std::setprecision #include #include #include From 6bf7cd9f30b397a9fd232978fee5941d015c74e0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 15:44:50 +0200 Subject: [PATCH 34/44] Fix for old CMake --- 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 a8f0b2a90..0fe062dc3 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -416,7 +416,7 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) PURPOSE "Required by GNU Radio." TYPE REQUIRED ) - if(CMAKE_VERSION VERSION_GREATER 3.0) + if(CMAKE_VERSION VERSION_GREATER 3.8) target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp) else() set(LOG4CPP_WITH_OLD_CMAKE TRUE) From 1a6dc7263d4be972015e43ad9fd49a63ee8c77ac Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Aug 2022 21:29:54 +0200 Subject: [PATCH 35/44] CMake: fix for old CMake --- cmake/Modules/FindGNURADIO.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 0fe062dc3..32656e8ae 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -416,7 +416,7 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) PURPOSE "Required by GNU Radio." TYPE REQUIRED ) - if(CMAKE_VERSION VERSION_GREATER 3.8) + if(CMAKE_VERSION VERSION_GREATER 3.13) target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp) else() set(LOG4CPP_WITH_OLD_CMAKE TRUE) @@ -430,6 +430,7 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) PURPOSE "Required by GNU Radio." TYPE REQUIRED ) + set(GNURADIO_USES_SPDLOG TRUE) target_link_libraries(Gnuradio::runtime INTERFACE spdlog::spdlog) target_link_libraries(Gnuradio::blocks INTERFACE spdlog::spdlog) endif() From 141457df95c4a6c02c1bd7fe7f044285b035b58c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 24 Aug 2022 11:31:36 +0200 Subject: [PATCH 36/44] Report spdlog version in CMake summary --- cmake/Modules/FindGNURADIO.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 32656e8ae..9e03fdae8 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -20,7 +20,7 @@ include(FindPackageHandleStandardArgs) # if GR_REQUIRED_COMPONENTS is not defined, it will be set to the following list if(NOT GR_REQUIRED_COMPONENTS) - set(GR_REQUIRED_COMPONENTS RUNTIME PMT BLOCKS FFT FILTER ANALOG) + set(GR_REQUIRED_COMPONENTS RUNTIME PMT BLOCKS FFT FILTER ANALOG) endif() # Allows us to use all .cmake files in this directory @@ -426,7 +426,7 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) find_package(spdlog REQUIRED CONFIG) set_package_properties(spdlog PROPERTIES URL "https://github.com/gabime/spdlog" - DESCRIPTION "Very fast, header-only/compiled, C++ logging library" + DESCRIPTION "Very fast, header-only/compiled, C++ logging library (found: v${spdlog_VERSION})" PURPOSE "Required by GNU Radio." TYPE REQUIRED ) From e8eb8a5ace1e3828acf70d8429dee3e7a25102e5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Aug 2022 10:07:50 +0200 Subject: [PATCH 37/44] Reorder private members --- .../gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 2 +- .../gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h | 2 +- .../gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 2 +- .../gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 27d62058a..0c3884cf3 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 @@ -135,9 +135,9 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), d_preamble_timestamp_samples(0.0), - d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), + d_extend_correlation_ms(extend_correlation_ms), d_correlation_length_samples(static_cast(d_vector_length)), d_sample_counter(0ULL), d_acq_sample_stamp(0), diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h index 999b1f7a2..696991b86 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -171,9 +171,9 @@ private: double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; double d_preamble_timestamp_samples; - int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; + int32_t d_extend_correlation_ms; // Integration period in samples int32_t d_correlation_length_samples; 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 b137f50eb..ad99f53cd 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 @@ -133,9 +133,9 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc d_carr_phase_error_secs_Ti(0.0), d_code_error_chips_Ti(0.0), d_preamble_timestamp_samples(0.0), - d_extend_correlation_ms(extend_correlation_ms), d_code_error_filt_chips_s(0.0), d_code_error_filt_chips_Ti(0.0), + d_extend_correlation_ms(extend_correlation_ms), d_correlation_length_samples(static_cast(d_vector_length)), d_sample_counter(0ULL), d_acq_sample_stamp(0), diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h index ae9047f7b..203e47d2e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h @@ -166,9 +166,9 @@ private: double d_carr_phase_error_secs_Ti; double d_code_error_chips_Ti; double d_preamble_timestamp_samples; - int32_t d_extend_correlation_ms; double d_code_error_filt_chips_s; double d_code_error_filt_chips_Ti; + int32_t d_extend_correlation_ms; // Integration period in samples int32_t d_correlation_length_samples; From 223a4b16d855835eae0b6aeb22d1e7b3c27e0cca Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Aug 2022 10:16:40 +0200 Subject: [PATCH 38/44] Reorder private members --- src/algorithms/channel/adapters/channel.cc | 5 ++--- src/algorithms/channel/adapters/channel.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index adb392e9f..18590afca 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -40,6 +40,8 @@ Channel::Channel(const ConfigurationInterface* configuration, role_(role), channel_(channel) { + glonass_extend_correlation_ms_ = configuration->property("Tracking_1G.extend_correlation_ms", 0) + configuration->property("Tracking_2G.extend_correlation_ms", 0); + channel_fsm_ = std::make_shared(); flag_enable_fpga_ = configuration->property("GNSS-SDR.enable_FPGA", false); @@ -104,9 +106,6 @@ Channel::Channel(const ConfigurationInterface* configuration, gnss_signal_ = Gnss_Signal(signal_str); channel_msg_rx_ = channel_msg_receiver_make_cc(channel_fsm_, repeat_); - - glonass_extend_correlation_ms_ = 0; - glonass_extend_correlation_ms_ = configuration->property("Tracking_1G.extend_correlation_ms", 0) + configuration->property("Tracking_2G.extend_correlation_ms", 0); } diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index b9d3dbfc6..519f6babd 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -107,10 +107,10 @@ private: std::string role_; std::mutex mx_; uint32_t channel_; + int glonass_extend_correlation_ms_; bool connected_; bool repeat_; bool flag_enable_fpga_; - int glonass_extend_correlation_ms_; }; From f98a64604979b87a35428f61dcf92b92eeda2676 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Aug 2022 13:38:57 +0200 Subject: [PATCH 39/44] CI: Add liborc-0.4-dev to ubuntu:latest --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc27accc3..0b747318d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: install dependencies - run: sudo apt-get update && sudo apt-get install ninja-build libboost-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-serialization-dev liblog4cpp5-dev gnuradio-dev gr-osmosdr libpugixml-dev libpcap-dev libblas-dev liblapack-dev libarmadillo-dev libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev libmatio-dev googletest protobuf-compiler libprotobuf-dev python3-mako + run: sudo apt-get update && sudo apt-get install ninja-build libboost-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-serialization-dev liblog4cpp5-dev gnuradio-dev gr-osmosdr libpugixml-dev libpcap-dev libblas-dev liblapack-dev libarmadillo-dev libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev libmatio-dev googletest protobuf-compiler libprotobuf-dev python3-mako liborc-0.4-dev - name: configure run: cd build && cmake -GNinja .. - name: build From 56130310d273eafb8c3203c68cce88fcef3843f3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Aug 2022 14:18:29 +0200 Subject: [PATCH 40/44] Allow non-standards-conforming construct in the SUPL library (credits: @jwmelto) --- src/core/libs/supl/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/libs/supl/CMakeLists.txt b/src/core/libs/supl/CMakeLists.txt index 36b7261c7..a08631e91 100644 --- a/src/core/libs/supl/CMakeLists.txt +++ b/src/core/libs/supl/CMakeLists.txt @@ -65,6 +65,15 @@ target_include_directories(core_libs_supl ${CMAKE_CURRENT_SOURCE_DIR}/types ) +# This is ancient and unmaintained code. As the project migrates to modern +# compilers, non-standards-conforming constructs will be flagged as errors. This +# should be upgraded, but until then, allow non-standards-conforming constructs +if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) + set_target_properties(core_libs_supl + PROPERTIES C_EXTENSIONS ON + ) +endif() + set_property(TARGET core_libs_supl APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ From 268dbbc61f959d70df2549d6574d0f264f585521 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 26 Aug 2022 09:14:58 +0200 Subject: [PATCH 41/44] Add iomanip include --- src/algorithms/PVT/libs/kml_printer.cc | 1 + src/tests/system-tests/position_test.cc | 1 + .../observables/hybrid_observables_test.cc | 1 + .../observables/hybrid_observables_test_fpga.cc | 1 + .../telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc | 1 + .../tracking/gps_l1_ca_dll_pll_tracking_test.cc | 1 + .../tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc | 1 + .../tracking/gps_l1_ca_kf_tracking_test.cc | 1 + 8 files changed, 8 insertions(+) diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index dee5d6c7a..ad7ccb0e3 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -24,6 +24,7 @@ #include // for mkstemp #include // for tm #include // for exception +#include // for std::setprecision #include // for cout, cerr #include #include // for S_IXUSR | S_IRWXG | S_IRWXO diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index f3f96c0da..a2bb5181d 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc index 43388e8b2..9cb2337d4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #if GNSSTK_USES_GPSTK_NAMESPACE diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index b34f52d86..37264bf4b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc index bc56d4cd2..3155a3ab8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index fb3a63cef..87af5fe45 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index 85d54d1a1..0fa07a93a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -42,6 +42,7 @@ #include #include // FPGA read input file #include +#include #include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc index ea3bd765d..ae94e744a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include From 182b87c0228ab95c2930e4dd6a4c84980e966099 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 26 Aug 2022 09:43:11 +0200 Subject: [PATCH 42/44] Make use of std::lcm instead of Boost when possible --- src/algorithms/PVT/adapters/CMakeLists.txt | 11 +++++++++-- src/algorithms/PVT/adapters/rtklib_pvt.cc | 5 +++++ src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt | 11 +++++++++-- src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 5 +++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/algorithms/PVT/adapters/CMakeLists.txt b/src/algorithms/PVT/adapters/CMakeLists.txt index 6b9ff33e6..658e493ac 100644 --- a/src/algorithms/PVT/adapters/CMakeLists.txt +++ b/src/algorithms/PVT/adapters/CMakeLists.txt @@ -32,11 +32,18 @@ target_include_directories(pvt_adapters ${GNSSSDR_SOURCE_DIR}/src/core/interfaces ) -if(USE_OLD_BOOST_MATH_COMMON_FACTOR) +if((NOT (CMAKE_VERSION VERSION_LESS "3.1")) AND NOT (CMAKE_CXX_STANDARD VERSION_LESS 17)) target_compile_definitions(pvt_adapters PRIVATE - -DUSE_OLD_BOOST_MATH_COMMON_FACTOR=1 + -DUSE_STD_COMMON_FACTOR=1 ) +else() + if(USE_OLD_BOOST_MATH_COMMON_FACTOR) + target_compile_definitions(pvt_adapters + PRIVATE + -DUSE_OLD_BOOST_MATH_COMMON_FACTOR=1 + ) + endif() endif() if(ENABLE_CLANG_TIDY) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index aef8a6e58..ccc6bcfac 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -28,6 +28,10 @@ #include "rtklib_rtkpos.h" // for rtkfree, rtkinit #include // for LOG #include // for std::cout +#if USE_STD_COMMON_FACTOR +#include +namespace bc = std; +#else #if USE_OLD_BOOST_MATH_COMMON_FACTOR #include namespace bc = boost::math; @@ -35,6 +39,7 @@ namespace bc = boost::math; #include namespace bc = boost::integer; #endif +#endif using namespace std::string_literals; diff --git a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt index 3cfae32f6..ae1b728bf 100644 --- a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt @@ -74,11 +74,18 @@ if(ENABLE_CLANG_TIDY) endif() endif() -if(USE_OLD_BOOST_MATH_COMMON_FACTOR) +if((NOT (CMAKE_VERSION VERSION_LESS "3.1")) AND NOT (CMAKE_CXX_STANDARD VERSION_LESS 17)) target_compile_definitions(pvt_gr_blocks PRIVATE - -DUSE_OLD_BOOST_MATH_COMMON_FACTOR=1 + -DUSE_STD_COMMON_FACTOR=1 ) +else() + if(USE_OLD_BOOST_MATH_COMMON_FACTOR) + target_compile_definitions(pvt_gr_blocks + PRIVATE + -DUSE_OLD_BOOST_MATH_COMMON_FACTOR=1 + ) + endif() endif() if(USE_BOOST_BIND_PLACEHOLDERS) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index a12949e0f..b4c87afd9 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -86,6 +86,10 @@ #include #endif +#if USE_STD_COMMON_FACTOR +#include +namespace bc = std; +#else #if USE_OLD_BOOST_MATH_COMMON_FACTOR #include namespace bc = boost::math; @@ -93,6 +97,7 @@ namespace bc = boost::math; #include namespace bc = boost::integer; #endif +#endif #if PMT_USES_BOOST_ANY #include From e161545155a0fd23e0bff5e902d1597bbbb303dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Into=20P=C3=A4=C3=A4kk=C3=B6nen?= Date: Wed, 24 Aug 2022 18:25:06 +0300 Subject: [PATCH 43/44] add options for changing usrp device arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Into Pääkkönen --- .../signal_source/adapters/uhd_signal_source.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.cc b/src/algorithms/signal_source/adapters/uhd_signal_source.cc index 9b222bdb5..efaae370b 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.cc +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.cc @@ -65,6 +65,20 @@ UhdSignalSource::UhdSignalSource(const ConfigurationInterface* configuration, sample_rate_ = configuration->property(role + ".sampling_frequency", 4.0e6); item_type_ = configuration->property(role + ".item_type", default_item_type); + // UHD TRANSPORT PARAMETERS + // option to manually set device "num_recv_frames" + std::string device_num_recv_frames = configuration->property(role + ".device_num_recv_frames", empty); + if (empty != device_num_recv_frames) // if not empty + { + dev_addr["num_recv_frames"] = device_num_recv_frames; + } + // option to manually set device "recv_frame_size" + std::string device_recv_frame_size = configuration->property(role + ".device_recv_frame_size", empty); + if (empty != device_recv_frame_size) // if not empty + { + dev_addr["recv_frame_size"] = device_recv_frame_size; + } + if (RF_channels_ == 1) { // Single RF channel UHD operation (backward compatible config file format) From 62c4a10f03e4272676dce541efbe1a79afaf1de7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 26 Aug 2022 23:15:24 +0200 Subject: [PATCH 44/44] Document new parameters for UHD_Signal_Source --- docs/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 512b55ccc..e93a5309e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -78,6 +78,9 @@ All notable changes to GNSS-SDR will be documented in this file. `Osmosdr_Signal_Source` implementation of a `SignalSource`. - The `Osmosdr_Signal_Source` implementation learned a new parameter `if_bw` to manually set the bandwidth of the bandpass filter on the radio frontend. +- The `UHD_Signal_Source` learned two new optional parameters + `device_recv_frame_size` and `device_num_recv_frames` for overriding + [transport layer defaults](https://files.ettus.com/manual/page_transport.html). - The new configuration parameter `Channels_XX.RF_channel_ID` allows to specify the signal source per channel group. - Allowed the CMake project to be a sub-project.