From 605128e5e0594856283736b7f516f95ad2e364ba Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 29 Jul 2019 15:57:18 +0200 Subject: [PATCH 1/8] Improving HW reset for FPGA-accelerated receiver --- src/core/receiver/gnss_flowgraph.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 0c0171e18..e73c812b3 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1466,10 +1466,19 @@ void GNSSFlowgraph::start_acquisition_helper() void GNSSFlowgraph::perform_hw_reset() { - // a stop acquisition command causes the SW to reset the HW - std::shared_ptr channel_ptr; - channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); - channel_ptr->acquisition()->stop_acquisition(); + // a stop acquisition command causes the SW to reset the HW + std::shared_ptr channel_ptr; + + for (uint32_t i=0; i< channels_count_;i++) + { + channel_ptr = std::dynamic_pointer_cast(channels_.at(i)); + channel_ptr->tracking()->stop_tracking(); + } + + std::this_thread::sleep_for (std::chrono::milliseconds(500)); + + channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); + channel_ptr->acquisition()->stop_acquisition(); } #endif From 2482f14bd8d58ce62fe123b1472f361241c588d9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 07:40:23 +0200 Subject: [PATCH 2/8] Apply code formatting --- src/core/receiver/gnss_flowgraph.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 7e2158dfc..060adfb5d 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1468,19 +1468,19 @@ void GNSSFlowgraph::start_acquisition_helper() void GNSSFlowgraph::perform_hw_reset() { - // a stop acquisition command causes the SW to reset the HW - std::shared_ptr channel_ptr; + // a stop acquisition command causes the SW to reset the HW + std::shared_ptr channel_ptr; - for (uint32_t i=0; i< channels_count_;i++) - { - channel_ptr = std::dynamic_pointer_cast(channels_.at(i)); - channel_ptr->tracking()->stop_tracking(); - } + for (uint32_t i = 0; i < channels_count_; i++) + { + channel_ptr = std::dynamic_pointer_cast(channels_.at(i)); + channel_ptr->tracking()->stop_tracking(); + } - std::this_thread::sleep_for (std::chrono::milliseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); - channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); - channel_ptr->acquisition()->stop_acquisition(); + channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); + channel_ptr->acquisition()->stop_acquisition(); } #endif From 1f476957e38375fe2cb421a62481d7315966d9ad Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 08:06:05 +0200 Subject: [PATCH 3/8] Remove unused public member --- src/algorithms/PVT/libs/rtklib_solver.cc | 1 - src/algorithms/PVT/libs/rtklib_solver.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 45de55b96..f546ce63e 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -94,7 +94,6 @@ Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag d_dump_filename = std::move(dump_filename); d_flag_dump_enabled = flag_dump_to_file; d_flag_dump_mat_enabled = flag_dump_to_mat; - count_valid_position = 0; this->set_averaging_flag(false); rtk_ = rtk; diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index 1fa4ba8dd..a393c1f63 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -126,8 +126,6 @@ public: Beidou_Dnav_Iono beidou_dnav_iono; std::map beidou_dnav_almanac_map; - int count_valid_position; - private: rtk_t rtk_{}; std::string d_dump_filename; From 2fe38e937af81b11736db9f24061342f92f9987d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 08:06:53 +0200 Subject: [PATCH 4/8] Fix wrong assignment --- .../gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc index 50abe691e..b1be0dd90 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc @@ -193,7 +193,7 @@ sbas_l1_telemetry_decoder_gs::Symbol_Aligner_And_Decoder::Symbol_Aligner_And_Dec std::array g_encoder{121, 91}; d_vd1 = std::make_shared(g_encoder.data(), d_KK, nn); - d_vd1 = std::make_shared(g_encoder.data(), d_KK, nn); + d_vd2 = std::make_shared(g_encoder.data(), d_KK, nn); d_past_symbol = 0; } From 9b4597572cbf414fc6d9fb61264f709083b37b23 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 12:38:03 +0200 Subject: [PATCH 5/8] Cleaning --- src/core/system_parameters/GPS_L1_CA.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index 420a49d01..fb0321b0f 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -71,9 +71,7 @@ const uint32_t GPS_L1_CA_OPT_ACQ_FS_HZ = 2000000; //!< Sampling frequency that */ const double MAX_TOA_DELAY_MS = 20; -//#define NAVIGATION_SOLUTION_RATE_MS 1000 // this cannot go here -//const double GPS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) -const double GPS_STARTOFFSET_MS = 60.0; +const double GPS_STARTOFFSET_MS = 68.802; // [ms] Initial signal travel time (only for old ls_pvt implementation) // OBSERVABLE HISTORY DEEP FOR INTERPOLATION const int32_t GPS_L1_CA_HISTORY_DEEP = 100; From cc54b4a1220e007026f93158ec1373973d2cd5d5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 12:51:36 +0200 Subject: [PATCH 6/8] =?UTF-8?q?Enforce=C2=A0rule=2015.1=C2=A0of=20the=20Hi?= =?UTF-8?q?gh=20Integrity=20C++=20Coding=20Standard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://www.perforce.com/resources/qac/high-integrity-c-coding-standard-exception-handling --- .clang-tidy | 1 + src/algorithms/tracking/libs/tcp_communication.cc | 5 +++-- src/utils/front-end-cal/front_end_cal.cc | 5 +++-- src/utils/front-end-cal/front_end_cal.h | 2 +- src/utils/front-end-cal/main.cc | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3515d6a2a..33eeda4b4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,6 +12,7 @@ Checks: '-*, cppcoreguidelines-slicing, google-build-namespaces, google-runtime-int, + hicpp-exception-baseclass, misc-misplaced-const, misc-new-delete-overloads, misc-non-copyable-objects, diff --git a/src/algorithms/tracking/libs/tcp_communication.cc b/src/algorithms/tracking/libs/tcp_communication.cc index 30809ecc6..f0b191c3e 100644 --- a/src/algorithms/tracking/libs/tcp_communication.cc +++ b/src/algorithms/tracking/libs/tcp_communication.cc @@ -32,6 +32,7 @@ #include "tcp_communication.h" #include "tcp_packet_data.h" #include +#include #include @@ -87,7 +88,7 @@ void Tcp_Communication::send_receive_tcp_packet_galileo_e1(boost::array #include // for operator<< #include +#include #include extern Concurrent_Map global_gps_ephemeris_map; @@ -303,7 +304,7 @@ arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, const } -double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) +double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false) { int num_secs = 10; double step_secs = 0.5; @@ -359,7 +360,7 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub mean_Doppler_Hz = arma::mean(Doppler_Hz); return mean_Doppler_Hz; } - throw(1); + throw std::runtime_error("1"); } diff --git a/src/utils/front-end-cal/front_end_cal.h b/src/utils/front-end-cal/front_end_cal.h index 07022e505..5f23311b9 100644 --- a/src/utils/front-end-cal/front_end_cal.h +++ b/src/utils/front-end-cal/front_end_cal.h @@ -65,7 +65,7 @@ public: * 3- Approximate receiver Latitude and Longitude (WGS-84) * */ - double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height); + double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false); /*! * \brief This function models the Elonics E4000 + RTL2832 front-end diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index efd752206..935bb4946 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -574,7 +574,7 @@ int main(int argc, char** argv) { std::cout << "Exception caught while reading ephemeris" << std::endl; } - catch (int ex) + catch (const std::exception& ex) { std::cout << " " << it.first << " " << it.second << " (Eph not found)" << std::endl; } From 8ce0358de6b2e9298186c9bb65d045345a2c1f33 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 19:00:23 +0200 Subject: [PATCH 7/8] Clang-tidy fixes --- .../tracking/cpu_multicorrelator_real_codes_test.cc | 2 +- src/utils/front-end-cal/main.cc | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc index c05fa53b1..4640cb73d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc @@ -139,7 +139,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) //create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.push_back(std::thread(run_correlator_cpu_real_codes, + thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 935bb4946..eae79f406 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -121,7 +121,6 @@ private: public: int rx_message; - ~FrontEndCal_msg_rx() override; //!< Default destructor }; @@ -155,9 +154,6 @@ FrontEndCal_msg_rx::FrontEndCal_msg_rx() : gr::block("FrontEndCal_msg_rx", gr::i } -FrontEndCal_msg_rx::~FrontEndCal_msg_rx() = default; - - void wait_message() { while (!stop) From 5e5c68c2f980c200455c43b12f2f224f5cdd5456 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 19:07:36 +0200 Subject: [PATCH 8/8] Add more performance and high integrity checks --- .clang-tidy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 33eeda4b4..4e0602b32 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -8,11 +8,14 @@ Checks: '-*, cert-err60-cpp, cert-flp30-c, clang-analyzer-cplusplus*, + cppcoreguidelines-pro-type-cstyle-cast, cppcoreguidelines-pro-type-static-cast-downcast, cppcoreguidelines-slicing, + cppcoreguidelines-special-member-functions, google-build-namespaces, google-runtime-int, hicpp-exception-baseclass, + hicpp-explicit-conversions, misc-misplaced-const, misc-new-delete-overloads, misc-non-copyable-objects, @@ -25,14 +28,22 @@ Checks: '-*, modernize-raw-string-literal, modernize-use-auto, modernize-use-bool-literals, + modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-noexcept, modernize-use-nullptr, performance-faster-string-find, + performance-for-range-copy, + performance-implicit-conversion-in-loop, performance-inefficient-algorithm, + performance-inefficient-string-concatenation, + performance-inefficient-vector-operation, performance-move-const-arg, + performance-move-constructor-init, + performance-noexcept-move-constructor, performance-type-promotion-in-math-fn, + performance-unnecessary-copy-initialization, performance-unnecessary-value-param, readability-container-size-empty, readability-identifier-naming,