Fix deadlock

master
Xavier Arteaga 3 years ago committed by Xavier Arteaga
parent a5130673f6
commit d4fd4c8350

@ -420,12 +420,6 @@ int srsran_ssb_set_cfg(srsran_ssb_t* q, const srsran_ssb_cfg_t* cfg)
return SRSRAN_ERROR_INVALID_INPUTS; return SRSRAN_ERROR_INVALID_INPUTS;
} }
printf("-- srate=%.2fMHz; center_freq=%.2fMHz; ssb_freq=%.2fMHz; scs=%s;\n",
cfg->srate_hz / 1e6,
cfg->center_freq_hz / 1e6,
cfg->ssb_freq_hz / 1e6,
srsran_subcarrier_spacing_to_str(cfg->scs));
// Calculate subcarrier spacing in Hz // Calculate subcarrier spacing in Hz
q->scs_hz = (float)SRSRAN_SUBC_SPACING_NR(cfg->scs); q->scs_hz = (float)SRSRAN_SUBC_SPACING_NR(cfg->scs);
@ -1133,14 +1127,6 @@ int srsran_ssb_search(srsran_ssb_t* q, const cf_t* in, uint32_t nof_samples, srs
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (fabs(q->cfg.ssb_freq_hz - 1842.05e6) < 1e6) {
printf("-- freq=%.3f; N_id=%d; EPRE=%+.2f; RSRP=%+.2f;\n",
q->cfg.ssb_freq_hz,
N_id,
measurements.epre_dB,
measurements.rsrp_dB);
}
// Save result // Save result
res->N_id = N_id; res->N_id = N_id;
res->t_offset = t_offset; res->t_offset = t_offset;

@ -146,6 +146,8 @@ phy_interface_rrc_nr::phy_nr_state_t phy_nr_sa::get_state()
void phy_nr_sa::reset_nr() void phy_nr_sa::reset_nr()
{ {
sync.reset(); sync.reset();
sync.cell_go_idle();
} }
// This function executes one part of the procedure immediately and returns to continue in the background. // This function executes one part of the procedure immediately and returns to continue in the background.
@ -157,10 +159,10 @@ bool phy_nr_sa::start_cell_search(const cell_search_args_t& req)
{ {
// TODO: verify arguments are valid before starting procedure // TODO: verify arguments are valid before starting procedure
logger.info("Cell Search: Going to IDLE");
sync.cell_go_idle();
cmd_worker_cell.add_cmd([this, req]() { cmd_worker_cell.add_cmd([this, req]() {
logger.info("Cell Search: Going to IDLE");
sync.cell_go_idle();
// Prepare cell search configuration from the request // Prepare cell search configuration from the request
nr::cell_search::cfg_t cfg = {}; nr::cell_search::cfg_t cfg = {};
cfg.srate_hz = req.srate_hz; cfg.srate_hz = req.srate_hz;

@ -185,20 +185,18 @@ sync_state::state_t sync_sa::get_state()
void sync_sa::run_state_idle() void sync_sa::run_state_idle()
{ {
#define test 1 if (not radio->is_init()) {
if (radio->is_init() && test) { return;
logger.debug("Discarding samples and sending tx_end");
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, rx_buffer);
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
radio->tx_end();
} else {
logger.debug("Sleeping 1 s");
sleep(1);
} }
logger.debug("Discarding samples and sending tx_end");
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, rx_buffer);
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
radio->tx_end();
} }
void sync_sa::run_state_cell_search() void sync_sa::run_state_cell_search()
@ -221,19 +219,8 @@ void sync_sa::run_state_cell_search()
cell_search_nof_trials++; cell_search_nof_trials++;
if (cs_ret.result == cell_search::ret_t::CELL_FOUND) {
logger.error("CELL FOUND!");
rrc_interface_phy_nr::cell_search_result_t result = {};
result.cell_found = true;
result.pci = cs_ret.ssb_res.N_id;
result.pbch_msg = cs_ret.ssb_res.pbch_msg;
result.measurements = cs_ret.ssb_res.measurements;
stack->cell_search_found_cell(result);
}
// Leave CELL_SEARCH state if error or success and transition to IDLE // Leave CELL_SEARCH state if error or success and transition to IDLE
if (/*cs_ret.result || */ cell_search_nof_trials >= cell_search_max_trials) { if (cs_ret.result == cell_search::ret_t::CELL_FOUND || cell_search_nof_trials >= cell_search_max_trials) {
phy_state.state_exit(); phy_state.state_exit();
} }
} }

@ -38,7 +38,7 @@ public:
// Wait for tick // Wait for tick
std::unique_lock<std::mutex> lock(pending_tti_mutex); std::unique_lock<std::mutex> lock(pending_tti_mutex);
while (not pending_tti and running) { while (not pending_tti and running) {
pending_tti_cvar.wait(lock); pending_tti_cvar.wait_for(lock, std::chrono::milliseconds(1));
} }
// Let the tick proceed // Let the tick proceed
@ -46,12 +46,13 @@ public:
pending_tti_cvar.notify_all(); pending_tti_cvar.notify_all();
} }
void tick() uint32_t count = 0;
void tick()
{ {
// Wait for TTI to get processed // Wait for TTI to get processed
std::unique_lock<std::mutex> lock(pending_tti_mutex); std::unique_lock<std::mutex> lock(pending_tti_mutex);
while (pending_tti) { while (pending_tti and running) {
pending_tti_cvar.wait(lock); pending_tti_cvar.wait_for(lock, std::chrono::milliseconds(1));
} }
// Let the TTI proceed // Let the TTI proceed

Loading…
Cancel
Save