From 2dbbd8b4660bc82d9dd01baa95781d5a838b87c0 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 2 Dec 2019 17:46:26 +0100 Subject: [PATCH] Minor esthetic changes --- lib/examples/pdsch_enodeb.c | 18 +++++++++--------- lib/src/phy/rf/rf_utils.c | 6 +++--- lib/src/phy/sync/sync.c | 10 +++++----- lib/src/phy/ue/ue_cell_search.c | 4 +++- lib/src/phy/ue/ue_mib.c | 4 ++-- lib/src/phy/ue/ue_sync.c | 30 ++++++++++++++++-------------- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 96107fc07..a272f4f64 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -825,7 +825,7 @@ int main(int argc, char **argv) { nf = 0; bool send_data = false; - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { srslte_softbuffer_tx_reset(softbuffers[i]); } @@ -835,15 +835,15 @@ int main(int argc, char **argv) { #endif ZERO_OBJECT(pdsch_cfg); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - pdsch_cfg.softbuffers.tx[i] = softbuffers[i]; + for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) { + pdsch_cfg.softbuffers.tx[j] = softbuffers[j]; } pdsch_cfg.rnti = UE_CRNTI; pmch_cfg.pdsch_cfg = pdsch_cfg; while ((nf < nof_frames || nof_frames == -1) && !go_exit) { - for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) { + for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1) && !go_exit; sf_idx++) { /* Set Antenna port resource elements to zero */ bzero(sf_symbols[0], sizeof(cf_t) * sf_n_re); @@ -944,7 +944,7 @@ int main(int argc, char **argv) { sem_post(&net_sem); } } - }else{ // We're sending MCH on subframe 1 - PDCCH + PMCH + } else { // We're sending MCH on subframe 1 - PDCCH + PMCH dl_sf.sf_type = SRSLTE_SF_MBSFN; /* Force 1 word and MCS 2 */ @@ -960,8 +960,8 @@ int main(int argc, char **argv) { exit(-1); } - for (int i = 0; i < pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8; i++) { - data_mbms[i] = i % 255; + for (int j = 0; j < pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8; j++) { + data_mbms[j] = j % 255; } pmch_cfg.area_id = mbsfn_area_id; @@ -985,11 +985,11 @@ int main(int argc, char **argv) { } /* Transform to OFDM symbols */ - if(mch_table[sf_idx] == 0 || mbsfn_area_id < 0){ + if (mch_table[sf_idx] == 0 || mbsfn_area_id < 0) { for (i = 0; i < cell.nof_ports; i++) { srslte_ofdm_tx_sf(&ifft[i]); } - }else{ + } else { srslte_ofdm_tx_sf(&ifft_mbsfn); } diff --git a/lib/src/phy/rf/rf_utils.c b/lib/src/phy/rf/rf_utils.c index 619f90844..f3b6f33ba 100644 --- a/lib/src/phy/rf/rf_utils.c +++ b/lib/src/phy/rf/rf_utils.c @@ -184,12 +184,13 @@ int rf_cell_search(srslte_rf_t *rf, uint32_t nof_rx_antennas, } else { ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); } + + srslte_rf_stop_rx_stream(rf); + if (ret < 0) { - srslte_rf_stop_rx_stream(rf); ERROR("Error searching cell\n"); return SRSLTE_ERROR; } else if (ret == 0) { - srslte_rf_stop_rx_stream(rf); ERROR("Could not find any cell in this frequency\n"); return SRSLTE_SUCCESS; } @@ -221,7 +222,6 @@ int rf_cell_search(srslte_rf_t *rf, uint32_t nof_rx_antennas, *cfo = found_cells[max_peak_cell].cfo; } - srslte_rf_stop_rx_stream(rf); srslte_ue_cellsearch_free(&cs); return ret; diff --git a/lib/src/phy/sync/sync.c b/lib/src/phy/sync/sync.c index 42fd2296c..56a56bbb3 100644 --- a/lib/src/phy/sync/sync.c +++ b/lib/src/phy/sync/sync.c @@ -321,7 +321,7 @@ static void generate_freq_sss(srslte_sync_t* q, uint32_t N_id_1) srslte_dft_run_c(&q->idftp_sss, symbol, q->sss_signal[n]); } q->sss_generated = true; - INFO("Generated SSS for N_id_1=%d, cell_id=%d\n", N_id_1, cell_id); + DEBUG("Generated SSS for N_id_1=%d, cell_id=%d\n", N_id_1, cell_id); } int srslte_sync_set_N_id_1(srslte_sync_t* q, uint32_t N_id_1) @@ -523,7 +523,7 @@ static bool sync_sss_symbol(srslte_sync_t* q, const cf_t* input, uint32_t* sf_id } *N_id_1 = q->N_id_1; *corr = ratio; - INFO("SSS correlation with N_id_1=%d, sf0=%.2f, sf5=%.2f, sf_idx=%d, ratio=%.1f\n", + DEBUG("SSS correlation with N_id_1=%d, sf0=%.2f, sf5=%.2f, sf_idx=%d, ratio=%.1f\n", q->N_id_1, res[0], res[1], @@ -668,7 +668,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin q->cfo_cp_mean = SRSLTE_VEC_EMA(cfo_cp, q->cfo_cp_mean, q->cfo_ema_alpha); } - INFO("CP-CFO: estimated=%f, mean=%f\n", cfo_cp, q->cfo_cp_mean); + DEBUG("CP-CFO: estimated=%f, mean=%f\n", cfo_cp, q->cfo_cp_mean); /* Correct CFO with the averaged CFO estimation */ srslte_cfo_correct(&q->cfo_corr_frame, input_ptr, q->temp, -q->cfo_cp_mean / q->fft_size); @@ -686,7 +686,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin } } - INFO("PSS: id=%d, peak_pos=%d, peak_value=%f\n", q->N_id_2, peak_pos, q->peak_value); + DEBUG("PSS: id=%d, peak_pos=%d, peak_value=%f\n", q->N_id_2, peak_pos, q->peak_value); // Save peak position if (peak_position) { @@ -719,7 +719,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin q->cfo_pss_mean = SRSLTE_VEC_EMA(q->cfo_pss, q->cfo_pss_mean, q->cfo_ema_alpha); } - INFO("PSS-CFO: filter=%s, estimated=%f, mean=%f\n", + DEBUG("PSS-CFO: filter=%s, estimated=%f, mean=%f\n", q->pss_filtering_enabled ? "yes" : "no", q->cfo_pss, q->cfo_pss_mean); diff --git a/lib/src/phy/ue/ue_cell_search.c b/lib/src/phy/ue/ue_cell_search.c index a52bb1670..1ce21c70b 100644 --- a/lib/src/phy/ue/ue_cell_search.c +++ b/lib/src/phy/ue/ue_cell_search.c @@ -121,6 +121,7 @@ int srslte_ue_cellsearch_init_multi(srslte_ue_cellsearch_t* q, for (int i = 0; i < nof_rx_antennas; i++) { q->sf_buffer[i] = srslte_vec_malloc(3 * sizeof(cf_t) * SRSLTE_SF_LEN_PRB(100)); + bzero(q->sf_buffer[i], 3 * sizeof(cf_t) * SRSLTE_SF_LEN_PRB(100)); } q->nof_rx_antennas = nof_rx_antennas; @@ -263,6 +264,7 @@ int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q, uint32_t nof_detected_cells = 0; for (uint32_t N_id_2=0;N_id_2<3 && ret >= 0;N_id_2++) { + INFO("CELL SEARCH: Starting scan for N_id_2=%d\n", N_id_2); ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); if (ret < 0) { ERROR("Error searching cell\n"); @@ -319,7 +321,7 @@ int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t * q, q->candidates[nof_detected_frames].psr = srslte_sync_get_peak_value(&q->ue_sync.sfind); q->candidates[nof_detected_frames].cfo = 15000 * srslte_sync_get_cfo(&q->ue_sync.sfind); q->candidates[nof_detected_frames].frame_type = srslte_ue_sync_get_frame_type(&q->ue_sync); - DEBUG("CELL SEARCH: [%d/%d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s, CFO=%.1f KHz\n", + INFO("CELL SEARCH: [%d/%d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s, CFO=%.1f KHz\n", nof_detected_frames, nof_scanned_frames, q->nof_valid_frames, diff --git a/lib/src/phy/ue/ue_mib.c b/lib/src/phy/ue/ue_mib.c index f973862ba..7cbffbe9e 100644 --- a/lib/src/phy/ue/ue_mib.c +++ b/lib/src/phy/ue/ue_mib.c @@ -160,12 +160,12 @@ int srslte_ue_mib_decode(srslte_ue_mib_t * q, if (ret < 0) { ERROR("Error decoding PBCH (%d)\n", ret); } else if (ret == 1) { - INFO("MIB decoded: %u\n", q->frame_cnt); + INFO("MIB decoded: %u, snr=%.1f dB\n", q->frame_cnt, q->chest_res.snr_db); srslte_ue_mib_reset(q); ret = SRSLTE_UE_MIB_FOUND; } else { ret = SRSLTE_UE_MIB_NOTFOUND; - INFO("MIB not decoded: %u\n", q->frame_cnt); + INFO("MIB not decoded: %u, snr=%.1f dB\n", q->frame_cnt, q->chest_res.snr_db); q->frame_cnt++; } diff --git a/lib/src/phy/ue/ue_sync.c b/lib/src/phy/ue/ue_sync.c index 9f49d3478..2b56d5b3e 100644 --- a/lib/src/phy/ue/ue_sync.c +++ b/lib/src/phy/ue/ue_sync.c @@ -136,17 +136,16 @@ void srslte_ue_sync_reset(srslte_ue_sync_t *q) { q->frame_find_cnt = 0; } -int srslte_ue_sync_start_agc(srslte_ue_sync_t* q, - float(set_gain_callback)(void*, float), - float min_gain, - float max_gain, - float init_gain_value) -{ +int srslte_ue_sync_start_agc(srslte_ue_sync_t *q, + float (set_gain_callback)(void *, float), + float min_gain_db, + float max_gain_db, + float init_gain_value_db) { int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream); q->do_agc = n==0?true:false; if (q->do_agc) { - srslte_agc_set_gain_range(&q->agc, min_gain, max_gain); - srslte_agc_set_gain(&q->agc, init_gain_value); + srslte_agc_set_gain_range(&q->agc, min_gain_db, max_gain_db); + srslte_agc_set_gain(&q->agc, init_gain_value_db); srslte_ue_sync_set_agc_period(q, 4); } return n; @@ -595,7 +594,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) /* Adjust current CFO estimation with PSS * Since sync track has enabled only PSS-based correlation, get_cfo() returns that value only, already filtered. */ - INFO("TRACK: cfo_current=%f, cfo_strack=%f\n", 15000*q->cfo_current_value, 15000*srslte_sync_get_cfo(&q->strack)); + DEBUG("TRACK: cfo_current=%f, cfo_strack=%f\n", 15000*q->cfo_current_value, 15000*srslte_sync_get_cfo(&q->strack)); if (15000*fabsf(srslte_sync_get_cfo(&q->strack)) > q->cfo_pss_min) { q->cfo_current_value += srslte_sync_get_cfo(&q->strack)*q->cfo_loop_bw_pss; q->pss_stable_cnt = 0; @@ -765,9 +764,10 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_P srslte_agc_process(&q->agc, input_buffer[0], q->sf_len); } - INFO("SYNC FIND: sf_idx=%d, ret=%d, next_state=%d\n", q->sf_idx, ret, q->state); + INFO("SYNC FIND: sf_idx=%d, ret=%d, peak_pos=%d, peak_value=%.2f, mean_cp_cfo=%.2f, mean_pss_cfo=%.2f, total_cfo_khz=%.1f\n", q->sf_idx, ret, q->peak_idx, + q->sfind.peak_value, q->sfind.cfo_cp_mean, q->sfind.cfo_pss_mean, 15 * srslte_sync_get_cfo(&q->sfind)); - break; + break; case SF_TRACK: ret = 1; @@ -829,10 +829,12 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_P } q->frame_total_cnt++; - } - - INFO("SYNC TRACK: sf_idx=%d, ret=%d, next_state=%d\n", q->sf_idx, ret, q->state); + INFO("SYNC TRACK: sf_idx=%d, ret=%d, peak_pos=%d, peak_value=%.2f, mean_cp_cfo=%.2f, mean_pss_cfo=%.2f, total_cfo_khz=%.1f\n", q->sf_idx, ret, track_idx, + q->strack.peak_value, q->strack.cfo_cp_mean, q->strack.cfo_pss_mean, 15 * srslte_sync_get_cfo(&q->strack)); + } else { + INFO("SYNC TRACK: sf_idx=%d, ret=%d, next_state=%d\n", q->sf_idx, ret, q->state); + } break; } }