From 9ef12859b0f3b236c0dc73d578dbe990f14dfdff Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 6 Jul 2018 11:10:26 +0200 Subject: [PATCH] register rf error handler in radio benchmark --- lib/src/radio/test/benchmark_radio.cc | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/src/radio/test/benchmark_radio.cc b/lib/src/radio/test/benchmark_radio.cc index db3371cd7..d15adaa6b 100644 --- a/lib/src/radio/test/benchmark_radio.cc +++ b/lib/src/radio/test/benchmark_radio.cc @@ -40,6 +40,11 @@ double duration = 0.01; /* in seconds, 10 ms by default */ cf_t *buffers[SRSLTE_MAX_PORTS]; bool tx_enable = false; +uint32_t num_lates = 0; +uint32_t num_overflows = 0; +uint32_t num_underflows = 0; +uint32_t num_other_error = 0; + void usage(char *prog) { printf("Usage: %s [rpstvh]\n", prog); @@ -97,6 +102,29 @@ void sig_int_handler(int signo) } } +void rf_msg(srslte_rf_error_t error) +{ + if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW) { + num_overflows++; + } else + if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_UNDERFLOW) { + num_underflows++; + } else + if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_LATE) { + num_lates++; + } else { + num_other_error++; + } +} + +void print_rf_summary(void) +{ + printf("#lates=%d\n", num_lates); + printf("#overflows=%d\n", num_overflows); + printf("#underflows=%d\n", num_underflows); + printf("#num_other_error=%d\n", num_other_error); +} + int main(int argc, char **argv) { int ret = SRSLTE_ERROR; @@ -137,6 +165,8 @@ int main(int argc, char **argv) goto clean_exit; } + radio_h->register_error_handler(rf_msg); + radio_h->set_rx_freq(freq); /* Set radio */ @@ -194,5 +224,7 @@ clean_exit: printf("Ok!\n"); } + print_rf_summary(); + return ret; }