Fixed problem in decode_pbch() with frame unaligment

master
ismagom 10 years ago
parent 103ead6298
commit fded8e40d1

@ -178,7 +178,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1);
}
if (ue_mib_init_known_cell(&ue_mib, cell, false)) {
if (ue_mib_init(&ue_mib, cell, false)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}

@ -59,7 +59,7 @@ int decode_pbch(void *uhd, ue_celldetect_result_t *found_cell, uint32_t nof_fram
goto free_and_exit;
}
if (ue_mib_init(&uemib, found_cell->cell_id, found_cell->cp)) {
if (ue_mib_init_1_92(&uemib, found_cell->cell_id, found_cell->cp)) {
fprintf(stderr, "Error initiating PBCH decoder\n");
goto free_and_exit;
}
@ -77,13 +77,13 @@ int decode_pbch(void *uhd, ue_celldetect_result_t *found_cell, uint32_t nof_fram
DEBUG("Calling ue_mib_decode() %d/%d\n", nof_frames, nof_frames_total);
n = ue_mib_sync_and_decode(&uemib, buffer, flen);
n = ue_mib_sync_and_decode_1_92(&uemib, buffer, flen);
if (n == LIBLTE_ERROR || n == LIBLTE_ERROR_INVALID_INPUTS) {
fprintf(stderr, "Error calling ue_mib_decode()\n");
goto free_and_exit;
}
if (n == MIB_FRAME_UNALIGNED) {
printf("Realigning frame\n");
INFO("Realigning frame\n",0);
// Receive some randon number of samples to try to resynchronise the frame.
if (cuhd_recv(uhd, buffer, 1500, 1)<0) {
fprintf(stderr, "Error receiving from USRP\n");
@ -147,6 +147,8 @@ int detect_cell(cell_detect_cfg_t *config, void *uhd, ue_celldetect_result_t *fo
uint32_t flen = 4800;
int n;
bzero(found_cell, sizeof(ue_celldetect_result_t));
ue_celldetect_set_N_id_2(&cd, N_id_2);
do {
@ -160,11 +162,12 @@ int detect_cell(cell_detect_cfg_t *config, void *uhd, ue_celldetect_result_t *fo
n = ue_celldetect_scan(&cd, buffer, flen);
switch(n) {
case CS_FRAME_UNALIGNED:
printf("Realigning frame\n");
INFO("Realigning frame\n",0);
if (cuhd_recv(uhd, buffer, flen/2, 1)<0) {
fprintf(stderr, "Error receiving from USRP\n");
goto free_and_exit;
}
break;
case CS_CELL_DETECTED:
ue_celldetect_get_cell(&cd, found_cell);
if (found_cell->peak > 0) {
@ -189,7 +192,7 @@ int detect_cell(cell_detect_cfg_t *config, void *uhd, ue_celldetect_result_t *fo
goto free_and_exit;
}
} while(n == 0);
} while(n == 0 || n == CS_FRAME_UNALIGNED);
free_and_exit:
free(buffer);

@ -242,7 +242,6 @@ int main(int argc, char **argv) {
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN/8];
ra_pdsch_t ra_dl;
ra_prb_t prb_alloc;
refsignal_cs_t csr_signal;
int i;
uint8_t *data;
cf_t *sf_symbols[MAX_PORTS];

@ -202,7 +202,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1);
}
if (ue_mib_init_known_cell(&ue_mib, cell, false)) {
if (ue_mib_init(&ue_mib, cell, false)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}

@ -76,7 +76,6 @@ typedef struct LIBLTE_API {
bool rnti_is_set;
uint16_t rnti;
uint32_t nof_iterations;
uint64_t average_nof_iterations_n;
float average_nof_iterations;
/* buffers */

@ -84,11 +84,11 @@ typedef struct LIBLTE_API {
} ue_mib_t;
LIBLTE_API int ue_mib_init(ue_mib_t *q,
LIBLTE_API int ue_mib_init_1_92(ue_mib_t *q,
uint32_t cell_id,
lte_cp_t cp);
LIBLTE_API int ue_mib_init_known_cell(ue_mib_t *q,
LIBLTE_API int ue_mib_init(ue_mib_t *q,
lte_cell_t cell,
bool do_sync);
@ -96,7 +96,7 @@ LIBLTE_API void ue_mib_free(ue_mib_t *q);
LIBLTE_API void ue_mib_reset(ue_mib_t *q);
LIBLTE_API int ue_mib_sync_and_decode(ue_mib_t *q,
LIBLTE_API int ue_mib_sync_and_decode_1_92(ue_mib_t *q,
cf_t *signal,
uint32_t nsamples);

@ -197,7 +197,6 @@ int pdsch_init(pdsch_t *q, lte_cell_t cell) {
ret = LIBLTE_ERROR;
q->cell = cell;
q->average_nof_iterations_n = 0;
q->max_symbols = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp);
INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports,
@ -578,10 +577,8 @@ int pdsch_decode_tb(pdsch_t *q, uint8_t *data, uint32_t tbs, uint32_t nb_e,
}
} while (q->nof_iterations < TDEC_MAX_ITERATIONS && !early_stop);
q->average_nof_iterations = VEC_CMA((float) q->nof_iterations,
q->average_nof_iterations,
q->average_nof_iterations_n);
q->average_nof_iterations_n++;
q->average_nof_iterations = VEC_EMA((float) q->nof_iterations, q->average_nof_iterations, 0.2);
/* Copy data to another buffer, removing the Codeblock CRC */
if (i < harq_process->cb_segm.C - 1) {

@ -237,7 +237,7 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value)
uint32_t conv_output_len;
if (!lte_N_id_2_isvalid(q->N_id_2)) {
fprintf(stderr, "Error finding PSS peak, N_id_2 not set\n");
fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n");
return LIBLTE_ERROR;
}

@ -36,6 +36,7 @@
#include "liblte/phy/utils/debug.h"
#include "liblte/phy/utils/vector.h"
#define FIND_FFTSIZE 64
#define FIND_SFLEN 5*SF_LEN(FIND_FFTSIZE)
@ -51,7 +52,7 @@ int ue_celldetect_init_max(ue_celldetect_t * q, uint32_t max_frames_total, uint3
bzero(q, sizeof(ue_celldetect_t));
q->candidates = malloc(sizeof(ue_celldetect_result_t) * max_frames_detected);
q->candidates = calloc(sizeof(ue_celldetect_result_t), max_frames_detected);
if (!q->candidates) {
perror("malloc");
goto clean_exit;
@ -59,12 +60,12 @@ int ue_celldetect_init_max(ue_celldetect_t * q, uint32_t max_frames_total, uint3
if (sync_init(&q->sfind, FIND_SFLEN, FIND_FFTSIZE)) {
goto clean_exit;
}
q->mode_ntimes = malloc(sizeof(uint32_t) * max_frames_detected);
q->mode_ntimes = calloc(sizeof(uint32_t), max_frames_detected);
if (!q->mode_ntimes) {
perror("malloc");
goto clean_exit;
}
q->mode_counted = malloc(sizeof(uint8_t) * max_frames_detected);
q->mode_counted = calloc(sizeof(uint8_t), max_frames_detected);
if (!q->mode_counted) {
perror("malloc");
goto clean_exit;
@ -160,9 +161,6 @@ void ue_celldetect_get_cell(ue_celldetect_t * q, ue_celldetect_result_t *found_c
}
uint32_t max_times=0, mode_pos=0;
for (i=0;i<q->nof_frames_detected;i++) {
if (q->mode_ntimes[i] > 0) {
DEBUG("ntimes[%d]=%d (CID: %d)\n",i,q->mode_ntimes[i],q->candidates[i].cell_id);
}
if (q->mode_ntimes[i] > max_times) {
max_times = q->mode_ntimes[i];
mode_pos = i;
@ -177,9 +175,11 @@ void ue_celldetect_get_cell(ue_celldetect_t * q, ue_celldetect_result_t *found_c
if (CP_ISNORM(q->candidates[i].cp)) {
nof_normal++;
}
if (q->mode_ntimes[mode_pos]) {
found_cell->peak += q->candidates[i].peak/q->mode_ntimes[mode_pos];
}
}
}
if (nof_normal > q->mode_ntimes[mode_pos]/2) {
found_cell->cp = CPNORM;
} else {

@ -145,7 +145,6 @@ void ue_dl_free(ue_dl_t *q) {
}
LIBLTE_API float mean_exec_time=0;
int frame_cnt=0;
dci_format_t ue_formats[] = {Format1A,Format1}; // Format1B should go here also
const uint32_t nof_ue_formats = 2;
@ -174,6 +173,8 @@ int ue_dl_decode(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint32
/* Get channel estimates for each port */
chest_dl_estimate(&q->chest, q->sf_symbols, q->ce, sf_idx);
/* First decode PCFICH and obtain CFI */
if (pcfich_decode(&q->pcfich, q->sf_symbols, q->ce,
chest_dl_get_noise_estimate(&q->chest), sf_idx, &cfi, &cfi_distance)<0) {
@ -230,7 +231,6 @@ int ue_dl_decode(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint32
} else {
rvidx = ra_dl.rv_idx;
}
if (rvidx == 0) {
if (pdsch_harq_setup(&q->harq_process[0], ra_dl.mcs, &ra_dl.prb_alloc)) {
fprintf(stderr, "Error configuring HARQ process\n");
@ -254,12 +254,9 @@ int ue_dl_decode(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint32
q->pkts_total++;
}
}
gettimeofday(&t[2], NULL);
get_time_interval(t);
mean_exec_time = (float) VEC_CMA((float) t[0].tv_usec, mean_exec_time, frame_cnt);
frame_cnt++;
mean_exec_time = (float) VEC_EMA((float) t[0].tv_usec, mean_exec_time, 0.01);
if (crc_rem == rnti && ret == LIBLTE_SUCCESS) {

@ -38,7 +38,7 @@
#define MIB_FIND_THRESHOLD 0.0
int ue_mib_init(ue_mib_t * q,
int ue_mib_init_1_92(ue_mib_t * q,
uint32_t cell_id,
lte_cp_t cp)
{
@ -47,10 +47,10 @@ int ue_mib_init(ue_mib_t * q,
cell.nof_prb = 6;
cell.id = cell_id;
cell.cp = cp;
return ue_mib_init_known_cell(q, cell, true);
return ue_mib_init(q, cell, true);
}
int ue_mib_init_known_cell(ue_mib_t * q,
int ue_mib_init(ue_mib_t * q,
lte_cell_t cell,
bool do_sync)
{
@ -95,7 +95,6 @@ int ue_mib_init(ue_mib_t * q,
goto clean_exit;
}
if (lte_fft_init(&q->fft, cell.cp, cell.nof_prb)) {
fprintf(stderr, "Error initializing FFT\n");
goto clean_exit;
@ -168,7 +167,6 @@ int ue_mib_decode_aligned_frame(ue_mib_t * q, cf_t *input,
if (ret < 0) {
return LIBLTE_ERROR;
}
INFO("Channel estimated for %d ports, Noise: %f\n", q->chest.cell.nof_ports,
chest_dl_get_noise_estimate(&q->chest));
/* Reset decoder if we missed a frame */
@ -216,7 +214,7 @@ void ue_mib_get_payload(ue_mib_t *q,
}
}
int ue_mib_sync_and_decode(ue_mib_t * q,
int ue_mib_sync_and_decode_1_92(ue_mib_t * q,
cf_t *signal,
uint32_t nsamples)
{

Loading…
Cancel
Save