1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-27 01:14:51 +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 LIBIIO_INCLUDE_DIRS
NAMES gnuradio/iio/api.h NAMES gnuradio/iio/api.h
HINTS $ENV{LIBIIO_DIR}/include HINTS $ENV{LIBIIO_DIR}/include
${PC_LIBIIO_INCLUDEDIR} ${PC_LIBIIO_INCLUDEDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/include PATHS ${CMAKE_INSTALL_PREFIX}/include
/usr/local/include /usr/local/include
/usr/include /usr/include
/opt/local/include
) )
FIND_LIBRARY( FIND_LIBRARY(
LIBIIO_LIBRARIES LIBIIO_LIBRARIES
NAMES libiio.so NAMES libiio.so iio
HINTS $ENV{LIBIIO_DIR}/lib HINTS $ENV{LIBIIO_DIR}/lib
${PC_LIBIIO_LIBDIR} ${PC_LIBIIO_LIBDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/lib PATHS ${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib64
/usr/local/lib /usr/local/lib
@ -23,10 +24,30 @@ FIND_LIBRARY(
/usr/lib /usr/lib
/usr/lib64 /usr/lib64
/usr/lib/x86_64-linux-gnu /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) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS)
MARK_AS_ADVANCED(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); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
//AD9361 Local Oscillator generation for dual band operation //AD9361 Local Oscillator generation for dual band operation
enable_dds_lo_=configuration->property(role + ".enable_dds_lo", false); 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_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); freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
scale_dds_dbfs_=configuration->property(role + ".scale_dds_dbfs", 0.0); scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
phase_dds_deg_=configuration->property(role + ".phase_dds_deg", 0.0); phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_=configuration->property(role + ".tx_attenuation_db", 0.0); tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
item_size_ = sizeof(gr_complex); item_size_ = sizeof(gr_complex);
@ -87,72 +86,73 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
if (item_type_.compare("gr_complex") == 0) if (item_type_.compare("gr_complex") == 0)
{ {
if (RF_channels_==1) if (RF_channels_ == 1)
{
if (rx1_en_ and rx2_en_)
{ {
LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !"; if (rx1_en_ and rx2_en_)
} {
else LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !";
{ }
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( else
uri_.c_str(), freq_, sample_rate_, {
bandwidth_, fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
rx1_en_, rx2_en_, uri_.c_str(), freq_, sample_rate_,
buffer_size_, quadrature_, rf_dc_, bandwidth_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, rx1_en_, rx2_en_,
gain_mode_rx2_.c_str(), rf_gain_rx2_, buffer_size_, quadrature_, rf_dc_,
rf_port_select_.c_str(), filter_file_.c_str(), bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
filter_auto_); gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO //configure LO
if (enable_dds_lo_==true) if (enable_dds_lo_ == true)
{ {
std::cout<<"Enabling Local Oscillator generator in FMCOMMS2\n"; std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_, config_ad9361_lo_remote(uri_,
bandwidth_, bandwidth_,
sample_rate_, sample_rate_,
freq_rf_tx_hz_, freq_rf_tx_hz_,
tx_attenuation_db_, tx_attenuation_db_,
freq_dds_tx_hz_, freq_dds_tx_hz_,
scale_dds_dbfs_); scale_dds_dbfs_);
} }
}
} }
} else if (RF_channels_ == 2)
else if(RF_channels_==2)
{
if (!(rx1_en_ and rx2_en_))
{ {
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( LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !";
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{
LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !";
}
} }
else else
{ {
@ -177,10 +177,10 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
Fmcomms2SignalSource::~Fmcomms2SignalSource() Fmcomms2SignalSource::~Fmcomms2SignalSource()
{ {
if (enable_dds_lo_==true) if (enable_dds_lo_ == true)
{ {
ad9361_disable_lo_remote(uri_); ad9361_disable_lo_remote(uri_);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,8 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#ifndef __AD9361_MANAGER__ #ifndef GNSS_SDR_AD9361_MANAGER_H
#define __AD9361_MANAGER__ #define GNSS_SDR_AD9361_MANAGER_H
#include <string> #include <string>
@ -42,31 +42,36 @@
#endif #endif
/* RX is input, TX is output */ /* RX is input, TX is output */
enum iodev { RX, TX }; enum iodev
{
RX,
TX
};
/* common RX and TX streaming params */ /* common RX and TX streaming params */
struct stream_cfg { struct stream_cfg
long long bw_hz; // Analog banwidth in Hz {
long long fs_hz; // Baseband sample rate in Hz long long bw_hz; // Analog banwidth in Hz
long long lo_hz; // Local oscillator frequency in Hz long long fs_hz; // Baseband sample rate in Hz
const char* rfport; // Port name long long lo_hz; // Local oscillator frequency in Hz
const char *rfport; // Port name
}; };
/* check return value of attr_write function */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* finds AD9361 streaming IIO devices */
bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev); 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 */ /* applies streaming configuration through IIO */
bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid); 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_, bool config_ad9361_rx_local(unsigned long bandwidth_,
unsigned long sample_rate_, unsigned long sample_rate_,
unsigned long freq_, unsigned long freq_,
std::string rf_port_select_, std::string rf_port_select_,
std::string gain_mode_rx1_, std::string gain_mode_rx1_,
std::string gain_mode_rx2_, std::string gain_mode_rx2_,
double rf_gain_rx1_, double rf_gain_rx1_,
double rf_gain_rx2_); double rf_gain_rx2_);
bool config_ad9361_rx_remote(std::string remote_host, bool config_ad9361_rx_remote(std::string remote_host,
unsigned long bandwidth_, unsigned long bandwidth_,
unsigned long sample_rate_, unsigned long sample_rate_,
unsigned long freq_, unsigned long freq_,
std::string rf_port_select_, std::string rf_port_select_,
std::string gain_mode_rx1_, std::string gain_mode_rx1_,
std::string gain_mode_rx2_, std::string gain_mode_rx2_,
double rf_gain_rx1_, double rf_gain_rx1_,
double rf_gain_rx2_); double rf_gain_rx2_);
bool config_ad9361_lo_local(unsigned long bandwidth_, bool config_ad9361_lo_local(unsigned long bandwidth_,
unsigned long sample_rate_, unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_, unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_, double tx_attenuation_db_,
long long freq_dds_tx_hz_, long long freq_dds_tx_hz_,
double scale_dds_dbfs_); double scale_dds_dbfs_);
bool config_ad9361_lo_remote(std::string remote_host, bool config_ad9361_lo_remote(std::string remote_host,
unsigned long bandwidth_, unsigned long bandwidth_,
unsigned long sample_rate_, unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_, unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_, double tx_attenuation_db_,
long long freq_dds_tx_hz_, long long freq_dds_tx_hz_,
double scale_dds_dbfs_); double scale_dds_dbfs_);
bool ad9361_disable_lo_remote(std::string remote_host); bool ad9361_disable_lo_remote(std::string remote_host);
bool ad9361_disable_lo_local(); bool ad9361_disable_lo_local();
#endif #endif