From 55a208ede857f196ac86274238c3a03b21387a6b Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 19 Jun 2020 09:45:42 +0200 Subject: [PATCH] SRSENB: added PRACH worker plot --- srsenb/hdr/phy/prach_worker.h | 12 ++++++++++++ srsenb/src/phy/prach_worker.cc | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/srsenb/hdr/phy/prach_worker.h b/srsenb/hdr/phy/prach_worker.h index 1e0d2a848..e19eefda8 100644 --- a/srsenb/hdr/phy/prach_worker.h +++ b/srsenb/hdr/phy/prach_worker.h @@ -28,6 +28,13 @@ #include "srslte/common/threads.h" #include "srslte/interfaces/enb_interfaces.h" +// Setting ENABLE_PRACH_GUI to non zero enables a GUI showing signal received in the PRACH window. +#define ENABLE_PRACH_GUI 0 + +#if defined(ENABLE_GUI) and ENABLE_PRACH_GUI +#include +#endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI + namespace srsenb { class prach_worker : srslte::thread @@ -55,6 +62,11 @@ private: srslte_prach_cfg_t prach_cfg = {}; srslte_prach_t prach = {}; +#if defined(ENABLE_GUI) and ENABLE_PRACH_GUI + plot_real_t plot_real; + std::array plot_buffer; +#endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI + const static int sf_buffer_sz = 128 * 1024; class sf_buffer { diff --git a/srsenb/src/phy/prach_worker.cc b/srsenb/src/phy/prach_worker.cc index 4fa4404f4..3591b10e4 100644 --- a/srsenb/src/phy/prach_worker.cc +++ b/srsenb/src/phy/prach_worker.cc @@ -54,6 +54,19 @@ int prach_worker::init(const srslte_cell_t& cell_, initiated = true; sf_cnt = 0; + +#if defined(ENABLE_GUI) and ENABLE_PRACH_GUI + char title[32] = {}; + snprintf(title, sizeof(title), "PRACH buffer %d", cc_idx); + + sdrgui_init(); + plot_real_init(&plot_real); + plot_real_setTitle(&plot_real, title); + plot_real_setXAxisAutoScale(&plot_real, true); + plot_real_setYAxisAutoScale(&plot_real, true); + plot_real_addToWindowGrid(&plot_real, (char*)"PRACH", 0, cc_idx); +#endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI + return 0; } @@ -137,6 +150,12 @@ int prach_worker::run_tti(sf_buffer* b) if (prach_offsets[i] * 1e6 < max_prach_offset_us) { stack->rach_detected(b->tti, cc_idx, prach_indices[i], (uint32_t)(prach_offsets[i] * 1e6)); + +#if defined(ENABLE_GUI) and ENABLE_PRACH_GUI + uint32_t nof_samples = SRSLTE_MIN(nof_sf * SRSLTE_SF_LEN_PRB(cell.nof_prb), 3 * SRSLTE_SF_LEN_MAX); + srslte_vec_abs_cf(b->samples, plot_buffer.data(), nof_samples); + plot_real_setNewData(&plot_real, plot_buffer.data(), nof_samples); +#endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI } } }