From 5d43fc903e87769dc3483941916c78199fa99b8a Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 25 Jun 2020 12:42:21 +0200 Subject: [PATCH] UHD: fix SPP equal 0 --- lib/src/phy/rf/rf_uhd_generic.h | 12 ++++++++++-- lib/src/phy/rf/rf_uhd_imp.cc | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/src/phy/rf/rf_uhd_generic.h b/lib/src/phy/rf/rf_uhd_generic.h index 177f3156a..cc3563378 100644 --- a/lib/src/phy/rf/rf_uhd_generic.h +++ b/lib/src/phy/rf/rf_uhd_generic.h @@ -149,12 +149,20 @@ public: uhd_error get_rx_stream(const uhd::stream_args_t& args, size_t& max_num_samps) override { UHD_SAFE_C_SAVE_ERROR(this, rx_stream = nullptr; rx_stream = usrp->get_rx_stream(args); - max_num_samps = rx_stream->get_max_num_samps();) + max_num_samps = rx_stream->get_max_num_samps(); + if (max_num_samps == 0UL) { + last_error = "The maximum number of receive samples is zero."; + return UHD_ERROR_VALUE; + }) } uhd_error get_tx_stream(const uhd::stream_args_t& args, size_t& max_num_samps) override { UHD_SAFE_C_SAVE_ERROR(this, tx_stream = nullptr; tx_stream = usrp->get_tx_stream(args); - max_num_samps = tx_stream->get_max_num_samps();) + max_num_samps = tx_stream->get_max_num_samps(); + if (max_num_samps == 0UL) { + last_error = "The maximum number of transmit samples is zero."; + return UHD_ERROR_VALUE; + }) } uhd_error set_tx_gain(size_t ch, double gain) override { UHD_SAFE_C_SAVE_ERROR(this, usrp->set_tx_gain(gain, ch);) } uhd_error set_rx_gain(size_t ch, double gain) override { UHD_SAFE_C_SAVE_ERROR(this, usrp->set_rx_gain(gain, ch);) } diff --git a/lib/src/phy/rf/rf_uhd_imp.cc b/lib/src/phy/rf/rf_uhd_imp.cc index 5f8c7901f..de6563a64 100644 --- a/lib/src/phy/rf/rf_uhd_imp.cc +++ b/lib/src/phy/rf/rf_uhd_imp.cc @@ -594,7 +594,7 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) } // Samples-Per-Packet option, 0 means automatic - std::string spp = "0"; + std::string spp; if (device_addr.has_key("spp")) { spp = device_addr.pop("spp"); } @@ -809,7 +809,13 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) // Initialize TX/RX stream args handler->stream_args.cpu_format = "fc32"; handler->stream_args.otw_format = otw_format; - handler->stream_args.args.set("spp", spp); + if (not spp.empty()) { + if (spp == "0") { + Warning( + "The parameter spp is 0, some UHD versions do not handle it as default and receive method will overflow."); + } + handler->stream_args.args.set("spp", spp); + } handler->stream_args.channels.resize(nof_channels); for (size_t i = 0; i < (size_t)nof_channels; i++) { handler->stream_args.channels[i] = i;