Fixed bug in ue_mib and improved pdsch_ue console output and plots

This commit is contained in:
ismagom 2014-11-17 13:04:30 +00:00
parent 5193112041
commit a21c8c7993
15 changed files with 153 additions and 139 deletions

View File

@ -267,8 +267,7 @@ int main(int argc, char **argv) {
rssi = VEC_CMA(chest_dl_get_rssi(&chest),rssi,nframes);
rsrq = VEC_CMA(chest_dl_get_rsrq(&chest),rsrq,nframes);
rsrp = VEC_CMA(chest_dl_get_rsrp(&chest),rsrp,nframes);
float noise = chest_dl_get_noise_estimate(&chest);
snr = VEC_CMA(rssi/(noise*noise*2*cell.nof_ports*fft.symbol_sz),snr,nframes);
snr = VEC_CMA(chest_dl_get_snr(&chest),snr,nframes);
nframes++;
// Plot and Printf

View File

@ -165,9 +165,6 @@ int detect_cell(cell_detect_cfg_t *config, void *uhd, ue_celldetect_result_t *fo
fprintf(stderr, "Error receiving from USRP\n");
goto free_and_exit;
}
/* FIXME: What should we do here?? */
ret = -1;
goto free_and_exit;
case CS_CELL_DETECTED:
ue_celldetect_get_cell(&cd, found_cell);
if (found_cell->peak > 0) {

View File

@ -60,13 +60,15 @@ typedef struct {
int nof_subframes;
bool disable_plots;
int force_N_id_2;
uint16_t rnti;
char *uhd_args;
float uhd_freq;
float uhd_gain;
}prog_args_t;
void args_default(prog_args_t *args) {
args->nof_subframes = -1;
args->nof_subframes = -1;
args->rnti = SIRNTI;
args->force_N_id_2 = -1; // Pick the best
args->uhd_args = "";
args->uhd_freq = -1.0;
@ -74,9 +76,10 @@ void args_default(prog_args_t *args) {
}
void usage(prog_args_t *args, char *prog) {
printf("Usage: %s [agldnv] -f rx_frequency (in Hz)\n", prog);
printf("Usage: %s [agldnrv] -f rx_frequency (in Hz)\n", prog);
printf("\t-a UHD args [Default %s]\n", args->uhd_args);
printf("\t-g UHD RX gain [Default %.2f dB]\n", args->uhd_gain);
printf("\t-r RNTI [Default 0x%x]\n",args->rnti);
printf("\t-l Force N_id_2 [Default best]\n");
#ifndef DISABLE_GRAPHICS
printf("\t-d disable plots [Default enabled]\n");
@ -90,7 +93,7 @@ void usage(prog_args_t *args, char *prog) {
void parse_args(prog_args_t *args, int argc, char **argv) {
int opt;
args_default(args);
while ((opt = getopt(argc, argv, "agldnvf")) != -1) {
while ((opt = getopt(argc, argv, "agldnvrf")) != -1) {
switch (opt) {
case 'a':
args->uhd_args = argv[optind];
@ -104,6 +107,9 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
case 'n':
args->nof_subframes = atoi(argv[optind]);
break;
case 'r':
args->rnti = atoi(argv[optind]);
break;
case 'l':
args->force_N_id_2 = atoi(argv[optind]);
break;
@ -128,6 +134,15 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
/* TODO: Do something with the output data */
uint8_t data[10000], data_unpacked[1000];
bool go_exit = false;
void sig_int_handler(int signo)
{
if (signo == SIGINT) {
go_exit = true;
}
}
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return cuhd_recv(h, data, nsamples, 1);
@ -145,14 +160,12 @@ int main(int argc, char **argv) {
ue_mib_t ue_mib;
void *uhd;
ue_dl_t ue_dl;
lte_fft_t fft;
chest_dl_t chest;
uint32_t nof_trials = 0;
uint32_t sfn = 0; // system frame number
int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint32_t sfn_offset;
float snr = 0;
parse_args(&prog_args, argc, argv);
#ifndef DISABLE_GRAPHICS
@ -160,7 +173,7 @@ int main(int argc, char **argv) {
init_plots();
}
#endif
printf("Opening UHD device...\n");
if (cuhd_open(prog_args.uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n");
@ -185,7 +198,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}
if (ue_dl_init(&ue_dl, cell, 1234)) {
if (ue_dl_init(&ue_dl, cell, 1234)) { // This is the User RNTI
fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1);
}
@ -193,83 +206,75 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}
pdsch_set_rnti(&ue_dl.pdsch, SIRNTI);
/* Initialize subframe counter */
sf_cnt = 0;
if (lte_fft_init(&fft, cell.cp, cell.nof_prb)) {
fprintf(stderr, "Error initiating FFT\n");
return -1;
}
if (chest_dl_init(&chest, cell)) {
fprintf(stderr, "Error initiating channel estimator\n");
return -1;
}
// Register Ctrl+C handler
signal(SIGINT, sig_int_handler);
/* Main loop */
while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) {
while (go_exit == false &&
(sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1))
{
ret = ue_sync_get_buffer(&ue_sync, &sf_buffer);
if (ret < 0) {
fprintf(stderr, "Error calling ue_sync_work()\n");
go_exit=true;
}
/* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */
if (ret == 1) {
if (ue_sync_get_sfidx(&ue_sync) == 0) {
pbch_decode_reset(&ue_mib.pbch);
n = ue_mib_decode_aligned_frame(&ue_mib,
sf_buffer, bch_payload_unpacked,
NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
exit(-1);
} else if (n == MIB_FOUND) {
bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
sfn = (sfn + sfn_offset)%1024;
}
}
/* We are looking for SI Blocks, search only in appropiate places */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
n = ue_dl_decode(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), sfn, SIRNTI);
if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
exit(-1);
} else if (n == 0) {
printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, ExecTime: %6.1f us, NOI: %.2f,"
"PDCCH-Det: %.3f, PDSCH-BLER: %.3f\r",
ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000,
mean_exec_time, pdsch_average_noi(&ue_dl.pdsch),
(float) ue_dl.nof_pdcch_detected/nof_trials,
(float) ue_dl.pkt_errors/ue_dl.pkts_total,nof_trials);
}
nof_trials++;
}
} else if (ret == 0) {
/*printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r",
sync_get_peak_value(&ue_sync.sfind),
ue_sync.frame_total_cnt, ue_sync.state);
*/
}
if (ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++;
if (sfn == 1024) {
sfn = 0;
if (ue_sync_get_sfidx(&ue_sync) == 0) {
pbch_decode_reset(&ue_mib.pbch);
n = ue_mib_decode_aligned_frame(&ue_mib,
sf_buffer, bch_payload_unpacked,
NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
go_exit=true;
} else if (n == MIB_FOUND) {
bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
sfn = (sfn + sfn_offset)%1024;
}
}
#ifndef DISABLE_GRAPHICS
if (!prog_args.disable_plots && ue_sync_get_sfidx(&ue_sync) == 5) {
do_plots(&ue_dl, 5);
/* We are looking for SI Blocks, search only in appropiate places */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
n = ue_dl_decode(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), sfn, prog_args.rnti);
if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
}
nof_trials++;
}
#endif
snr = VEC_CMA(chest_dl_get_snr(&ue_dl.chest),snr,sf_cnt);
}
if (ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++;
if (sfn == 1024) {
sfn = 0;
}
}
#ifndef DISABLE_GRAPHICS
if (!prog_args.disable_plots && ue_sync_get_sfidx(&ue_sync) == 5) {
do_plots(&ue_dl, 5);
}
#endif
if ((sf_cnt%10)==0) {
printf("CFO: %+6.2f KHz, SFO: %+6.2f Khz, SNR: %5.1f dB, NOI: %.2f, "
"PDCCH-Miss: %5.2f%%, PDSCH-BLER: %5.2f%% (%d blocks)\r",
ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000,
10*log10f(snr), pdsch_average_noi(&ue_dl.pdsch),
100*(1-(float) ue_dl.nof_pdcch_detected/nof_trials),
(float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,nof_trials, ue_dl.pkts_total);
}
sf_cnt++;
} // Main loop
ue_dl_free(&ue_dl);
ue_mib_free(&ue_mib);
ue_sync_free(&ue_sync);
cuhd_close(uhd);
printf("\nBye\n");
@ -291,24 +296,23 @@ int main(int argc, char **argv) {
#include "liblte/graphics/plot.h"
plot_real_t poutfft;
plot_complex_t pce;
plot_real_t pce;
plot_scatter_t pscatrecv, pscatequal;
float tmp_plot[SLOT_LEN_RE(MAX_PRB, CPNORM)];
float tmp_plot2[SLOT_LEN_RE(MAX_PRB, CPNORM)];
void init_plots() {
plot_init();
plot_real_init(&poutfft);
plot_real_setTitle(&poutfft, "Output FFT - Magnitude");
plot_real_setLabels(&poutfft, "Index", "dB");
plot_real_setYAxisScale(&poutfft, -30, 20);
plot_real_setYAxisScale(&poutfft, -60, 0);
plot_complex_init(&pce);
plot_complex_setTitle(&pce, "Channel Estimates");
plot_complex_setYAxisScale(&pce, Ip, -3, 3);
plot_complex_setYAxisScale(&pce, Q, -3, 3);
plot_complex_setYAxisScale(&pce, Magnitude, 0, 4);
plot_complex_setYAxisScale(&pce, Phase, -M_PI, M_PI);
plot_real_init(&pce);
plot_real_setTitle(&pce, "Channel Response - Magnitude");
plot_real_setLabels(&pce, "Index", "dB");
plot_real_setYAxisScale(&pce, -60, 0);
plot_scatter_init(&pscatrecv);
plot_scatter_setTitle(&pscatrecv, "Received Symbols");
@ -326,13 +330,19 @@ void do_plots(ue_dl_t *q, uint32_t sf_idx) {
uint32_t nof_re = SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp);
uint32_t nof_symbols = q->harq_process[0].prb_alloc.re_sf[sf_idx];
for (i = 0; i < nof_re; i++) {
tmp_plot[i] = 10 * log10f(cabsf(q->sf_symbols[i]));
tmp_plot[i] = 20 * log10f(cabsf(q->sf_symbols[i]));
if (isinf(tmp_plot[i])) {
tmp_plot[i] = -80;
}
}
for (i = 0; i < REFSIGNAL_NUM_SF(q->cell.nof_prb,0); i++) {
tmp_plot2[i] = 20 * log10f(cabsf(q->chest.pilot_estimates_average[0][i]));
if (isinf(tmp_plot2[i])) {
tmp_plot2[i] = -80;
}
}
plot_real_setNewData(&poutfft, tmp_plot, nof_re);
plot_complex_setNewData(&pce, q->ce[0], nof_re);
plot_real_setNewData(&pce, tmp_plot2, REFSIGNAL_NUM_SF(q->cell.nof_prb,0));
plot_scatter_setNewData(&pscatrecv, q->pdsch.pdsch_symbols[0], nof_symbols);
plot_scatter_setNewData(&pscatequal, q->pdsch.pdsch_d, nof_symbols);
}

View File

@ -99,6 +99,8 @@ LIBLTE_API int chest_dl_estimate_port(chest_dl_t *q,
uint32_t sf_idx,
uint32_t port_id);
LIBLTE_API float chest_dl_get_snr(chest_dl_t *q);
LIBLTE_API float chest_dl_get_noise_estimate(chest_dl_t *q);
LIBLTE_API float chest_dl_get_rssi(chest_dl_t *q);

View File

@ -53,8 +53,7 @@
typedef enum LIBLTE_API { SF_FIND, SF_TRACK} ue_sync_state_t;
#define TRACK_MAX_LOST 10
#define MEASURE_EXEC_TIME
//#define MEASURE_EXEC_TIME
typedef struct LIBLTE_API {
sync_t sfind;

View File

@ -39,7 +39,7 @@ typedef _Complex float cf_t;
#define VEC_CMA(data, average, n) ((data) + ((data) - (average)) / ((n)+1))
// Exponential moving average
#define VEC_EMA(data, average, alpha) ((factor)*(data)+(1-alpha)*(average))
#define VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average))
/** Return the sum of all the elements */
LIBLTE_API int vec_acc_ii(int *x, uint32_t len);

View File

@ -331,6 +331,15 @@ float chest_dl_get_noise_estimate(chest_dl_t *q) {
return vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports;
}
float chest_dl_get_snr(chest_dl_t *q) {
float noise = chest_dl_get_noise_estimate(q);
if (noise) {
return chest_dl_get_rssi(q)/(noise*2*q->cell.nof_ports*lte_symbol_sz(q->cell.nof_prb));
} else {
return 0.0;
}
}
float chest_dl_get_rssi(chest_dl_t *q) {
return q->rssi;
}

View File

@ -85,7 +85,10 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, uint16_t c_rnti,
ra_prb_get_re_dl(&ra_dl->prb_alloc, cell.nof_prb, cell.nof_ports, cell.nof_prb<10?(cfi+1):cfi, cell.cp);
ret = LIBLTE_SUCCESS;
}
} else {
fprintf(stderr, "Unsupported message type: ");
dci_msg_type_fprint(stderr, type);
}
}
return ret;
}

View File

@ -296,14 +296,6 @@ int pbch_decode_frame(pbch_t *q, uint32_t src, uint32_t dst, uint32_t n,
/* unrate matching */
rm_conv_rx(q->temp, 4 * nof_bits, q->pbch_rm_f, BCH_ENCODED_LEN);
/* FIXME: If channel estimates are zero, received LLR are NaN. Check and return error */
for (j = 0; j < BCH_ENCODED_LEN; j++) {
if (isnan(q->pbch_rm_f[j]) || isinf(q->pbch_rm_f[j])) {
printf("Some CE are NaN or Inf!\n");
return LIBLTE_ERROR;
}
}
/* decode */
viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data, BCH_PAYLOADCRC_LEN);

View File

@ -578,7 +578,6 @@ 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);

View File

@ -232,7 +232,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
{
int peak_pos;
ret = LIBLTE_ERROR;
ret = LIBLTE_SUCCESS;
if (peak_position) {
*peak_position = 0;
@ -266,7 +266,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
/* If peak is over threshold, compute CFO and SSS */
if (q->peak_value >= q->threshold) {
if (find_offset + peak_pos >= q->fft_size) {
if (find_offset + peak_pos >= q->fft_size + CP_EXT(q->fft_size)) {
q->cfo = pss_synch_cfo_compute(&q->pss, &input[find_offset+peak_pos-q->fft_size]);
if (q->sss_en) {
ret = sync_sss(q, input, find_offset + peak_pos);
@ -278,15 +278,13 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
ret = 1;
}
} else {
INFO("Warning: no space for CFO computation\n",0);
INFO("No space for CFO computation: frame starts at \n",peak_pos);
}
if (peak_position) {
*peak_position = (uint32_t) peak_pos;
}
} else {
ret = LIBLTE_SUCCESS;
}
}
INFO("SYNC ret=%d N_id_2=%d pos=%d peak=%.2f/%.2f=%.2f threshold=%.2f sf_idx=%d offset=%d\n",
ret, q->N_id_2, peak_pos, peak_unnormalized,energy,q->peak_value, q->threshold, q->sf_idx, find_offset);

View File

@ -240,6 +240,9 @@ int ue_dl_decode(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint32
}
}
if (q->harq_process[0].mcs.mod > 0) {
pdsch_set_rnti(&q->pdsch, rnti);
ret = pdsch_decode(&q->pdsch, q->sf_symbols, q->ce, chest_dl_get_noise_estimate(&q->chest), data, sf_idx,
&q->harq_process[0], rvidx);
if (ret == LIBLTE_ERROR) {

View File

@ -194,8 +194,6 @@ int ue_mib_decode_aligned_frame(ue_mib_t * q, cf_t *input,
return ret;
}
int counter1=0,counter2=0,counter3=0,counter4=0;
void ue_mib_get_payload(ue_mib_t *q,
uint8_t bch_payload[BCH_PAYLOAD_LEN],
uint32_t *nof_tx_ports,
@ -244,35 +242,37 @@ int ue_mib_sync_and_decode(ue_mib_t * q,
return -1;
}
if (ret == 0) {
counter2++;
} else if (ret == 1) {
counter4++;
}
int peak_idx_i = (int) peak_idx;
/* Check if we have space for reading the MIB and we are in Subframe #0 */
if (ret == 1 &&
nf*MIB_FRAME_SIZE_SEARCH + peak_idx_i + MIB_FRAME_SIZE_SEARCH/10 <= nsamples &&
nf*MIB_FRAME_SIZE_SEARCH + peak_idx_i - MIB_FRAME_SIZE_SEARCH/10 >= 0 &&
sync_sss_detected(&q->sfind) &&
sync_get_sf_idx(&q->sfind) == 0)
if (ret == 1)
{
INFO("Trying to decode MIB\n",0);
ret = ue_mib_decode_aligned_frame(q,
&signal[nf*MIB_FRAME_SIZE_SEARCH+peak_idx-MIB_FRAME_SIZE_SEARCH/10],
q->bch_payload, &q->nof_tx_ports, &q->sfn_offset);
counter3++;
} else if (ret == 1 && !sync_sss_detected(&q->sfind)) {
INFO("SSS not detected\n",0);
ret = 0;
if (sync_sss_detected(&q->sfind))
{
if (sync_get_sf_idx(&q->sfind) == 0)
{
if (nf*MIB_FRAME_SIZE_SEARCH + peak_idx + MIB_FRAME_SIZE_SEARCH/10 <= nsamples &&
nf*MIB_FRAME_SIZE_SEARCH + peak_idx > MIB_FRAME_SIZE_SEARCH/10)
{
// PSS and SSS detected and we have space to decode the PBCH.
INFO("Trying to decode PBCH\n",0);
ret = ue_mib_decode_aligned_frame(q,
&signal[nf*MIB_FRAME_SIZE_SEARCH+peak_idx-MIB_FRAME_SIZE_SEARCH/10],
q->bch_payload, &q->nof_tx_ports, &q->sfn_offset);
} else {
printf("Not enough space for PBCH: PSS signal is at offset %d\n",peak_idx);
ret = MIB_FRAME_UNALIGNED;
}
} else {
// Wait for subframe 0
ret = 0;
}
} else {
INFO("SSS not detected\n",0);
ret = 0; // wait to detect it
}
} else {
printf("Not enough space for PBCH\n",0);
ret = MIB_FRAME_UNALIGNED;
INFO("PSS not detected\n",0);
ret = 0; // wait to detect it?
}
counter1++;
INFO("Total: %3d - Sync0: %3d - Sync1: %3d - Tried: %3d - Peak: %4d - Ret: %d\n",counter1,counter2,counter4, counter3, peak_idx, ret);
q->frame_cnt++;
}
}

View File

@ -46,8 +46,9 @@ cf_t dummy[MAX_TIME_OFFSET];
#define CURRENT_SLOTLEN_RE SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)
#define CURRENT_SFLEN_RE SF_LEN_RE(q->cell.nof_prb, q->cell.cp)
#define FIND_THRESHOLD 1.2
#define TRACK_THRESHOLD 0.2
#define FIND_THRESHOLD 1.0
#define TRACK_THRESHOLD 0.4
#define TRACK_MAX_LOST 5
int ue_sync_init(ue_sync_t *q,
@ -186,10 +187,12 @@ int track_peak_ok(ue_sync_t *q, uint32_t track_idx) {
/* Make sure subframe idx is what we expect */
if ((q->sf_idx != sync_get_sf_idx(&q->strack)) && q->decode_sss_on_track) {
INFO("Warning: Expected SF idx %d but got %d (%d,%g - %d,%g)!\n",
q->sf_idx, sync_get_sf_idx(&q->strack), q->strack.m0, q->strack.m0_value, q->strack.m1, q->strack.m1_value);
q->sf_idx, sync_get_sf_idx(&q->strack),
q->strack.m0, q->strack.m0_value, q->strack.m1, q->strack.m1_value);
/* FIXME: What should we do in this case? */
q->sf_idx = sync_get_sf_idx(&q->strack);
q->state = SF_FIND;
//q->state = SF_FIND;
} else {
q->time_offset = ((int) track_idx - (int) CURRENT_FFTSIZE);
@ -220,7 +223,7 @@ int track_peak_no(ue_sync_t *q) {
/* if we missed too many PSS go back to FIND */
q->frame_no_cnt++;
if (q->frame_no_cnt >= TRACK_MAX_LOST) {
printf("\n%d frames lost. Going back to FIND\n", (int) q->frame_no_cnt);
INFO("\n%d frames lost. Going back to FIND\n", (int) q->frame_no_cnt);
q->state = SF_FIND;
} else {
INFO("Tracking peak not found. Peak %.3f, %d lost\n",
@ -256,8 +259,7 @@ static int receive_samples(ue_sync_t *q) {
int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) {
int ret = LIBLTE_ERROR_INVALID_INPUTS;
uint32_t track_idx;
struct timeval t[3];
if (q != NULL &&
sf_symbols != NULL &&
q->input_buffer != NULL)
@ -273,7 +275,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) {
ret = sync_find(&q->sfind, q->input_buffer, 0, &q->peak_idx);
if (ret < 0) {
fprintf(stderr, "Error finding correlation peak (%d)\n", ret);
return -1;
return LIBLTE_ERROR;
}
if (ret == 1) {
@ -286,6 +288,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) {
rlen = q->peak_idx;
}
if (q->recv_callback(q->stream, q->input_buffer, rlen) < 0) {
fprintf(stderr, "Error calling recv callback function\n");
return LIBLTE_ERROR;
}
}
@ -301,6 +304,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) {
if (q->sf_idx == 0 || q->sf_idx == 5) {
#ifdef MEASURE_EXEC_TIME
struct timeval t[3];
gettimeofday(&t[1], NULL);
#endif
@ -310,7 +314,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) {
ret = sync_find(&q->strack, q->input_buffer, CURRENT_SFLEN/2-CURRENT_FFTSIZE, &track_idx);
if (ret < 0) {
fprintf(stderr, "Error tracking correlation peak\n");
return -1;
return LIBLTE_ERROR;
}
#ifdef MEASURE_EXEC_TIME

View File

@ -239,9 +239,8 @@ int main(int argc, char **argv) {
#endif
pos = pss_synch_find_pss(&pss, input_buffer, &peak);
printf("CELL_ID: %3d CFO: %+.4f KHz, SFO: %+.4f Khz, TimeOffset: %4d, Exec: %3.2f\r",
sync_get_cell_id(&s.sfind), ue_sync_get_cfo(&s)/1000, ue_sync_get_sfo(&s)/1000, pos,
s.mean_exec_time);
printf("CELL_ID: %3d CFO: %+.4f KHz, SFO: %+.4f Khz, TimeOffset: %4d\r",
sync_get_cell_id(&s.sfind), ue_sync_get_cfo(&s)/1000, ue_sync_get_sfo(&s)/1000, pos);
fflush(stdout);
if (VERBOSE_ISINFO()) {
printf("\n");