mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-14 11:15:47 +00:00
Fix building in some configurations
This commit is contained in:
parent
cb99011de8
commit
3f21367587
@ -2293,6 +2293,7 @@ set_package_properties(LIBAD9361 PROPERTIES
|
||||
)
|
||||
if(NOT LIBAD9361_FOUND)
|
||||
set(ENABLE_AD9361 OFF)
|
||||
set(ENABLE_FMCOMMS2 OFF)
|
||||
endif()
|
||||
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
||||
if(NOT GRIIO_FOUND)
|
||||
@ -2574,9 +2575,9 @@ add_subdirectory(src)
|
||||
################################################################################
|
||||
add_feature_info(ENABLE_UHD ENABLE_UHD "Enables UHD_Signal_Source for using RF front-ends from the USRP family. Requires gr-uhd.")
|
||||
add_feature_info(ENABLE_OSMOSDR ENABLE_OSMOSDR "Enables Osmosdr_Signal_Source and RtlTcp_Signal_Source for using RF front-ends compatible with the OsmoSDR driver. Requires gr-osmosdr.")
|
||||
add_feature_info(ENABLE_FMCOMMS2 ENABLE_FMCOMMS2 "Enables Fmcomms2_Signal_Source for FMCOMMS2/3/4 devices. Requires gr-iio.")
|
||||
add_feature_info(ENABLE_FMCOMMS2 ENABLE_FMCOMMS2 "Enables Fmcomms2_Signal_Source for FMCOMMS2/3/4 devices. Requires gr-iio and libad9361-dev.")
|
||||
add_feature_info(ENABLE_PLUTOSDR ENABLE_PLUTOSDR "Enables Plutosdr_Signal_Source for using ADALM-PLUTO boards. Requires gr-iio.")
|
||||
add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source for devices with the AD9361 chipset. Requires libiio and libad9361.")
|
||||
add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source for devices with the AD9361 chipset. Requires libiio and libad9361-dev.")
|
||||
add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.")
|
||||
add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.")
|
||||
add_feature_info(ENABLE_GN3S ENABLE_GN3S "Enables Gn3s_Signal_Source for using the GN3S v2 dongle. Requires gr-gn3s.")
|
||||
|
@ -32,10 +32,10 @@
|
||||
#include "fmcomms2_signal_source.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
#include "GPS_L2C.h"
|
||||
#include "ad9361_manager.h"
|
||||
#include "configuration_interface.h"
|
||||
#include "gnss_sdr_valve.h"
|
||||
#include <glog/logging.h>
|
||||
#include <iio.h>
|
||||
#include <algorithm> // for max
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
@ -341,190 +341,6 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface *configuration
|
||||
}
|
||||
|
||||
|
||||
bool Fmcomms2SignalSource::config_ad9361_lo_remote(const std::string &remote_host,
|
||||
uint64_t bandwidth_,
|
||||
uint64_t sample_rate_,
|
||||
uint64_t freq_rf_tx_hz_,
|
||||
double tx_attenuation_db_,
|
||||
int64_t freq_dds_tx_hz_,
|
||||
double scale_dds_dbfs_,
|
||||
double phase_dds_deg_)
|
||||
{
|
||||
// TX stream config
|
||||
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
|
||||
struct stream_cfg txcfg;
|
||||
txcfg.bw_hz = bandwidth_;
|
||||
txcfg.fs_hz = sample_rate_;
|
||||
txcfg.lo_hz = freq_rf_tx_hz_;
|
||||
txcfg.rfport = "A";
|
||||
|
||||
std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl;
|
||||
struct iio_context *ctx;
|
||||
ctx = iio_create_network_context(remote_host.c_str());
|
||||
if (!ctx)
|
||||
{
|
||||
std::cout << "No context\n";
|
||||
throw std::runtime_error("AD9361 IIO No context");
|
||||
}
|
||||
|
||||
// find tx device
|
||||
struct iio_device *tx;
|
||||
|
||||
std::cout << "* Acquiring AD9361 TX streaming devices\n";
|
||||
|
||||
if (!get_ad9361_stream_dev(ctx, TX, &tx))
|
||||
{
|
||||
std::cout << "No tx dev found\n";
|
||||
throw std::runtime_error("AD9361 IIO No tx dev found");
|
||||
};
|
||||
|
||||
std::cout << "* Configuring AD9361 for streaming TX\n";
|
||||
if (!cfg_ad9361_streaming_ch(ctx, &txcfg, TX, 0))
|
||||
{
|
||||
std::cout << "TX port 0 not found\n";
|
||||
throw std::runtime_error("AD9361 IIO TX port 0 not found");
|
||||
}
|
||||
|
||||
// ENABLE DDS on TX1
|
||||
struct iio_device *ad9361_phy;
|
||||
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||
int ret;
|
||||
// set output amplifier attenuation
|
||||
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set out_voltage0_hardwaregain value " << -std::abs(tx_attenuation_db_) << ". Error " << ret << std::endl;
|
||||
}
|
||||
|
||||
// shut down signal in TX2
|
||||
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.75);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set out_voltage1_hardwaregain value -89.75 dB. Error " << ret << std::endl;
|
||||
}
|
||||
struct iio_device *dds;
|
||||
dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc");
|
||||
struct iio_channel *dds_channel0_I;
|
||||
dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true);
|
||||
|
||||
struct iio_channel *dds_channel0_Q;
|
||||
dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true);
|
||||
|
||||
ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", true);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to toggle DDS: " << ret << std::endl;
|
||||
}
|
||||
|
||||
// set frequency, scale and phase
|
||||
ret = iio_channel_attr_write_longlong(dds_channel0_I, "frequency", static_cast<int64_t>(freq_dds_tx_hz_));
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS frequency I: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", static_cast<int64_t>(freq_dds_tx_hz_));
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", phase_dds_deg_ * 1000.0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", phase_dds_deg_ * 1000.0 + 270000.0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_I, "scale", pow(10, scale_dds_dbfs_ / 20.0));
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS scale I: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", pow(10, scale_dds_dbfs_ / 20.0));
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl;
|
||||
}
|
||||
|
||||
// disable TX2
|
||||
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set out_voltage1_hardwaregain value " << -89.0 << " error " << ret << std::endl;
|
||||
}
|
||||
|
||||
struct iio_channel *dds_channel1_I;
|
||||
dds_channel1_I = iio_device_find_channel(dds, "TX2_I_F1", true);
|
||||
|
||||
struct iio_channel *dds_channel1_Q;
|
||||
dds_channel1_Q = iio_device_find_channel(dds, "TX2_Q_F1", true);
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel1_I, "scale", 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX2 DDS scale I: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel1_Q, "scale", 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX2 DDS scale Q: " << ret << std::endl;
|
||||
}
|
||||
|
||||
iio_context_destroy(ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Fmcomms2SignalSource::ad9361_disable_lo_remote(const std::string &remote_host)
|
||||
{
|
||||
std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl;
|
||||
struct iio_context *ctx;
|
||||
ctx = iio_create_network_context(remote_host.c_str());
|
||||
if (!ctx)
|
||||
{
|
||||
std::cout << "No context\n";
|
||||
throw std::runtime_error("AD9361 IIO No context");
|
||||
}
|
||||
struct iio_device *dds;
|
||||
dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc");
|
||||
struct iio_channel *dds_channel0_I;
|
||||
dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true);
|
||||
|
||||
struct iio_channel *dds_channel0_Q;
|
||||
dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true);
|
||||
int ret;
|
||||
ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", false);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to toggle DDS: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_I, "scale", 0.0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS scale I: " << ret << std::endl;
|
||||
}
|
||||
|
||||
ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", 0.0);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl;
|
||||
}
|
||||
|
||||
iio_context_destroy(ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Fmcomms2SignalSource::~Fmcomms2SignalSource()
|
||||
{
|
||||
if (enable_dds_lo_ == true)
|
||||
|
@ -82,16 +82,6 @@ public:
|
||||
gr::basic_block_sptr get_right_block() override;
|
||||
|
||||
private:
|
||||
bool config_ad9361_lo_remote(const std::string &remote_host,
|
||||
uint64_t bandwidth,
|
||||
uint64_t sample_rate,
|
||||
uint64_t freq_rf_tx_hz,
|
||||
double tx_attenuation_db,
|
||||
int64_t freq_dds_tx_hz,
|
||||
double scale_dds_dbfs,
|
||||
double phase_dds_deg);
|
||||
|
||||
bool ad9361_disable_lo_remote(const std::string &remote_host);
|
||||
std::string role_;
|
||||
|
||||
// Front-end settings
|
||||
|
@ -17,7 +17,7 @@
|
||||
#
|
||||
|
||||
|
||||
if(ENABLE_AD9361)
|
||||
if(ENABLE_FMCOMMS2 OR ENABLE_AD9361)
|
||||
set(OPT_SIGNAL_SOURCE_LIB_SOURCES ad9361_manager.cc)
|
||||
set(OPT_SIGNAL_SOURCE_LIB_HEADERS ad9361_manager.h)
|
||||
endif()
|
||||
@ -67,13 +67,9 @@ if(ENABLE_FMCOMMS2 OR ENABLE_AD9361)
|
||||
target_link_libraries(signal_source_libs
|
||||
PUBLIC
|
||||
Iio::iio
|
||||
)
|
||||
if(ENABLE_AD9361)
|
||||
target_link_libraries(signal_source_libs
|
||||
PRIVATE
|
||||
Iio::ad9361
|
||||
PRIVATE
|
||||
Iio::ad9361
|
||||
)
|
||||
endif()
|
||||
if(LIBAD9361_VERSION)
|
||||
if(LIBAD9361_VERSION VERSION_GREATER 0.1)
|
||||
target_compile_definitions(signal_source_libs
|
||||
|
Loading…
Reference in New Issue
Block a user