diff --git a/lib/examples/usrp_capture_sync.c b/lib/examples/usrp_capture_sync.c index 613f26d84..424521e3a 100644 --- a/lib/examples/usrp_capture_sync.c +++ b/lib/examples/usrp_capture_sync.c @@ -213,6 +213,6 @@ int main(int argc, char **argv) { } } - printf("Ok - wrote %d subframes\n", subframe_count); + printf("\nOk - wrote %d subframes\n", subframe_count); exit(0); } diff --git a/lib/include/srslte/phy/ue/ue_sync.h b/lib/include/srslte/phy/ue/ue_sync.h index 233b87b11..a5e126e5f 100644 --- a/lib/include/srslte/phy/ue/ue_sync.h +++ b/lib/include/srslte/phy/ue/ue_sync.h @@ -96,7 +96,8 @@ typedef struct SRSLTE_API { srslte_filesource_t file_source; bool file_mode; - float file_cfo; + float file_cfo; + bool file_wrap_enable; srslte_cfo_t file_cfo_correct; srslte_ue_sync_state_t state; @@ -185,6 +186,9 @@ SRSLTE_API int srslte_ue_sync_init_file_multi(srslte_ue_sync_t *q, SRSLTE_API void srslte_ue_sync_free(srslte_ue_sync_t *q); +SRSLTE_API void srslte_ue_sync_file_wrap(srslte_ue_sync_t *q, + bool enable); + SRSLTE_API int srslte_ue_sync_set_cell(srslte_ue_sync_t *q, srslte_cell_t cell); diff --git a/lib/src/phy/ue/ue_sync.c b/lib/src/phy/ue/ue_sync.c index f3360dda7..480835e6b 100644 --- a/lib/src/phy/ue/ue_sync.c +++ b/lib/src/phy/ue/ue_sync.c @@ -58,6 +58,10 @@ int srslte_ue_sync_init_file(srslte_ue_sync_t *q, uint32_t nof_prb, char *file_n return srslte_ue_sync_init_file_multi(q, nof_prb, file_name, offset_time, offset_freq, 1); } +void srslte_ue_sync_file_wrap(srslte_ue_sync_t *q, bool enable) { + q->file_wrap_enable = enable; +} + int srslte_ue_sync_init_file_multi(srslte_ue_sync_t *q, uint32_t nof_prb, char *file_name, int offset_time, float offset_freq, uint32_t nof_rx_ant) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -68,7 +72,8 @@ int srslte_ue_sync_init_file_multi(srslte_ue_sync_t *q, uint32_t nof_prb, char * { ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_ue_sync_t)); - q->file_mode = true; + q->file_mode = true; + q->file_wrap_enable = true; q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)); q->file_cfo = -offset_freq; q->fft_size = srslte_symbol_sz(nof_prb); @@ -691,11 +696,15 @@ int srslte_ue_sync_zerocopy_multi(srslte_ue_sync_t *q, cf_t *input_buffer[SRSLTE return SRSLTE_ERROR; } if (n == 0) { - srslte_filesource_seek(&q->file_source, 0); - q->sf_idx = 9; - n = srslte_filesource_read_multi(&q->file_source, (void **) input_buffer, q->sf_len, q->nof_rx_antennas); - if (n < 0) { - fprintf(stderr, "Error reading input file\n"); + if (q->file_wrap_enable) { + srslte_filesource_seek(&q->file_source, 0); + q->sf_idx = 9; + n = srslte_filesource_read_multi(&q->file_source, (void **) input_buffer, q->sf_len, q->nof_rx_antennas); + if (n < 0) { + fprintf(stderr, "Error reading input file\n"); + return SRSLTE_ERROR; + } + } else { return SRSLTE_ERROR; } }