From e2facef540107e0eac4ea789103650f775a6eae5 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 22 Sep 2021 11:31:54 +0200 Subject: [PATCH] Abort radio application if decimation/interpolation ratios are not integer --- lib/src/radio/radio.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index 27366f482..9d83d86fd 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -14,6 +14,7 @@ #include "srsran/common/standard_streams.h" #include "srsran/common/string_helpers.h" #include "srsran/config.h" +#include "srsran/support/srsran_assert.h" #include #include #include @@ -702,6 +703,13 @@ void radio::set_rx_srate(const double& srate) } } + // Assert ratio is integer + srsran_assert(((uint32_t)cur_rx_srate % (uint32_t)srate) == 0, + "The sampling rate ratio is not integer (%.2f MHz / %.2 MHz = %.3f)", + cur_rx_srate / 1e6, + srate / 1e6, + cur_rx_srate / srate); + // Update decimators uint32_t ratio = (uint32_t)ceil(cur_rx_srate / srate); for (uint32_t ch = 0; ch < nof_channels; ch++) { @@ -948,6 +956,13 @@ void radio::set_tx_srate(const double& srate) } } + // Assert ratio is integer + srsran_assert(((uint32_t)cur_tx_srate % (uint32_t)srate) == 0, + "The sampling rate ratio is not integer (%.2f MHz / %.2 MHz = %.3f)", + cur_rx_srate / 1e6, + srate / 1e6, + cur_rx_srate / srate); + // Update interpolators uint32_t ratio = (uint32_t)ceil(cur_tx_srate / srate); for (uint32_t ch = 0; ch < nof_channels; ch++) {