1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-12 19:20:32 +00:00

Fix formatting

This commit is contained in:
Carles Fernandez 2024-08-08 14:05:03 +02:00
parent e4f807e210
commit a19d260281
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -13,6 +13,7 @@
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
#include "ad936x_iio_custom.h" #include "ad936x_iio_custom.h"
#include "display.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <chrono> #include <chrono>
@ -22,7 +23,6 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "display.h"
#if USE_GLOG_AND_GFLAGS #if USE_GLOG_AND_GFLAGS
#include <glog/logging.h> #include <glog/logging.h>
@ -45,6 +45,7 @@ ad936x_iio_custom::ad936x_iio_custom(int debug_level_, int log_level_)
n_channels = 0; n_channels = 0;
} }
ad936x_iio_custom::~ad936x_iio_custom() ad936x_iio_custom::~ad936x_iio_custom()
{ {
// disable TX // disable TX
@ -60,11 +61,13 @@ void ad936x_iio_custom::set_gnsstime_queue(std::shared_ptr<Concurrent_Queue<Gnss
GnssTime_queue = std::move(queue); GnssTime_queue = std::move(queue);
} }
void ad936x_iio_custom::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue) void ad936x_iio_custom::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue)
{ {
Pps_queue = std::move(queue); Pps_queue = std::move(queue);
} }
bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::string board_type) bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::string board_type)
{ {
// Find devices // Find devices
@ -126,7 +129,6 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
return false; return false;
} }
phy = iio_context_find_device(ctx, "ad9361-phy"); phy = iio_context_find_device(ctx, "ad9361-phy");
if (phy == NULL) if (phy == NULL)
@ -329,7 +331,6 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
configure_params(dds_dev, params_dds); configure_params(dds_dev, params_dds);
} }
return true; return true;
} }
@ -346,6 +347,7 @@ bool ad936x_iio_custom::check_device()
} }
} }
bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string &param, std::string &value) bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string &param, std::string &value)
{ {
struct iio_channel *chn = 0; struct iio_channel *chn = 0;
@ -387,6 +389,7 @@ bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string &param,
} }
} }
bool ad936x_iio_custom::read_die_temp(double &temp_c) bool ad936x_iio_custom::read_die_temp(double &temp_c)
{ {
std::string temp_mC_str; std::string temp_mC_str;
@ -411,6 +414,8 @@ bool ad936x_iio_custom::read_die_temp(double &temp_c)
return false; return false;
} }
} }
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_,
@ -426,7 +431,6 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
double lo_attenuation_db_, double lo_attenuation_db_,
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;
@ -611,14 +615,12 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Warning: rf_port_select write returned: " << ret << "\n"; std::cerr << "Warning: rf_port_select write returned: " << ret << "\n";
no_errors = false; no_errors = false;
} }
// ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_); // ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_);
// if (ret < 0) // if (ret < 0)
// { // {
// std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n"; // std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n";
// no_errors = false; // no_errors = false;
// } // }
long long set_rf_bw; long long set_rf_bw;
ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw); ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw);
if (ret < 0) if (ret < 0)
@ -631,7 +633,6 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Info: rf_bandwidth read returned: " << set_rf_bw << " Hz \n"; std::cerr << "Info: rf_bandwidth read returned: " << set_rf_bw << " Hz \n";
} }
if (setRXGain(0, gain_mode_rx0_, rf_gain_rx0_) == false) if (setRXGain(0, gain_mode_rx0_, rf_gain_rx0_) == false)
{ {
std::cerr << "Info: setRXGain read returned false \n"; std::cerr << "Info: setRXGain read returned false \n";
@ -663,14 +664,12 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Warning: rf_port_select write returned: " << ret << "\n"; std::cerr << "Warning: rf_port_select write returned: " << ret << "\n";
no_errors = false; no_errors = false;
} }
// ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_); // ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_);
// if (ret < 0) // if (ret < 0)
// { // {
// std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n"; // std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n";
// no_errors = false; // no_errors = false;
// } // }
long long set_rf_bw; long long set_rf_bw;
ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw); ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw);
if (ret < 0) if (ret < 0)
@ -703,6 +702,7 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
return no_errors; return no_errors;
} }
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;
@ -748,6 +748,7 @@ bool ad936x_iio_custom::get_rx_frequency(long long &freq_hz)
return true; return true;
} }
bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain_dB) bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain_dB)
{ {
if (check_device() == false) return false; if (check_device() == false) return false;
@ -780,6 +781,7 @@ 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;
@ -818,6 +820,7 @@ bool ad936x_iio_custom::calibrate([[maybe_unused]] int ch, [[maybe_unused]] doub
return true; return true;
} }
void ad936x_iio_custom::monitor_thread_fn() void ad936x_iio_custom::monitor_thread_fn()
{ {
uint32_t val; uint32_t val;
@ -869,6 +872,7 @@ void ad936x_iio_custom::monitor_thread_fn()
return; return;
} }
void ad936x_iio_custom::stop_record() void ad936x_iio_custom::stop_record()
{ {
receive_samples = false; receive_samples = false;
@ -917,6 +921,7 @@ void ad936x_iio_custom::PlutoTxEnable(bool txon)
} }
} }
void ad936x_iio_custom::setPlutoGpo(int p) void ad936x_iio_custom::setPlutoGpo(int p)
{ {
char pins[11]; char pins[11];
@ -955,7 +960,6 @@ 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;
@ -1008,6 +1012,8 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
return true; return true;
} }
void ad936x_iio_custom::get_PPS_timestamp() void ad936x_iio_custom::get_PPS_timestamp()
{ {
GnssTime tow; GnssTime tow;
@ -1044,7 +1050,6 @@ void ad936x_iio_custom::get_PPS_timestamp()
// record pps rise samplestamp associated to the absolute sample counter // record pps rise samplestamp associated to the absolute sample counter
// PPS rising edge must be associated with the corresponding uBlox time message (tx once a second) // PPS rising edge must be associated with the corresponding uBlox time message (tx once a second)
if (GnssTime_queue->timed_wait_and_pop(tow, 2000) == false) if (GnssTime_queue->timed_wait_and_pop(tow, 2000) == false)
{ {
if (receive_samples == true) if (receive_samples == true)
@ -1075,6 +1080,8 @@ void ad936x_iio_custom::get_PPS_timestamp()
} }
} }
} }
bool ad936x_iio_custom::start_sample_rx(bool ppsmode) bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
{ {
// using queues of smart pointers to preallocated buffers // using queues of smart pointers to preallocated buffers
@ -1120,9 +1127,7 @@ bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
// start sample overflow detector // start sample overflow detector
overflow_monitor_thread = std::thread(&ad936x_iio_custom::monitor_thread_fn, this); overflow_monitor_thread = std::thread(&ad936x_iio_custom::monitor_thread_fn, this);
// start PPS and GNSS Time capture thread // start PPS and GNSS Time capture thread
if (ppsmode == true) if (ppsmode == true)
{ {
capture_time_thread = std::thread(&ad936x_iio_custom::get_PPS_timestamp, this); capture_time_thread = std::thread(&ad936x_iio_custom::get_PPS_timestamp, this);
@ -1130,16 +1135,19 @@ bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
return true; return true;
} }
void ad936x_iio_custom::pop_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer) void ad936x_iio_custom::pop_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer)
{ {
used_buffers.wait_and_pop(current_buffer); used_buffers.wait_and_pop(current_buffer);
} }
void ad936x_iio_custom::push_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer) void ad936x_iio_custom::push_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer)
{ {
free_buffers.push(current_buffer); free_buffers.push(current_buffer);
} }
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;