Merged with master

master
ismagom 10 years ago
commit fe2fe70d48

@ -302,18 +302,12 @@ int main(int argc, char **argv) {
INFO("Stopping UHD and flushing buffer...\r",0);
cuhd_stop_rx_stream(uhd);
cuhd_flush_buffer(uhd);
if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}
cuhd_flush_buffer(uhd);
}
#endif
/* If reading from file, go straight to PDSCH decoding. Otherwise, decode MIB first */
if (prog_args.input_file_name) {
state = DECODE_PDSCH;
/* preset cell configuration */
cell.id = prog_args.file_cell_id;
cell.cp = SRSLTE_CP_NORM;
@ -329,7 +323,6 @@ int main(int argc, char **argv) {
} else {
#ifndef DISABLE_UHD
state = DECODE_MIB;
if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
@ -337,6 +330,13 @@ int main(int argc, char **argv) {
#endif
}
state = DECODE_MIB;
if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}
if (srslte_ue_dl_init(&ue_dl, cell)) { // This is the User RNTI
fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1);
@ -501,6 +501,8 @@ int main(int argc, char **argv) {
sf_cnt++;
} // Main loop
pthread_cancel(plot_thread);
pthread_join(plot_thread, NULL);
srslte_ue_dl_free(&ue_dl);
srslte_ue_sync_free(&ue_sync);

@ -42,7 +42,7 @@
static bool keep_running = true;
char *output_file_name = NULL;
char *uhd_args="";
float uhd_gain=40.0, uhd_freq=-1.0;
float uhd_gain=60.0, uhd_freq=-1.0;
int nof_prb = 6;
int nof_subframes = -1;
int N_id_2 = -1;
@ -57,7 +57,7 @@ void usage(char *prog) {
printf("\t-g UHD Gain [Default %.2f dB]\n", uhd_gain);
printf("\t-p nof_prb [Default %d]\n", nof_prb);
printf("\t-n nof_subframes [Default %d]\n", nof_subframes);
printf("\t-v srslte_verbose\n");
printf("\t-v verbose\n");
}
void parse_args(int argc, char **argv) {
@ -104,25 +104,18 @@ int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t
return cuhd_recv(h, data, nsamples, 1);
}
enum receiver_state { DECODE_MIB, SAVE_FILE} state;
int main(int argc, char **argv) {
cf_t *buffer;
int subframe_count, n;
int n;
void *uhd;
srslte_filesink_t sink;
srslte_ue_mib_t ue_mib;
srslte_ue_sync_t ue_sync;
srslte_cell_t cell;
enum receiver_state state;
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
signal(SIGINT, int_handler);
parse_args(argc, argv);
subframe_count = 0;
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening UHD device...\n");
@ -145,17 +138,12 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}
if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1);
}
state = DECODE_MIB;
bool decoded_mib = false;
uint32_t sfn, sfn_offset;
printf("Waiting for SFN=0\n");
uint32_t subframe_count = 0;
bool start_capture = false;
bool stop_capture = false;
while((subframe_count < nof_subframes || nof_subframes == -1)
&& keep_running)
&& !stop_capture)
{
n = srslte_ue_sync_get_buffer(&ue_sync, &buffer);
if (n < 0) {
@ -163,39 +151,20 @@ int main(int argc, char **argv) {
exit(-1);
}
if (n == 1) {
switch (state) {
case DECODE_MIB:
if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
srslte_pbch_decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, buffer, bch_payload, NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
exit(-1);
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_pbch_mib_unpack(bch_payload, &cell, &sfn);
sfn = (sfn + sfn_offset)%1024;
decoded_mib = true;
}
}
if (decoded_mib && srslte_ue_sync_get_sfidx(&ue_sync) == 9 && sfn == 1023) {
srslte_pbch_mib_fprint(stdout, &cell, sfn);
printf("Decoded MIB. SFN: %d\n", sfn);
state = SAVE_FILE;
}
break;
case SAVE_FILE:
printf("Writing to file %4d subframes...\r", subframe_count);
srslte_filesink_write(&sink, buffer, SRSLTE_SF_LEN_PRB(nof_prb));
subframe_count++;
break;
}
if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++;
if (sfn == 1024) {
sfn = 0;
}
if (!start_capture) {
if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) {
start_capture = true;
}
} else {
printf("Writing to file %6d subframes...\r", subframe_count);
srslte_filesink_write(&sink, buffer, SRSLTE_SF_LEN_PRB(nof_prb));
subframe_count++;
}
}
if (!keep_running) {
if (!start_capture || (start_capture && srslte_ue_sync_get_sfidx(&ue_sync) == 9)) {
stop_capture = true;
}
}
}

Loading…
Cancel
Save