SRSUE: added NR-PDSCH constellation in GUI

master
Xavier Arteaga 4 years ago committed by Andre Puschmann
parent f6b4f65f12
commit 3ee667c4a5

@ -71,6 +71,8 @@ public:
bool work_dl();
int read_pdsch_d(cf_t* pdsch_d);
private:
srslte_dl_slot_cfg_t dl_slot_cfg = {};
uint32_t cc_idx = 0;

@ -49,6 +49,8 @@ public:
cf_t* get_buffer(uint32_t cc_idx, uint32_t antenna_idx);
uint32_t get_buffer_len();
void set_tti(uint32_t tti);
int read_pdsch_d(cf_t* pdsch_d);
void start_plot();
private:
/* Inherited from thread_pool::worker. Function called every subframe to run the DL/UL processing */

@ -35,10 +35,10 @@
#include "srsgui/srsgui.h"
#include <semaphore.h>
void init_plots(srsue::lte::sf_worker* worker);
pthread_t plot_thread;
sem_t plot_sem;
static int plot_worker_id = -1;
static void init_plots(srsue::lte::sf_worker* worker);
static pthread_t plot_thread;
static sem_t plot_sem;
static int plot_worker_id = -1;
#else
#pragma message "Compiling without srsGUI support"
#endif
@ -332,6 +332,8 @@ float sf_worker::get_cfo()
#ifdef ENABLE_GUI
plot_real_t pce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS];
plot_scatter_t pconst;
plot_scatter_t pconst_nr;
bool pconst_nr_ready = false;
#define SCATTER_PDSCH_BUFFER_LEN (20 * 6 * SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM))
#define SCATTER_PDSCH_PLOT_LEN 4000
float tmp_plot[SCATTER_PDSCH_BUFFER_LEN];
@ -352,7 +354,7 @@ static uint32_t isync = 0;
static float sync_buffer[SYNC_PLOT_LEN];
#endif /* SYNC_PLOT_LEN > 0 */
void* plot_thread_run(void* arg)
static void* plot_thread_run(void* arg)
{
auto worker = (srsue::lte::sf_worker*)arg;
uint32_t row_count = 0;
@ -373,11 +375,19 @@ void* plot_thread_run(void* arg)
row_count = worker->get_rx_nof_antennas();
plot_scatter_init(&pconst);
plot_scatter_setTitle(&pconst, (char*)"PDSCH - Equalized Symbols");
plot_scatter_setTitle(&pconst, (char*)"LTE - PDSCH - Equalized Symbols");
plot_scatter_setXAxisScale(&pconst, -4, 4);
plot_scatter_setYAxisScale(&pconst, -4, 4);
plot_scatter_addToWindowGrid(&pconst, (char*)"srsue", 0, row_count);
plot_scatter_addToWindowGrid(&pconst, (char*)"srsue", 0, row_count++);
plot_scatter_init(&pconst_nr);
plot_scatter_setTitle(&pconst_nr, (char*)"NR - PDSCH - Equalized Symbols");
plot_scatter_setXAxisScale(&pconst_nr, -4, 4);
plot_scatter_setYAxisScale(&pconst_nr, -4, 4);
plot_scatter_addToWindowGrid(&pconst_nr, (char*)"srsue", 0, row_count++);
pconst_nr_ready = true;
#if CFO_PLOT_LEN > 0
plot_real_init(&pcfo);

@ -167,5 +167,12 @@ bool cc_worker::work_dl()
return true;
}
int cc_worker::read_pdsch_d(cf_t* pdsch_d)
{
uint32_t nof_re = ue_dl.carrier.nof_prb * SRSLTE_NRE * 12;
srslte_vec_cf_copy(pdsch_d, ue_dl.pdsch.d[0], nof_re);
return nof_re;
}
} // namespace nr
} // namespace srsue

@ -21,6 +21,18 @@
#include "srsue/hdr/phy/nr/sf_worker.h"
#ifdef ENABLE_GUI
#include "srsgui/srsgui.h"
#include <semaphore.h>
static void init_plots(srsue::nr::sf_worker* worker);
static pthread_t plot_thread;
static sem_t plot_sem;
static int plot_worker_id = -1;
#else
#pragma message "Compiling without srsGUI support"
#endif
namespace srsue {
namespace nr {
sf_worker::sf_worker(phy_nr_state* phy_state_, srslte::log* log) : phy_state(phy_state_), log_h(log)
@ -67,7 +79,83 @@ void sf_worker::work_imp()
for (auto& w : cc_workers) {
w->work_dl();
}
/* Tell the plotting thread to draw the plots */
#ifdef ENABLE_GUI
if ((int)get_id() == plot_worker_id) {
sem_post(&plot_sem);
}
#endif
}
int sf_worker::read_pdsch_d(cf_t* pdsch_d)
{
return cc_workers[0]->read_pdsch_d(pdsch_d);
}
void sf_worker::start_plot()
{
#ifdef ENABLE_GUI
if (plot_worker_id == -1) {
plot_worker_id = get_id();
srslte::console("Starting NR plot for worker_id=%d\n", plot_worker_id);
init_plots(this);
} else {
srslte::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id);
}
#else
srslte::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n");
#endif
}
} // namespace nr
} // namespace srsue
} // namespace srsue
#ifdef ENABLE_GUI
extern plot_scatter_t pconst_nr;
extern bool pconst_nr_ready;
#define SCATTER_PDSCH_PLOT_LEN 4000
static cf_t tmp_pconst_nr[SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)];
extern bool plot_quit;
static void* plot_thread_run(void* arg)
{
auto worker = (srsue::nr::sf_worker*)arg;
sleep(1);
int readed_pdsch_re = 0;
while (!plot_quit) {
sem_wait(&plot_sem);
if (readed_pdsch_re < SCATTER_PDSCH_PLOT_LEN) {
int n = worker->read_pdsch_d(&tmp_pconst_nr[readed_pdsch_re]);
readed_pdsch_re += n;
} else {
if (readed_pdsch_re > 0 and pconst_nr_ready) {
plot_scatter_setNewData(&pconst_nr, tmp_pconst_nr, readed_pdsch_re);
}
readed_pdsch_re = 0;
}
}
return nullptr;
}
static void init_plots(srsue::nr::sf_worker* worker)
{
if (sem_init(&plot_sem, 0, 0)) {
perror("sem_init");
exit(-1);
}
pthread_attr_t attr;
struct sched_param param = {};
param.sched_priority = 0;
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
pthread_attr_setschedparam(&attr, &param);
if (pthread_create(&plot_thread, &attr, plot_thread_run, worker)) {
perror("pthread_create");
exit(-1);
}
}
#endif

@ -441,6 +441,9 @@ void phy::set_crnti(uint16_t rnti)
void phy::start_plot()
{
lte_workers[0]->start_plot();
if (args.nof_nr_carriers > 0) {
nr_workers[0]->start_plot();
}
}
void phy::enable_pregen_signals(bool enable)

Loading…
Cancel
Save