wait with init of GUI until cell is found and initialized

with the stack refactor we've introduced a regression in which
the GUI was started too early when no cell was found yet.

this caused the GUI to be initilized with only one Tx port. When connecting
to a cell with ports, the GUI plotter would then write
into unitialized memory.
master
Andre Puschmann 5 years ago
parent 4f5e991480
commit 3127f59b4c

@ -63,15 +63,16 @@ public:
void set_crnti(uint16_t rnti); void set_crnti(uint16_t rnti);
void enable_pregen_signals(bool enabled); void enable_pregen_signals(bool enabled);
/* Methods for plotting */ ///< Methods for plotting called from GUI thread
int read_ce_abs(float* ce_abs, uint32_t tx_antenna, uint32_t rx_antenna); int read_ce_abs(float* ce_abs, uint32_t tx_antenna, uint32_t rx_antenna);
uint32_t get_cell_nof_ports() uint32_t get_cell_nof_ports()
{ {
if (cell_initiated) { // wait until cell is initialized
return cell.nof_ports; std::unique_lock<std::mutex> lock(mutex);
} else { while (!cell_initiated) {
return 1; cell_init_cond.wait(lock);
} }
return cell.nof_ports;
} }
uint32_t get_rx_nof_antennas() { return phy->args->nof_rx_ant; } uint32_t get_rx_nof_antennas() { return phy->args->nof_rx_ant; }
int read_pdsch_d(cf_t* pdsch_d); int read_pdsch_d(cf_t* pdsch_d);
@ -101,6 +102,7 @@ private:
srslte_cell_t cell = {}; srslte_cell_t cell = {};
srslte_tdd_config_t tdd_config = {}; srslte_tdd_config_t tdd_config = {};
std::condition_variable cell_init_cond;
bool cell_initiated = false; bool cell_initiated = false;
cf_t* prach_ptr = nullptr; cf_t* prach_ptr = nullptr;

@ -90,13 +90,12 @@ void sf_worker::reset()
bool sf_worker::set_cell(uint32_t cc_idx, srslte_cell_t cell_) bool sf_worker::set_cell(uint32_t cc_idx, srslte_cell_t cell_)
{ {
bool ret = false;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
if (cc_idx < cc_workers.size()) { if (cc_idx < cc_workers.size()) {
if (!cc_workers[cc_idx]->set_cell(cell_)) { if (!cc_workers[cc_idx]->set_cell(cell_)) {
Error("Setting cell for cc=%d\n", cc_idx); Error("Setting cell for cc=%d\n", cc_idx);
goto unlock; return false;
} }
} else { } else {
Error("Setting cell for cc=%d; Not enough CC workers (%zd);\n", cc_idx, cc_workers.size()); Error("Setting cell for cc=%d; Not enough CC workers (%zd);\n", cc_idx, cc_workers.size());
@ -105,11 +104,10 @@ bool sf_worker::set_cell(uint32_t cc_idx, srslte_cell_t cell_)
if (cc_idx == 0) { if (cc_idx == 0) {
cell = cell_; cell = cell_;
cell_initiated = true; cell_initiated = true;
cell_init_cond.notify_one();
} }
ret = true;
unlock: return true;
return ret;
} }
cf_t* sf_worker::get_buffer(uint32_t carrier_idx, uint32_t antenna_idx) cf_t* sf_worker::get_buffer(uint32_t carrier_idx, uint32_t antenna_idx)
@ -468,6 +466,9 @@ void* plot_thread_run(void* arg)
plot_scatter_addToWindowGrid(&psync, (char*)"srsue", 1, row_count++); plot_scatter_addToWindowGrid(&psync, (char*)"srsue", 1, row_count++);
#endif /* SYNC_PLOT_LEN > 0 */ #endif /* SYNC_PLOT_LEN > 0 */
uint32_t num_tx = worker->get_cell_nof_ports();
uint32_t num_rx = worker->get_rx_nof_antennas();
int n; int n;
int readed_pdsch_re = 0; int readed_pdsch_re = 0;
while (!plot_quit) { while (!plot_quit) {
@ -477,8 +478,8 @@ void* plot_thread_run(void* arg)
n = worker->read_pdsch_d(&tmp_plot2[readed_pdsch_re]); n = worker->read_pdsch_d(&tmp_plot2[readed_pdsch_re]);
readed_pdsch_re += n; readed_pdsch_re += n;
} else { } else {
for (uint32_t tx = 0; tx < worker->get_cell_nof_ports(); tx++) { for (uint32_t tx = 0; tx < num_tx; tx++) {
for (uint32_t rx = 0; rx < worker->get_rx_nof_antennas(); rx++) { for (uint32_t rx = 0; rx < num_rx; rx++) {
n = worker->read_ce_abs(tmp_plot, tx, rx); n = worker->read_ce_abs(tmp_plot, tx, rx);
if (n > 0) { if (n > 0) {
plot_real_setNewData(&pce[tx][rx], tmp_plot, n); plot_real_setNewData(&pce[tx][rx], tmp_plot, n);
@ -502,7 +503,6 @@ void* plot_thread_run(void* arg)
void init_plots(srsue::sf_worker* worker) void init_plots(srsue::sf_worker* worker)
{ {
if (sem_init(&plot_sem, 0, 0)) { if (sem_init(&plot_sem, 0, 0)) {
perror("sem_init"); perror("sem_init");
exit(-1); exit(-1);

@ -374,8 +374,7 @@ bool sync::cell_is_camping()
void sync::run_thread() void sync::run_thread()
{ {
sf_worker* worker = NULL; sf_worker* worker = nullptr;
sf_worker* last_worker = NULL;
cf_t* buffer[SRSLTE_MAX_RADIOS][SRSLTE_MAX_PORTS] = {NULL}; cf_t* buffer[SRSLTE_MAX_RADIOS][SRSLTE_MAX_PORTS] = {NULL};
bool is_end_of_burst = false; bool is_end_of_burst = false;

Loading…
Cancel
Save