1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-07-03 18:33:15 +00:00

Apply clang-tidy

This commit is contained in:
Carles Fernandez 2022-05-31 07:34:12 +02:00
parent 59aced3b78
commit 037ad07478
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 17 additions and 16 deletions

View File

@ -22,6 +22,7 @@
#include <fstream> // for ifstream #include <fstream> // for ifstream
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <utility>
#include <vector> #include <vector>
/* check return value of attr_write function */ /* check return value of attr_write function */
@ -91,6 +92,7 @@ bool get_ad9361_stream_ch(struct iio_context *ctx __attribute__((unused)), enum
return *chn != nullptr; return *chn != nullptr;
} }
/* finds AD9361 phy IIO configuration channel with id chid */ /* finds AD9361 phy IIO configuration channel with id chid */
bool get_phy_chan(struct iio_device *dev, 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)
{ {
@ -116,6 +118,7 @@ bool get_phy_chan(struct iio_device *dev, enum iodev d, int chid, struct iio_cha
} }
} }
/* finds AD9361 local oscillator IIO configuration channels */ /* finds AD9361 local oscillator IIO configuration channels */
bool get_lo_chan(struct iio_device *dev, enum iodev d, int chid, struct iio_channel **chn) bool get_lo_chan(struct iio_device *dev, enum iodev d, int chid, struct iio_channel **chn)
{ {
@ -152,7 +155,8 @@ void cfg_ad9361_streaming_ch(struct stream_cfg *cfg, iio_channel *chn)
wr_ch_lli(chn, "sampling_frequency", cfg->fs_hz); wr_ch_lli(chn, "sampling_frequency", cfg->fs_hz);
} }
int setup_filter(std::string filter_source_, uint64_t bandwidth_, uint64_t sample_rate_, uint64_t freq_, const std::string &rf_port_select_,
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_) 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; int ret;
@ -251,6 +255,7 @@ int setup_filter(std::string filter_source_, uint64_t bandwidth_, uint64_t sampl
return 0; 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 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; int ret;
@ -304,6 +309,7 @@ int setup_device_parameters(iio_device *ad9361_phy_dev, bool quadrature_, bool r
return ret; return ret;
} }
bool config_ad9361_rx_local(uint64_t bandwidth_, bool config_ad9361_rx_local(uint64_t bandwidth_,
uint64_t sample_rate_, uint64_t sample_rate_,
uint64_t freq0_, uint64_t freq0_,
@ -325,7 +331,6 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
{ {
// RX stream config // RX stream config
struct iio_context *ctx; struct iio_context *ctx;
// Streaming devices // Streaming devices
struct iio_device *rx; struct iio_device *rx;
@ -387,7 +392,6 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
} }
// set-up AD9361-A stream device // set-up AD9361-A stream device
std::string rx_stream_dev_a = (enable_ad9361_b ? RX_STREAM_DEV_A : RX_STREAM_DEV); 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"; std::cout << "* Acquiring " << rx_stream_dev_a << " streaming device\n";
rx = iio_context_find_device(ctx, rx_stream_dev_a.c_str()); rx = iio_context_find_device(ctx, rx_stream_dev_a.c_str());
@ -425,7 +429,6 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
if (enable_ad9361_b) if (enable_ad9361_b)
{ {
// set-up AD9361-B stream device // set-up AD9361-B stream device
std::cout << "* Acquiring " << RX_STREAM_DEV_B << " streaming device\n"; std::cout << "* Acquiring " << RX_STREAM_DEV_B << " streaming device\n";
rx = iio_context_find_device(ctx, RX_STREAM_DEV_B.c_str()); rx = iio_context_find_device(ctx, RX_STREAM_DEV_B.c_str());
if (!rx) if (!rx)
@ -624,7 +627,7 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
{ {
return false; return false;
} }
if (setup_filter(filter_source_, bandwidth_, sample_rate_, freq_, rf_port_select_, ad9361_phy, rx_chan0, chn, 0, filter_filename_, Fpass_, Fstop_) == -1) 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)
{ {
return false; return false;
} }
@ -1235,6 +1238,7 @@ bool disable_ad9361_rx_local()
return true; return true;
} }
bool disable_ad9361_rx_remote(const std::string &remote_host) bool disable_ad9361_rx_remote(const std::string &remote_host)
{ {
struct iio_context *ctx; struct iio_context *ctx;

View File

@ -31,7 +31,7 @@ int Fpga_DMA::DMA_open()
return tx_channel.fd; 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); PROT_READ | PROT_WRITE, MAP_SHARED, tx_channel.fd, 0);
if (tx_channel.buf_ptr == MAP_FAILED) 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() const
{ {
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture #if INTPTR_MAX == INT64_MAX // 64-bit processor architecture
return &tx_channel.buf_ptr[0].buffer; 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 #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'; std::cerr << "Proxy DMA Tx transfer error " << '\n';
return -1; return -1;
} }
#else // 32-bit processor architecture #else // 32-bit processor architecture
const int num_bytes_sent = write(tx_fd, buffer.data(), nbytes); const int num_bytes_sent = write(tx_fd, buffer.data(), nbytes);
if (num_bytes_sent != nbytes) if (num_bytes_sent != nbytes)
{ {
return -1; return -1;
} }
#endif #endif
return 0; return 0;
} }
int Fpga_DMA::DMA_close()
int Fpga_DMA::DMA_close() const
{ {
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture #if INTPTR_MAX == INT64_MAX // 64-bit processor architecture
if (munmap(tx_channel.buf_ptr, sizeof(struct channel_buffer))) if (munmap(tx_channel.buf_ptr, sizeof(struct channel_buffer)))

View File

@ -78,17 +78,17 @@ public:
/*! /*!
* \brief Obtain DMA buffer address. * \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) const;
/*! /*!
* \brief Transfer DMA data * \brief Transfer DMA data
*/ */
int DMA_write(int nbytes); int DMA_write(int nbytes) const;
/*! /*!
* \brief Close the DMA device driver * \brief Close the DMA device driver
*/ */
int DMA_close(void); int DMA_close(void) const;
private: private:
#if INTPTR_MAX == INT64_MAX // 64-bit processor architecture #if INTPTR_MAX == INT64_MAX // 64-bit processor architecture