mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-07 14:40:12 +00:00
Apply clang-tidy fixes
This commit is contained in:
parent
4dee92ddf5
commit
c4e84ffcfc
@ -76,7 +76,10 @@ Ad936xCustomSignalSource::Ad936xCustomSignalSource(const ConfigurationInterface*
|
|||||||
item_size_ = sizeof(gr_complex);
|
item_size_ = sizeof(gr_complex);
|
||||||
// 1. Make the driver instance
|
// 1. Make the driver instance
|
||||||
bool customsamplesize = false;
|
bool customsamplesize = false;
|
||||||
if (ssize_ != 12 or spattern_ == true) customsamplesize = true; // custom FPGA DMA firmware
|
if (ssize_ != 12 || spattern_ == true)
|
||||||
|
{
|
||||||
|
customsamplesize = true; // custom FPGA DMA firmware
|
||||||
|
}
|
||||||
if (ssize_ == 12) // default original FPGA DMA firmware
|
if (ssize_ == 12) // default original FPGA DMA firmware
|
||||||
{
|
{
|
||||||
ssize_ = 16; // set to 16 bits and do not try to change sample size
|
ssize_ = 16; // set to 16 bits and do not try to change sample size
|
||||||
@ -153,8 +156,14 @@ Ad936xCustomSignalSource::Ad936xCustomSignalSource(const ConfigurationInterface*
|
|||||||
|
|
||||||
for (int n = 0; n < n_channels; n++)
|
for (int n = 0; n < n_channels; n++)
|
||||||
{
|
{
|
||||||
if (n == 0) inverted_spectrum_vec.push_back(inverted_spectrum_ch0_);
|
if (n == 0)
|
||||||
if (n == 1) inverted_spectrum_vec.push_back(inverted_spectrum_ch1_);
|
{
|
||||||
|
inverted_spectrum_vec.push_back(inverted_spectrum_ch0_);
|
||||||
|
}
|
||||||
|
if (n == 1)
|
||||||
|
{
|
||||||
|
inverted_spectrum_vec.push_back(inverted_spectrum_ch1_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int n = 0; n < n_channels; n++)
|
for (int n = 0; n < n_channels; n++)
|
||||||
|
@ -33,15 +33,15 @@
|
|||||||
|
|
||||||
|
|
||||||
ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
||||||
std::string pluto_uri_,
|
const std::string& pluto_uri_,
|
||||||
std::string board_type_,
|
const std::string& board_type_,
|
||||||
long long bandwidth_,
|
long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string& rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string& rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string& gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string& gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -49,7 +49,7 @@ ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
|||||||
long long freq_2ch,
|
long long freq_2ch,
|
||||||
bool ppsmode_,
|
bool ppsmode_,
|
||||||
bool customsamplesize_,
|
bool customsamplesize_,
|
||||||
std::string fe_ip_,
|
const std::string& fe_ip_,
|
||||||
int fe_ctlport_,
|
int fe_ctlport_,
|
||||||
int ssize_,
|
int ssize_,
|
||||||
int bshift_,
|
int bshift_,
|
||||||
@ -85,6 +85,7 @@ ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
|||||||
tx_lo_channel_));
|
tx_lo_channel_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ad936x_iio_source::ad9361_channel_demux_and_record(ad936x_iio_samples* samples_in, int nchannels, std::vector<std::fstream>* files_out)
|
void ad936x_iio_source::ad9361_channel_demux_and_record(ad936x_iio_samples* samples_in, int nchannels, std::vector<std::fstream>* files_out)
|
||||||
{
|
{
|
||||||
uint32_t current_byte = 0;
|
uint32_t current_byte = 0;
|
||||||
@ -101,16 +102,17 @@ void ad936x_iio_source::ad9361_channel_demux_and_record(ad936x_iio_samples *samp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ad936x_iio_source::ad936x_iio_source(
|
ad936x_iio_source::ad936x_iio_source(
|
||||||
std::string pluto_uri_,
|
const std::string& pluto_uri_,
|
||||||
std::string board_type_,
|
const std::string& board_type_,
|
||||||
long long bandwidth_,
|
long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string& rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string& rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string& gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string& gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -118,7 +120,7 @@ ad936x_iio_source::ad936x_iio_source(
|
|||||||
long long freq_2ch,
|
long long freq_2ch,
|
||||||
bool ppsmode_,
|
bool ppsmode_,
|
||||||
bool customsamplesize_,
|
bool customsamplesize_,
|
||||||
std::string fe_ip_,
|
const std::string& fe_ip_,
|
||||||
int fe_ctlport_,
|
int fe_ctlport_,
|
||||||
int ssize_,
|
int ssize_,
|
||||||
int bshift_,
|
int bshift_,
|
||||||
@ -171,54 +173,81 @@ ad936x_iio_source::ad936x_iio_source(
|
|||||||
case 16:
|
case 16:
|
||||||
{
|
{
|
||||||
std::cout << "FPGA sample size set to 16 bits per sample.\n";
|
std::cout << "FPGA sample size set to 16 bits per sample.\n";
|
||||||
if (pps_rx->send_cmd("ssize=16\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("ssize=16\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
std::cout << "FPGA sample size set to 8 bits per sample.\n";
|
std::cout << "FPGA sample size set to 8 bits per sample.\n";
|
||||||
if (pps_rx->send_cmd("ssize=8\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("ssize=8\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
std::cout << "FPGA sample size set to 4 bits per sample.\n";
|
std::cout << "FPGA sample size set to 4 bits per sample.\n";
|
||||||
if (pps_rx->send_cmd("ssize=4\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("ssize=4\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
std::cout << "FPGA sample size set to 2 bits per sample.\n";
|
std::cout << "FPGA sample size set to 2 bits per sample.\n";
|
||||||
if (pps_rx->send_cmd("ssize=2\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("ssize=2\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
std::cout << "WARNING: Unsupported ssize. FPGA sample size set to 16 bits per sample.\n";
|
std::cout << "WARNING: Unsupported ssize. FPGA sample size set to 16 bits per sample.\n";
|
||||||
if (pps_rx->send_cmd("ssize=16") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("ssize=16") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bshift_ >= 0 and bshift_ <= 14)
|
if (bshift_ >= 0 and bshift_ <= 14)
|
||||||
{
|
{
|
||||||
std::cout << "FPGA sample bits shift left set to " + std::to_string(bshift_) + " positions.\n";
|
std::cout << "FPGA sample bits shift left set to " + std::to_string(bshift_) + " positions.\n";
|
||||||
if (pps_rx->send_cmd("bshift=" + std::to_string(bshift_) + "\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("bshift=" + std::to_string(bshift_) + "\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "WARNING: Unsupported bshift. FPGA sample bits shift left set to 0.\n";
|
std::cout << "WARNING: Unsupported bshift. FPGA sample bits shift left set to 0.\n";
|
||||||
if (pps_rx->send_cmd("bshift=0\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("bshift=0\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spattern_ == true)
|
if (spattern_ == true)
|
||||||
{
|
{
|
||||||
std::cout << "FPGA debug sample pattern is active!.\n";
|
std::cout << "FPGA debug sample pattern is active!.\n";
|
||||||
if (pps_rx->send_cmd("spattern=1\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("spattern=1\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "FPGA debug sample pattern disabled.\n";
|
std::cout << "FPGA debug sample pattern disabled.\n";
|
||||||
if (pps_rx->send_cmd("spattern=0\n") == false) std::cout << "cmd send error!\n";
|
if (pps_rx->send_cmd("spattern=0\n") == false)
|
||||||
|
{
|
||||||
|
std::cout << "cmd send error!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -267,6 +296,7 @@ ad936x_iio_source::ad936x_iio_source(
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ad936x_iio_source::~ad936x_iio_source()
|
ad936x_iio_source::~ad936x_iio_source()
|
||||||
{
|
{
|
||||||
// Terminate PPS thread
|
// Terminate PPS thread
|
||||||
@ -284,6 +314,7 @@ bool ad936x_iio_source::start()
|
|||||||
return ad936x_custom->start_sample_rx(false);
|
return ad936x_custom->start_sample_rx(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ad936x_iio_source::stop()
|
bool ad936x_iio_source::stop()
|
||||||
{
|
{
|
||||||
std::cout << "stopping ad936x_iio_source...\n";
|
std::cout << "stopping ad936x_iio_source...\n";
|
||||||
@ -291,6 +322,7 @@ bool ad936x_iio_source::stop()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ad936x_iio_source::general_work(int noutput_items,
|
int ad936x_iio_source::general_work(int noutput_items,
|
||||||
__attribute__((unused)) gr_vector_int& ninput_items,
|
__attribute__((unused)) gr_vector_int& ninput_items,
|
||||||
__attribute__((unused)) gr_vector_const_void_star& input_items,
|
__attribute__((unused)) gr_vector_const_void_star& input_items,
|
||||||
@ -301,7 +333,6 @@ int ad936x_iio_source::general_work(int noutput_items,
|
|||||||
ad936x_custom->pop_sample_buffer(current_buffer);
|
ad936x_custom->pop_sample_buffer(current_buffer);
|
||||||
current_samples = current_buffer.get();
|
current_samples = current_buffer.get();
|
||||||
|
|
||||||
|
|
||||||
// I and Q samples are interleaved in buffer: IQIQIQ...
|
// I and Q samples are interleaved in buffer: IQIQIQ...
|
||||||
int32_t n_interleaved_iq_samples_per_channel = current_samples->n_bytes / (ad936x_custom->n_channels * 2);
|
int32_t n_interleaved_iq_samples_per_channel = current_samples->n_bytes / (ad936x_custom->n_channels * 2);
|
||||||
if (noutput_items < n_interleaved_iq_samples_per_channel)
|
if (noutput_items < n_interleaved_iq_samples_per_channel)
|
||||||
|
@ -44,15 +44,15 @@ class ad936x_iio_source;
|
|||||||
using ad936x_iio_source_sptr = gnss_shared_ptr<ad936x_iio_source>;
|
using ad936x_iio_source_sptr = gnss_shared_ptr<ad936x_iio_source>;
|
||||||
|
|
||||||
ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
||||||
std::string pluto_uri_,
|
const std::string &pluto_uri_,
|
||||||
std::string board_type_,
|
const std::string &board_type_,
|
||||||
long long bandwidth_,
|
long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string &rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string &rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string &gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string &gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -60,7 +60,7 @@ ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
|||||||
long long freq_2ch,
|
long long freq_2ch,
|
||||||
bool ppsmode_,
|
bool ppsmode_,
|
||||||
bool customsamplesize_,
|
bool customsamplesize_,
|
||||||
std::string fe_ip_,
|
const std::string &fe_ip_,
|
||||||
int fe_ctlport_,
|
int fe_ctlport_,
|
||||||
int ssize_,
|
int ssize_,
|
||||||
int bshift_,
|
int bshift_,
|
||||||
@ -90,15 +90,15 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
friend ad936x_iio_source_sptr ad936x_iio_make_source_sptr(
|
||||||
std::string pluto_uri_,
|
const std::string &pluto_uri_,
|
||||||
std::string board_type_,
|
const std::string &board_type_,
|
||||||
long long bandwidth_,
|
long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string &rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string &rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string &gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string &gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -106,7 +106,7 @@ private:
|
|||||||
long long freq_2ch,
|
long long freq_2ch,
|
||||||
bool ppsmode_,
|
bool ppsmode_,
|
||||||
bool customsamplesize_,
|
bool customsamplesize_,
|
||||||
std::string fe_ip_,
|
const std::string &fe_ip_,
|
||||||
int fe_ctlport_,
|
int fe_ctlport_,
|
||||||
int ssize_,
|
int ssize_,
|
||||||
int bshift_,
|
int bshift_,
|
||||||
@ -116,15 +116,15 @@ private:
|
|||||||
int tx_lo_channel_);
|
int tx_lo_channel_);
|
||||||
|
|
||||||
ad936x_iio_source(
|
ad936x_iio_source(
|
||||||
std::string pluto_uri_,
|
const std::string &pluto_uri_,
|
||||||
std::string board_type_,
|
const std::string &board_type_,
|
||||||
long long bandwidth_,
|
long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string &rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string &rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string &gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string &gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -132,7 +132,7 @@ private:
|
|||||||
long long freq_2ch,
|
long long freq_2ch,
|
||||||
bool ppsmode_,
|
bool ppsmode_,
|
||||||
bool customsamplesize_,
|
bool customsamplesize_,
|
||||||
std::string fe_ip_,
|
const std::string &fe_ip_,
|
||||||
int fe_ctlport_,
|
int fe_ctlport_,
|
||||||
int ssize_,
|
int ssize_,
|
||||||
int bshift_,
|
int bshift_,
|
||||||
|
@ -36,7 +36,6 @@ if((ENABLE_FPGA AND ENABLE_AD9361) OR ENABLE_MAX2771)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_PLUTOSDR)
|
if(ENABLE_PLUTOSDR)
|
||||||
set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} ad936x_iio_samples.cc)
|
|
||||||
set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} ad936x_iio_samples.h)
|
set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} ad936x_iio_samples.h)
|
||||||
set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} ad936x_iio_custom.cc)
|
set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} ad936x_iio_custom.cc)
|
||||||
set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} ad936x_iio_custom.h)
|
set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} ad936x_iio_custom.h)
|
||||||
|
@ -636,7 +636,7 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (setup_filter(std::move(filter_source_), bandwidth_, sample_rate_, freq_, rf_port_select_, ad9361_phy, rx_chan0, chn, 0, std::move(filter_filename_), Fpass_, Fstop_) == -1)
|
if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq_, rf_port_select_, ad9361_phy, rx_chan0, chn, 0, std::move(filter_filename_), Fpass_, Fstop_) == -1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -31,29 +31,36 @@
|
|||||||
#include <absl/log/log.h>
|
#include <absl/log/log.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ad936x_iio_custom::ad936x_iio_custom(int debug_level_, int log_level_)
|
ad936x_iio_custom::ad936x_iio_custom(
|
||||||
|
int debug_level_,
|
||||||
|
int log_level_) : n_channels(0),
|
||||||
|
ctx(nullptr),
|
||||||
|
phy(nullptr),
|
||||||
|
stream_dev(nullptr),
|
||||||
|
dds_dev(nullptr),
|
||||||
|
receive_samples(false),
|
||||||
|
fpga_overflow(false),
|
||||||
|
sample_rate_sps(0),
|
||||||
|
debug_level(debug_level_),
|
||||||
|
log_level(log_level_),
|
||||||
|
PPS_mode(false)
|
||||||
{
|
{
|
||||||
receive_samples = false;
|
|
||||||
fpga_overflow = false;
|
|
||||||
sample_rate_sps = 0;
|
|
||||||
ctx = NULL;
|
|
||||||
phy = NULL;
|
|
||||||
dds_dev = NULL;
|
|
||||||
stream_dev = NULL;
|
|
||||||
debug_level = debug_level_;
|
|
||||||
log_level = log_level_;
|
|
||||||
PPS_mode = false;
|
|
||||||
n_channels = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ad936x_iio_custom::~ad936x_iio_custom()
|
ad936x_iio_custom::~ad936x_iio_custom()
|
||||||
{
|
{
|
||||||
// disable TX
|
// disable TX
|
||||||
if (phy != NULL) PlutoTxEnable(false);
|
if (phy != nullptr)
|
||||||
|
{
|
||||||
|
PlutoTxEnable(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Close device
|
// Close device
|
||||||
if (ctx != NULL) iio_context_destroy(ctx);
|
if (ctx != nullptr)
|
||||||
|
{
|
||||||
|
iio_context_destroy(ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +76,7 @@ void ad936x_iio_custom::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Que
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::string board_type)
|
bool ad936x_iio_custom::initialize_device(const std::string &pluto_device_uri, const std::string &board_type)
|
||||||
{
|
{
|
||||||
// Find devices
|
// Find devices
|
||||||
if (pluto_device_uri == "local")
|
if (pluto_device_uri == "local")
|
||||||
@ -124,7 +131,7 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
|
|||||||
ctx = iio_create_context_from_uri(pluto_device_uri.c_str());
|
ctx = iio_create_context_from_uri(pluto_device_uri.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Unable to create context from uri: " << pluto_device_uri << std::endl;
|
std::cout << "Unable to create context from uri: " << pluto_device_uri << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -132,16 +139,16 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
|
|||||||
|
|
||||||
phy = iio_context_find_device(ctx, "ad9361-phy");
|
phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||||
|
|
||||||
if (phy == NULL)
|
if (phy == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Unable to find ad9361-phy device from uri: " << pluto_device_uri << std::endl;
|
std::cout << "Unable to find ad9361-phy device from uri: " << pluto_device_uri << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (board_type.compare("fmcomms5") == 0)
|
if (board_type == "fmcomms5")
|
||||||
{
|
{
|
||||||
stream_dev = iio_context_find_device(ctx, "cf-ad9361-A"); // first ad9361 in FMCOMMS5
|
stream_dev = iio_context_find_device(ctx, "cf-ad9361-A"); // first ad9361 in FMCOMMS5
|
||||||
if (stream_dev == NULL)
|
if (stream_dev == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Unable to find cf-ad9361-A device from uri: " << pluto_device_uri << std::endl;
|
std::cout << "Unable to find cf-ad9361-A device from uri: " << pluto_device_uri << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -150,13 +157,13 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream_dev = iio_context_find_device(ctx, "cf-ad9361-lpc"); // regular AD9361 stream device in single AD9361 boards
|
stream_dev = iio_context_find_device(ctx, "cf-ad9361-lpc"); // regular AD9361 stream device in single AD9361 boards
|
||||||
if (stream_dev == NULL)
|
if (stream_dev == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Unable to find cf-ad9361-lpc device from uri: " << pluto_device_uri << std::endl;
|
std::cout << "Unable to find cf-ad9361-lpc device from uri: " << pluto_device_uri << std::endl;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
dds_dev = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); // DDS core for LO oscillator (external transverter operation)
|
dds_dev = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); // DDS core for LO oscillator (external transverter operation)
|
||||||
if (stream_dev == NULL)
|
if (stream_dev == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Warning: Unable to find cf-ad9361-dds-core-lpc device from uri: " << pluto_device_uri << std::endl;
|
std::cout << "Warning: Unable to find cf-ad9361-dds-core-lpc device from uri: " << pluto_device_uri << std::endl;
|
||||||
};
|
};
|
||||||
@ -169,23 +176,22 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
|
|||||||
void ad936x_iio_custom::configure_params(struct iio_device *phy,
|
void ad936x_iio_custom::configure_params(struct iio_device *phy,
|
||||||
const std::vector<std::string> ¶ms)
|
const std::vector<std::string> ¶ms)
|
||||||
{
|
{
|
||||||
for (std::vector<std::string>::const_iterator it = params.begin();
|
for (const auto ¶m : params)
|
||||||
it != params.end(); ++it)
|
|
||||||
{
|
{
|
||||||
struct iio_channel *chn = NULL;
|
struct iio_channel *chn = nullptr;
|
||||||
const char *attr = NULL;
|
const char *attr = nullptr;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pos = it->find('=');
|
pos = param.find('=');
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
{
|
{
|
||||||
std::cerr << "Malformed line: " << *it << std::endl;
|
std::cerr << "Malformed line: " << param << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string key = it->substr(0, pos);
|
std::string key = param.substr(0, pos);
|
||||||
std::string val = it->substr(pos + 1, std::string::npos);
|
std::string val = param.substr(pos + 1, std::string::npos);
|
||||||
|
|
||||||
ret = iio_device_identify_filename(phy,
|
ret = iio_device_identify_filename(phy,
|
||||||
key.c_str(), &chn, &attr);
|
key.c_str(), &chn, &attr);
|
||||||
@ -197,13 +203,19 @@ void ad936x_iio_custom::configure_params(struct iio_device *phy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chn)
|
if (chn)
|
||||||
|
{
|
||||||
ret = iio_channel_attr_write(chn,
|
ret = iio_channel_attr_write(chn,
|
||||||
attr, val.c_str());
|
attr, val.c_str());
|
||||||
|
}
|
||||||
else if (iio_device_find_attr(phy, attr))
|
else if (iio_device_find_attr(phy, attr))
|
||||||
|
{
|
||||||
ret = iio_device_attr_write(phy, attr, val.c_str());
|
ret = iio_device_attr_write(phy, attr, val.c_str());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ret = iio_device_debug_attr_write(phy,
|
ret = iio_device_debug_attr_write(phy,
|
||||||
attr, val.c_str());
|
attr, val.c_str());
|
||||||
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Unable to write attribute " << key
|
std::cerr << "Unable to write attribute " << key
|
||||||
@ -217,9 +229,9 @@ void ad936x_iio_custom::set_params_rx(struct iio_device *phy_device,
|
|||||||
unsigned long long frequency,
|
unsigned long long frequency,
|
||||||
unsigned long samplerate, unsigned long bandwidth,
|
unsigned long samplerate, unsigned long bandwidth,
|
||||||
bool quadrature, bool rfdc, bool bbdc,
|
bool quadrature, bool rfdc, bool bbdc,
|
||||||
std::string gain1, double gain1_value,
|
const std::string &gain1, double gain1_value,
|
||||||
std::string gain2, double gain2_value,
|
const std::string &gain2, double gain2_value,
|
||||||
std::string port_select)
|
const std::string &port_select)
|
||||||
{
|
{
|
||||||
std::vector<std::string> params;
|
std::vector<std::string> params;
|
||||||
|
|
||||||
@ -290,7 +302,7 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
|||||||
std::to_string(phase_dds_deg_ * 1000.0));
|
std::to_string(phase_dds_deg_ * 1000.0));
|
||||||
params_dds.push_back("out_altvoltage0_TX1_I_F1_scale=" +
|
params_dds.push_back("out_altvoltage0_TX1_I_F1_scale=" +
|
||||||
std::to_string(scale_dds_));
|
std::to_string(scale_dds_));
|
||||||
params_dds.push_back("out_altvoltage0_TX1_I_F1_raw=1");
|
params_dds.emplace_back("out_altvoltage0_TX1_I_F1_raw=1");
|
||||||
// DDS TX CH1 Q (tone #1)
|
// DDS TX CH1 Q (tone #1)
|
||||||
params_dds.push_back("out_altvoltage2_TX1_Q_F1_frequency=" +
|
params_dds.push_back("out_altvoltage2_TX1_Q_F1_frequency=" +
|
||||||
std::to_string(freq_dds_tx_hz_));
|
std::to_string(freq_dds_tx_hz_));
|
||||||
@ -298,7 +310,7 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
|||||||
std::to_string(phase_dds_deg_ * 1000.0 + 270000.0));
|
std::to_string(phase_dds_deg_ * 1000.0 + 270000.0));
|
||||||
params_dds.push_back("out_altvoltage2_TX1_Q_F1_scale=" +
|
params_dds.push_back("out_altvoltage2_TX1_Q_F1_scale=" +
|
||||||
std::to_string(scale_dds_));
|
std::to_string(scale_dds_));
|
||||||
params_dds.push_back("out_altvoltage2_TX1_Q_F1_raw=1");
|
params_dds.emplace_back("out_altvoltage2_TX1_Q_F1_raw=1");
|
||||||
|
|
||||||
configure_params(dds_dev, params_dds);
|
configure_params(dds_dev, params_dds);
|
||||||
}
|
}
|
||||||
@ -319,7 +331,7 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
|||||||
std::to_string(phase_dds_deg_ * 1000.0));
|
std::to_string(phase_dds_deg_ * 1000.0));
|
||||||
params_dds.push_back("out_altvoltage4_TX2_I_F1_scale=" +
|
params_dds.push_back("out_altvoltage4_TX2_I_F1_scale=" +
|
||||||
std::to_string(scale_dds_));
|
std::to_string(scale_dds_));
|
||||||
params_dds.push_back("out_altvoltage4_TX2_I_F1_raw=1");
|
params_dds.emplace_back("out_altvoltage4_TX2_I_F1_raw=1");
|
||||||
// DDS TX CH2 Q (tone #1)
|
// DDS TX CH2 Q (tone #1)
|
||||||
params_dds.push_back("out_altvoltage6_TX2_Q_F1_frequency=" +
|
params_dds.push_back("out_altvoltage6_TX2_Q_F1_frequency=" +
|
||||||
std::to_string(freq_dds_tx_hz_));
|
std::to_string(freq_dds_tx_hz_));
|
||||||
@ -327,7 +339,7 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
|||||||
std::to_string(phase_dds_deg_ * 1000.0 + 270000.0));
|
std::to_string(phase_dds_deg_ * 1000.0 + 270000.0));
|
||||||
params_dds.push_back("out_altvoltage6_TX2_Q_F1_scale=" +
|
params_dds.push_back("out_altvoltage6_TX2_Q_F1_scale=" +
|
||||||
std::to_string(scale_dds_));
|
std::to_string(scale_dds_));
|
||||||
params_dds.push_back("out_altvoltage6_TX2_Q_F1_raw=1");
|
params_dds.emplace_back("out_altvoltage6_TX2_Q_F1_raw=1");
|
||||||
|
|
||||||
configure_params(dds_dev, params_dds);
|
configure_params(dds_dev, params_dds);
|
||||||
}
|
}
|
||||||
@ -338,7 +350,7 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
|||||||
|
|
||||||
bool ad936x_iio_custom::check_device()
|
bool ad936x_iio_custom::check_device()
|
||||||
{
|
{
|
||||||
if (stream_dev != NULL)
|
if (stream_dev != nullptr)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -351,8 +363,8 @@ bool ad936x_iio_custom::check_device()
|
|||||||
|
|
||||||
bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string ¶m, std::string &value)
|
bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string ¶m, std::string &value)
|
||||||
{
|
{
|
||||||
struct iio_channel *chn = 0;
|
struct iio_channel *chn = nullptr;
|
||||||
const char *attr = 0;
|
const char *attr = nullptr;
|
||||||
char valuestr[256];
|
char valuestr[256];
|
||||||
int ret;
|
int ret;
|
||||||
ssize_t nchars;
|
ssize_t nchars;
|
||||||
@ -399,9 +411,12 @@ bool ad936x_iio_custom::read_die_temp(double &temp_c)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint32_t temp_mC = boost::lexical_cast<uint32_t>(temp_mC_str);
|
auto temp_mC = boost::lexical_cast<uint32_t>(temp_mC_str);
|
||||||
temp_c = static_cast<double>(temp_mC) / 1000.0;
|
temp_c = static_cast<double>(temp_mC) / 1000.0;
|
||||||
if (temp_c > 120) temp_c = -1;
|
if (temp_c > 120)
|
||||||
|
{
|
||||||
|
temp_c = -1;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (const boost::bad_lexical_cast &e)
|
catch (const boost::bad_lexical_cast &e)
|
||||||
@ -420,10 +435,10 @@ bool ad936x_iio_custom::read_die_temp(double &temp_c)
|
|||||||
bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
|
bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string &rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string &rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string &gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string &gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -433,16 +448,19 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
|
|||||||
bool high_side_lo_,
|
bool high_side_lo_,
|
||||||
int tx_lo_channel_)
|
int tx_lo_channel_)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool no_errors = true;
|
bool no_errors = true;
|
||||||
std::cout << "Configuring phy device parameters...\n";
|
std::cout << "Configuring phy device parameters...\n";
|
||||||
int ret;
|
int ret;
|
||||||
if (rf_filter.compare("Disabled") == 0)
|
if (rf_filter == "Disabled")
|
||||||
{
|
{
|
||||||
std::cout << "LNA Filter switch is disabled.\n";
|
std::cout << "LNA Filter switch is disabled.\n";
|
||||||
}
|
}
|
||||||
else if (rf_filter.compare("Auto") == 0)
|
else if (rf_filter == "Auto")
|
||||||
{
|
{
|
||||||
std::cout << "Selecting LNA RF filter based on the selected RF frequency... \n";
|
std::cout << "Selecting LNA RF filter based on the selected RF frequency... \n";
|
||||||
if (freq_ == 1575420000)
|
if (freq_ == 1575420000)
|
||||||
@ -499,9 +517,9 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
|
|||||||
params.push_back("out_voltage_rf_bandwidth=" +
|
params.push_back("out_voltage_rf_bandwidth=" +
|
||||||
std::to_string(bandwidth_));
|
std::to_string(bandwidth_));
|
||||||
|
|
||||||
params.push_back("in_voltage_quadrature_tracking_en=1");
|
params.emplace_back("in_voltage_quadrature_tracking_en=1");
|
||||||
params.push_back("in_voltage_rf_dc_offset_tracking_en=1");
|
params.emplace_back("in_voltage_rf_dc_offset_tracking_en=1");
|
||||||
params.push_back("in_voltage_bb_dc_offset_tracking_en=1");
|
params.emplace_back("in_voltage_bb_dc_offset_tracking_en=1");
|
||||||
|
|
||||||
configure_params(phy, params);
|
configure_params(phy, params);
|
||||||
|
|
||||||
@ -706,7 +724,10 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
|
|||||||
|
|
||||||
bool ad936x_iio_custom::set_rx_frequency(long long freq_hz)
|
bool ad936x_iio_custom::set_rx_frequency(long long freq_hz)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Configure RX LO channel (NOTICE that altvoltage0 is the RX LO oscillator!, altvoltage1 is the TX oscillator)
|
// Configure RX LO channel (NOTICE that altvoltage0 is the RX LO oscillator!, altvoltage1 is the TX oscillator)
|
||||||
struct iio_channel *lo_ch;
|
struct iio_channel *lo_ch;
|
||||||
|
|
||||||
@ -729,7 +750,10 @@ bool ad936x_iio_custom::set_rx_frequency(long long freq_hz)
|
|||||||
|
|
||||||
bool ad936x_iio_custom::get_rx_frequency(long long &freq_hz)
|
bool ad936x_iio_custom::get_rx_frequency(long long &freq_hz)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Configure RX LO channel (NOTICE that altvoltage0 is the RX LO oscillator!, altvoltage1 is the TX oscillator)
|
// Configure RX LO channel (NOTICE that altvoltage0 is the RX LO oscillator!, altvoltage1 is the TX oscillator)
|
||||||
struct iio_channel *lo_ch;
|
struct iio_channel *lo_ch;
|
||||||
|
|
||||||
@ -750,9 +774,12 @@ bool ad936x_iio_custom::get_rx_frequency(long long &freq_hz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain_dB)
|
bool ad936x_iio_custom::setRXGain(int ch_num, const std::string &gain_mode, double gain_dB)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::vector<std::string> params;
|
std::vector<std::string> params;
|
||||||
if (ch_num == 0)
|
if (ch_num == 0)
|
||||||
{
|
{
|
||||||
@ -785,7 +812,10 @@ bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain
|
|||||||
|
|
||||||
double ad936x_iio_custom::get_rx_gain(int ch_num)
|
double ad936x_iio_custom::get_rx_gain(int ch_num)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return -1;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
double gain_dB; // gain in dB
|
double gain_dB; // gain in dB
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (ch_num == 0)
|
if (ch_num == 0)
|
||||||
@ -816,7 +846,10 @@ double ad936x_iio_custom::get_rx_gain(int ch_num)
|
|||||||
|
|
||||||
bool ad936x_iio_custom::calibrate([[maybe_unused]] int ch, [[maybe_unused]] double bw_hz)
|
bool ad936x_iio_custom::calibrate([[maybe_unused]] int ch, [[maybe_unused]] double bw_hz)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// todo
|
// todo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -865,12 +898,13 @@ void ad936x_iio_custom::monitor_thread_fn()
|
|||||||
{
|
{
|
||||||
ret = iio_device_reg_write(stream_dev, 0x80000088, val);
|
ret = iio_device_reg_write(stream_dev, 0x80000088, val);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
{
|
||||||
fprintf(stderr, "Failed to clearn DMA status register: %s\n",
|
fprintf(stderr, "Failed to clearn DMA status register: %s\n",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -941,7 +975,7 @@ void ad936x_iio_custom::setPlutoGpo(int p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
|
bool ad936x_iio_custom::select_rf_filter(const std::string &rf_filter)
|
||||||
{
|
{
|
||||||
// adi,gpo-manual-mode-enable Enables GPO manual mode, this will conflict with automatic ENSM slave and eLNA mode
|
// adi,gpo-manual-mode-enable Enables GPO manual mode, this will conflict with automatic ENSM slave and eLNA mode
|
||||||
// adi,gpo-manual-mode-enable-mask Enable bit mask, setting or clearing bits will change the level of the corresponding output. Bit0 → GPO, Bit1 → GPO1, Bit2 → GPO2, Bit3 → GP03
|
// adi,gpo-manual-mode-enable-mask Enable bit mask, setting or clearing bits will change the level of the corresponding output. Bit0 → GPO, Bit1 → GPO1, Bit2 → GPO2, Bit3 → GP03
|
||||||
@ -961,7 +995,10 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
|
|||||||
// 1 Enable
|
// 1 Enable
|
||||||
// X Enable Mask if Identifier=0xF
|
// X Enable Mask if Identifier=0xF
|
||||||
|
|
||||||
if (check_device() == false) return false;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// int plutoGpo = 0;
|
// int plutoGpo = 0;
|
||||||
int ret;
|
int ret;
|
||||||
ret = iio_device_debug_attr_write(phy, "adi,gpo-manual-mode-enable", "1");
|
ret = iio_device_debug_attr_write(phy, "adi,gpo-manual-mode-enable", "1");
|
||||||
@ -972,7 +1009,7 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rf_filter.compare("E1") == 0)
|
if (rf_filter == "E1")
|
||||||
{
|
{
|
||||||
// set gpio0 to switch L1 filter
|
// set gpio0 to switch L1 filter
|
||||||
// setPlutoGpo(plutoGpo);
|
// setPlutoGpo(plutoGpo);
|
||||||
@ -983,7 +1020,7 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rf_filter.compare("E5E6") == 0)
|
else if (rf_filter == "E5E6")
|
||||||
{
|
{
|
||||||
// set gpio0 to switch L5/L6 filter (GPO0)
|
// set gpio0 to switch L5/L6 filter (GPO0)
|
||||||
// plutoGpo = plutoGpo | 0x10;
|
// plutoGpo = plutoGpo | 0x10;
|
||||||
@ -995,7 +1032,7 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rf_filter.compare("none") == 0)
|
if (rf_filter == "none")
|
||||||
{
|
{
|
||||||
std::cout << "RF external filter not selected\n";
|
std::cout << "RF external filter not selected\n";
|
||||||
}
|
}
|
||||||
@ -1108,18 +1145,18 @@ bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
|
|||||||
switch (n_channels)
|
switch (n_channels)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
channels.push_back("voltage0"); // Channel 0 I
|
channels.emplace_back("voltage0"); // Channel 0 I
|
||||||
channels.push_back("voltage1"); // Channel 0 Q
|
channels.emplace_back("voltage1"); // Channel 0 Q
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
channels.push_back("voltage0"); // Channel 0 I
|
channels.emplace_back("voltage0"); // Channel 0 I
|
||||||
channels.push_back("voltage1"); // Channel 0 Q
|
channels.emplace_back("voltage1"); // Channel 0 Q
|
||||||
channels.push_back("voltage2"); // Channel 1 I
|
channels.emplace_back("voltage2"); // Channel 1 I
|
||||||
channels.push_back("voltage3"); // Channel 1 Q
|
channels.emplace_back("voltage3"); // Channel 1 Q
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
channels.push_back("voltage0"); // Channel 0 I
|
channels.emplace_back("voltage0"); // Channel 0 I
|
||||||
channels.push_back("voltage1"); // Channel 0 Q
|
channels.emplace_back("voltage1"); // Channel 0 Q
|
||||||
}
|
}
|
||||||
|
|
||||||
receive_samples = true;
|
receive_samples = true;
|
||||||
@ -1151,7 +1188,10 @@ void ad936x_iio_custom::push_sample_buffer(std::shared_ptr<ad936x_iio_samples> &
|
|||||||
|
|
||||||
void ad936x_iio_custom::capture(const std::vector<std::string> &channels)
|
void ad936x_iio_custom::capture(const std::vector<std::string> &channels)
|
||||||
{
|
{
|
||||||
if (check_device() == false) return;
|
if (check_device() == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct iio_buffer *rxbuf;
|
struct iio_buffer *rxbuf;
|
||||||
|
|
||||||
@ -1179,16 +1219,14 @@ void ad936x_iio_custom::capture(const std::vector<std::string> &channels)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (std::vector<std::string>::const_iterator it =
|
for (const auto &channel : channels)
|
||||||
channels.begin();
|
|
||||||
it != channels.end(); ++it)
|
|
||||||
{
|
{
|
||||||
struct iio_channel *chn =
|
struct iio_channel *chn =
|
||||||
iio_device_find_channel(stream_dev,
|
iio_device_find_channel(stream_dev,
|
||||||
it->c_str(), false);
|
channel.c_str(), false);
|
||||||
if (!chn)
|
if (!chn)
|
||||||
{
|
{
|
||||||
std::cerr << "Channel " << it->c_str() << " not found\n";
|
std::cerr << "Channel " << channel.c_str() << " not found\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1247,7 +1285,10 @@ void ad936x_iio_custom::capture(const std::vector<std::string> &channels)
|
|||||||
|
|
||||||
items_in_buffer = static_cast<unsigned long>(ret) / bytes_to_interleaved_iq_samples;
|
items_in_buffer = static_cast<unsigned long>(ret) / bytes_to_interleaved_iq_samples;
|
||||||
|
|
||||||
if (items_in_buffer == 0) return;
|
if (items_in_buffer == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
current_samples->n_channels = n_channels;
|
current_samples->n_channels = n_channels;
|
||||||
current_samples->n_interleaved_iq_samples = items_in_buffer;
|
current_samples->n_interleaved_iq_samples = items_in_buffer;
|
||||||
|
@ -41,15 +41,15 @@ class ad936x_iio_custom
|
|||||||
public:
|
public:
|
||||||
ad936x_iio_custom(int debug_level_, int log_level_);
|
ad936x_iio_custom(int debug_level_, int log_level_);
|
||||||
virtual ~ad936x_iio_custom();
|
virtual ~ad936x_iio_custom();
|
||||||
bool initialize_device(std::string pluto_device_uri, std::string board_type);
|
bool initialize_device(const std::string &pluto_device_uri, const std::string &board_type);
|
||||||
|
|
||||||
bool init_config_ad9361_rx(long long bandwidth_,
|
bool init_config_ad9361_rx(long long bandwidth_,
|
||||||
long long sample_rate_,
|
long long sample_rate_,
|
||||||
long long freq_,
|
long long freq_,
|
||||||
std::string rf_port_select_,
|
const std::string &rf_port_select_,
|
||||||
std::string rf_filter,
|
const std::string &rf_filter,
|
||||||
std::string gain_mode_rx0_,
|
const std::string &gain_mode_rx0_,
|
||||||
std::string gain_mode_rx1_,
|
const std::string &gain_mode_rx1_,
|
||||||
double rf_gain_rx0_,
|
double rf_gain_rx0_,
|
||||||
double rf_gain_rx1_,
|
double rf_gain_rx1_,
|
||||||
bool enable_ch0,
|
bool enable_ch0,
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
bool calibrate(int ch, double bw_hz);
|
bool calibrate(int ch, double bw_hz);
|
||||||
|
|
||||||
double get_rx_gain(int ch_num);
|
double get_rx_gain(int ch_num);
|
||||||
bool setRXGain(int ch_num, std::string gain_mode, double gain_dB);
|
bool setRXGain(int ch_num, const std::string &gain_mode, double gain_dB);
|
||||||
|
|
||||||
bool set_antenna_port(int ch, int antenna_idx);
|
bool set_antenna_port(int ch, int antenna_idx);
|
||||||
double get_frequency(int ch);
|
double get_frequency(int ch);
|
||||||
@ -94,9 +94,9 @@ private:
|
|||||||
unsigned long long frequency,
|
unsigned long long frequency,
|
||||||
unsigned long samplerate, unsigned long bandwidth,
|
unsigned long samplerate, unsigned long bandwidth,
|
||||||
bool quadrature, bool rfdc, bool bbdc,
|
bool quadrature, bool rfdc, bool bbdc,
|
||||||
std::string gain1, double gain1_value,
|
const std::string &gain1, double gain1_value,
|
||||||
std::string gain2, double gain2_value,
|
const std::string &gain2, double gain2_value,
|
||||||
std::string port_select);
|
const std::string &port_select);
|
||||||
|
|
||||||
bool config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
bool config_ad9361_dds(uint64_t freq_rf_tx_hz_,
|
||||||
double tx_attenuation_db_,
|
double tx_attenuation_db_,
|
||||||
@ -108,7 +108,7 @@ private:
|
|||||||
void get_PPS_timestamp();
|
void get_PPS_timestamp();
|
||||||
void capture(const std::vector<std::string> &channels);
|
void capture(const std::vector<std::string> &channels);
|
||||||
|
|
||||||
bool select_rf_filter(std::string rf_filter);
|
bool select_rf_filter(const std::string &rf_filter);
|
||||||
|
|
||||||
void monitor_thread_fn();
|
void monitor_thread_fn();
|
||||||
|
|
||||||
@ -121,12 +121,6 @@ private:
|
|||||||
struct iio_device *stream_dev;
|
struct iio_device *stream_dev;
|
||||||
struct iio_device *dds_dev;
|
struct iio_device *dds_dev;
|
||||||
|
|
||||||
// stream
|
|
||||||
uint64_t sample_rate_sps;
|
|
||||||
int debug_level;
|
|
||||||
int log_level;
|
|
||||||
bool PPS_mode;
|
|
||||||
|
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
|
|
||||||
@ -140,6 +134,12 @@ private:
|
|||||||
std::thread capture_samples_thread;
|
std::thread capture_samples_thread;
|
||||||
std::thread overflow_monitor_thread;
|
std::thread overflow_monitor_thread;
|
||||||
std::thread capture_time_thread;
|
std::thread capture_time_thread;
|
||||||
|
|
||||||
|
// stream
|
||||||
|
uint64_t sample_rate_sps;
|
||||||
|
int debug_level;
|
||||||
|
int log_level;
|
||||||
|
bool PPS_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/*!
|
|
||||||
* \file ad936x_iio_samples.cc
|
|
||||||
* \brief A class that holds a custom sample buffer for Analog Devices AD936x family front-ends.
|
|
||||||
* \author Javier Arribas, jarribas(at)cttc.es
|
|
||||||
*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
|
||||||
* This file is part of GNSS-SDR.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ad936x_iio_samples.h"
|
|
||||||
|
|
||||||
ad936x_iio_samples::ad936x_iio_samples()
|
|
||||||
{
|
|
||||||
n_bytes = 0;
|
|
||||||
n_interleaved_iq_samples = 0;
|
|
||||||
step_bytes = 0;
|
|
||||||
n_channels = 0;
|
|
||||||
}
|
|
@ -33,11 +33,11 @@
|
|||||||
class ad936x_iio_samples
|
class ad936x_iio_samples
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ad936x_iio_samples();
|
ad936x_iio_samples() = default;
|
||||||
uint32_t n_bytes;
|
uint32_t n_bytes{0};
|
||||||
uint32_t n_interleaved_iq_samples;
|
uint32_t n_interleaved_iq_samples{0};
|
||||||
uint16_t n_channels;
|
uint16_t n_channels{0};
|
||||||
uint16_t step_bytes;
|
uint16_t step_bytes{0};
|
||||||
char buffer[IIO_DEFAULTAD936XAPIFIFOSIZE_SAMPLES * 4 * 4]; // max 16 bits samples per buffer (4 channels, 2-bytes per I + 2-bytes per Q)
|
char buffer[IIO_DEFAULTAD936XAPIFIFOSIZE_SAMPLES * 4 * 4]; // max 16 bits samples per buffer (4 channels, 2-bytes per I + 2-bytes per Q)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,19 +20,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
pps_tcp_rx::pps_tcp_rx()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
is_connected = false;
|
|
||||||
clientSd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pps_tcp_rx::~pps_tcp_rx()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated destructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void pps_tcp_rx::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue)
|
void pps_tcp_rx::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue)
|
||||||
{
|
{
|
||||||
@ -40,7 +27,7 @@ void pps_tcp_rx::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pps_tcp_rx::send_cmd(std::string cmd)
|
bool pps_tcp_rx::send_cmd(std::string cmd) const
|
||||||
{
|
{
|
||||||
if (is_connected == true)
|
if (is_connected == true)
|
||||||
{
|
{
|
||||||
@ -64,7 +51,7 @@ bool pps_tcp_rx::send_cmd(std::string cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pps_tcp_rx::receive_pps(std::string ip_address, int port)
|
void pps_tcp_rx::receive_pps(const std::string &ip_address, int port)
|
||||||
{
|
{
|
||||||
// create a message buffer
|
// create a message buffer
|
||||||
char buf[1500];
|
char buf[1500];
|
||||||
@ -117,7 +104,7 @@ void pps_tcp_rx::receive_pps(std::string ip_address, int port)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new_pps.samplestamp = std::strtoul(data.at(0).substr(found + 3).c_str(), NULL, 0);
|
new_pps.samplestamp = std::strtoul(data.at(0).substr(found + 3).c_str(), nullptr, 0);
|
||||||
}
|
}
|
||||||
catch (const std::exception &ex)
|
catch (const std::exception &ex)
|
||||||
{
|
{
|
||||||
@ -133,7 +120,7 @@ void pps_tcp_rx::receive_pps(std::string ip_address, int port)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new_pps.overflow_reg = std::stoi(data.at(1).substr(found + 2).c_str(), NULL, 0);
|
new_pps.overflow_reg = std::stoi(data.at(1).substr(found + 2).c_str(), nullptr, 0);
|
||||||
}
|
}
|
||||||
catch (const std::exception &ex)
|
catch (const std::exception &ex)
|
||||||
{
|
{
|
||||||
@ -155,9 +142,11 @@ void pps_tcp_rx::receive_pps(std::string ip_address, int port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
new_pps_line += c;
|
new_pps_line += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "pps_tcp_rx: Socket disconnected!\n!";
|
std::cout << "pps_tcp_rx: Socket disconnected!\n!";
|
||||||
|
@ -28,15 +28,15 @@ class pps_tcp_rx
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> Pps_queue;
|
std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> Pps_queue;
|
||||||
int clientSd;
|
int clientSd{-1};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
volatile bool is_connected;
|
volatile bool is_connected{false};
|
||||||
pps_tcp_rx();
|
pps_tcp_rx() = default;
|
||||||
virtual ~pps_tcp_rx();
|
virtual ~pps_tcp_rx() = default;
|
||||||
|
|
||||||
void receive_pps(std::string ip_address, int port);
|
void receive_pps(const std::string& ip_address, int port);
|
||||||
bool send_cmd(std::string cmd);
|
bool send_cmd(std::string cmd) const;
|
||||||
|
|
||||||
void set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue);
|
void set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user