From 08ce4cdd759399c94f29e646ed00912edd7aa5e1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 00:15:20 +0100 Subject: [PATCH 1/5] Sort includes, fix coverity scan defect --- .../tracking/adapters/CMakeLists.txt | 2 ++ .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 1 + .../galileo_e5a_dll_pll_tracking_fpga.cc | 1 + .../gps_l1_ca_dll_pll_tracking_fpga.cc | 14 ++++++++-- .../gps_l2_m_dll_pll_tracking_fpga.cc | 1 + .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 10 ++++--- .../tracking/libs/fpga_multicorrelator.cc | 28 +++++++++---------- .../tracking/libs/fpga_multicorrelator.h | 1 - 8 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt index e51180bf6..199abc7c7 100644 --- a/src/algorithms/tracking/adapters/CMakeLists.txt +++ b/src/algorithms/tracking/adapters/CMakeLists.txt @@ -98,6 +98,8 @@ target_link_libraries(tracking_adapters tracking_gr_blocks algorithms_libs gnss_sdr_flags + PRIVATE + Volkgnsssdr::volkgnsssdr ) target_include_directories(tracking_adapters diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 3d692c5db..564fd37fe 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -41,6 +41,7 @@ #include "galileo_e1_signal_processing.h" #include "gnss_sdr_flags.h" #include +#include using google::LogMessage; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index d9af5fab2..ab1a615cb 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -36,6 +36,7 @@ #include "galileo_e5_signal_processing.h" #include "gnss_sdr_flags.h" #include +#include using google::LogMessage; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 57427275a..2f1ad36d6 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -41,14 +41,12 @@ #include "gnss_sdr_flags.h" #include "gps_sdr_signal_processing.h" #include +#include #define NUM_PRNs 32 using google::LogMessage; -void GpsL1CaDllPllTrackingFpga::stop_tracking() -{ -} GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( ConfigurationInterface* configuration, const std::string& role, @@ -148,16 +146,24 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; } + GpsL1CaDllPllTrackingFpga::~GpsL1CaDllPllTrackingFpga() { delete[] d_ca_codes; } + void GpsL1CaDllPllTrackingFpga::start_tracking() { tracking_fpga_sc->start_tracking(); } + +void GpsL1CaDllPllTrackingFpga::stop_tracking() +{ +} + + /* * Set tracking channel unique ID */ @@ -167,11 +173,13 @@ void GpsL1CaDllPllTrackingFpga::set_channel(unsigned int channel) tracking_fpga_sc->set_channel(channel); } + void GpsL1CaDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); } + void GpsL1CaDllPllTrackingFpga::connect(gr::top_block_sptr top_block) { if (top_block) diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc index acf564b00..f9a77761d 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc @@ -42,6 +42,7 @@ #include "gnss_sdr_flags.h" #include "gps_l2c_signal.h" #include +#include #define NUM_PRNs 32 diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index b77a280a8..8641af5dd 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -43,14 +43,12 @@ #include "gnss_sdr_flags.h" #include "gps_l5_signal.h" #include +#include #define NUM_PRNs 32 using google::LogMessage; -void GpsL5DllPllTrackingFpga::stop_tracking() -{ -} GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( ConfigurationInterface *configuration, const std::string &role, @@ -123,7 +121,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.carrier_lock_th = carrier_lock_th; // FPGA configuration parameters - std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; @@ -210,6 +207,11 @@ void GpsL5DllPllTrackingFpga::start_tracking() } +void GpsL5DllPllTrackingFpga::stop_tracking() +{ +} + + /* * Set tracking channel unique ID */ diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index cd85c98d5..b832a828c 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -36,19 +36,12 @@ #include "fpga_multicorrelator.h" #include -#include -#include +#include #include -#include -#include #include -#include -#include -#include +#include // for O_RDWR, O_RSYNC #include -#include -#include -#include +#include // for PROT_READ, PROT_WRITE, MAP_SHARED #include // FPGA register access constants @@ -248,8 +241,14 @@ void Fpga_Multicorrelator_8sc::set_channel(uint32_t channel) int32_t numdevice = d_device_base + d_channel; devicebasetemp << numdevice; mergedname = d_device_name + devicebasetemp.str(); - strcpy(device_io_name, mergedname.substr(0, MAX_LENGTH_DEVICEIO_NAME).c_str()); + if (mergedname.size() > MAX_LENGTH_DEVICEIO_NAME) + { + mergedname = mergedname.substr(0, MAX_LENGTH_DEVICEIO_NAME); + } + + mergedname.copy(device_io_name, mergedname.size() + 1); + device_io_name[mergedname.size()] = '\0'; std::cout << "trk device_io_name = " << device_io_name << std::endl; if ((d_device_descriptor = open(device_io_name, O_RDWR | O_SYNC)) == -1) @@ -267,14 +266,14 @@ void Fpga_Multicorrelator_8sc::set_channel(uint32_t channel) std::cout << "Cannot map deviceio" << device_io_name << std::endl; } - // sanity check : check test register + // sanity check: check test register uint32_t writeval = TEST_REGISTER_TRACK_WRITEVAL; uint32_t readval; readval = Fpga_Multicorrelator_8sc::fpga_acquisition_test_register(writeval); if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; - std::cout << "tracking test register sanity check failed" << std::endl; + std::cout << "Tracking test register sanity check failed" << std::endl; } else { @@ -343,8 +342,7 @@ void Fpga_Multicorrelator_8sc::fpga_compute_code_shift_parameters(void) for (i = 0; i < d_n_correlators; i++) { - temp_calculation = floor( - d_shifts_chips[i] - d_rem_code_phase_chips); + temp_calculation = floor(d_shifts_chips[i] - d_rem_code_phase_chips); if (temp_calculation < 0) { diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index 1a44de781..df060c362 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -38,7 +38,6 @@ #define GNSS_SDR_FPGA_MULTICORRELATOR_8SC_H_ #include -#include #include // FPGA register addresses From c4d9a3631c9577f2911d0f1aef408840d0b7c5a2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 00:16:57 +0100 Subject: [PATCH 2/5] Fix leaks --- .../acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc | 7 +++++++ .../tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc | 1 + 2 files changed, 8 insertions(+) diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 14a6f0675..b99db53b6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -89,6 +89,7 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, if (!rx_signal_file) { std::cerr << "Unable to open file!" << std::endl; + free(buffer_float); return; } @@ -123,6 +124,9 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, if (!buffer_DMA) { std::cerr << "Memory error!" << std::endl; + free(buffer_float); + fclose(rx_signal_file); + return; } // open the DMA descriptor @@ -130,6 +134,9 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, if (dma_descr < 0) { std::cerr << "Can't open loop device\n"; + free(buffer_float); + free(buffer_DMA); + fclose(rx_signal_file); return; } 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 a6f1348e3..9ca2cd870 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 @@ -87,6 +87,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, if (!buffer_DMA) { std::cerr << "Memory error!" << std::endl; + close(dma_descr); return; } From 5cbafa276f6f87f8ee80c83a91d916f34382c813 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 10:56:07 +0100 Subject: [PATCH 3/5] Make Galileo FNAV epehemeris less verbose in terminal --- src/core/system_parameters/galileo_fnav_message.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index 918b7e9c7..689d8e339 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -487,13 +487,13 @@ bool Galileo_Fnav_Message::have_new_ephemeris() // Check if we have a new ephem // if all ephemeris pages have the same IOD, then they belong to the same block if ((FNAV_IODnav_1 == FNAV_IODnav_2) and (FNAV_IODnav_3 == FNAV_IODnav_4) and (FNAV_IODnav_1 == FNAV_IODnav_3)) { - std::cout << "Ephemeris (1, 2, 3) have been received and belong to the same batch" << std::endl; + DLOG(INFO) << "Ephemeris (1, 2, 3) have been received and belong to the same batch"; flag_ephemeris_1 = false; // clear the flag flag_ephemeris_2 = false; // clear the flag flag_ephemeris_3 = false; // clear the flag flag_all_ephemeris = true; IOD_ephemeris = FNAV_IODnav_1; - std::cout << "Batch number: " << IOD_ephemeris << std::endl; + DLOG(INFO) << "Batch number: " << IOD_ephemeris; return true; } } From 0564b790e7c8dd80ff8ec89bfc6a0f2c09ea25d2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 10:57:05 +0100 Subject: [PATCH 4/5] Take into account that PATH could be empty --- src/tests/common-files/gnuplot_i.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index afdc47c3a..5f825b8b5 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -2082,10 +2082,13 @@ bool Gnuplot::get_program_path() // Retrieves a C string containing the value of environment variable PATH path = std::getenv("PATH"); std::stringstream s; - s << path; - if (s.fail()) + if (!path) { - throw GnuplotException("Path is not set"); + s << path; + } + if (s.fail() or s.gcount() == 0) + { + throw GnuplotException("PATH is not set"); } std::string path_str = s.str(); From 5635d6a0121dce1576551b805c39d5f8a5030a33 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 3 Mar 2019 10:58:08 +0100 Subject: [PATCH 5/5] Fix RTCM printer for L5 --- src/algorithms/libs/rtcm.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/algorithms/libs/rtcm.cc b/src/algorithms/libs/rtcm.cc index 43915ee3b..db5ef79cc 100644 --- a/src/algorithms/libs/rtcm.cc +++ b/src/algorithms/libs/rtcm.cc @@ -3366,6 +3366,7 @@ std::map Rtcm::gps_signal_map = [] { gps_signal_map_["5I"] = 22; gps_signal_map_["5Q"] = 23; gps_signal_map_["5X"] = 24; + gps_signal_map_["L5"] = 24; // Workaround. TODO: check if it was I or Q return gps_signal_map_; }();