1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-18 11:09:56 +00:00

Improve messages if configuration fails

This commit is contained in:
Carles Fernandez 2021-02-27 11:05:39 +01:00
parent c47fa0d895
commit 816bd94379
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 179 additions and 40 deletions

View File

@ -111,6 +111,7 @@
#include "two_bit_packed_file_signal_source.h"
#include <glog/logging.h>
#include <exception> // for exception
#include <iostream> // for cerr
#include <utility> // for move
#if RAW_UDP
@ -283,6 +284,12 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner(
return conditioner_;
}
if (signal_conditioner != "Signal_Conditioner")
{
std::cerr << "Error in configuration file: SignalConditioner.implementation=" << signal_conditioner << " is not a valid value.\n";
return nullptr;
}
// single-antenna version
std::unique_ptr<GNSSBlockInterface> conditioner_ = std::make_unique<SignalConditioner>(
GetBlock(configuration, role_datatypeadapter, 1, 1),
@ -298,9 +305,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetObservables(const Confi
const std::string empty_implementation;
std::string implementation = configuration->property("Observables.implementation", empty_implementation);
LOG(INFO) << "Getting Observables with implementation " << implementation;
if (implementation != "Hybrid_Observables")
if (implementation.find("_Observables") == std::string::npos)
{
LOG(WARNING) << "Error in configuration file: please set Observables.implementation=Hybrid_Observables";
std::cerr << "Error in configuration file: please set Observables.implementation=Hybrid_Observables\n";
return nullptr;
}
unsigned int Galileo_channels = configuration->property("Channels_1B.count", 0);
Galileo_channels += configuration->property("Channels_5X.count", 0);
@ -332,9 +340,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetPVT(const Configuration
const std::string empty_implementation;
std::string implementation = configuration->property("PVT.implementation", empty_implementation);
LOG(INFO) << "Getting PVT with implementation " << implementation;
if (implementation != "RTKLIB_PVT")
if (implementation.find("_PVT") == std::string::npos)
{
LOG(WARNING) << "Error in configuration file: please set PVT.implementation=RTKLIB_PVT";
std::cerr << "Error in configuration file: please set PVT.implementation=RTKLIB_PVT\n";
return nullptr;
}
unsigned int Galileo_channels = configuration->property("Channels_1B.count", 0);
Galileo_channels += configuration->property("Channels_5X.count", 0);
@ -388,7 +397,7 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel(
std::string trk_item_type = configuration->property("Tracking_" + signal + appendix2 + item_prop, default_item_type);
if (acq_item_type != trk_item_type)
{
LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!";
std::cerr << "Configuration error: Acquisition and Tracking blocks must have the same input data type!\n";
return nullptr;
}
@ -410,7 +419,7 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel(
}
if (trk_->item_size() == 0)
{
LOG(ERROR) << trk_->role() << item_prop << "=" << acq_item_type << " is not defined for implementation " << trk_->implementation();
std::cerr << "Configuration error: " << trk_->role() << item_prop << "=" << acq_item_type << " is not defined for implementation " << trk_->implementation() << '\n';
return nullptr;
}
@ -1264,13 +1273,14 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
else
{
// Consider making this a fatal error, terminating the program. Unfortunately, existing unit tests expect otherwise
LOG(ERROR) << role << ".implementation=" << implementation << " is an undefined implementation.";
std::cerr << "Configuration error in " << role << " block: implementation " + implementation + " is not available.\n"s;
block = nullptr;
}
}
catch (const std::exception& e)
{
std::cout << "GNSS-SDR program ended.\n";
std::cout << "Configuration error. GNSS-SDR program ended.\n";
LOG(INFO) << "Exception raised while instantiating a block: " << e.what();
exit(1);
}
return block;
@ -1464,7 +1474,8 @@ std::unique_ptr<AcquisitionInterface> GNSSBlockFactory::GetAcqBlock(
else
{
LOG(ERROR) << role << " block: Undefined implementation" << (implementation == "Wrong"s ? "" : " "s + implementation);
std::cerr << "Configuration error in " << role << " block: implementation " << (implementation == "Wrong"s ? "not defined."s : implementation + " not available."s) << '\n';
block = nullptr;
}
return block;
}
@ -1618,7 +1629,8 @@ std::unique_ptr<TrackingInterface> GNSSBlockFactory::GetTrkBlock(
#endif
else
{
LOG(ERROR) << role << " block: Undefined implementation" << (implementation == "Wrong"s ? "" : " "s + implementation);
std::cerr << "Configuration error in " << role << " block: implementation " << (implementation == "Wrong"s ? "not defined."s : implementation + " not available."s) << '\n';
block = nullptr;
}
return block;
}
@ -1709,7 +1721,8 @@ std::unique_ptr<TelemetryDecoderInterface> GNSSBlockFactory::GetTlmBlock(
else
{
LOG(ERROR) << role << " block: Undefined implementation" << (implementation == "Wrong"s ? "" : " "s + implementation);
std::cerr << "Configuration error in " << role << " block: implementation " << (implementation == "Wrong"s ? "not defined."s : implementation + " not available."s) << '\n';
block = nullptr;
}
return block;

View File

@ -106,13 +106,13 @@ void GNSSFlowgraph::init()
for (int i = 0; i < sources_count_; i++)
{
std::cout << "Creating source " << i << '\n';
DLOG(INFO) << "Creating source " << i;
sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), i));
if (enable_fpga_offloading_ == false)
{
auto& src = sig_source_.back();
auto RF_Channels = src->getRfChannels();
std::cout << "RF Channels " << RF_Channels << '\n';
std::cout << "RF Channels: " << RF_Channels << '\n';
for (auto j = 0U; j < RF_Channels; ++j)
{
sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID));
@ -527,7 +527,8 @@ int GNSSFlowgraph::connect_fpga_flowgraph()
{
if (src == nullptr)
{
help_hint_ += " * Undefined SignalSource.implementation in the configuration file.\n";
help_hint_ += " * Check implementation name for SignalSource block.\n";
help_hint_ += " Signal Source block implementation for FPGA off-loading should be Ad9361_Fpga_Signal_Source\n";
return 1;
}
if (src->item_size() == 0)
@ -559,17 +560,9 @@ int GNSSFlowgraph::connect_fpga_flowgraph()
DLOG(INFO) << "Blocks connected internally to the top_block";
// Connect the counter
if (sig_source_.at(0) != nullptr)
if (connect_fpga_sample_counter() != 0)
{
if (connect_fpga_sample_counter() != 0)
{
return 1;
}
}
else
{
help_hint_ += " * Check implementation name for SignalSource block\n";
help_hint_ += " Signal Source block implementation for FPGA off-loading should be 'Ad9361_Fpga_Signal_Source'\n";
return 1;
}
@ -695,6 +688,12 @@ int GNSSFlowgraph::connect_signal_conditioners()
{
for (auto& sig : sig_conditioner_)
{
if (sig == nullptr)
{
help_hint_ += " * The Signal_Conditioner implementation set in the configuration file does not exist.\n";
help_hint_ += " Check the Signal Conditioner documentation at https://gnss-sdr.org/docs/sp-blocks/signal-conditioner/\n";
return error;
}
sig->connect(top_block_);
}
DLOG(INFO) << "Signal Conditioner blocks successfully connected to the top_block";

View File

@ -29,7 +29,6 @@
#include "observables_interface.h"
#include "pvt_interface.h"
#include "signal_source_interface.h"
#include "telemetry_decoder_interface.h"
#include "tracking_interface.h"
#include <gtest/gtest.h>
#include <pmt/pmt.h>
@ -55,7 +54,20 @@ TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource)
TEST(GNSSBlockFactoryTest, InstantiateWrongSignalSource)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("SignalSource.implementation", "Pepito");
configuration->set_property("SignalSource.implementation", "Parapsychological_Source");
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
// Example of a factory as a unique_ptr
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
// Example of a block as a unique_ptr
auto signal_source = factory->GetSignalSource(configuration.get(), queue.get());
EXPECT_EQ(nullptr, signal_source);
}
TEST(GNSSBlockFactoryTest, InstantiateWrongSignalSource2)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("SignalSource.implementation", "Pass_Through");
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
// Example of a factory as a unique_ptr
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
@ -76,6 +88,26 @@ TEST(GNSSBlockFactoryTest, InstantiateSignalConditioner)
}
TEST(GNSSBlockFactoryTest, InstantiateWrongSignalConditioner)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("SignalConditioner.implementation", "Signal_Ruinder");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> signal_conditioner = factory->GetSignalConditioner(configuration.get());
EXPECT_EQ(nullptr, signal_conditioner);
}
TEST(GNSSBlockFactoryTest, InstantiateWrongSignalConditioner2)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("SignalConditioner.implementation", "Fir_Filter");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> signal_conditioner = factory->GetSignalConditioner(configuration.get());
EXPECT_EQ(nullptr, signal_conditioner);
}
TEST(GNSSBlockFactoryTest, InstantiateFIRFilter)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
@ -138,6 +170,7 @@ TEST(GNSSBlockFactoryTest, InstantiateFreqXlatingFIRFilter)
configuration->set_property("InputFilter.sampling_frequency", "4000000");
configuration->set_property("InputFilter.IF", "34000");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> input_filter = factory->GetBlock(configuration.get(), "InputFilter", 1, 1);
@ -151,10 +184,8 @@ TEST(GNSSBlockFactoryTest, InstantiatePulseBlankingFilter)
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
configuration->set_property("InputFilter.implementation", "Pulse_Blanking_Filter");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> input_filter = factory->GetBlock(configuration.get(), "InputFilter", 1, 1);
EXPECT_STREQ("InputFilter", input_filter->role().c_str());
EXPECT_STREQ("Pulse_Blanking_Filter", input_filter->implementation().c_str());
}
@ -165,10 +196,8 @@ TEST(GNSSBlockFactoryTest, InstantiateNotchFilter)
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
configuration->set_property("InputFilter.implementation", "Notch_Filter");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> input_filter = factory->GetBlock(configuration.get(), "InputFilter", 1, 1);
EXPECT_STREQ("InputFilter", input_filter->role().c_str());
EXPECT_STREQ("Notch_Filter", input_filter->implementation().c_str());
}
@ -179,15 +208,24 @@ TEST(GNSSBlockFactoryTest, InstantiateNotchFilterLite)
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
configuration->set_property("InputFilter.implementation", "Notch_Filter_Lite");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> input_filter = factory->GetBlock(configuration.get(), "InputFilter", 1, 1);
EXPECT_STREQ("InputFilter", input_filter->role().c_str());
EXPECT_STREQ("Notch_Filter_Lite", input_filter->implementation().c_str());
}
TEST(GNSSBlockFactoryTest, InstantiateWrongFilter)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
configuration->set_property("InputFilter.implementation", "Pollen_Filter");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> input_filter = factory->GetBlock(configuration.get(), "InputFilter", 1, 1);
EXPECT_EQ(nullptr, input_filter);
}
TEST(GNSSBlockFactoryTest, InstantiateDirectResampler)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
@ -199,6 +237,16 @@ TEST(GNSSBlockFactoryTest, InstantiateDirectResampler)
}
TEST(GNSSBlockFactoryTest, InstantiateWrongResampler)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Resampler.implementation", "RaNdOm_Resampler");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<GNSSBlockInterface> resampler = factory->GetBlock(configuration.get(), "Resampler", 1, 1);
EXPECT_EQ(nullptr, resampler);
}
TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaPcpsAcquisition)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
@ -247,6 +295,16 @@ TEST(GNSSBlockFactoryTest, InstantiateGalileoE1PcpsAmbiguousAcquisition)
}
TEST(GNSSBlockFactoryTest, InstantiateWrongAcquisition)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Alchemy");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(configuration.get(), "Acquisition", 1, 0);
EXPECT_EQ(nullptr, acq_);
}
TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaDllPllTracking)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
@ -283,6 +341,16 @@ TEST(GNSSBlockFactoryTest, InstantiateGalileoE1DllPllVemlTracking)
}
TEST(GNSSBlockFactoryTest, InstantiateWrongTracking)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Tracking.implementation", "The perfect tracking");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> trk_ = factory->GetBlock(configuration.get(), "Tracking", 1, 1);
EXPECT_EQ(nullptr, trk_);
}
TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaTelemetryDecoder)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
@ -294,17 +362,35 @@ TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaTelemetryDecoder)
}
TEST(GNSSBlockFactoryTest, InstantiateWrongTelemetryDecoder)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("TelemetryDecoder.implementation", "GPS_Xenomorphic_Telemetry_Decoder");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> telemetry_decoder = factory->GetBlock(configuration.get(), "TelemetryDecoder", 1, 1);
EXPECT_EQ(nullptr, telemetry_decoder);
}
TEST(GNSSBlockFactoryTest, InstantiateEmptyTelemetryDecoder)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("TelemetryDecoder.implementation", std::string(""));
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> telemetry_decoder = factory->GetBlock(configuration.get(), "TelemetryDecoder", 1, 1);
EXPECT_EQ(nullptr, telemetry_decoder);
}
TEST(GNSSBlockFactoryTest, InstantiateChannels)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Channels_1C.count", "2");
configuration->set_property("Channels_1E.count", "0");
configuration->set_property("Channels.in_acquisition", "2");
configuration->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Acquisition");
configuration->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_Tracking");
configuration->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder");
configuration->set_property("Channel0.item_type", "gr_complex");
configuration->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Acquisition");
configuration->set_property("Channel1.item_type", "gr_complex");
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = factory->GetChannels(configuration.get(), queue.get());
@ -313,18 +399,37 @@ TEST(GNSSBlockFactoryTest, InstantiateChannels)
}
TEST(GNSSBlockFactoryTest, InstantiateObservables)
TEST(GNSSBlockFactoryTest, InstantiateWrongObservables)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Observables.implementation", "Supercalifragilistic_Observables");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
auto observables = factory->GetObservables(configuration.get());
EXPECT_EQ(nullptr, observables);
}
TEST(GNSSBlockFactoryTest, InstantiateWrongObservables2)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Observables.implementation", "Pass_Through");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
auto observables = factory->GetObservables(configuration.get());
EXPECT_STREQ("Observables", observables->role().c_str());
EXPECT_STREQ("Pass_Through", observables->implementation().c_str());
EXPECT_EQ(nullptr, observables);
}
TEST(GNSSBlockFactoryTest, InstantiateGpsL1CaObservables)
TEST(GNSSBlockFactoryTest, InstantiateWrongObservables3)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Observables.implementation", "RTKLIB_PVT");
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
auto observables = factory->GetObservables(configuration.get());
EXPECT_EQ(nullptr, observables);
}
TEST(GNSSBlockFactoryTest, InstantiateObservables)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("Observables.implementation", "Hybrid_Observables");
@ -356,3 +461,25 @@ TEST(GNSSBlockFactoryTest, InstantiateWrongPvt)
auto pvt = std::dynamic_pointer_cast<PvtInterface>(pvt_);
EXPECT_EQ(nullptr, pvt);
}
TEST(GNSSBlockFactoryTest, InstantiateWrongPvt2)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("PVT.implementation", "Pass_Through");
auto factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> pvt_ = factory->GetPVT(configuration.get());
auto pvt = std::dynamic_pointer_cast<PvtInterface>(pvt_);
EXPECT_EQ(nullptr, pvt);
}
TEST(GNSSBlockFactoryTest, InstantiateWrongPvt3)
{
std::shared_ptr<InMemoryConfiguration> configuration = std::make_shared<InMemoryConfiguration>();
configuration->set_property("PVT.implementation", "Quantum_Particle_PVT");
auto factory = std::make_unique<GNSSBlockFactory>();
std::shared_ptr<GNSSBlockInterface> pvt_ = factory->GetPVT(configuration.get());
auto pvt = std::dynamic_pointer_cast<PvtInterface>(pvt_);
EXPECT_EQ(nullptr, pvt);
}