From 6459f516d8164caf89922e46b0bc1960b3c28f50 Mon Sep 17 00:00:00 2001 From: ismagom Date: Wed, 12 Mar 2014 10:57:27 -0500 Subject: [PATCH] Fixed some minor bugs --- examples/pbch_ue.c | 21 +++++++--- examples/scan_mib.c | 10 ++--- examples/scan_pss.c | 8 ++-- lte/include/lte/modem/demod_hard.h | 2 +- lte/lib/common/src/lte.c | 2 + lte/lib/mimo/src/precoding.c | 50 ++++++++++++++++++++++-- lte/lib/ratematching/test/rm_conv_test.c | 1 + lte/lib/utils/src/cexptab.c | 3 ++ 8 files changed, 79 insertions(+), 18 deletions(-) diff --git a/examples/pbch_ue.c b/examples/pbch_ue.c index fedb9c345..e2f82bbf9 100644 --- a/examples/pbch_ue.c +++ b/examples/pbch_ue.c @@ -58,7 +58,7 @@ #define NOF_PORTS 2 float find_threshold = 40.0, track_threshold = 8.0; -int max_track_lost = 9, nof_slots = -1; +int max_track_lost = 20, nof_slots = -1; int track_len=300; char *input_file_name = NULL; int disable_plots = 0; @@ -80,7 +80,7 @@ cfo_t cfocorr; enum sync_state {FIND, TRACK}; void usage(char *prog) { - printf("Usage: %s [iagfndv]\n", prog); + printf("Usage: %s [iagfndvp]\n", prog); printf("\t-i input_file [Default use USRP]\n"); #ifndef DISABLE_UHD printf("\t-a UHD args [Default %s]\n", uhd_args); @@ -90,6 +90,7 @@ void usage(char *prog) { printf("\t UHD is disabled. CUHD library not available\n"); #endif printf("\t-n nof_frames [Default %d]\n", nof_slots); + printf("\t-p PSS threshold [Default %f]\n", find_threshold); #ifndef DISABLE_GRAPHICS printf("\t-d disable plots [Default enabled]\n"); #else @@ -100,7 +101,7 @@ void usage(char *prog) { void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "iagfndv")) != -1) { + while ((opt = getopt(argc, argv, "iagfndvp")) != -1) { switch(opt) { case 'i': input_file_name = argv[optind]; @@ -114,6 +115,9 @@ void parse_args(int argc, char **argv) { case 'f': uhd_freq = atof(argv[optind]); break; + case 'p': + find_threshold = atof(argv[optind]); + break; case 'n': nof_slots = atoi(argv[optind]); break; @@ -423,7 +427,9 @@ int main(int argc, char **argv) { find_idx += track_idx - track_len; if (nslot != sync_get_slot_id(&strack)) { INFO("Expected slot %d but got %d\n", nslot, sync_get_slot_id(&strack)); - printf("\r\n");fflush(stdout); + printf("\r\n"); + fflush(stdout); + printf("\r\n"); state = FIND; } } @@ -431,7 +437,9 @@ int main(int argc, char **argv) { /* if we missed too many PSS go back to FIND */ if (frame_cnt - last_found > max_track_lost) { INFO("%d frames lost. Going back to FIND", frame_cnt - last_found); - printf("\r\n");fflush(stdout); + printf("\r\n"); + fflush(stdout); + printf("\r\n"); state = FIND; } @@ -447,6 +455,9 @@ int main(int argc, char **argv) { last_found = frame_cnt; if (verbose == VERBOSE_NONE) { if (!nof_found_mib) { + printf("\r\n"); + fflush(stdout); + printf("\r\n"); pbch_mib_fprint(stdout, &mib); } } diff --git a/examples/scan_mib.c b/examples/scan_mib.c index 16654ff53..90bec1080 100644 --- a/examples/scan_mib.c +++ b/examples/scan_mib.c @@ -53,11 +53,11 @@ #define IS_SIGNAL(i) (10*log10f(rssi[i]) + 30 > rssi_threshold) int band, earfcn=-1; -float find_threshold = 40.0, track_threshold = 8.0; +float find_threshold = 10.0, track_threshold = 8.0; int earfcn_start=-1, earfcn_end = -1; -float rssi_threshold = -30.0; +float rssi_threshold = -45.0; int max_track_lost=9; -int nof_frames_find=8, nof_frames_track=100, nof_samples_rssi=50000; +int nof_frames_find=20, nof_frames_track=100, nof_samples_rssi=50000; int track_len=500; cf_t *input_buffer, *fft_buffer, *ce[MAX_PORTS]; @@ -72,7 +72,7 @@ int *idx_v, *idx_valid, *t; float *p2a_v; void *uhd; int nof_bands; -float uhd_gain = 30.0; +float uhd_gain = 20.0; #define MAX_EARFCN 1000 lte_earfcn_t channels[MAX_EARFCN]; @@ -232,7 +232,7 @@ void base_free() { int i; #ifndef DISABLE_UHD - cuhd_close(&uhd); + cuhd_close(uhd); #endif sync_free(&sfind); diff --git a/examples/scan_pss.c b/examples/scan_pss.c index 599a6cb06..fb754acab 100644 --- a/examples/scan_pss.c +++ b/examples/scan_pss.c @@ -49,11 +49,11 @@ int band, earfcn=-1; -float find_threshold = 40.0, track_threshold = 8.0; +float find_threshold = 10.0, track_threshold = 8.0; int earfcn_start=-1, earfcn_end = -1; -float rssi_threshold = -30.0; +float rssi_threshold = -45.0; int max_track_lost=9; -int nof_frames_find=8, nof_frames_track=100, nof_samples_rssi=50000; +int nof_frames_find=20, nof_frames_track=100, nof_samples_rssi=50000; int track_len=500; cf_t *input_buffer; @@ -184,7 +184,7 @@ int base_init(int frame_length) { void base_free() { - cuhd_close(&uhd); + cuhd_close(uhd); free(input_buffer); free(idx_v); free(idx_valid); diff --git a/lte/include/lte/modem/demod_hard.h b/lte/include/lte/modem/demod_hard.h index 4525ff7a1..c7608b5d8 100644 --- a/lte/include/lte/modem/demod_hard.h +++ b/lte/include/lte/modem/demod_hard.h @@ -54,7 +54,7 @@ typedef struct { enum modem_std std; // Symbol mapping standard (see modem_table.h) } init; - const cf_t* input; + cf_t* input; int in_len; char* output; diff --git a/lte/lib/common/src/lte.c b/lte/lib/common/src/lte.c index 8147b68d1..e475cf161 100644 --- a/lte/lib/common/src/lte.c +++ b/lte/lib/common/src/lte.c @@ -30,6 +30,7 @@ #include #include +#include #include "lte/common/base.h" @@ -156,6 +157,7 @@ char *lte_mimotype2str(mimo_type_t type) { case SPATIAL_MULTIPLEX: return "multiplex"; } + return NULL; } float get_fd(struct lte_band *band, int earfcn) { diff --git a/lte/lib/mimo/src/precoding.c b/lte/lib/mimo/src/precoding.c index 4bb5176eb..fad5947c0 100644 --- a/lte/lib/mimo/src/precoding.c +++ b/lte/lib/mimo/src/precoding.c @@ -53,8 +53,29 @@ int precoding_diversity(cf_t *x[MAX_LAYERS], cf_t *y[MAX_PORTS], int nof_ports, } return i; } else if (nof_ports == 4) { - fprintf(stderr, "Error not implemented\n"); - return -1; + int m_ap = (nof_symbols%4)?(nof_symbols*4-2):nof_symbols*4; + for (i=0;i 0) != bits[i]) { nof_errors++; diff --git a/lte/lib/utils/src/cexptab.c b/lte/lib/utils/src/cexptab.c index 235b69389..d1e13ab93 100644 --- a/lte/lib/utils/src/cexptab.c +++ b/lte/lib/utils/src/cexptab.c @@ -68,6 +68,9 @@ void cexptab_gen(cexptab_t *h, cf_t *x, float freq, int len) { if (phase >= (float) h->size) { phase -= (float) h->size; } + if (phase <= 0) { + phase += (float) h->size; + } } }