1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-26 00:46:59 +00:00

Apply clang-format, fix libiio detection in MacOS

This commit is contained in:
Carles Fernandez 2018-03-27 21:10:31 +02:00
parent 1d0452463f
commit b31f929655
4 changed files with 559 additions and 471 deletions

View File

@ -5,17 +5,18 @@ FIND_PATH(
LIBIIO_INCLUDE_DIRS
NAMES gnuradio/iio/api.h
HINTS $ENV{LIBIIO_DIR}/include
${PC_LIBIIO_INCLUDEDIR}
${PC_LIBIIO_INCLUDEDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/include
/usr/local/include
/usr/include
/opt/local/include
)
FIND_LIBRARY(
LIBIIO_LIBRARIES
NAMES libiio.so
NAMES libiio.so iio
HINTS $ENV{LIBIIO_DIR}/lib
${PC_LIBIIO_LIBDIR}
${PC_LIBIIO_LIBDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
/usr/local/lib
@ -23,10 +24,30 @@ FIND_LIBRARY(
/usr/lib
/usr/lib64
/usr/lib/x86_64-linux-gnu
/usr/lib/gcc/alpha-linux-gnu
/usr/lib/gcc/aarch64-linux-gnu
/usr/lib/gcc/arm-linux-gnueabi
/usr/lib/gcc/arm-linux-gnueabihf
/usr/lib/gcc/hppa-linux-gnu
/usr/lib/gcc/i686-gnu
/usr/lib/gcc/i686-linux-gnu
/usr/lib/gcc/x86_64-kfreebsd-gnu
/usr/lib/gcc/i686-kfreebsd-gnu
/usr/lib/gcc/m68k-linux-gnu
/usr/lib/gcc/mips-linux-gnu
/usr/lib/gcc/mips64el-linux-gnuabi64
/usr/lib/gcc/mipsel-linux-gnu
/usr/lib/gcc/powerpc-linux-gnu
/usr/lib/gcc/powerpc-linux-gnuspe
/usr/lib/gcc/powerpc64-linux-gnu
/usr/lib/gcc/powerpc64le-linux-gnu
/usr/lib/gcc/s390x-linux-gnu
/usr/lib/gcc/sparc64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnux32
/usr/lib/gcc/sh4-linux-gnu
/Library/Frameworks/iio.framework/
)
message("find libiio:")
message(${LIBIIO_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS)
MARK_AS_ADVANCED(LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS)

View File

@ -71,13 +71,12 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
//AD9361 Local Oscillator generation for dual band operation
enable_dds_lo_=configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_=configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ-GPS_L2_FREQ_HZ-1000);
freq_dds_tx_hz_=configuration->property(role + ".freq_dds_tx_hz", 1000);
scale_dds_dbfs_=configuration->property(role + ".scale_dds_dbfs", 0.0);
phase_dds_deg_=configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_=configuration->property(role + ".tx_attenuation_db", 0.0);
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000);
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
item_size_ = sizeof(gr_complex);
@ -87,72 +86,73 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
if (item_type_.compare("gr_complex") == 0)
{
if (RF_channels_==1)
{
if (rx1_en_ and rx2_en_)
if (RF_channels_ == 1)
{
LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !";
}
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
if (rx1_en_ and rx2_en_)
{
LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !";
}
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
if (enable_dds_lo_==true)
{
std::cout<<"Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
//configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
}
}
}
else if(RF_channels_==2)
{
if (!(rx1_en_ and rx2_en_))
else if (RF_channels_ == 2)
{
LOG(FATAL) << "Configuration error: RF_channels=2 but are not enabled both receivers in FMCOMMS2 !";
if (!(rx1_en_ and rx2_en_))
{
LOG(FATAL) << "Configuration error: RF_channels=2 but are not enabled both receivers in FMCOMMS2 !";
}
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
}
}
else
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
if (enable_dds_lo_==true)
{
std::cout<<"Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !";
}
}else{
LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !";
}
}
else
{
@ -177,10 +177,10 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
Fmcomms2SignalSource::~Fmcomms2SignalSource()
{
if (enable_dds_lo_==true)
{
ad9361_disable_lo_remote(uri_);
}
if (enable_dds_lo_ == true)
{
ad9361_disable_lo_remote(uri_);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,8 @@
* -------------------------------------------------------------------------
*/
#ifndef __AD9361_MANAGER__
#define __AD9361_MANAGER__
#ifndef GNSS_SDR_AD9361_MANAGER_H
#define GNSS_SDR_AD9361_MANAGER_H
#include <string>
@ -42,31 +42,36 @@
#endif
/* RX is input, TX is output */
enum iodev { RX, TX };
enum iodev
{
RX,
TX
};
/* common RX and TX streaming params */
struct stream_cfg {
long long bw_hz; // Analog banwidth in Hz
long long fs_hz; // Baseband sample rate in Hz
long long lo_hz; // Local oscillator frequency in Hz
const char* rfport; // Port name
struct stream_cfg
{
long long bw_hz; // Analog banwidth in Hz
long long fs_hz; // Baseband sample rate in Hz
long long lo_hz; // Local oscillator frequency in Hz
const char *rfport; // Port name
};
/* check return value of attr_write function */
void errchk(int v, const char* what);
void errchk(int v, const char *what);
/* write attribute: long long int */
void wr_ch_lli(struct iio_channel *chn, const char* what, long long val);
void wr_ch_lli(struct iio_channel *chn, const char *what, long long val);
/* write attribute: string */
void wr_ch_str(struct iio_channel *chn, const char* what, const char* str);
void wr_ch_str(struct iio_channel *chn, const char *what, const char *str);
/* helper function generating channel names */
char* get_ch_name(const char* type, int id, char* tmpstr);
char *get_ch_name(const char *type, int id, char *tmpstr);
/* returns ad9361 phy device */
struct iio_device* get_ad9361_phy(struct iio_context *ctx);
struct iio_device *get_ad9361_phy(struct iio_context *ctx);
/* finds AD9361 streaming IIO devices */
bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev);
@ -83,45 +88,43 @@ bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn
/* applies streaming configuration through IIO */
bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid);
bool config_ad9361_rx_local(unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
bool config_ad9361_rx_remote(std::string remote_host,
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
bool config_ad9361_lo_local(unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
bool config_ad9361_lo_remote(std::string remote_host,
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
bool ad9361_disable_lo_remote(std::string remote_host);
bool ad9361_disable_lo_local();
#endif