Fix for old versions of libad9361

This commit is contained in:
Carles Fernandez 2019-10-09 22:08:08 +02:00
parent 54698bd211
commit b0c00eb5b0
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 45 additions and 5 deletions

View File

@ -2292,7 +2292,6 @@ set_package_properties(LIBAD9361 PROPERTIES
TYPE OPTIONAL
)
if(NOT LIBAD9361_FOUND)
set(GRIIO_FOUND FALSE)
set(ENABLE_AD9361 OFF)
endif()
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)

View File

@ -70,6 +70,13 @@ if(ENABLE_FMCOMMS2 OR ENABLE_AD9361)
PRIVATE
Iio::ad9361
)
if(LIBAD9361_VERSION)
if(LIBAD9361_VERSION VERSION_GREATER 0.1)
target_compile_definitions(signal_source_libs
PUBLIC -DLIBAD9361_VERSION_GREATER_THAN_01=1
)
endif()
endif()
endif()
if(ENABLE_CLANG_TIDY)

View File

@ -189,7 +189,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
bool quadrature_,
bool rfdc_,
bool bbdc_,
const std::string &filter_source_,
std::string filter_source_,
std::string filter_filename_,
float Fpass_,
float Fstop_)
@ -204,6 +204,19 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
struct iio_channel *rx_chan2;
int ret;
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
if (filter_source_ == "Design")
{
std::cout << "Option filter_source=Design is not available in this version. Set to filter_source=Off" << std::endl;
filter_source_ = std::string("Off");
}
if (Fpass_ != 0.0 or Fstop_ != 0.0)
{
Fpass_ = 0.0;
Fstop_ = 0.0;
}
#endif
ctx = iio_create_default_context();
if (!ctx)
{
@ -301,6 +314,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#if LIBAD9361_VERSION_GREATER_THAN_01
else if (filter_source_ == "Design")
{
ret = ad9361_set_bb_rate_custom_filter_manual(
@ -321,6 +335,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#endif
else
{
throw std::runtime_error("Unknown filter configuration");
@ -409,7 +424,7 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
bool quadrature_,
bool rfdc_,
bool bbdc_,
const std::string &filter_source_,
std::string filter_source_,
std::string filter_filename_,
float Fpass_,
float Fstop_)
@ -422,6 +437,19 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
struct iio_channel *rx_chan1;
struct iio_channel *rx_chan2;
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
if (filter_source_ == "Design")
{
std::cout << "Option filter_source=Design is not available in this version. Set to filter_source=Off" << std::endl;
filter_source_ = std::string("Off");
}
if (Fpass_ != 0.0 or Fstop_ != 0.0)
{
Fpass_ = 0.0;
Fstop_ = 0.0;
}
#endif
ctx = iio_create_network_context(remote_host.c_str());
if (!ctx)
{
@ -523,6 +551,7 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#if LIBAD9361_VERSION_GREATER_THAN_01
else if (filter_source_ == "Design")
{
ret = ad9361_set_bb_rate_custom_filter_manual(
@ -543,6 +572,7 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#endif
else
{
throw std::runtime_error("Unknown filter configuration");

View File

@ -93,7 +93,7 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
bool quadrature_,
bool rfdc_,
bool bbdc_,
const std::string &filter_source_,
std::string filter_source_,
std::string filter_filename_,
float Fpass_,
float Fstop_);
@ -109,7 +109,11 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
double rf_gain_rx2_,
bool quadrature_,
bool rfdc_,
bool bbdc_);
bool bbdc_,
std::string filter_source_,
std::string filter_filename_,
float Fpass_,
float Fstop_);
bool config_ad9361_lo_local(uint64_t bandwidth_,
uint64_t sample_rate_,