diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 2f697f6b9..4631270d2 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -4103,7 +4103,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream & out, const Gps_Ephemeris & eph, std::string sys = "G"; gs.System = *sys.c_str(); std::string sig = "2S"; - std::memcpy((void*)gs.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = mmap_iter->second.PRN; total_mmap.insert(std::pair(mmap_iter->second.PRN, gs)); } @@ -4315,7 +4315,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sys = "E"; gs.System = *sys.c_str(); std::string sig = "1B"; - std::memcpy((void*)gs.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; total_map.insert(std::pair(prn_, gs)); } @@ -4340,7 +4340,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sys = "E"; gs.System = *sys.c_str(); std::string sig = "1B"; - std::memcpy((void*)gs.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; total_map.insert(std::pair(prn_, gs)); } @@ -4350,7 +4350,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sys = "E"; gs.System = *sys.c_str(); std::string sig = "5X"; - std::memcpy((void*)gs.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; total_map.insert(std::pair(prn_, gs)); } @@ -4366,7 +4366,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string sys = "E"; gs.System = *sys.c_str(); std::string sig = "5X"; - std::memcpy((void*)gs.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs.Signal), sig.c_str(), 3); gs.PRN = prn_; total_map.insert(std::pair(prn_, gs)); } diff --git a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc index 64eaa7523..ca80ee6ff 100644 --- a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc +++ b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc @@ -211,7 +211,7 @@ void gps_fpga_acquisition_8sc::run_acquisition(void) { // enable interrupts int reenable = 1; - write(d_fd, (void *) &reenable, sizeof(int)); + write(d_fd, reinterpret_cast(&reenable), sizeof(int)); d_map_base[5] = 0; // writing anything to reg 4 launches the acquisition process @@ -241,7 +241,7 @@ void gps_fpga_acquisition_8sc::set_phase_step(unsigned int doppler_index) float phase_step_rad_int_temp; int32_t phase_step_rad_int; - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + int doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) @@ -297,10 +297,10 @@ void gps_fpga_acquisition_8sc::open_device() LOG(WARNING) << "Cannot open deviceio" << d_device_name; } - d_map_base = (volatile unsigned *) mmap(NULL, PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0); + d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); - if (d_map_base == (void *) -1) + if (d_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; } @@ -328,7 +328,8 @@ void gps_fpga_acquisition_8sc::open_device() void gps_fpga_acquisition_8sc::close_device() { - if (munmap((void*) d_map_base, PAGE_SIZE) == -1) + unsigned * aux = const_cast(d_map_base); + if (munmap(static_cast(aux), PAGE_SIZE) == -1) { printf("Failed to unmap memory uio\n"); } diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index eb59941e9..544589e13 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -93,15 +93,16 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, gnss_signal_ = Gnss_Signal(implementation_); channel_msg_rx = channel_msg_receiver_make_cc(&channel_fsm_, repeat_); - } + // Destructor Channel::~Channel() { channel_fsm_.terminate(); } + void Channel::connect(gr::top_block_sptr top_block) { if (connected_) @@ -109,22 +110,22 @@ void Channel::connect(gr::top_block_sptr top_block) LOG(WARNING) << "channel already connected internally"; return; } - if (flag_enable_fpga==false) - { - pass_through_->connect(top_block); - } + if (flag_enable_fpga == false) + { + pass_through_->connect(top_block); + } acq_->connect(top_block); trk_->connect(top_block); nav_->connect(top_block); //Synchronous ports - if (flag_enable_fpga==false) - { - top_block->connect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); - DLOG(INFO) << "pass_through_ -> acquisition"; - top_block->connect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); - DLOG(INFO) << "pass_through_ -> tracking"; - } + if (flag_enable_fpga == false) + { + top_block->connect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); + DLOG(INFO) << "pass_through_ -> acquisition"; + top_block->connect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); + DLOG(INFO) << "pass_through_ -> tracking"; + } top_block->connect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); DLOG(INFO) << "tracking -> telemetry_decoder"; @@ -148,17 +149,17 @@ void Channel::disconnect(gr::top_block_sptr top_block) return; } - if (flag_enable_fpga==false) - { - top_block->disconnect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); - top_block->disconnect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); - } + if (flag_enable_fpga == false) + { + top_block->disconnect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0); + top_block->disconnect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0); + } top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); - if (flag_enable_fpga==false) - { - pass_through_->disconnect(top_block); - } + if (flag_enable_fpga == false) + { + pass_through_->disconnect(top_block); + } acq_->disconnect(top_block); trk_->disconnect(top_block); nav_->disconnect(top_block); @@ -183,7 +184,7 @@ void Channel::set_signal(const Gnss_Signal& gnss_signal) gnss_signal_ = gnss_signal; std::string str_aux = gnss_signal_.get_signal_str(); const char * str = str_aux.c_str(); // get a C style null terminated string - std::memcpy((void*)gnss_synchro_.Signal, str, 3); // copy string into synchro char array: 2 char + null + std::memcpy(static_cast(gnss_synchro_.Signal), str, 3); // copy string into synchro char array: 2 char + null gnss_synchro_.Signal[2] = 0; // make sure that string length is only two characters gnss_synchro_.PRN = gnss_signal_.get_satellite().get_PRN(); gnss_synchro_.System = gnss_signal_.get_satellite().get_system_short().c_str()[0]; diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc index 3f94b25e1..d2319945c 100755 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc @@ -431,7 +431,7 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri current_synchro_data.System = {'E'}; std::string str_aux = "1B"; const char * str = str_aux.c_str(); // get a C style null terminated string - std::memcpy((void*)current_synchro_data.Signal, str, 3); + std::memcpy(static_cast(current_synchro_data.Signal), str, 3); current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index 9e17260fd..6204215a5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -441,7 +441,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work (int noutput_items __attr current_synchro_data.System = {'E'}; std::string str_aux = "1B"; const char * str = str_aux.c_str(); // get a C style null terminated string - std::memcpy((void*)current_synchro_data.Signal, str, 3); + std::memcpy(static_cast(current_synchro_data.Signal), str, 3); current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index 974f61faf..9bb40eefa 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -482,7 +482,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work (int noutput_items __attri current_synchro_data.System = {'G'}; std::string str_aux = "1C"; const char * str = str_aux.c_str(); // get a C style null terminated string - std::memcpy((void*)current_synchro_data.Signal, str, 3); + std::memcpy(static_cast(current_synchro_data.Signal), str, 3); current_synchro_data.fs = d_fs_in; *out[0] = current_synchro_data; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc index 179dcb071..cec90a8f3 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc @@ -149,7 +149,6 @@ bool fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, std::string device_name, unsigned int device_base) { - d_n_correlators = n_correlators; d_device_name = device_name; d_device_base = device_base; @@ -188,7 +187,6 @@ fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc() bool fpga_multicorrelator_8sc::free() { // unlock the hardware - fpga_multicorrelator_8sc::unlock_channel(); // unlock the channel // free the FPGA dynamically created variables @@ -228,10 +226,10 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel) LOG(WARNING) << "Cannot open deviceio" << device_io_name; } - d_map_base = (volatile unsigned *) mmap(NULL, PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0); + d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); - if (d_map_base == (void *) -1) + if (d_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA tracking module " << d_channel << "into user memory"; @@ -240,8 +238,7 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel) // sanity check : check test register unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; unsigned readval; - readval = fpga_multicorrelator_8sc::fpga_acquisition_test_register( - writeval); + readval = fpga_multicorrelator_8sc::fpga_acquisition_test_register(writeval); if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; @@ -250,7 +247,6 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel) { LOG(INFO) << "Test register sanity check success !"; } - } @@ -269,7 +265,6 @@ unsigned fpga_multicorrelator_8sc::fpga_acquisition_test_register( void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void) { - int k, s; unsigned code_chip; unsigned select_fpga_correlator; @@ -278,7 +273,6 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void) for (s = 0; s < d_n_correlators; s++) { - d_map_base[11] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips; k++) { @@ -393,7 +387,7 @@ void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void) { // enable interrupts int reenable = 1; - write(d_device_descriptor, (void *) &reenable, sizeof(int)); + write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int)); d_map_base[14] = 0; // writing anything to reg 14 launches the tracking } @@ -423,7 +417,6 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) d_corr_out[k] = lv_cmake(readval_real, readval_imag); } - } diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc index 9d275bef0..d8ffe84ef 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc @@ -141,7 +141,7 @@ void GpsL2MPcpsAcquisitionTest::init() gnss_synchro.System = 'G'; std::string signal = "2S"; //strncpy(gnss_synchro.Signal, signal.c_str(), 3); - std::memcpy((void*)gnss_synchro.Signal, signal.c_str(), 3); // copy string into synchro char array: 2 char + null + std::memcpy(static_cast(gnss_synchro.Signal), signal.c_str(), 3); // copy string into synchro char array: 2 char + null gnss_synchro.Signal[2] = 0; // make sure that string length is only two characters gnss_synchro.PRN = 7; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 3a4bda179..fdf1d7d2c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -158,10 +158,10 @@ TEST(RinexPrinterTest, GalileoObsLog) gs4.System = *sys.c_str(); std::string sig = "1B"; - std::memcpy((void*)gs1.Signal, sig.c_str(), 3); - std::memcpy((void*)gs2.Signal, sig.c_str(), 3); - std::memcpy((void*)gs3.Signal, sig.c_str(), 3); - std::memcpy((void*)gs4.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs1.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs2.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs3.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs4.Signal), sig.c_str(), 3); gs1.PRN = 3; gs2.PRN = 8; @@ -227,12 +227,12 @@ TEST(RinexPrinterTest, GpsObsLogDualBand) gs4.System = *sys.c_str(); std::string sig = "1C"; - std::memcpy((void*)gs1.Signal, sig.c_str(), 3); - std::memcpy((void*)gs2.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs1.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs2.Signal), sig.c_str(), 3); sig = "2S"; - std::memcpy((void*)gs3.Signal, sig.c_str(), 3); - std::memcpy((void*)gs4.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs3.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs4.Signal), sig.c_str(), 3); gs1.PRN = 3; gs2.PRN = 8; @@ -309,12 +309,12 @@ TEST(RinexPrinterTest, GalileoObsLogDualBand) gs4.System = *sys.c_str(); std::string sig = "1B"; - std::memcpy((void*)gs1.Signal, sig.c_str(), 3); - std::memcpy((void*)gs2.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs1.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs2.Signal), sig.c_str(), 3); sig = "5X"; - std::memcpy((void*)gs3.Signal, sig.c_str(), 3); - std::memcpy((void*)gs4.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs3.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs4.Signal), sig.c_str(), 3); gs1.PRN = 3; gs2.PRN = 8; @@ -401,18 +401,18 @@ TEST(RinexPrinterTest, MixedObsLog) gs8.System = *sys.c_str(); std::string sig = "1C"; - std::memcpy((void*)gs1.Signal, sig.c_str(), 3); - std::memcpy((void*)gs2.Signal, sig.c_str(), 3); - std::memcpy((void*)gs3.Signal, sig.c_str(), 3); - std::memcpy((void*)gs4.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs1.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs2.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs3.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs4.Signal), sig.c_str(), 3); sig = "5X"; - std::memcpy((void*)gs5.Signal, sig.c_str(), 3); - std::memcpy((void*)gs6.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs5.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs6.Signal), sig.c_str(), 3); sig = "1B"; - std::memcpy((void*)gs7.Signal, sig.c_str(), 3); - std::memcpy((void*)gs8.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gs7.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gs8.Signal), sig.c_str(), 3); gs1.PRN = 3; gs2.PRN = 8; 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 7c6683d84..11bd5d7cc 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 @@ -198,7 +198,7 @@ TEST(RtcmTest, MT1001) std::string sig = "1C"; gnss_synchro.System = *sys.c_str(); - std::memcpy((void*)gnss_synchro.Signal, sig.c_str(), 3); + std::memcpy(static_cast(gnss_synchro.Signal), sig.c_str(), 3); gnss_synchro.Pseudorange_m = 20000000.0; double obs_time = 25.0; std::map pseudoranges; @@ -348,11 +348,11 @@ TEST(RtcmTest, MSMCell) gnss_synchro4.System = *gal.c_str(); gnss_synchro5.System = *gps.c_str(); - std::memcpy((void*)gnss_synchro.Signal, x5.c_str(), 3); - std::memcpy((void*)gnss_synchro2.Signal, s2.c_str(), 3); - std::memcpy((void*)gnss_synchro3.Signal, c1.c_str(), 3); - std::memcpy((void*)gnss_synchro4.Signal, x5.c_str(), 3); - std::memcpy((void*)gnss_synchro5.Signal, c1.c_str(), 3); + std::memcpy(static_cast(gnss_synchro.Signal), x5.c_str(), 3); + std::memcpy(static_cast(gnss_synchro2.Signal), s2.c_str(), 3); + std::memcpy(static_cast(gnss_synchro3.Signal), c1.c_str(), 3); + std::memcpy(static_cast(gnss_synchro4.Signal), x5.c_str(), 3); + std::memcpy(static_cast(gnss_synchro5.Signal), c1.c_str(), 3); gnss_synchro.Pseudorange_m = 20000000.0; gnss_synchro2.Pseudorange_m = 20001010.0; @@ -419,7 +419,7 @@ TEST(RtcmTest, MSMCell) Gnss_Synchro gnss_synchro6; gnss_synchro6.PRN = 10; gnss_synchro6.System = *gps.c_str(); - std::memcpy((void*)gnss_synchro6.Signal, s2.c_str(), 3); + std::memcpy(static_cast(gnss_synchro6.Signal), s2.c_str(), 3); gnss_synchro6.Pseudorange_m = 24000000.0; std::map pseudoranges3; @@ -472,10 +472,10 @@ TEST(RtcmTest, MSM1) gnss_synchro3.System = *sys.c_str(); gnss_synchro4.System = *sys.c_str(); - std::memcpy((void*)gnss_synchro.Signal, sig.c_str(), 3); - std::memcpy((void*)gnss_synchro2.Signal, sig.c_str(), 3); - std::memcpy((void*)gnss_synchro3.Signal, sig2.c_str(), 3); - std::memcpy((void*)gnss_synchro4.Signal, sig2.c_str(), 3); + std::memcpy(static_cast(gnss_synchro.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gnss_synchro2.Signal), sig.c_str(), 3); + std::memcpy(static_cast(gnss_synchro3.Signal), sig2.c_str(), 3); + std::memcpy(static_cast(gnss_synchro4.Signal), sig2.c_str(), 3); gnss_synchro.Pseudorange_m = 20000000.0; gnss_synchro2.Pseudorange_m = 20001010.0;