1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-13 05:37:20 +00:00

Apply automated code formatting

Documented at .clang-format
See http://clang.llvm.org/docs/ClangFormat.html and http://clang.llvm.org/docs/ClangFormatStyleOptions.html
This commit is contained in:
Carles Fernandez
2018-03-03 02:03:39 +01:00
parent c9ac8c78af
commit 34f24562cf
902 changed files with 36939 additions and 34573 deletions

View File

@@ -68,7 +68,7 @@
#include <gnuradio/blocks/file_sink.h>
#include <stdlib.h>
#include <chrono>
#include <ctime> // for ctime
#include <ctime> // for ctime
#include <exception>
#include <memory>
#include <queue>
@@ -87,8 +87,8 @@ concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
bool stop;
concurrent_queue<int> channel_internal_queue;
GpsL1CaPcpsAcquisitionFineDoppler *acquisition;
Gnss_Synchro *gnss_synchro;
GpsL1CaPcpsAcquisitionFineDoppler* acquisition;
Gnss_Synchro* gnss_synchro;
std::vector<Gnss_Synchro> gnss_sync_vector;
@@ -109,7 +109,7 @@ private:
public:
int rx_message;
~FrontEndCal_msg_rx(); //!< Default destructor
~FrontEndCal_msg_rx(); //!< Default destructor
};
@@ -122,29 +122,29 @@ FrontEndCal_msg_rx_sptr FrontEndCal_msg_rx_make()
void FrontEndCal_msg_rx::msg_handler_events(pmt::pmt_t msg)
{
try
{
{
long int message = pmt::to_long(msg);
rx_message = message;
channel_internal_queue.push(rx_message);
}
catch(boost::bad_any_cast& e)
{
}
catch (boost::bad_any_cast& e)
{
LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n";
rx_message = 0;
}
}
}
FrontEndCal_msg_rx::FrontEndCal_msg_rx() :
gr::block("FrontEndCal_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
FrontEndCal_msg_rx::FrontEndCal_msg_rx() : gr::block("FrontEndCal_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
{
this->message_port_register_in(pmt::mp("events"));
this->set_msg_handler(pmt::mp("events"), boost::bind(&FrontEndCal_msg_rx::msg_handler_events, this, _1));
rx_message = 0;
}
FrontEndCal_msg_rx::~FrontEndCal_msg_rx()
{}
FrontEndCal_msg_rx::~FrontEndCal_msg_rx() {}
// ###########################################################
@@ -156,20 +156,20 @@ void wait_message()
channel_internal_queue.wait_and_pop(message);
//std::cout<<"Acq mesage rx="<<message<<std::endl;
switch (message)
{
case 1: // Positive acq
gnss_sync_vector.push_back(*gnss_synchro);
//acquisition->reset();
break;
case 2: // negative acq
//acquisition->reset();
break;
case 3:
stop = true;
break;
default:
break;
}
{
case 1: // Positive acq
gnss_sync_vector.push_back(*gnss_synchro);
//acquisition->reset();
break;
case 2: // negative acq
//acquisition->reset();
break;
case 3:
stop = true;
break;
default:
break;
}
}
}
@@ -180,47 +180,46 @@ bool front_end_capture(std::shared_ptr<ConfigurationInterface> configuration)
GNSSBlockFactory block_factory;
boost::shared_ptr<gr::msg_queue> queue;
queue = gr::msg_queue::make(0);
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
std::shared_ptr<GNSSBlockInterface> source;
try
{
{
source = block_factory.GetSignalSource(configuration, queue);
}
catch(const boost::exception_ptr & e)
{
}
catch (const boost::exception_ptr& e)
{
std::cout << "Exception caught in creating source " << e << std::endl;
return 0;
}
}
std::shared_ptr<GNSSBlockInterface> conditioner;
try
{
{
conditioner = block_factory.GetSignalConditioner(configuration);
}
catch(const boost::exception_ptr & e)
{
}
catch (const boost::exception_ptr& e)
{
std::cout << "Exception caught in creating signal conditioner " << e << std::endl;
return 0;
}
}
gr::block_sptr sink;
sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat");
//--- Find number of samples per spreading code ---
long fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000);
int samples_per_code = round(fs_in_
/ (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
int samples_per_code = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
int nsamples = samples_per_code * 50;
int skip_samples = fs_in_ * 5; // skip 5 seconds
int skip_samples = fs_in_ * 5; // skip 5 seconds
gr::block_sptr head = gr::blocks::head::make(sizeof(gr_complex), nsamples);
gr::block_sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), skip_samples);
try
{
{
source->connect(top_block);
conditioner->connect(top_block);
top_block->connect(source->get_right_block(), 0, conditioner->get_left_block(), 0);
@@ -228,12 +227,12 @@ bool front_end_capture(std::shared_ptr<ConfigurationInterface> configuration)
top_block->connect(skiphead, 0, head, 0);
top_block->connect(head, 0, sink, 0);
top_block->run();
}
catch(const std::exception & e)
{
}
catch (const std::exception& e)
{
std::cout << "Failure connecting the GNU Radio blocks " << e.what() << std::endl;
return false;
}
}
//delete conditioner;
//delete source;
@@ -241,7 +240,8 @@ bool front_end_capture(std::shared_ptr<ConfigurationInterface> configuration)
}
static time_t utc_time(int week, long tow) {
static time_t utc_time(int week, long tow)
{
time_t t;
/* Jan 5/6 midnight 1980 - beginning of GPS time as Unix time */
@@ -260,13 +260,10 @@ static time_t utc_time(int week, long tow) {
int main(int argc, char** argv)
{
const std::string intro_help(
std::string("\n RTL-SDR E4000 RF front-end center frequency and sampling rate calibration tool that uses GPS signals\n")
+
"Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)\n"
+
"This program comes with ABSOLUTELY NO WARRANTY;\n"
+
"See COPYING file to see a copy of the General Public License\n \n");
std::string("\n RTL-SDR E4000 RF front-end center frequency and sampling rate calibration tool that uses GPS signals\n") +
"Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)\n" +
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
"See COPYING file to see a copy of the General Public License\n \n");
google::SetUsageMessage(intro_help);
google::SetVersionString(FRONT_END_CAL_VERSION);
@@ -279,14 +276,14 @@ int main(int argc, char** argv)
{
std::cout << "Logging will be done at "
<< "/tmp"
<< std::endl
<< "Use front-end-cal --log_dir=/path/to/log to change that."
<< std::endl;
<< "/tmp"
<< std::endl
<< "Use front-end-cal --log_dir=/path/to/log to change that."
<< std::endl;
}
else
{
const boost::filesystem::path p (FLAGS_log_dir);
const boost::filesystem::path p(FLAGS_log_dir);
if (!boost::filesystem::exists(p))
{
std::cout << "The path "
@@ -317,12 +314,12 @@ int main(int argc, char** argv)
}
else
{
std::cout << "Failure connecting to SUPL server" <<std::endl;
std::cout << "Failure connecting to SUPL server" << std::endl;
}
// 3. Capture some front-end samples to hard disk
try
{
{
if (front_end_capture(configuration))
{
std::cout << "Front-end RAW samples captured" << std::endl;
@@ -331,19 +328,19 @@ int main(int argc, char** argv)
{
std::cout << "Failure capturing front-end samples" << std::endl;
}
}
catch(const boost::bad_lexical_cast & e)
{
}
catch (const boost::bad_lexical_cast& e)
{
std::cout << "Exception caught while capturing samples (bad lexical cast)" << std::endl;
}
catch(const boost::io::too_few_args & e)
{
}
catch (const boost::io::too_few_args& e)
{
std::cout << "Exception caught while capturing samples (too few args)" << std::endl;
}
catch(...)
{
}
catch (...)
{
std::cout << "Unexpected exception" << std::endl;
}
}
// 4. Setup GNU Radio flowgraph (file_source -> Acquisition_10m)
gr::top_block_sptr top_block;
@@ -372,13 +369,14 @@ int main(int argc, char** argv)
source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat");
boost::shared_ptr<FrontEndCal_msg_rx> msg_rx;
try
{
{
msg_rx = FrontEndCal_msg_rx_make();
}
catch(const std::exception & e)
{
std::cout << "Failure connecting the message port system: " << e.what() << std::endl; exit(0);
}
}
catch (const std::exception& e)
{
std::cout << "Failure connecting the message port system: " << e.what() << std::endl;
exit(0);
}
//gr_basic_block_sptr head = gr_make_head(sizeof(gr_complex), nsamples);
//gr_head_sptr head_sptr = boost::dynamic_pointer_cast<gr_head>(head);
@@ -386,23 +384,23 @@ int main(int argc, char** argv)
//head_sptr->reset();
try
{
{
acquisition->connect(top_block);
top_block->connect(source, 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx,pmt::mp("events"));
}
catch(const std::exception & e)
{
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}
catch (const std::exception& e)
{
std::cout << "Failure connecting the GNU Radio blocks: " << e.what() << std::endl;
}
}
// 5. Run the flowgraph
// Get visible GPS satellites (positive acquisitions with Doppler measurements)
// Compute Doppler estimations
//todo: Fix the front-end cal to support new channel internal message system (no more external queues)
std::map<int,double> doppler_measurements_map;
std::map<int,double> cn0_measurements_map;
std::map<int, double> doppler_measurements_map;
std::map<int, double> cn0_measurements_map;
boost::thread ch_thread;
@@ -413,7 +411,7 @@ int main(int argc, char** argv)
bool start_msg = true;
for (unsigned int PRN=1; PRN<33; PRN++)
for (unsigned int PRN = 1; PRN < 33; PRN++)
{
gnss_synchro->PRN = PRN;
acquisition->set_gnss_synchro(gnss_synchro);
@@ -422,13 +420,13 @@ int main(int argc, char** argv)
acquisition->reset();
stop = false;
try
{
{
ch_thread = boost::thread(wait_message);
}
catch(const boost::thread_resource_error & e)
{
}
catch (const boost::thread_resource_error& e)
{
LOG(INFO) << "Exception caught (thread resource error)";
}
}
top_block->run();
if (start_msg == true)
{
@@ -436,16 +434,16 @@ int main(int argc, char** argv)
std::cout << "[";
start_msg = false;
}
if (gnss_sync_vector.size()>0)
if (gnss_sync_vector.size() > 0)
{
std::cout << " " << PRN << " ";
double doppler_measurement_hz = 0;
for (std::vector<Gnss_Synchro>::iterator it = gnss_sync_vector.begin() ; it != gnss_sync_vector.end(); ++it)
for (std::vector<Gnss_Synchro>::iterator it = gnss_sync_vector.begin(); it != gnss_sync_vector.end(); ++it)
{
doppler_measurement_hz += (*it).Acq_doppler_hz;
}
doppler_measurement_hz = doppler_measurement_hz/gnss_sync_vector.size();
doppler_measurements_map.insert(std::pair<int,double>(PRN, doppler_measurement_hz));
doppler_measurement_hz = doppler_measurement_hz / gnss_sync_vector.size();
doppler_measurements_map.insert(std::pair<int, double>(PRN, doppler_measurement_hz));
}
else
{
@@ -453,13 +451,13 @@ int main(int argc, char** argv)
}
channel_internal_queue.push(3);
try
{
{
ch_thread.join();
}
catch(const boost::thread_resource_error & e)
{
}
catch (const boost::thread_resource_error& e)
{
LOG(INFO) << "Exception caught while joining threads.";
}
}
gnss_sync_vector.clear();
boost::dynamic_pointer_cast<gr::blocks::file_source>(source)->seek(0, 0);
std::cout.flush();
@@ -478,7 +476,7 @@ int main(int argc, char** argv)
double current_TOW = 0;
if (global_gps_ephemeris_map.size() > 0)
{
std::map<int,Gps_Ephemeris> Eph_map;
std::map<int, Gps_Ephemeris> Eph_map;
Eph_map = global_gps_ephemeris_map.get_map_copy();
current_TOW = Eph_map.begin()->second.d_TOW;
@@ -486,7 +484,7 @@ int main(int argc, char** argv)
fprintf(stdout, "Reference Time:\n");
fprintf(stdout, " GPS Week: %d\n", Eph_map.begin()->second.i_GPS_week);
fprintf(stdout, " GPS TOW: %ld %lf\n", (long int)current_TOW, (long int)current_TOW*0.08);
fprintf(stdout, " GPS TOW: %ld %lf\n", (long int)current_TOW, (long int)current_TOW * 0.08);
fprintf(stdout, " ~ UTC: %s", ctime(&t));
std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl;
}
@@ -521,43 +519,42 @@ int main(int argc, char** argv)
return 0;
}
std::map<int,double> f_if_estimation_Hz_map;
std::map<int,double> f_fs_estimation_Hz_map;
std::map<int,double> f_ppm_estimation_Hz_map;
std::map<int, double> f_if_estimation_Hz_map;
std::map<int, double> f_fs_estimation_Hz_map;
std::map<int, double> f_ppm_estimation_Hz_map;
std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) <<
"Doppler analysis results:" << std::endl;
std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Doppler analysis results:" << std::endl;
std::cout << "SV ID Measured [Hz] Predicted [Hz]" << std::endl;
for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it)
for (std::map<int, double>::iterator it = doppler_measurements_map.begin(); it != doppler_measurements_map.end(); ++it)
{
try
{
{
double doppler_estimated_hz;
doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m);
std::cout << " " << it->first << " " << it->second << " " << doppler_estimated_hz << std::endl;
// 7. Compute front-end IF and sampling frequency estimation
// Compare with the measurements and compute clock drift using FE model
double estimated_fs_Hz, estimated_f_if_Hz, f_osc_err_ppm;
front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it->second,fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm );
front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it->second, fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm);
f_if_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_f_if_Hz));
f_fs_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_fs_Hz));
f_ppm_estimation_Hz_map.insert(std::pair<int,double>(it->first,f_osc_err_ppm));
}
catch(const std::logic_error & e)
{
f_if_estimation_Hz_map.insert(std::pair<int, double>(it->first, estimated_f_if_Hz));
f_fs_estimation_Hz_map.insert(std::pair<int, double>(it->first, estimated_fs_Hz));
f_ppm_estimation_Hz_map.insert(std::pair<int, double>(it->first, f_osc_err_ppm));
}
catch (const std::logic_error& e)
{
std::cout << "Logic error caught: " << e.what() << std::endl;
}
catch(const boost::lock_error & e)
{
}
catch (const boost::lock_error& e)
{
std::cout << "Exception caught while reading ephemeris" << std::endl;
}
catch(int ex)
{
}
catch (int ex)
{
std::cout << " " << it->first << " " << it->second << " (Eph not found)" << std::endl;
}
}
}
// FINAL FE estimations
@@ -566,7 +563,7 @@ int main(int argc, char** argv)
double mean_osc_err_ppm = 0;
int n_elements = f_if_estimation_Hz_map.size();
for (std::map<int,double>::iterator it = f_if_estimation_Hz_map.begin() ; it != f_if_estimation_Hz_map.end(); ++it)
for (std::map<int, double>::iterator it = f_if_estimation_Hz_map.begin(); it != f_if_estimation_Hz_map.end(); ++it)
{
mean_f_if_Hz += (*it).second;
mean_fs_Hz += f_fs_estimation_Hz_map.find((*it).first)->second;
@@ -587,31 +584,28 @@ int main(int argc, char** argv)
<< "Corrected Doppler vs. Predicted" << std::endl;
std::cout << "SV ID Corrected [Hz] Predicted [Hz]" << std::endl;
for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it)
for (std::map<int, double>::iterator it = doppler_measurements_map.begin(); it != doppler_measurements_map.end(); ++it)
{
try
{
{
double doppler_estimated_hz;
doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m);
std::cout << " " << it->first << " " << it->second - mean_f_if_Hz << " " << doppler_estimated_hz << std::endl;
}
catch(const std::logic_error & e)
{
std::cout << " " << it->first << " " << it->second - mean_f_if_Hz << " " << doppler_estimated_hz << std::endl;
}
catch (const std::logic_error& e)
{
std::cout << "Logic error caught: " << e.what() << std::endl;
}
catch(const boost::lock_error & e)
{
}
catch (const boost::lock_error& e)
{
std::cout << "Exception caught while reading ephemeris" << std::endl;
}
catch(int ex)
{
}
catch (int ex)
{
std::cout << " " << it->first << " " << it->second - mean_f_if_Hz << " (Eph not found)" << std::endl;
}
}
}
// 8. Generate GNSS-SDR config file.
delete acquisition;
delete gnss_synchro;