1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-18 21:23:02 +00:00

Fix usage of GNU Radio GR-IIO module API

This commit is contained in:
Carles Fernandez 2021-06-05 01:21:53 +02:00
parent ab6a774f4a
commit e966006d35
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 46 additions and 24 deletions

View File

@ -29,6 +29,7 @@
#include <exception> #include <exception>
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <vector>
using namespace std::string_literals; using namespace std::string_literals;
@ -170,7 +171,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configu
std::cout << "device address: " << uri_ << '\n'; std::cout << "device address: " << uri_ << '\n';
std::cout << "LO frequency : " << freq_ << " Hz\n"; std::cout << "LO frequency : " << freq_ << " Hz\n";
std::cout << "sample rate: " << sample_rate_ << " Hz\n"; std::cout << "sample rate: " << sample_rate_ << " Sps\n";
if (item_type_ == "gr_complex") if (item_type_ == "gr_complex")
{ {
@ -183,15 +184,24 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configu
else else
{ {
#if GNURADIO_API_IIO #if GNURADIO_API_IIO
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( std::vector<bool> enable_channels{rx1_en_, rx2_en_};
uri_.c_str(), freq_, sample_rate_, fmcomms2_source_f32c_ = gr::iio::fmcomms2_source::make(uri_, enable_channels, buffer_size_);
bandwidth_, fmcomms2_source_f32c_->set_frequency(freq_);
rx1_en_, rx2_en_, fmcomms2_source_f32c_->set_samplerate(sample_rate_);
buffer_size_, quadrature_, rf_dc_, if (rx1_en_)
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, {
gain_mode_rx2_.c_str(), rf_gain_rx2_, fmcomms2_source_f32c_->set_gain_mode(0, gain_mode_rx1_);
rf_port_select_.c_str(), filter_source_.c_str(), fmcomms2_source_f32c_->set_gain(0, rf_gain_rx1_);
filter_filename_.c_str(), Fpass_, Fstop_); }
if (rx2_en_)
{
fmcomms2_source_f32c_->set_gain_mode(1, gain_mode_rx2_);
fmcomms2_source_f32c_->set_gain(1, rf_gain_rx2_);
}
fmcomms2_source_f32c_->set_quadrature(quadrature_);
fmcomms2_source_f32c_->set_rfdc(rf_dc_);
fmcomms2_source_f32c_->set_bbdc(bb_dc_);
fmcomms2_source_f32c_->set_filter_params(filter_source_, filter_filename_, Fpass_, Fstop_);
#else #else
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_, uri_.c_str(), freq_, sample_rate_,
@ -250,15 +260,18 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configu
else else
{ {
#if GNURADIO_API_IIO #if GNURADIO_API_IIO
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( std::vector<bool> enable_channels{rx1_en_, rx2_en_};
uri_.c_str(), freq_, sample_rate_, fmcomms2_source_f32c_ = gr::iio::fmcomms2_source::make(uri_, enable_channels, buffer_size_);
bandwidth_, fmcomms2_source_f32c_->set_frequency(freq_);
rx1_en_, rx2_en_, fmcomms2_source_f32c_->set_samplerate(sample_rate_);
buffer_size_, quadrature_, rf_dc_, fmcomms2_source_f32c_->set_gain_mode(0, gain_mode_rx1_);
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, fmcomms2_source_f32c_->set_gain(0, rf_gain_rx1_);
gain_mode_rx2_.c_str(), rf_gain_rx2_, fmcomms2_source_f32c_->set_gain_mode(1, gain_mode_rx2_);
rf_port_select_.c_str(), filter_source_.c_str(), fmcomms2_source_f32c_->set_gain(1, rf_gain_rx2_);
filter_filename_.c_str(), Fpass_, Fstop_); fmcomms2_source_f32c_->set_quadrature(quadrature_);
fmcomms2_source_f32c_->set_rfdc(rf_dc_);
fmcomms2_source_f32c_->set_bbdc(bb_dc_);
fmcomms2_source_f32c_->set_filter_params(filter_source_, filter_filename_, Fpass_, Fstop_);
#else #else
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_, uri_.c_str(), freq_, sample_rate_,

View File

@ -61,7 +61,11 @@ public:
gr::basic_block_sptr get_right_block() override; gr::basic_block_sptr get_right_block() override;
private: private:
#if GNURADIO_API_IIO
gr::iio::fmcomms2_source::sptr fmcomms2_source_f32c_;
#else
gr::iio::fmcomms2_source_f32c::sptr fmcomms2_source_f32c_; gr::iio::fmcomms2_source_f32c::sptr fmcomms2_source_f32c_;
#endif
gnss_shared_ptr<gr::block> valve_; gnss_shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;

View File

@ -121,15 +121,20 @@ PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configu
std::cout << "device address: " << uri_ << '\n'; std::cout << "device address: " << uri_ << '\n';
std::cout << "frequency : " << freq_ << " Hz\n"; std::cout << "frequency : " << freq_ << " Hz\n";
std::cout << "sample rate: " << sample_rate_ << " Hz\n"; std::cout << "sample rate: " << sample_rate_ << " Sps\n";
std::cout << "gain mode: " << gain_mode_ << '\n'; std::cout << "gain mode: " << gain_mode_ << '\n';
std::cout << "item type: " << item_type_ << '\n'; std::cout << "item type: " << item_type_ << '\n';
#if GNURADIO_API_IIO #if GNURADIO_API_IIO
plutosdr_source_ = gr::iio::pluto_source::make(uri_, freq_, sample_rate_, plutosdr_source_ = gr::iio::pluto_source::make(uri_, buffer_size_);
bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_, plutosdr_source_->set_frequency(freq_);
gain_mode_.c_str(), rf_gain_, filter_source_.c_str(), plutosdr_source_->set_samplerate(sample_rate_);
filter_filename_.c_str(), Fpass_, Fstop_); plutosdr_source_->set_gain_mode(gain_mode_);
plutosdr_source_->set_gain(rf_gain_);
plutosdr_source_->set_quadrature(quadrature_);
plutosdr_source_->set_rfdc(rf_dc_);
plutosdr_source_->set_bbdc(bb_dc_);
plutosdr_source_->set_filter_params(filter_source_, filter_filename_, Fpass_, Fstop_);
#else #else
plutosdr_source_ = gr::iio::pluto_source::make(uri_, freq_, sample_rate_, plutosdr_source_ = gr::iio::pluto_source::make(uri_, freq_, sample_rate_,
bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_, bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_,