|
|
@ -40,8 +40,6 @@
|
|
|
|
#include "srslte/cuhd/cuhd.h"
|
|
|
|
#include "srslte/cuhd/cuhd.h"
|
|
|
|
#include "srslte/cuhd/cuhd_utils.h"
|
|
|
|
#include "srslte/cuhd/cuhd_utils.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define B210_DEFAULT_GAIN_CORREC 100.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cell_search_cfg_t cell_detect_config = {
|
|
|
|
cell_search_cfg_t cell_detect_config = {
|
|
|
|
5000, // maximum number of frames to receive for MIB decoding
|
|
|
|
5000, // maximum number of frames to receive for MIB decoding
|
|
|
|
50, // maximum number of frames to receive for PSS correlation
|
|
|
|
50, // maximum number of frames to receive for PSS correlation
|
|
|
@ -115,7 +113,16 @@ int parse_args(prog_args_t *args, int argc, char **argv) {
|
|
|
|
/**********************************************************************/
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: Do something with the output data */
|
|
|
|
/* TODO: Do something with the output data */
|
|
|
|
uint8_t data[10000];
|
|
|
|
uint8_t data[1000000];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool go_exit = false;
|
|
|
|
|
|
|
|
void sig_int_handler(int signo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("SIGINT received. Exiting...\n");
|
|
|
|
|
|
|
|
if (signo == SIGINT) {
|
|
|
|
|
|
|
|
go_exit = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
|
|
|
|
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
|
|
|
|
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
|
|
|
|
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
|
|
|
@ -168,31 +175,51 @@ int main(int argc, char **argv) {
|
|
|
|
cuhd_set_rx_gain(uhd, 50);
|
|
|
|
cuhd_set_rx_gain(uhd, 50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sigset_t sigset;
|
|
|
|
|
|
|
|
sigemptyset(&sigset);
|
|
|
|
|
|
|
|
sigaddset(&sigset, SIGINT);
|
|
|
|
|
|
|
|
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
|
|
|
|
|
|
|
signal(SIGINT, sig_int_handler);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
|
|
|
|
|
|
|
|
|
|
|
/* set receiver frequency */
|
|
|
|
/* set receiver frequency */
|
|
|
|
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq);
|
|
|
|
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq);
|
|
|
|
cuhd_rx_wait_lo_locked(uhd);
|
|
|
|
cuhd_rx_wait_lo_locked(uhd);
|
|
|
|
printf("Tunning receiver to %.3f MHz\n", (double ) prog_args.uhd_freq/1000000);
|
|
|
|
printf("Tunning receiver to %.3f MHz\n", (double ) prog_args.uhd_freq/1000000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t ntrial=0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell);
|
|
|
|
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell);
|
|
|
|
if (ret < 0) {
|
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "Error searching cell\n");
|
|
|
|
fprintf(stderr, "Error searching for cell\n");
|
|
|
|
return -1;
|
|
|
|
exit(-1);
|
|
|
|
} else if (ret == 0) {
|
|
|
|
} else if (ret == 0 && !go_exit) {
|
|
|
|
printf("Cell not found\n");
|
|
|
|
printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (ret == 0 && !go_exit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (go_exit) {
|
|
|
|
exit(0);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set sampling frequency */
|
|
|
|
/* set sampling frequency */
|
|
|
|
int srate = srslte_sampling_freq_hz(cell.nof_prb);
|
|
|
|
int srate = srslte_sampling_freq_hz(cell.nof_prb);
|
|
|
|
if (srate != -1) {
|
|
|
|
if (srate != -1) {
|
|
|
|
/* Modify master clock rate for 15 Mhz */
|
|
|
|
if (srate < 10e6) {
|
|
|
|
if (cell.nof_prb == 75) {
|
|
|
|
cuhd_set_master_clock_rate(uhd, 4*srate);
|
|
|
|
cuhd_set_master_clock_rate(uhd, 23.04e6);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cuhd_set_master_clock_rate(uhd, srate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
|
|
|
|
|
|
|
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
|
|
|
|
|
|
|
|
if (srate_uhd != srate) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Could not set sampling rate\n");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cuhd_set_rx_srate(uhd, (double) srate);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
|
|
|
|
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INFO("Stopping UHD and flushing buffer...\n",0);
|
|
|
|
INFO("Stopping UHD and flushing buffer...\n",0);
|
|
|
@ -240,7 +267,7 @@ int main(int argc, char **argv) {
|
|
|
|
float rx_gain_offset = 0;
|
|
|
|
float rx_gain_offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* Main loop */
|
|
|
|
/* Main loop */
|
|
|
|
while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) {
|
|
|
|
while ((sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) && !go_exit) {
|
|
|
|
|
|
|
|
|
|
|
|
ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
|
|
|
|
ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
|
|
|
|
if (ret < 0) {
|
|
|
|
if (ret < 0) {
|
|
|
|