mirror of https://github.com/PentHertz/srsLTE.git
Fixed bug when receiving all zeros samples
This commit is contained in:
parent
6459f516d8
commit
f588d670ad
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
#define NOF_PORTS 2
|
#define NOF_PORTS 2
|
||||||
|
|
||||||
float find_threshold = 40.0, track_threshold = 8.0;
|
float find_threshold = 30.0, track_threshold = 10.0;
|
||||||
int max_track_lost = 20, nof_slots = -1;
|
int max_track_lost = 20, nof_slots = -1;
|
||||||
int track_len=300;
|
int track_len=300;
|
||||||
char *input_file_name = NULL;
|
char *input_file_name = NULL;
|
||||||
|
@ -65,7 +65,7 @@ int disable_plots = 0;
|
||||||
|
|
||||||
int go_exit=0;
|
int go_exit=0;
|
||||||
|
|
||||||
float uhd_freq = 2400000000.0, uhd_gain = 20.0;
|
float uhd_freq = 2600000000.0, uhd_gain = 20.0;
|
||||||
char *uhd_args = "";
|
char *uhd_args = "";
|
||||||
|
|
||||||
filesource_t fsrc;
|
filesource_t fsrc;
|
||||||
|
@ -328,6 +328,7 @@ int main(int argc, char **argv) {
|
||||||
float cfo;
|
float cfo;
|
||||||
int n;
|
int n;
|
||||||
int nof_found_mib = 0;
|
int nof_found_mib = 0;
|
||||||
|
float timeoffset = 0;
|
||||||
|
|
||||||
#ifdef DISABLE_UHD
|
#ifdef DISABLE_UHD
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
|
@ -398,18 +399,23 @@ int main(int argc, char **argv) {
|
||||||
INFO("FIND %3d:\tPAR=%.2f\n", frame_cnt, sync_get_peak_to_avg(&sfind));
|
INFO("FIND %3d:\tPAR=%.2f\n", frame_cnt, sync_get_peak_to_avg(&sfind));
|
||||||
if (find_idx != -1) {
|
if (find_idx != -1) {
|
||||||
/* if found peak, go to track and set track threshold */
|
/* if found peak, go to track and set track threshold */
|
||||||
frame_cnt = -1;
|
|
||||||
last_found = 0;
|
|
||||||
sync_set_threshold(&strack, track_threshold);
|
|
||||||
sync_force_N_id_2(&strack, sync_get_N_id_2(&sfind));
|
|
||||||
cell_id = sync_get_cell_id(&sfind);
|
cell_id = sync_get_cell_id(&sfind);
|
||||||
mib_decoder_init(cell_id);
|
if (cell_id != -1) {
|
||||||
nof_found_mib = 0;
|
frame_cnt = -1;
|
||||||
nslot = sync_get_slot_id(&sfind);
|
last_found = 0;
|
||||||
nslot=(nslot+10)%20;
|
sync_set_threshold(&strack, track_threshold);
|
||||||
cfo = 0;
|
sync_force_N_id_2(&strack, sync_get_N_id_2(&sfind));
|
||||||
printf("\n");
|
mib_decoder_init(cell_id);
|
||||||
state = TRACK;
|
nof_found_mib = 0;
|
||||||
|
nslot = sync_get_slot_id(&sfind);
|
||||||
|
nslot=(nslot+10)%20;
|
||||||
|
cfo = 0;
|
||||||
|
timeoffset = 0;
|
||||||
|
printf("\n");
|
||||||
|
state = TRACK;
|
||||||
|
} else {
|
||||||
|
printf("cellid=-1\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (verbose == VERBOSE_NONE) {
|
if (verbose == VERBOSE_NONE) {
|
||||||
printf("Finding PSS... PAR=%.2f\r", sync_get_peak_to_avg(&sfind));
|
printf("Finding PSS... PAR=%.2f\r", sync_get_peak_to_avg(&sfind));
|
||||||
|
@ -423,8 +429,10 @@ int main(int argc, char **argv) {
|
||||||
if (track_idx != -1) {
|
if (track_idx != -1) {
|
||||||
/* compute cumulative moving average CFO */
|
/* compute cumulative moving average CFO */
|
||||||
cfo = (sync_get_cfo(&strack) + frame_cnt * cfo) / (frame_cnt + 1);
|
cfo = (sync_get_cfo(&strack) + frame_cnt * cfo) / (frame_cnt + 1);
|
||||||
|
/* compute cumulative moving average time offset */
|
||||||
|
timeoffset = (float) (track_idx-track_len + timeoffset * frame_cnt) / (frame_cnt + 1);
|
||||||
last_found = frame_cnt;
|
last_found = frame_cnt;
|
||||||
find_idx += track_idx - track_len;
|
find_idx = (find_idx + track_idx - track_len)%FLEN;
|
||||||
if (nslot != sync_get_slot_id(&strack)) {
|
if (nslot != sync_get_slot_id(&strack)) {
|
||||||
INFO("Expected slot %d but got %d\n", nslot, sync_get_slot_id(&strack));
|
INFO("Expected slot %d but got %d\n", nslot, sync_get_slot_id(&strack));
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
|
@ -432,6 +440,9 @@ int main(int argc, char **argv) {
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
state = FIND;
|
state = FIND;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* if sync not found, adjust time offset with the averaged value */
|
||||||
|
find_idx = (find_idx + (int) timeoffset)%FLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we missed too many PSS go back to FIND */
|
/* if we missed too many PSS go back to FIND */
|
||||||
|
@ -448,11 +459,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
cfo_correct(&cfocorr, input_buffer, -cfo/128);
|
cfo_correct(&cfocorr, input_buffer, -cfo/128);
|
||||||
|
|
||||||
if (nslot == 0) {
|
if (nslot == 0 && find_idx + 960 < FLEN) {
|
||||||
INFO("Finding MIB at idx %d\n", find_idx);
|
INFO("Finding MIB at idx %d\n", find_idx);
|
||||||
if (mib_decoder_run(&input_buffer[find_idx], &mib)) {
|
if (mib_decoder_run(&input_buffer[find_idx], &mib)) {
|
||||||
INFO("MIB detected attempt=%d\n", frame_cnt);
|
INFO("MIB detected attempt=%d\n", frame_cnt);
|
||||||
last_found = frame_cnt;
|
|
||||||
if (verbose == VERBOSE_NONE) {
|
if (verbose == VERBOSE_NONE) {
|
||||||
if (!nof_found_mib) {
|
if (!nof_found_mib) {
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
|
@ -466,8 +476,8 @@ int main(int argc, char **argv) {
|
||||||
INFO("MIB not found attempt %d\n",frame_cnt);
|
INFO("MIB not found attempt %d\n",frame_cnt);
|
||||||
}
|
}
|
||||||
if (frame_cnt) {
|
if (frame_cnt) {
|
||||||
printf("SFN: %4d\tCFO: %+.4f KHz\tTimeOffset: %4d\tErrors: %4d/%4d\tErrorRate: %.1e\r", mib.sfn,
|
printf("SFN: %4d, CFO: %+.4f KHz, SFO: %+.4f Khz, TimeOffset: %4d, Errors: %4d/%4d, ErrorRate: %.1e\r", mib.sfn,
|
||||||
cfo*15, find_idx, frame_cnt-2*(nof_found_mib-1), frame_cnt,
|
cfo*15, timeoffset/5, find_idx, frame_cnt-2*(nof_found_mib-1), frame_cnt,
|
||||||
(float) (frame_cnt-2*(nof_found_mib-1))/frame_cnt);
|
(float) (frame_cnt-2*(nof_found_mib-1))/frame_cnt);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "phch.h"
|
#include "phch.h"
|
||||||
#include "lte/phch/pbch.h"
|
#include "lte/phch/pbch.h"
|
||||||
|
@ -57,6 +58,7 @@ bool pbch_exists(int nframe, int nslot) {
|
||||||
int pbch_cp(cf_t *input, cf_t *output, int nof_prb, lte_cp_t cp, int cell_id, bool put) {
|
int pbch_cp(cf_t *input, cf_t *output, int nof_prb, lte_cp_t cp, int cell_id, bool put) {
|
||||||
int i;
|
int i;
|
||||||
cf_t *ptr;
|
cf_t *ptr;
|
||||||
|
assert(cell_id >= 0);
|
||||||
if (put) {
|
if (put) {
|
||||||
ptr = input;
|
ptr = input;
|
||||||
output += nof_prb * RE_X_RB / 2 - 36;
|
output += nof_prb * RE_X_RB / 2 - 36;
|
||||||
|
@ -110,6 +112,9 @@ int pbch_get(cf_t *slot1_data, cf_t *pbch, int nof_prb, lte_cp_t cp, int cell_id
|
||||||
/** Initializes the PBCH channel receiver */
|
/** Initializes the PBCH channel receiver */
|
||||||
int pbch_init(pbch_t *q, int cell_id, lte_cp_t cp) {
|
int pbch_init(pbch_t *q, int cell_id, lte_cp_t cp) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
if (cell_id < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
bzero(q, sizeof(pbch_t));
|
bzero(q, sizeof(pbch_t));
|
||||||
q->cell_id = cell_id;
|
q->cell_id = cell_id;
|
||||||
q->cp = cp;
|
q->cp = cp;
|
||||||
|
@ -374,9 +379,24 @@ int pbch_decode_frame(pbch_t *q, pbch_mib_t *mib, int src, int dst, int n, int n
|
||||||
/* unrate matching */
|
/* unrate matching */
|
||||||
rm_conv_rx(q->temp, q->pbch_rm_f, 4 * nof_bits, 120);
|
rm_conv_rx(q->temp, q->pbch_rm_f, 4 * nof_bits, 120);
|
||||||
|
|
||||||
|
/* FIXME: If channel estimates are zero, received LLR are NaN. Check and return error */
|
||||||
|
for (j=0;j<120;j++) {
|
||||||
|
if (isnan(q->pbch_rm_f[j]) || isinf(q->pbch_rm_f[j])) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* decode */
|
/* decode */
|
||||||
viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data);
|
viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data);
|
||||||
|
|
||||||
|
int c=0;
|
||||||
|
for (j=0;j<40;j++) {
|
||||||
|
c+=q->data[j];
|
||||||
|
}
|
||||||
|
if (!c) {
|
||||||
|
c=1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pbch_crc_check(q->data, nof_ports)) {
|
if (!pbch_crc_check(q->data, nof_ports)) {
|
||||||
/* unpack MIB */
|
/* unpack MIB */
|
||||||
pbch_mib_unpack(q->data, mib);
|
pbch_mib_unpack(q->data, mib);
|
||||||
|
|
Loading…
Reference in New Issue