Merge with next

This commit is contained in:
Javier Arribas 2022-06-03 21:08:13 +02:00
commit f8b227952a
21 changed files with 558 additions and 359 deletions

View File

@ -332,7 +332,7 @@ set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master")
set(GNSSSDR_GPSTK_LOCAL_VERSION "8.0.0")
set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23")
set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.12")
set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.20.1")
set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.1")
set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.6.1")
set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7")

View File

@ -496,16 +496,19 @@ $ sudo apt-get install autoconf automake libtool curl make g++ unzip
and then:
```
$ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protobuf-cpp-3.20.1.tar.gz
$ tar xvfz protobuf-cpp-3.20.1.tar.gz
$ cd protobuf-3.20.1
$ git clone https://github.com/protocolbuffers/protobuf.git
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure
$ make
$ /configure
$ make -j$(nproc)
$ sudo make install
$ sudo ldconfig
```
For more options, please check the
[Protocol Buffers' installation instructions](https://github.com/protocolbuffers/protobuf/blob/main/src/README.md/).
#### Install [Pugixml](https://pugixml.org/ "Pugixml's Homepage"), a light-weight C++ XML processing library:
```

View File

@ -173,6 +173,8 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration,
* 15 | Galileo E1B + Galileo E5b
* 16 | GPS L2C + GPS L5
* 17 | GPS L2C + Galileo E5a
* 18 | GPS L2C + Galileo E5b
* 19 | Galileo E5a + Galileo E5b
* 20 | GPS L5 + Galileo E5b
* 21 | GPS L1 C/A + Galileo E1B + GPS L2C
* 22 | GPS L1 C/A + Galileo E1B + GPS L5
@ -302,10 +304,16 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration,
}
if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (gal_E6_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count == 0))
{
pvt_output_parameters.type_of_receiver = 18;
pvt_output_parameters.type_of_receiver = 18; // GPS L2C + Galileo E5b
}
if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count != 0) && (gal_E6_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count == 0))
{
pvt_output_parameters.type_of_receiver = 19; // Galileo E5a + Galileo E5b
}
if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (gal_E6_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count == 0))
{
pvt_output_parameters.type_of_receiver = 20; // GPS L5 + Galileo E5b
}
// if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (gal_E6_count == 0)) pvt_output_parameters.type_of_receiver = 19;
// if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (gal_E6_count == 0)) pvt_output_parameters.type_of_receiver = 20;
if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (gal_E6_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count == 0))
{
pvt_output_parameters.type_of_receiver = 21; // GPS L1 C/A + Galileo E1B + GPS L2C

View File

@ -1956,7 +1956,7 @@ void rtklib_pvt_gs::initialize_and_apply_carrier_phase_offset()
int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items __attribute__((unused)))
{
//**************** time tags ****************
// *************** time tags ****************
if (d_enable_rx_clock_correction == false) // todo: currently only works if clock correction is disabled
{
std::vector<gr::tag_t> tags_vec;
@ -1983,7 +1983,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item
}
}
}
//************* end time tags **************
// ************ end time tags **************
for (int32_t epoch = 0; epoch < noutput_items; epoch++)
{

View File

@ -470,6 +470,17 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons
d_rinex_header_written = true; // do not write header anymore
}
break;
case 19: // Galileo E5a + Galileo E5b
if ((galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()))
{
const std::string gal_signal("5X 7X");
rinex_obs_header(obsFile, galileo_ephemeris_iter->second, rx_time, gal_signal);
rinex_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model);
output_navfilename.push_back(navGalfilename);
log_rinex_nav(navGalFile, pvt_solver->galileo_ephemeris_map);
d_rinex_header_written = true; // do not write header anymore
}
break;
case 23: // GLONASS L1 C/A only
if (glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend())
{
@ -949,6 +960,18 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, cons
d_rinex_header_updated = true;
}
break;
case 19: // Galileo E5a + Galileo E5b
if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())
{
log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, "5X 7X");
}
if (!d_rinex_header_updated and (pvt_solver->galileo_utc_model.A0 != 0))
{
update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model);
update_obs_header(obsFile, pvt_solver->galileo_utc_model);
d_rinex_header_updated = true;
}
break;
case 23: // GLONASS L1 C/A only
if (glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend())
{
@ -1333,6 +1356,9 @@ void Rinex_Printer::log_rinex_nav_gal_nav(int type_of_rx, const std::map<int32_t
case 15: // Galileo E1B + Galileo E5b
log_rinex_nav(navGalFile, new_gal_eph);
break;
case 19: // Galileo E1B + Galileo E5b
log_rinex_nav(navGalFile, new_gal_eph);
break;
case 27: // Galileo E1B + GLONASS L1 C/A
case 30: // Galileo E1B + GLONASS L2 C/A
log_rinex_nav(navMixFile, new_gal_eph, new_glo_eph);

View File

@ -75,7 +75,7 @@ void beidou_b1i_code_gen_int(own::span<int32_t> dest, int32_t prn, uint32_t chip
}
// Set the delay
delay = code_length - delays[prn_idx] * 0; //**********************************
delay = code_length - delays[prn_idx] * 0; // *********************************
delay += chip_shift;
delay %= code_length;

View File

@ -717,7 +717,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused)
// Push the tracking observables into buffers to allow the observable interpolation at the desired Rx clock
for (uint32_t n = 0; n < d_nchannels_out; n++)
{
//**************** time tags ****************
// *************** time tags ****************
// std::vector<gr::tag_t> tags_vec;
// this->get_tags_in_range(tags_vec, n, this->nitems_read(n), this->nitems_read(n) + ninput_items[n]);
// for (std::vector<gr::tag_t>::iterator it = tags_vec.begin(); it != tags_vec.end(); ++it)
@ -741,7 +741,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused)
// }
// }
//************* end time tags **************
// ************ end time tags **************
for (int32_t m = 0; m < ninput_items[n]; m++)
{
// Push the valid tracking Gnss_Synchros to their corresponding deque

View File

@ -58,8 +58,9 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con
filter_filename_(configuration->property(role + ".filter_filename", filter_file_)),
filename0_(configuration->property(role + ".filename", empty_string)),
rf_gain_rx1_(configuration->property(role + ".gain_rx1", default_manual_gain_rx1)),
rf_gain_rx2_(configuration->property(role + ".gain_rx1", default_manual_gain_rx2)),
freq_(configuration->property(role + ".freq", static_cast<uint64_t>(GPS_L1_FREQ_HZ))),
rf_gain_rx2_(configuration->property(role + ".gain_rx2", default_manual_gain_rx2)),
freq0_(configuration->property(role + ".freq", 0)),
freq1_(configuration->property(role + ".freq1", static_cast<uint64_t>(GPS_L5_FREQ_HZ))),
sample_rate_(configuration->property(role + ".sampling_frequency", default_bandwidth)),
bandwidth_(configuration->property(role + ".bandwidth", default_bandwidth)),
samples_to_skip_(0),
@ -98,6 +99,12 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con
const double seconds_to_skip = configuration->property(role + ".seconds_to_skip", 0.0);
const size_t header_size = configuration->property(role + ".header_size", 0);
if (freq0_ == 0)
{
// use ".freq0"
freq0_ = configuration->property(role + ".freq0", static_cast<uint64_t>(GPS_L1_FREQ_HZ));
}
if (filter_auto_)
{
filter_source_ = configuration->property(role + ".filter_source", std::string("Auto"));
@ -340,12 +347,13 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con
LOG(WARNING) << "Invalid configuration value for bandwidth parameter. Set to bandwidth=" << default_bandwidth;
}
std::cout << "LO frequency : " << freq_ << " Hz\n";
std::cout << "LO frequency : " << freq0_ << " Hz\n";
try
{
config_ad9361_rx_local(bandwidth_,
sample_rate_,
freq_,
freq0_,
freq1_,
rf_port_select_,
rx1_enable_,
rx2_enable_,

View File

@ -126,7 +126,8 @@ private:
double rf_gain_rx1_;
double rf_gain_rx2_;
uint64_t freq_; // frequency of local oscillator
uint64_t freq0_; // frequency of local oscillator for ADRV9361-A 0
uint64_t freq1_; // frequency of local oscillator for ADRV9361-B (if present)
uint64_t sample_rate_;
uint64_t bandwidth_;
uint64_t samples_to_skip_;

View File

@ -22,6 +22,7 @@
#include <fstream> // for ifstream
#include <iostream>
#include <sstream>
#include <utility>
#include <vector>
/* check return value of attr_write function */
@ -93,7 +94,7 @@ bool get_ad9361_stream_ch(struct iio_context *ctx __attribute__((unused)), enum
/* finds AD9361 phy IIO configuration channel with id chid */
bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_channel **chn)
bool get_phy_chan(struct iio_device *dev, enum iodev d, int chid, struct iio_channel **chn)
{
std::stringstream name;
switch (d)
@ -102,14 +103,14 @@ bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_ch
name.str("");
name << "voltage";
name << chid;
*chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), false);
*chn = iio_device_find_channel(dev, name.str().c_str(), false);
return *chn != nullptr;
break;
case TX:
name.str("");
name << "voltage";
name << chid;
*chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), true);
*chn = iio_device_find_channel(dev, name.str().c_str(), true);
return *chn != nullptr;
break;
default:
@ -119,17 +120,26 @@ bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_ch
/* finds AD9361 local oscillator IIO configuration channels */
bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn)
bool get_lo_chan(struct iio_device *dev, enum iodev d, int chid, struct iio_channel **chn)
{
std::stringstream name;
switch (d)
{
// LO chan is always output, i.e. true
// LO chan is always output, i.e. true
case RX:
*chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage0", true);
name.str("");
name << "altvoltage";
name << chid;
*chn = iio_device_find_channel(dev, name.str().c_str(), true);
return *chn != nullptr;
break;
case TX:
*chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage1", true);
name.str("");
name << "altvoltage";
name << chid;
*chn = iio_device_find_channel(dev, name.str().c_str(), true);
return *chn != nullptr;
break;
default:
return false;
}
@ -137,36 +147,173 @@ 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)
void cfg_ad9361_streaming_ch(struct stream_cfg *cfg, iio_channel *chn)
{
struct iio_channel *chn = nullptr;
// Configure phy and lo channels
// LOG(INFO)<<"* Acquiring AD9361 phy channel"<<chid;
std::cout << "* Acquiring AD9361 phy channel" << chid << '\n';
if (!get_phy_chan(ctx, type, chid, &chn))
{
return false;
}
wr_ch_str(chn, "rf_port_select", cfg->rfport);
wr_ch_lli(chn, "rf_bandwidth", cfg->bw_hz);
wr_ch_lli(chn, "sampling_frequency", cfg->fs_hz);
}
// Configure LO channel
// LOG(INFO)<<"* Acquiring AD9361 "<<type == TX ? "TX" : "RX";
std::cout << "* Acquiring AD9361 " << (type == TX ? "TX" : "RX") << '\n';
if (!get_lo_chan(ctx, type, &chn))
int setup_filter(const std::string &filter_source_, uint64_t bandwidth_, uint64_t sample_rate_, uint64_t freq_, const std::string &rf_port_select_,
struct iio_device *ad9361_phy_dev, struct iio_channel *rx_chan, struct iio_channel *chn, int chid, std::string filter_filename_, float Fpass_, float Fstop_)
{
int ret;
if (filter_source_ == "Off")
{
return false;
struct stream_cfg rxcfg;
rxcfg.bw_hz = bandwidth_;
rxcfg.fs_hz = sample_rate_;
rxcfg.lo_hz = freq_;
rxcfg.rfport = rf_port_select_.c_str();
cfg_ad9361_streaming_ch(&rxcfg, chn);
}
wr_ch_lli(chn, "frequency", cfg->lo_hz);
return true;
else if (filter_source_ == "Auto")
{
ret = ad9361_set_bb_rate(ad9361_phy_dev, sample_rate_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
// set bw
// params.push_back("in_voltage_rf_bandwidth=" + boost::to_string(bandwidth));
}
// wr_ch_str(rx_chan, "rf_port_select", rf_port_select_.c_str());
ret = iio_device_attr_write(ad9361_phy_dev, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ad9361_phy_dev, RX, chid, &rx_chan))
{
return -1;
}
wr_ch_lli(rx_chan, "frequency", freq_);
}
else if (filter_source_ == "File")
{
try
{
if (!load_fir_filter(filter_filename_, ad9361_phy_dev))
{
throw std::runtime_error("Unable to load filter file");
}
}
catch (const std::runtime_error &e)
{
std::cout << "Exception cached when configuring the RX FIR filter: " << e.what() << '\n';
}
ret = iio_device_attr_write(ad9361_phy_dev, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ad9361_phy_dev, RX, chid, &rx_chan))
{
return -1;
}
wr_ch_lli(rx_chan, "frequency", freq_);
}
#if LIBAD9361_VERSION_GREATER_THAN_01
else if (filter_source_ == "Design")
{
ret = ad9361_set_bb_rate_custom_filter_manual(
ad9361_phy_dev, sample_rate_, static_cast<uint64_t>(Fpass_), static_cast<uint64_t>(Fstop_), bandwidth_, bandwidth_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
}
ret = iio_device_attr_write(ad9361_phy_dev, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ad9361_phy_dev, RX, chid, &rx_chan))
{
return -1;
}
wr_ch_lli(rx_chan, "frequency", freq_);
}
#endif
else
{
throw std::runtime_error("Unknown filter configuration");
}
// Filters can only be disabled after the sample rate has been set
if (filter_source_ == "Off")
{
ret = ad9361_set_trx_fir_enable(ad9361_phy_dev, false);
if (ret)
{
throw std::runtime_error("Unable to disable filters");
}
}
return 0;
}
int setup_device_parameters(iio_device *ad9361_phy_dev, bool quadrature_, bool rfdc_, bool bbdc_, const std::string &gain_mode_rx1_, const std::string &gain_mode_rx2_)
{
int ret;
ret = iio_device_attr_write(ad9361_phy_dev, "trx_rate_governor", "nominal");
if (ret < 0)
{
std::cout << "Failed to set trx_rate_governor: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write(ad9361_phy_dev, "ensm_mode", "fdd");
if (ret < 0)
{
std::cout << "Failed to set ensm_mode: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write(ad9361_phy_dev, "calib_mode", "auto");
if (ret < 0)
{
std::cout << "Failed to set calib_mode: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write_bool(ad9361_phy_dev, "in_voltage_quadrature_tracking_en", quadrature_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_quadrature_tracking_en: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write_bool(ad9361_phy_dev, "in_voltage_rf_dc_offset_tracking_en", rfdc_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_rf_dc_offset_tracking_en: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write_bool(ad9361_phy_dev, "in_voltage_bb_dc_offset_tracking_en", bbdc_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_bb_dc_offset_tracking_en: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write(ad9361_phy_dev, "in_voltage0_gain_control_mode", gain_mode_rx1_.c_str());
if (ret < 0)
{
std::cout << "Failed to set in_voltage0_gain_control_mode: " << ret << '\n';
return ret;
}
ret = iio_device_attr_write(ad9361_phy_dev, "in_voltage1_gain_control_mode", gain_mode_rx2_.c_str());
if (ret < 0)
{
std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << '\n';
}
return ret;
}
bool config_ad9361_rx_local(uint64_t bandwidth_,
uint64_t sample_rate_,
uint64_t freq_,
uint64_t freq0_,
uint64_t freq1_,
const std::string &rf_port_select_,
bool rx1_enable_,
bool rx2_enable_,
@ -184,12 +331,13 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
{
// RX stream config
std::cout << "AD9361 Acquiring IIO LOCAL context\n";
struct iio_context *ctx;
// Streaming devices
struct iio_device *rx;
struct iio_channel *rx_chan1;
struct iio_channel *rx_chan2;
struct iio_channel *rx_chan0; // stream channel 0
struct iio_channel *rx_chan1; // stream channel 1
struct iio_channel *chn; // phy channel
int ret;
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
@ -205,6 +353,8 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
}
#endif
// iio context
std::cout << "Acquiring IIO LOCAL context\n";
ctx = iio_create_default_context();
if (!ctx)
{
@ -218,181 +368,144 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
throw std::runtime_error("AD9361 IIO No devices");
}
// AD9361-A
struct iio_device *ad9361_phy;
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
std::cout << "* Acquiring AD9361 streaming devices\n";
if (!get_ad9361_stream_dev(ctx, RX, &rx))
std::cout << "Acquiring AD9361 phy devices\n";
ad9361_phy = iio_context_find_device(ctx, RX_DEV_A.c_str());
if (!ad9361_phy)
{
std::cout << "No rx dev found\n";
throw std::runtime_error("AD9361 IIO No rx dev found");
std::cout << "No " << RX_DEV_A << " dev found\n";
throw std::runtime_error("AD9361 IIO no rx dev found");
}
std::cout << "* Initializing AD9361 IIO streaming channels\n";
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
// AD9361-B
struct iio_device *ad9361_phy_B;
bool enable_ad9361_b;
ad9361_phy_B = iio_context_find_device(ctx, RX_DEV_B.c_str());
if (ad9361_phy_B)
{
std::cout << "RX channel 1 not found\n";
throw std::runtime_error("RX channel 1 not found");
enable_ad9361_b = true; // the RF board has two AD9361 devices
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
{
std::cout << "RX channel 2 not found\n";
throw std::runtime_error("RX channel 2 not found");
}
if (filter_source_ == "Off")
{
struct stream_cfg rxcfg;
rxcfg.bw_hz = bandwidth_;
rxcfg.fs_hz = sample_rate_;
rxcfg.lo_hz = freq_;
rxcfg.rfport = rf_port_select_.c_str();
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
{
std::cout << "RX port 0 not found\n";
throw std::runtime_error("AD9361 IIO RX port 0 not found");
}
}
else if (filter_source_ == "Auto")
{
ret = ad9361_set_bb_rate(ad9361_phy, sample_rate_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
// set bw
// params.push_back("in_voltage_rf_bandwidth=" + boost::to_string(bandwidth));
}
// wr_ch_str(rx_chan1, "rf_port_select", rf_port_select_.c_str());
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
else if (filter_source_ == "File")
{
try
{
if (!load_fir_filter(filter_filename_, ad9361_phy))
{
throw std::runtime_error("Unable to load filter file");
}
}
catch (const std::runtime_error &e)
{
std::cout << "Exception cached when configuring the RX FIR filter: " << e.what() << '\n';
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
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(
ad9361_phy, sample_rate_, static_cast<uint64_t>(Fpass_), static_cast<uint64_t>(Fstop_), bandwidth_, bandwidth_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#endif
else
{
throw std::runtime_error("Unknown filter configuration");
enable_ad9361_b = false; // the RF board has one AD9361 device
}
// Filters can only be disabled after the sample rate has been set
if (filter_source_ == "Off")
// set-up AD9361-A stream device
std::string rx_stream_dev_a = (enable_ad9361_b ? RX_STREAM_DEV_A : RX_STREAM_DEV);
std::cout << "* Acquiring " << rx_stream_dev_a << " streaming device\n";
rx = iio_context_find_device(ctx, rx_stream_dev_a.c_str());
if (!rx)
{
ret = ad9361_set_trx_fir_enable(ad9361_phy, false);
if (ret)
std::cout << "No " << rx_stream_dev_a << " stream dev found\n";
throw std::runtime_error("AD9361 IIO No " + rx_stream_dev_a + " stream dev found");
}
// get AD9361-A stream device channel 0 as rx channel 0
std::cout << "* Acquiring " << rx_stream_dev_a << " phy channel 0\n";
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan0))
{
std::cout << rx_stream_dev_a << " channel 0 not found\n";
throw std::runtime_error(rx_stream_dev_a + "RX channel 0 not found");
}
if (!get_phy_chan(ad9361_phy, RX, 0, &chn))
{
return false;
}
if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq0_, rf_port_select_, ad9361_phy, rx_chan0, chn, 0, filter_filename_, Fpass_, Fstop_) == -1)
{
return false;
}
// Configure LO channel
std::cout << "* Acquiring " << RX_DEV_A << " LO RX channel 0\n";
if (!get_lo_chan(ad9361_phy, RX, 0, &chn))
{
std::cout << "RX LO channel 0not found\n";
throw std::runtime_error("RX LO channel 0not found");
}
wr_ch_lli(chn, "frequency", freq0_);
if (enable_ad9361_b)
{
// set-up AD9361-B stream device
std::cout << "* Acquiring " << RX_STREAM_DEV_B << " streaming device\n";
rx = iio_context_find_device(ctx, RX_STREAM_DEV_B.c_str());
if (!rx)
{
throw std::runtime_error("Unable to disable filters");
std::cout << "No " << RX_STREAM_DEV_B << " stream dev found\n";
throw std::runtime_error("AD9361 IIO No " + RX_STREAM_DEV_B + " stream dev found");
}
// get AD9361-B stream device channel 0 as rx channel 1
std::cout << "* Acquiring " << RX_STREAM_DEV_B << " phy channel 0\n";
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
{
std::cout << RX_STREAM_DEV_B << " channel 0 not found\n";
throw std::runtime_error(RX_STREAM_DEV_B + "RX channel 0 not found");
}
if (!get_phy_chan(ad9361_phy_B, RX, 0, &chn))
{
return false;
}
if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq1_, rf_port_select_, ad9361_phy_B, rx_chan1, chn, 0, filter_filename_, Fpass_, Fstop_) == -1)
{
return false;
}
// Configure LO channel
std::cout << "* Acquiring " << RX_DEV_B << " LO RX channel 0\n";
if (!get_lo_chan(ad9361_phy_B, RX, 0, &chn))
{
std::cout << "RX LO channel 1 not found\n";
throw std::runtime_error("RX LO channel 1 not found");
}
wr_ch_lli(chn, "frequency", freq1_);
}
else
{
// GET ad9361-A stream device channel 1 as rx channel 1
std::cout << "* Acquiring " << rx_stream_dev_a << " phy channel 1\n";
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan1))
{
std::cout << rx_stream_dev_a << " channel 1 not found\n";
throw std::runtime_error(rx_stream_dev_a + "RX channel 1 not found");
}
if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq0_, rf_port_select_, ad9361_phy, rx_chan1, chn, 1, filter_filename_, Fpass_, Fstop_) == -1)
{
return false;
}
}
std::cout << "* Enabling IIO streaming channels\n";
if (rx1_enable_)
{
iio_channel_enable(rx_chan1);
iio_channel_enable(rx_chan0);
}
if (rx2_enable_)
{
iio_channel_enable(rx_chan2);
iio_channel_enable(rx_chan1);
ad9361_fmcomms5_multichip_sync(ctx, FIXUP_INTERFACE_TIMING | CHECK_SAMPLE_RATES);
}
if (!rx1_enable_ and !rx2_enable_)
{
std::cout << "WARNING: No Rx channels enabled.\n";
}
ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal");
if (ret < 0)
std::cout << "configuring " << RX_DEV_A << " device parameters\n";
if (setup_device_parameters(ad9361_phy, quadrature_, rfdc_, bbdc_, gain_mode_rx1_, gain_mode_rx2_) < 0)
{
std::cout << "Failed to set trx_rate_governor: " << ret << '\n';
throw std::runtime_error("configuring " + RX_DEV_A + " device parameters failed\n");
}
ret = iio_device_attr_write(ad9361_phy, "ensm_mode", "fdd");
if (ret < 0)
if (enable_ad9361_b)
{
std::cout << "Failed to set ensm_mode: " << ret << '\n';
}
ret = iio_device_attr_write(ad9361_phy, "calib_mode", "auto");
if (ret < 0)
{
std::cout << "Failed to set calib_mode: " << ret << '\n';
}
ret = iio_device_attr_write_bool(ad9361_phy, "in_voltage_quadrature_tracking_en", quadrature_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_quadrature_tracking_en: " << ret << '\n';
}
ret = iio_device_attr_write_bool(ad9361_phy, "in_voltage_rf_dc_offset_tracking_en", rfdc_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_rf_dc_offset_tracking_en: " << ret << '\n';
}
ret = iio_device_attr_write_bool(ad9361_phy, "in_voltage_bb_dc_offset_tracking_en", bbdc_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage_bb_dc_offset_tracking_en: " << ret << '\n';
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_gain_control_mode", gain_mode_rx1_.c_str());
if (ret < 0)
{
std::cout << "Failed to set in_voltage0_gain_control_mode: " << ret << '\n';
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage1_gain_control_mode", gain_mode_rx2_.c_str());
if (ret < 0)
{
std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << '\n';
std::cout << "configuring " << RX_DEV_B << " device parameters\n";
if (setup_device_parameters(ad9361_phy_B, quadrature_, rfdc_, bbdc_, gain_mode_rx2_, gain_mode_rx2_) < 0)
{
throw std::runtime_error("configuring " + RX_DEV_B + " device parameters failed\n");
}
}
if (gain_mode_rx1_ == "manual")
{
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage0_hardwaregain", rf_gain_rx1_);
@ -401,12 +514,27 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
std::cout << "Failed to set in_voltage0_hardwaregain: " << ret << '\n';
}
}
if (gain_mode_rx2_ == "manual")
if (!enable_ad9361_b)
{
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_);
if (ret < 0)
if (gain_mode_rx2_ == "manual")
{
std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << '\n';
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << '\n';
}
}
}
else
{
if (gain_mode_rx2_ == "manual")
{
ret = iio_device_attr_write_double(ad9361_phy_B, "in_voltage0_hardwaregain", rf_gain_rx2_);
if (ret < 0)
{
std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << '\n';
}
}
}
@ -440,8 +568,9 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
struct iio_context *ctx;
// Streaming devices
struct iio_device *rx;
struct iio_channel *rx_chan0;
struct iio_channel *rx_chan1;
struct iio_channel *rx_chan2;
struct iio_channel *chn; // phy channel
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
if (filter_source_ == "Design")
@ -484,124 +613,42 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
int ret;
std::cout << "* Initializing AD9361 IIO streaming channels\n";
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan0))
{
std::cout << "RX channel 1 not found\n";
throw std::runtime_error("RX channel 1 not found");
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan1))
{
std::cout << "RX channel 2 not found\n";
throw std::runtime_error("RX channel 2 not found");
}
if (filter_source_ == "Off")
if (!get_phy_chan(ad9361_phy, RX, 0, &chn))
{
struct stream_cfg rxcfg;
rxcfg.bw_hz = bandwidth_;
rxcfg.fs_hz = sample_rate_;
rxcfg.lo_hz = freq_;
rxcfg.rfport = rf_port_select_.c_str();
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
{
std::cout << "RX port 0 not found\n";
throw std::runtime_error("AD9361 IIO RX port 0 not found");
}
return false;
}
else if (filter_source_ == "Auto")
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)
{
ret = ad9361_set_bb_rate(ad9361_phy, sample_rate_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
// set bw
// params.push_back("in_voltage_rf_bandwidth=" + boost::to_string(bandwidth));
}
// wr_ch_str(rx_chan1, "rf_port_select", rf_port_select_.c_str());
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
else if (filter_source_ == "File")
{
try
{
if (!load_fir_filter(filter_filename_, ad9361_phy))
{
throw std::runtime_error("Unable to load filter file");
}
}
catch (const std::runtime_error &e)
{
std::cout << "Exception cached when configuring the RX FIR filter: " << e.what() << '\n';
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
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(
ad9361_phy, sample_rate_, static_cast<uint64_t>(Fpass_), static_cast<uint64_t>(Fstop_), bandwidth_, bandwidth_);
if (ret)
{
throw std::runtime_error("Unable to set BB rate");
}
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
if (ret)
{
throw std::runtime_error("Unable to set rf_port_select");
}
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
if (!get_lo_chan(ctx, RX, &rx_chan1))
{
return false;
}
wr_ch_lli(rx_chan1, "frequency", freq_);
}
#endif
else
{
throw std::runtime_error("Unknown filter configuration");
return false;
}
// Filters can only be disabled after the sample rate has been set
if (filter_source_ == "Off")
// Configure LO channel
std::cout << "* Acquiring LO channel RX\n";
if (!get_lo_chan(ad9361_phy, RX, 0, &chn))
{
ret = ad9361_set_trx_fir_enable(ad9361_phy, false);
if (ret)
{
throw std::runtime_error("Unable to disable filters");
}
std::cout << "RX LO channel not found\n";
throw std::runtime_error("RX LO channel not found");
}
wr_ch_lli(rx_chan0, "frequency", freq_);
std::cout << "* Enabling IIO streaming channels\n";
if (rx1_enable_)
{
iio_channel_enable(rx_chan1);
iio_channel_enable(rx_chan0);
}
if (rx2_enable_)
{
iio_channel_enable(rx_chan2);
iio_channel_enable(rx_chan1);
}
if (!rx1_enable_ and !rx2_enable_)
{
@ -682,6 +729,7 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
{
// TX stream config
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
struct iio_channel *tx_chan;
struct stream_cfg txcfg;
txcfg.bw_hz = bandwidth_;
txcfg.fs_hz = sample_rate_;
@ -709,15 +757,28 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
}
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");
if (!get_ad9361_stream_ch(ctx, TX, ad9361_phy, 0, &tx_chan))
{
std::cout << "TX channel 0 not found\n";
throw std::runtime_error("TX channel 0 not found");
}
cfg_ad9361_streaming_ch(&txcfg, tx_chan);
// Configure LO channel
std::cout << "* Acquiring LO channel TX\n";
if (!get_lo_chan(ad9361_phy, TX, 1, &tx_chan))
{
std::cout << "TX LO channel not found\n";
throw std::runtime_error("TX LO channel not found");
}
wr_ch_lli(tx_chan, "frequency", txcfg.lo_hz);
int ret;
// set output amplifier attenuation
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
@ -824,6 +885,7 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
{
// TX stream config
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
struct iio_channel *tx_chan;
struct stream_cfg txcfg;
txcfg.bw_hz = bandwidth_;
txcfg.fs_hz = sample_rate_;
@ -851,15 +913,28 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
}
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");
if (!get_ad9361_stream_ch(ctx, TX, ad9361_phy, 0, &tx_chan))
{
std::cout << "TX channel 0 not found\n";
throw std::runtime_error("TX channel 0 not found");
}
cfg_ad9361_streaming_ch(&txcfg, tx_chan);
// Configure LO channel
std::cout << "* Acquiring LO channel TX\n";
if (!get_lo_chan(ad9361_phy, TX, 1, &tx_chan))
{
std::cout << "TX LO channel not found\n";
throw std::runtime_error("TX LO channel not found");
}
wr_ch_lli(tx_chan, "frequency", txcfg.lo_hz);
int ret;
// set output amplifier attenuation
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
@ -1089,8 +1164,8 @@ bool disable_ad9361_rx_local()
{
struct iio_context *ctx;
struct iio_device *rx;
struct iio_channel *rx_chan0;
struct iio_channel *rx_chan1;
struct iio_channel *rx_chan2;
ctx = iio_create_default_context();
if (!ctx)
@ -1105,26 +1180,60 @@ bool disable_ad9361_rx_local()
return false;
}
if (!get_ad9361_stream_dev(ctx, RX, &rx))
// check if the second AD9361 is present
struct iio_device *ad9361_phy_B;
bool enable_ad9361_b;
ad9361_phy_B = iio_context_find_device(ctx, RX_DEV_B.c_str());
if (ad9361_phy_B)
{
std::cout << "No rx streams found when disabling RX channels\n";
return false;
enable_ad9361_b = true; // the RF board has two AD9361 devices
}
else
{
enable_ad9361_b = false; // the RF board has one AD9361 device
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
std::string rx_stream_dev_a = (enable_ad9361_b ? RX_STREAM_DEV_A : RX_STREAM_DEV);
rx = iio_context_find_device(ctx, rx_stream_dev_a.c_str());
if (!rx)
{
std::cout << "RX channel 1 not found when disabling RX channels\n";
return false;
std::cout << "No " << rx_stream_dev_a << " stream dev found when disabling RX channels\n";
throw std::runtime_error("AD9361 IIO No " + rx_stream_dev_a + " stream dev found");
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
// get AD9361-A stream device channel 0 as rx channel 0
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan0))
{
std::cout << "RX channel 2 not found when disabling RX channels\n";
return false;
std::cout << rx_stream_dev_a << " channel 0 not found when disabling RX channels\n";
throw std::runtime_error(rx_stream_dev_a + "RX channel 0 not found");
}
if (enable_ad9361_b)
{
rx = iio_context_find_device(ctx, RX_STREAM_DEV_B.c_str());
if (!rx)
{
std::cout << "No " << RX_STREAM_DEV_B << " stream dev found when disabling RX channels\n";
throw std::runtime_error("AD9361 IIO No " + RX_STREAM_DEV_B + " stream dev found");
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
{
std::cout << RX_STREAM_DEV_B << " channel 0 not found when disabling RX channels\n";
throw std::runtime_error(RX_STREAM_DEV_B + "RX channel 0 not found");
}
}
else
{
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan1))
{
std::cout << rx_stream_dev_a << " channel 1 not found\n";
throw std::runtime_error(rx_stream_dev_a + "RX channel 1 not found");
}
}
iio_channel_disable(rx_chan0);
iio_channel_disable(rx_chan1);
iio_channel_disable(rx_chan2);
iio_context_destroy(ctx);
return true;
}
@ -1134,8 +1243,8 @@ bool disable_ad9361_rx_remote(const std::string &remote_host)
{
struct iio_context *ctx;
struct iio_device *rx;
struct iio_channel *rx_chan0;
struct iio_channel *rx_chan1;
struct iio_channel *rx_chan2;
ctx = iio_create_network_context(remote_host.c_str());
if (!ctx)
@ -1150,19 +1259,19 @@ bool disable_ad9361_rx_remote(const std::string &remote_host)
return false;
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan0))
{
std::cout << "RX channel 1 not found at " << remote_host << " when disabling RX channels\n";
return false;
}
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan1))
{
std::cout << "RX channel 2 not found at " << remote_host << " when disabling RX channels\n";
return false;
}
iio_channel_disable(rx_chan0);
iio_channel_disable(rx_chan1);
iio_channel_disable(rx_chan2);
iio_context_destroy(ctx);
return true;
}

View File

@ -32,6 +32,13 @@
#define FIR_BUF_SIZE 8192
static const std::string RX_DEV_A = "ad9361-phy"; // one or two AD9361s are present
static const std::string RX_DEV_B = "ad9361-phy-B"; // one or two AD9361s are present
static const std::string RX_STREAM_DEV = "cf-ad9361-lpc"; // one AD9361 is present
static const std::string RX_STREAM_DEV_A = "cf-ad9361-A"; // two AD9361s are present
static const std::string RX_STREAM_DEV_B = "cf-ad9361-B"; // two AD9361s are present
static const std::string TX_STREAM_DEV = "cf-ad9361-dds-core-lpc";
/* RX is input, TX is output */
enum iodev
{
@ -77,7 +84,8 @@ bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, en
bool config_ad9361_rx_local(uint64_t bandwidth_,
uint64_t sample_rate_,
uint64_t freq_,
uint64_t freq0_,
uint64_t freq1_,
const std::string &rf_port_select_,
bool rx1_enable_,
bool rx2_enable_,

View File

@ -31,7 +31,7 @@ int Fpga_DMA::DMA_open()
return tx_channel.fd;
}
tx_channel.buf_ptr = (struct channel_buffer *)mmap(NULL, sizeof(struct channel_buffer) * TX_BUFFER_COUNT,
tx_channel.buf_ptr = (struct channel_buffer *)mmap(nullptr, sizeof(struct channel_buffer) * TX_BUFFER_COUNT,
PROT_READ | PROT_WRITE, MAP_SHARED, tx_channel.fd, 0);
if (tx_channel.buf_ptr == MAP_FAILED)
{
@ -68,7 +68,7 @@ int Fpga_DMA::DMA_open()
}
std::array<int8_t, BUFFER_SIZE> *Fpga_DMA::get_buffer_address(void)
std::array<int8_t, BUFFER_SIZE> *Fpga_DMA::get_buffer_address() // NOLINT(readability-make-member-function-const)
{
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture
return &tx_channel.buf_ptr[0].buffer;
@ -78,7 +78,7 @@ std::array<int8_t, BUFFER_SIZE> *Fpga_DMA::get_buffer_address(void)
}
int Fpga_DMA::DMA_write(int nbytes)
int Fpga_DMA::DMA_write(int nbytes) const
{
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture
@ -105,21 +105,18 @@ int Fpga_DMA::DMA_write(int nbytes)
std::cerr << "Proxy DMA Tx transfer error " << '\n';
return -1;
}
#else // 32-bit processor architecture
const int num_bytes_sent = write(tx_fd, buffer.data(), nbytes);
if (num_bytes_sent != nbytes)
{
return -1;
}
#endif
return 0;
}
int Fpga_DMA::DMA_close()
int Fpga_DMA::DMA_close() const
{
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture
if (munmap(tx_channel.buf_ptr, sizeof(struct channel_buffer)))

View File

@ -78,17 +78,17 @@ public:
/*!
* \brief Obtain DMA buffer address.
*/
std::array<int8_t, BUFFER_SIZE> *get_buffer_address(void);
std::array<int8_t, BUFFER_SIZE> *get_buffer_address(void); // NOLINT(readability-make-member-function-const)
/*!
* \brief Transfer DMA data
*/
int DMA_write(int nbytes);
int DMA_write(int nbytes) const;
/*!
* \brief Close the DMA device driver
*/
int DMA_close(void);
int DMA_close(void) const;
private:
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture

View File

@ -1103,7 +1103,6 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
case 3: // CNAV
{
// TODO
if (d_E6_TOW_set == true)
{
current_symbol.Flag_valid_word = true;

View File

@ -189,12 +189,12 @@ bool cuda_multicorrelator::init_cuda_integrated_resampler(
// ALLOCATE GPU MEMORY FOR INPUT/OUTPUT and INTERNAL vectors
size_t size = signal_length_samples * sizeof(GPU_Complex);
//********* ZERO COPY VERSION ************
// ******** ZERO COPY VERSION ************
// Set flag to enable zero copy access
// Optimal in shared memory devices (like Jetson K1)
//cudaSetDeviceFlags(cudaDeviceMapHost);
// cudaSetDeviceFlags(cudaDeviceMapHost);
//******** CudaMalloc version ***********
// ******* CudaMalloc version ***********
// input signal GPU memory (can be mapped to CPU memory in shared memory devices!)
// cudaMalloc((void **)&d_sig_in, size);
@ -237,7 +237,7 @@ bool cuda_multicorrelator::set_local_code_and_taps(
int n_correlators)
{
cudaSetDevice(selected_gps_device);
//********* ZERO COPY VERSION ************
// ******** ZERO COPY VERSION ************
// // Get device pointer from host memory. No allocation or memcpy
// cudaError_t code;
// // local code CPU -> GPU copy memory
@ -253,7 +253,7 @@ bool cuda_multicorrelator::set_local_code_and_taps(
// printf("cuda cudaHostGetDevicePointer error in set_local_code_and_taps \r\n");
// }
//******** CudaMalloc version ***********
// ******* CudaMalloc version ***********
//local code CPU -> GPU copy memory
cudaMemcpyAsync(d_local_codes_in, local_codes_in, sizeof(GPU_Complex) * code_length_chips, cudaMemcpyHostToDevice, stream1);
d_code_length_chips = code_length_chips;
@ -315,7 +315,7 @@ bool cuda_multicorrelator::Carrier_wipeoff_multicorrelator_resampler_cuda(
// input signal CPU -> GPU copy memory
//cudaMemcpyAsync(d_sig_in, d_sig_in_cpu, memSize,
// cudaMemcpyHostToDevice, stream2);
//***** NOTICE: NCO is computed on-the-fly, not need to copy NCO into GPU! ****
// **** NOTICE: NCO is computed on-the-fly, not need to copy NCO into GPU! ****
//launch the multitap correlator with integrated local code resampler!

View File

@ -144,7 +144,7 @@ int gnss_sdr_sample_counter::work(int noutput_items __attribute__((unused)),
out[0].Tracking_sample_counter = sample_counter;
current_T_rx_ms += interval_ms;
//**************** time tags ****************
// *************** time tags ****************
std::vector<gr::tag_t> tags_vec;
// notice that nitems_read is updated in decimation blocks after leaving work() with return 1, equivalent to call consume_each
this->get_tags_in_range(tags_vec, 0, this->nitems_read(0), this->nitems_read(0) + samples_per_output);
@ -182,7 +182,7 @@ int gnss_sdr_sample_counter::work(int noutput_items __attribute__((unused)),
}
}
//************* end time tags **************
// ************ end time tags **************
return 1;
}

View File

@ -481,7 +481,20 @@ int GNSSFlowgraph::connect_desktop_flowgraph()
LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal();
if (channels_state_[i] == 1)
{
#if ENABLE_FPGA
if (enable_fpga_offloading_)
{
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[i]);
tmp_thread.detach();
}
else
{
channels_.at(i)->start_acquisition();
}
#else
channels_.at(i)->start_acquisition();
#endif
LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition";
}
else
@ -1785,9 +1798,16 @@ void GNSSFlowgraph::acquisition_manager(unsigned int who)
channels_[current_channel]->assist_acquisition_doppler(0);
}
#if ENABLE_FPGA
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[current_channel]);
tmp_thread.detach();
if (enable_fpga_offloading_)
{
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[current_channel]);
tmp_thread.detach();
}
else
{
channels_[current_channel]->start_acquisition();
}
#else
channels_[current_channel]->start_acquisition();
#endif
@ -1891,9 +1911,16 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
channels_[who]->set_signal(channels_[who]->get_signal());
#if ENABLE_FPGA
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[who]);
tmp_thread.detach();
if (enable_fpga_offloading_)
{
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[who]);
tmp_thread.detach();
}
else
{
channels_[who]->start_acquisition();
}
#else
channels_[who]->start_acquisition();
#endif
@ -2021,7 +2048,20 @@ void GNSSFlowgraph::start_acquisition_helper()
{
if (channels_state_[i] == 1)
{
#if ENABLE_FPGA
if (enable_fpga_offloading_)
{
// create a task for the FPGA such that it doesn't stop the flow
std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[i]);
tmp_thread.detach();
}
else
{
channels_.at(i)->start_acquisition();
}
#else
channels_.at(i)->start_acquisition();
#endif
}
}
}

View File

@ -126,9 +126,9 @@ void* handler_DMA_galileo_e1_pcps_ambiguous_acq_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open DMA device
//**************************************************************************
// *************************************************************************
tx_fd = open("/dev/loop_tx", O_WRONLY);
if (tx_fd < 0)
{
@ -136,9 +136,9 @@ void* handler_DMA_galileo_e1_pcps_ambiguous_acq_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open input file
//**************************************************************************
// *************************************************************************
uint32_t skip_samples = 0; // static_cast<uint32_t>(FLAGS_skip_samples);
if (skip_samples + skip_used_samples > 0)

View File

@ -125,9 +125,9 @@ void* handler_DMA_gps_l1_acq_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open DMA device
//**************************************************************************
// *************************************************************************
tx_fd = open("/dev/loop_tx", O_WRONLY);
if (tx_fd < 0)
{
@ -135,9 +135,9 @@ void* handler_DMA_gps_l1_acq_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open input file
//**************************************************************************
// *************************************************************************
uint32_t skip_samples = 0; // static_cast<uint32_t>(FLAGS_skip_samples);
if (skip_samples + skip_used_samples > 0)

View File

@ -399,9 +399,9 @@ void* handler_DMA_obs_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open DMA device
//**************************************************************************
// *************************************************************************
tx_fd = open("/dev/loop_tx", O_WRONLY);
if (tx_fd < 0)
{
@ -409,9 +409,9 @@ void* handler_DMA_obs_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open input file
//**************************************************************************
// *************************************************************************
uint32_t skip_samples = static_cast<uint32_t>(FLAGS_skip_samples);

View File

@ -191,9 +191,9 @@ void* handler_DMA_trk_pull_in_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open DMA device
//**************************************************************************
// *************************************************************************
tx_fd = open("/dev/loop_tx", O_WRONLY);
if (tx_fd < 0)
{
@ -201,9 +201,9 @@ void* handler_DMA_trk_pull_in_test(void* arguments)
return nullptr;
}
//**************************************************************************
// *************************************************************************
// Open input file
//**************************************************************************
// *************************************************************************
uint32_t skip_samples = static_cast<uint32_t>(FLAGS_skip_samples);
if (skip_samples + skip_used_samples > 0)