1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-23 13:33:15 +00:00

Do not use LOG(FATAL) since the glog library could have been stripped

off
This commit is contained in:
Carles Fernandez 2017-08-25 19:17:12 +02:00
parent 4f292bbe8e
commit fc9740b4dc
7 changed files with 82 additions and 42 deletions

View File

@ -32,6 +32,7 @@
*/
#include "gps_l1_ca_pcps_acquisition_fpga.h"
#include <stdexcept>
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include "GPS_L1_CA.h"
@ -63,29 +64,24 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
DLOG(INFO) << "role " << role;
item_type_ = configuration_->property(role + ".item_type",
default_item_type);
item_type_ = configuration_->property(role + ".item_type", default_item_type);
fs_in = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000);
ifreq = configuration_->property(role + ".if", 0);
dump = configuration_->property(role + ".dump", false);
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
sampled_ms = configuration_->property(
role + ".coherent_integration_time_ms", 1);
sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1);
// note : the FPGA is implemented according to bit transition flag = 0. Setting bit transition flag to 1 has no effect.
bit_transition_flag = configuration_->property(
role + ".bit_transition_flag", false);
bit_transition_flag = configuration_->property(role + ".bit_transition_flag", false);
// note : the FPGA is implemented according to use_CFAR_algorithm = 0. Setting use_CFAR_algorithm to 1 has no effect.
use_CFAR_algorithm_flag = configuration_->property(
role + ".use_CFAR_algorithm", false);
use_CFAR_algorithm_flag = configuration_->property(role + ".use_CFAR_algorithm", false);
// note : the FPGA does not use the max_dwells variable.
max_dwells_ = configuration_->property(role + ".max_dwells", 1);
dump_filename = configuration_->property(role + ".dump_filename",
default_dump_filename);
dump_filename = configuration_->property(role + ".dump_filename", default_dump_filename);
//--- Find number of samples per spreading code -------------------------
code_length = round(
@ -104,12 +100,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
// vector_length_ *= 2;
// }
select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga",
0);
select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0);
std::string default_device_name = "/dev/uio0";
device_name = configuration_->property(role + ".devicename",
default_device_name);
device_name = configuration_->property(role + ".devicename", default_device_name);
if (item_type_.compare("cshort") == 0)
{
@ -124,7 +118,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
}
else
{
LOG(FATAL) << item_type_ << " FPGA only accepts chsort";
LOG(WARNING) << "item_type configured to " << item_type_ << "but FPGA implementation only accepts cshort";
throw std::invalid_argument( "Wrong input_type configuration. Should be cshort" );
}
channel_ = 0;

View File

@ -75,19 +75,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
{
item_size_ = sizeof(gr_complex);
// 1. Make the driver instance
try
{
if (!osmosdr_args_.empty())
{
std::cout << "OsmoSdr arguments: " << osmosdr_args_ << std::endl;
LOG(INFO) << "OsmoSdr arguments: " << osmosdr_args_;
}
osmosdr_source_ = osmosdr::source::make(osmosdr_args_);
}
catch( const boost::exception & e )
{
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
}
OsmosdrSignalSource::driver_instance();
// 2 set sampling rate
osmosdr_source_->set_sample_rate(sample_rate_);
@ -147,6 +135,24 @@ OsmosdrSignalSource::~OsmosdrSignalSource()
{}
void OsmosdrSignalSource::driver_instance()
{
try
{
if (!osmosdr_args_.empty())
{
std::cout << "OsmoSdr arguments: " << osmosdr_args_ << std::endl;
LOG(INFO) << "OsmoSdr arguments: " << osmosdr_args_;
}
osmosdr_source_ = osmosdr::source::make(osmosdr_args_);
}
catch( const boost::exception & e )
{
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
throw std::invalid_argument( "Wrong OsmoSdr arguments" );
}
}
void OsmosdrSignalSource::connect(gr::top_block_sptr top_block)
{

View File

@ -33,6 +33,7 @@
#ifndef GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H_
#define GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H_
#include <stdexcept>
#include <string>
#include <boost/shared_ptr.hpp>
#include <gnuradio/msg_queue.h>
@ -80,6 +81,7 @@ public:
gr::basic_block_sptr get_right_block() override;
private:
void driver_instance();
std::string role_;
// Front-end settings

View File

@ -78,16 +78,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
{
item_size_ = sizeof(gr_complex);
// 1. Make the gr block
try
{
std::cout << "Connecting to " << address_ << ":" << port_ << std::endl;
LOG (INFO) << "Connecting to " << address_ << ":" << port_;
signal_source_ = rtl_tcp_make_signal_source_c (address_, port_, flip_iq_);
}
catch( const boost::exception & e )
{
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
}
MakeBlock();
// 2 set sampling rate
signal_source_->set_sample_rate(sample_rate_);
@ -145,6 +136,22 @@ RtlTcpSignalSource::~RtlTcpSignalSource()
{}
void RtlTcpSignalSource::MakeBlock()
{
try
{
std::cout << "Connecting to " << address_ << ":" << port_ << std::endl;
LOG (INFO) << "Connecting to " << address_ << ":" << port_;
signal_source_ = rtl_tcp_make_signal_source_c (address_, port_, flip_iq_);
}
catch( const boost::exception & e )
{
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
throw std::runtime_error( "Failure connecting to the device" );
}
}
void RtlTcpSignalSource::connect(gr::top_block_sptr top_block)
{
if ( samples_ )

View File

@ -32,6 +32,7 @@
#ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H
#define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H
#include <stdexcept>
#include <string>
#include <boost/shared_ptr.hpp>
#include <gnuradio/msg_queue.h>
@ -81,6 +82,7 @@ public:
gr::basic_block_sptr get_right_block() override;
private:
void MakeBlock();
std::string role_;
// rtl_tcp settings

View File

@ -39,6 +39,7 @@
#endif
#include <chrono>
#include <iostream>
#include <memory>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception_ptr.hpp>
@ -140,15 +141,42 @@ int main(int argc, char** argv)
}
catch(const boost::exception & e)
{
LOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
if(GOOGLE_STRIP_LOG == 0)
{
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
}
else
{
std::cerr << "Boost exception: " << boost::diagnostic_information(e) << std::endl;
}
google::ShutDownCommandLineFlags();
return 1;
}
catch(const std::exception & ex)
{
LOG(FATAL) << "STD exception: " << ex.what();
if(GOOGLE_STRIP_LOG == 0)
{
LOG(WARNING) << "C++ Standard Library exception: " << ex.what();
}
else
{
std::cerr << "C++ Standard Library exception: " << ex.what() << std::endl;
}
google::ShutDownCommandLineFlags();
return 1;
}
catch(...)
{
LOG(INFO) << "Unexpected catch";
if(GOOGLE_STRIP_LOG == 0)
{
LOG(WARNING) << "Unexpected catch. This should not happen.";
}
else
{
std::cerr << "Unexpected catch. This should not happen." << std::endl;
}
google::ShutDownCommandLineFlags();
return 1;
}
// report the elapsed time

View File

@ -359,7 +359,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message()
}
catch( const boost::exception & e )
{
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
}
end = std::chrono::system_clock::now();