2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \file main.cc
|
|
|
|
* \brief Main file of the GNSS-SDR program.
|
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
2011-12-28 21:36:45 +00:00
|
|
|
* It sets up the logging system, creates a ControlThread object,
|
|
|
|
* makes it run, and releases memory back when the main thread has ended.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2013-01-22 20:40:25 +00:00
|
|
|
* Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
2013-01-22 20:40:25 +00:00
|
|
|
#ifndef GNSS_SDR_VERSION
|
2013-08-02 16:00:12 +00:00
|
|
|
#define GNSS_SDR_VERSION "0.0.2"
|
2013-01-22 20:40:25 +00:00
|
|
|
#endif
|
2011-12-27 21:21:12 +00:00
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2013-08-01 14:01:07 +00:00
|
|
|
#include <boost/exception/diagnostic_information.hpp>
|
|
|
|
#include <boost/exception_ptr.hpp>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <gflags/gflags.h>
|
|
|
|
#include <glog/log_severity.h>
|
|
|
|
#include <glog/logging.h>
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/msg_queue.h>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include "control_thread.h"
|
|
|
|
#include <queue>
|
|
|
|
#include <boost/thread/mutex.hpp>
|
|
|
|
#include <boost/thread/thread.hpp>
|
|
|
|
#include "concurrent_queue.h"
|
2013-03-15 18:05:37 +00:00
|
|
|
#include "concurrent_map.h"
|
2013-03-11 18:29:33 +00:00
|
|
|
#include "gps_ephemeris.h"
|
|
|
|
#include "gps_almanac.h"
|
|
|
|
#include "gps_iono.h"
|
|
|
|
#include "gps_utc_model.h"
|
2013-07-15 17:07:10 +00:00
|
|
|
#include "galileo_ephemeris.h"
|
|
|
|
#include "galileo_almanac.h"
|
|
|
|
#include "galileo_iono.h"
|
|
|
|
#include "galileo_utc_model.h"
|
2013-11-09 23:11:46 +00:00
|
|
|
#include "sbas_telemetry_data.h"
|
|
|
|
#include "sbas_ionospheric_correction.h"
|
|
|
|
#include "sbas_satellite_correction.h"
|
|
|
|
#include "sbas_ephemeris.h"
|
|
|
|
#include "sbas_time.h"
|
|
|
|
|
2012-02-08 19:50:16 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <ctime>
|
2012-02-23 19:10:48 +00:00
|
|
|
#include <memory>
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
using google::LogMessage;
|
|
|
|
|
2011-12-27 21:21:12 +00:00
|
|
|
DECLARE_string(log_dir);
|
|
|
|
|
2011-11-22 17:21:54 +00:00
|
|
|
/*!
|
|
|
|
* \todo make this queue generic for all the GNSS systems (javi)
|
|
|
|
*/
|
|
|
|
|
2011-12-28 21:36:45 +00:00
|
|
|
/*
|
2013-11-09 23:11:46 +00:00
|
|
|
* Concurrent queues that communicates the Telemetry Decoder
|
2011-10-01 18:45:20 +00:00
|
|
|
* to the Observables modules
|
|
|
|
*/
|
2013-03-14 12:52:32 +00:00
|
|
|
|
2013-07-15 17:07:10 +00:00
|
|
|
// For GPS NAVIGATION
|
2013-03-11 18:29:33 +00:00
|
|
|
concurrent_queue<Gps_Ephemeris> global_gps_ephemeris_queue;
|
|
|
|
concurrent_queue<Gps_Iono> global_gps_iono_queue;
|
|
|
|
concurrent_queue<Gps_Utc_Model> global_gps_utc_model_queue;
|
|
|
|
concurrent_queue<Gps_Almanac> global_gps_almanac_queue;
|
2013-03-20 18:19:26 +00:00
|
|
|
concurrent_queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
|
2013-03-11 18:29:33 +00:00
|
|
|
|
2013-03-15 18:05:37 +00:00
|
|
|
concurrent_map<Gps_Ephemeris> global_gps_ephemeris_map;
|
|
|
|
concurrent_map<Gps_Iono> global_gps_iono_map;
|
|
|
|
concurrent_map<Gps_Utc_Model> global_gps_utc_model_map;
|
2013-03-20 18:19:26 +00:00
|
|
|
concurrent_map<Gps_Almanac> global_gps_almanac_map;
|
|
|
|
concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
2013-03-15 18:05:37 +00:00
|
|
|
|
2013-07-15 17:07:10 +00:00
|
|
|
// For GALILEO NAVIGATION
|
|
|
|
concurrent_queue<Galileo_Ephemeris> global_galileo_ephemeris_queue;
|
|
|
|
concurrent_queue<Galileo_Iono> global_galileo_iono_queue;
|
|
|
|
concurrent_queue<Galileo_Utc_Model> global_galileo_utc_model_queue;
|
|
|
|
concurrent_queue<Galileo_Almanac> global_galileo_almanac_queue;
|
|
|
|
|
|
|
|
concurrent_map<Galileo_Ephemeris> global_galileo_ephemeris_map;
|
|
|
|
concurrent_map<Galileo_Iono> global_galileo_iono_map;
|
|
|
|
concurrent_map<Galileo_Utc_Model> global_galileo_utc_model_map;
|
|
|
|
concurrent_map<Galileo_Almanac> global_galileo_almanac_map;
|
|
|
|
|
2013-11-09 23:11:46 +00:00
|
|
|
// For SBAS CORRECTIONS
|
|
|
|
concurrent_queue<Sbas_Raw_Msg> global_sbas_raw_msg_queue;
|
|
|
|
concurrent_queue<Sbas_Ionosphere_Correction> global_sbas_iono_queue;
|
|
|
|
concurrent_queue<Sbas_Satellite_Correction> global_sbas_sat_corr_queue;
|
|
|
|
concurrent_queue<Sbas_Ephemeris> global_sbas_ephemeris_queue;
|
|
|
|
|
|
|
|
concurrent_map<Sbas_Ionosphere_Correction> global_sbas_iono_map;
|
|
|
|
concurrent_map<Sbas_Satellite_Correction> global_sbas_sat_corr_map;
|
|
|
|
concurrent_map<Sbas_Ephemeris> global_sbas_ephemeris_map;
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
const std::string intro_help(
|
|
|
|
std::string("\nGNSS-SDR is an Open Source GNSS Software Defined Receiver\n")
|
2011-12-28 21:36:45 +00:00
|
|
|
+
|
2013-02-17 12:01:09 +00:00
|
|
|
"Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)\n"
|
2011-12-28 21:36:45 +00:00
|
|
|
+
|
|
|
|
"This program comes with ABSOLUTELY NO WARRANTY;\n"
|
|
|
|
+
|
|
|
|
"See COPYING file to see a copy of the General Public License\n \n");
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2011-12-26 05:04:27 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
google::SetUsageMessage(intro_help);
|
2013-01-22 20:40:25 +00:00
|
|
|
google::SetVersionString(GNSS_SDR_VERSION);
|
2011-10-01 18:45:20 +00:00
|
|
|
google::ParseCommandLineFlags(&argc, &argv, true);
|
|
|
|
|
2012-02-23 19:10:48 +00:00
|
|
|
std::cout << "Initializing GNSS-SDR... Please wait." << std::endl;
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2011-12-27 21:21:12 +00:00
|
|
|
google::InitGoogleLogging(argv[0]);
|
|
|
|
if (FLAGS_log_dir.empty())
|
2011-12-28 21:36:45 +00:00
|
|
|
{
|
2012-07-15 01:08:18 +00:00
|
|
|
// temp_directory_path() is only available from
|
2013-01-19 17:06:39 +00:00
|
|
|
// Boost 1.45. Ubuntu 10.10 and Debian 6.0.6 ships with 1.42
|
2012-07-15 01:08:18 +00:00
|
|
|
std::cout << "Logging will be done at "
|
2013-01-19 17:06:39 +00:00
|
|
|
//<< boost::filesystem::temp_directory_path()
|
|
|
|
<< "/tmp"
|
2012-07-15 01:08:18 +00:00
|
|
|
<< std::endl
|
|
|
|
<< "Use gnss-sdr --log_dir=/path/to/log to change that."
|
|
|
|
<< std::endl;
|
2011-12-28 21:36:45 +00:00
|
|
|
}
|
2011-12-27 21:21:12 +00:00
|
|
|
else
|
2011-12-28 21:36:45 +00:00
|
|
|
{
|
|
|
|
const boost::filesystem::path p (FLAGS_log_dir);
|
|
|
|
if (!boost::filesystem::exists(p))
|
|
|
|
{
|
2012-07-15 01:08:18 +00:00
|
|
|
std::cout << "The path "
|
|
|
|
<< FLAGS_log_dir
|
|
|
|
<< " does not exist, attempting to create it"
|
|
|
|
<< std::endl;
|
2011-12-28 21:36:45 +00:00
|
|
|
boost::filesystem::create_directory(p);
|
|
|
|
}
|
2012-07-15 01:08:18 +00:00
|
|
|
std::cout << "Logging with be done at "
|
2013-08-02 16:00:12 +00:00
|
|
|
<< FLAGS_log_dir << std::endl;
|
2011-12-28 21:36:45 +00:00
|
|
|
}
|
2011-12-27 21:21:12 +00:00
|
|
|
|
2012-02-23 19:10:48 +00:00
|
|
|
std::unique_ptr<ControlThread> control_thread(new ControlThread());
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-02-08 19:50:16 +00:00
|
|
|
// record startup time
|
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
|
|
|
|
2013-08-02 16:00:12 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
control_thread->run();
|
|
|
|
}
|
|
|
|
catch( boost::exception & e )
|
2013-08-01 14:01:07 +00:00
|
|
|
{
|
2013-08-02 16:00:12 +00:00
|
|
|
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
|
2013-08-01 14:01:07 +00:00
|
|
|
}
|
|
|
|
catch(std::exception const& ex)
|
|
|
|
{
|
2013-08-02 16:00:12 +00:00
|
|
|
DLOG(FATAL) << "STD exception: " << ex.what();
|
2013-08-01 14:01:07 +00:00
|
|
|
}
|
2012-02-08 19:50:16 +00:00
|
|
|
// report the elapsed time
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
|
2012-07-15 01:08:18 +00:00
|
|
|
std::cout << "Total GNSS-SDR run time "
|
2013-08-02 16:00:12 +00:00
|
|
|
<< ((double)(end - begin))/1000000.0
|
|
|
|
<< " [seconds]" << std::endl;
|
2012-02-08 19:50:16 +00:00
|
|
|
|
2011-12-26 05:04:27 +00:00
|
|
|
google::ShutDownCommandLineFlags();
|
2012-07-02 12:45:20 +00:00
|
|
|
std::cout << "GNSS-SDR program ended." << std::endl;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|