nbiot: address review comments

master
Andre Puschmann 5 years ago
parent 09ee7588b0
commit c145d80547

@ -188,12 +188,12 @@ void parse_args(int argc, char** argv)
void base_init()
{
// init memory
sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
sf_buffer = srslte_vec_cf_malloc(sf_n_re);
if (!sf_buffer) {
perror("malloc");
exit(-1);
}
output_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
output_buffer = srslte_vec_cf_malloc(sf_n_samples);
if (!output_buffer) {
perror("malloc");
exit(-1);
@ -681,16 +681,10 @@ int main(int argc, char** argv)
if (output_file_name && snr != -100.0) {
// compute average energy per symbol
float abs[sf_n_samples];
srslte_vec_abs_square_cf(output_buffer, abs, sf_n_samples);
float abs_avg = 0;
for (int i = 0; i < sf_n_samples; i++) {
abs_avg += abs[i];
}
abs_avg /= sf_n_samples;
float abs_avg = srslte_vec_avg_power_cf(output_buffer, sf_n_samples);
// find the noise spectral density
float snr_lin = powf(10.0f, snr / 10);
float snr_lin = srslte_convert_dB_to_power(snr);
float n0 = abs_avg / snr_lin;
float nstd = sqrtf(n0 / 2);

@ -312,10 +312,12 @@ static char mib_buffer_disp[MAX_MSG_BUF], mib_buffer_decode[MAX_MSG_BUF];
static char sib1_buffer_disp[MAX_MSG_BUF], sib1_buffer_decode[MAX_MSG_BUF];
static char sib2_buffer_disp[MAX_MSG_BUF], sib2_buffer_decode[MAX_MSG_BUF];
#if HAVE_RSRP_PLOT
#define RSRP_TABLE_MAX_IDX 1024
static float rsrp_table[RSRP_TABLE_MAX_IDX];
static uint32_t rsrp_table_index = 0;
static uint32_t rsrp_num_plot = RSRP_TABLE_MAX_IDX;
#endif // HAVE_RSRP_PLOT
#endif // ENABLE_GUI
uint32_t sfn = 0; // system frame number
@ -400,18 +402,18 @@ int main(int argc, char** argv)
float nsss_peak_value;
int input_len = srate * 10 / 1000 * 2; // capture two full frames to make sure we have one NSSS
cf_t* buffer = malloc(sizeof(cf_t) * input_len * 2);
cf_t* buffer = srslte_vec_cf_malloc(input_len * 2);
if (!buffer) {
perror("malloc");
exit(-1);
}
if (srslte_nsss_synch_init(&nsss, cell, input_len, srate / 15000)) {
if (srslte_nsss_synch_init(&nsss, input_len, srate / 15000)) {
fprintf(stderr, "Error initializing NSSS object\n");
exit(-1);
}
srslte_rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf, false);
n = srslte_rf_recv(&rf, buffer, input_len, 1);
if (n != input_len) {
fprintf(stderr, "Error receiving samples\n");
@ -423,7 +425,7 @@ int main(int argc, char** argv)
printf("Detecting NSSS signal .. ");
fflush(stdout);
uint32_t sfn_partial;
srslte_nsss_sync_find(&nsss, buffer, &nsss_peak_value, (int*)&cell.n_id_ncell, &sfn_partial);
srslte_nsss_sync_find(&nsss, buffer, &nsss_peak_value, (uint32_t*)&cell.n_id_ncell, &sfn_partial);
printf("done!");
srslte_nsss_synch_free(&nsss);
free(buffer);

@ -209,42 +209,42 @@ int srslte_npdsch_init(srslte_npdsch_t* q)
q->encoder.tail_biting = true;
memcpy(q->encoder.poly, poly, 3 * sizeof(int));
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->d = srslte_vec_cf_malloc(q->max_re);
if (!q->d) {
goto clean;
}
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->ce[i] = srslte_vec_cf_malloc(q->max_re);
if (!q->ce[i]) {
goto clean;
}
for (int k = 0; k < q->max_re / 2; k++) {
q->ce[i][k] = 1;
}
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->x[i] = srslte_vec_cf_malloc(q->max_re);
if (!q->x[i]) {
goto clean;
}
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->symbols[i] = srslte_vec_cf_malloc(q->max_re);
if (!q->symbols[i]) {
goto clean;
}
q->sib_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->sib_symbols[i] = srslte_vec_cf_malloc(q->max_re);
if (!q->sib_symbols[i]) {
goto clean;
}
}
q->llr = srslte_vec_malloc(sizeof(float) * q->max_re * 2);
q->llr = srslte_vec_f_malloc(q->max_re * 2);
if (!q->llr) {
goto clean;
}
bzero(q->llr, sizeof(float) * q->max_re * 2);
q->temp = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_NPDSCH_MAX_TBS_CRC);
q->temp = srslte_vec_u8_malloc(SRSLTE_NPDSCH_MAX_TBS_CRC);
if (!q->temp) {
goto clean;
}
q->rm_b = srslte_vec_malloc(sizeof(float) * q->max_re * 2);
q->rm_b = srslte_vec_u8_malloc(q->max_re * 2);
if (!q->rm_b) {
goto clean;
}
@ -412,7 +412,11 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
}
total_syms += cfg->nbits.nof_re;
}
assert(total_syms == cfg->grant.nof_sf * cfg->nbits.nof_re);
if (total_syms != cfg->grant.nof_sf * cfg->nbits.nof_re) {
fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->grant.nof_sf * cfg->nbits.nof_re, total_syms);
return SRSLTE_ERROR;
}
#if DUMP_SIGNALS
if (SRSLTE_VERBOSE_ISDEBUG()) {
@ -445,7 +449,7 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q,
// demodulate symbols
srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, q->llr, cfg->grant.nof_sf * cfg->nbits.nof_re);
#if 0
#if DUMP_SIGNALS
uint8_t demodbuf[320];
hard_qpsk_demod(q->d,demodbuf,cfg->nbits.nof_re);
@ -567,7 +571,7 @@ int srslte_npdsch_encode_rnti(srslte_npdsch_t* q,
{
if (rnti != q->rnti) {
srslte_sequence_t seq;
// FIXME: skip sequence init if cfg->is_encoded==true
// TODO: skip sequence init if cfg->is_encoded==true
if (srslte_sequence_npdsch(&seq,
rnti,
0,

@ -118,7 +118,7 @@ void parse_args(int argc, char** argv)
}
break;
case 'x':
snr = atof(argv[optind]);
snr = strtof(argv[optind], NULL);
break;
case 'v':
srslte_verbose++;
@ -142,7 +142,7 @@ int base_init()
}
flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb)));
buff_ptrs[0] = malloc(flen * sizeof(cf_t));
buff_ptrs[0] = srslte_vec_cf_malloc(flen);
if (!buff_ptrs[0]) {
perror("malloc");
exit(-1);

Loading…
Cancel
Save