mirror of https://github.com/PentHertz/srsLTE.git
Added USRP arg options
This commit is contained in:
parent
8f4dee7c53
commit
cfc9e3e5d8
|
@ -44,7 +44,9 @@ char *output_file_name = NULL;
|
|||
int nof_frames=-1;
|
||||
int cell_id = 1;
|
||||
int nof_prb = 6;
|
||||
char *uhd_args = "";
|
||||
|
||||
float uhd_amp=0.25, uhd_gain=10.0, uhd_freq=2400000000;
|
||||
|
||||
filesink_t fsink;
|
||||
lte_fft_t ifft;
|
||||
|
@ -53,14 +55,14 @@ pbch_t pbch;
|
|||
cf_t *slot_buffer = NULL, *output_buffer = NULL;
|
||||
int slot_n_re, slot_n_samples;
|
||||
|
||||
#define cuhd_FREQ 2680000000
|
||||
#define cuhd_SAMP_FREQ 1920000
|
||||
#define cuhd_GAIN 10
|
||||
#define cuhd_AMP 0.25
|
||||
#define cuhd_ARGS "addr=192.168.10.3"
|
||||
#define UHD_SAMP_FREQ 1920000
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [ncvp]\n", prog);
|
||||
printf("Usage: %s [agmfoncvp]\n", prog);
|
||||
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
||||
printf("\t-g UHD TX gain [Default %.2f dB]\n", uhd_gain);
|
||||
printf("\t-m UHD signal amplitude [Default %.2f]\n", uhd_amp);
|
||||
printf("\t-f UHD TX frequency [Default %.1f MHz]\n", uhd_freq/1000000);
|
||||
printf("\t-o output_file [Default USRP]\n");
|
||||
printf("\t-n number of frames [Default %d]\n", nof_frames);
|
||||
printf("\t-c cell id [Default %d]\n", cell_id);
|
||||
|
@ -70,8 +72,20 @@ void usage(char *prog) {
|
|||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "oncpv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "agfmoncpv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'a':
|
||||
uhd_args = argv[optind];
|
||||
break;
|
||||
case 'g':
|
||||
uhd_gain = atof(argv[optind]);
|
||||
break;
|
||||
case 'm':
|
||||
uhd_amp = atof(argv[optind]);
|
||||
break;
|
||||
case 'f':
|
||||
uhd_freq = atof(argv[optind]);
|
||||
break;
|
||||
case 'o':
|
||||
output_file_name = argv[optind];
|
||||
break;
|
||||
|
@ -121,7 +135,7 @@ void base_init() {
|
|||
} else {
|
||||
#ifdef ENABLE_UHD
|
||||
printf("Opening UHD device...\n");
|
||||
if (cuhd_open(cuhd_ARGS,&uhd)) {
|
||||
if (cuhd_open(uhd_args,&uhd)) {
|
||||
fprintf(stderr, "Error opening uhd\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -138,13 +152,6 @@ void base_init() {
|
|||
fprintf(stderr, "Error creating PBCH object\n");
|
||||
exit(-1);
|
||||
}
|
||||
#ifdef ENABLE_MATLAB
|
||||
fmatlab = fopen("output.m", "w");
|
||||
if (!fmatlab) {
|
||||
perror("fopen");
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void base_free() {
|
||||
|
@ -166,9 +173,6 @@ void base_free() {
|
|||
cuhd_close(&uhd);
|
||||
#endif
|
||||
}
|
||||
#ifdef ENABLE_MATLAB
|
||||
fclose(fmatlab);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -222,9 +226,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
#ifdef ENABLE_UHD
|
||||
if (!output_file_name) {
|
||||
printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, cuhd_SAMP_FREQ)/1000000);
|
||||
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, cuhd_GAIN));
|
||||
printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, cuhd_FREQ)/1000000);
|
||||
printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, UHD_SAMP_FREQ)/1000000);
|
||||
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
|
||||
printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq)/1000000);
|
||||
cuhd_start_tx_stream(uhd);
|
||||
}
|
||||
#endif
|
||||
|
@ -258,7 +262,7 @@ int main(int argc, char **argv) {
|
|||
filesink_write(&fsink, output_buffer, slot_n_samples);
|
||||
} else {
|
||||
#ifdef ENABLE_UHD
|
||||
vec_sc_prod_cfc(output_buffer, cuhd_AMP, output_buffer, slot_n_samples);
|
||||
vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, slot_n_samples);
|
||||
cuhd_send(uhd, output_buffer, slot_n_samples, 1);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ int *idx_v, *idx_valid, *t;
|
|||
float *p2a_v;
|
||||
void *uhd;
|
||||
int nof_bands;
|
||||
float gain = 30.0;
|
||||
float uhd_gain = 30.0;
|
||||
|
||||
#define MAX_EARFCN 1000
|
||||
lte_earfcn_t channels[MAX_EARFCN];
|
||||
|
@ -95,7 +95,7 @@ void usage(char *prog) {
|
|||
printf("\t-T pss_track_nof_frames [Default %d]\n", nof_frames_track);
|
||||
printf("\t-t pss_track_threshold [Default %.2f]\n", track_threshold);
|
||||
printf("\t-l pss_track_len [Default %d]\n", track_len);
|
||||
printf("\t-g gain [Default %.2f dB]\n", gain);
|
||||
printf("\t-g gain [Default %.2f dB]\n", uhd_gain);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ void parse_args(int argc, char **argv) {
|
|||
track_threshold = atof(argv[optind]);
|
||||
break;
|
||||
case 'g':
|
||||
gain = atof(argv[optind]);
|
||||
uhd_gain = atof(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
|
@ -381,7 +381,7 @@ int main(int argc, char **argv) {
|
|||
#ifndef DISABLE_UHD
|
||||
cuhd_set_rx_srate(uhd, SAMP_FREQ);
|
||||
|
||||
cuhd_set_rx_gain(uhd, gain);
|
||||
cuhd_set_rx_gain(uhd, uhd_gain);
|
||||
#endif
|
||||
|
||||
freq=0;
|
||||
|
|
|
@ -49,13 +49,15 @@
|
|||
|
||||
#define NOF_PORTS 2
|
||||
|
||||
float freq = 2680000000.0;
|
||||
float find_threshold = 40.0, track_threshold = 8.0;
|
||||
int max_track_lost = 9, nof_frames = -1;
|
||||
int track_len=300;
|
||||
char *input_file_name = NULL;
|
||||
int disable_plots = 0;
|
||||
|
||||
float uhd_freq = 2400000000.0, uhd_gain = 20.0;
|
||||
char *uhd_args = "";
|
||||
|
||||
filesource_t fsrc;
|
||||
cf_t *input_buffer, *fft_buffer, *ce[MAX_PORTS_CTRL];
|
||||
pbch_t pbch;
|
||||
|
@ -68,32 +70,38 @@ plot_complex_t pce;
|
|||
plot_scatter_t pscatrecv, pscatequal;
|
||||
|
||||
void *uhd;
|
||||
float gain = 30.0;
|
||||
|
||||
enum sync_state {FIND, TRACK};
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [ifgv]\n", prog);
|
||||
printf("Usage: %s [iagfndv]\n", prog);
|
||||
printf("\t-i input_file [Default use USRP]\n");
|
||||
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
||||
printf("\t-g UHD RX gain [Default %.2f dB]\n", uhd_gain);
|
||||
printf("\t-f UHD RX frequency [Default %.1f MHz]\n", uhd_freq/1000000);
|
||||
printf("\t-n nof_frames [Default %d]\n", nof_frames);
|
||||
printf("\t-d disable plots [Default enabled]\n");
|
||||
printf("\t-f freq [Default %.1f MHz]\n", freq/MHZ);
|
||||
printf("\t-g gain [Default %.2f dB]\n", gain);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "ifdgv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "iagfndv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'i':
|
||||
input_file_name = argv[optind];
|
||||
break;
|
||||
case 'f':
|
||||
freq = atof(argv[optind]);
|
||||
case 'a':
|
||||
uhd_args = argv[optind];
|
||||
break;
|
||||
case 'g':
|
||||
gain = atof(argv[optind]);
|
||||
uhd_gain = atof(argv[optind]);
|
||||
break;
|
||||
case 'f':
|
||||
uhd_freq = atof(argv[optind]);
|
||||
break;
|
||||
case 'n':
|
||||
nof_frames = atoi(argv[optind]);
|
||||
break;
|
||||
case 'd':
|
||||
disable_plots = 1;
|
||||
|
@ -188,7 +196,7 @@ int base_init(int frame_length) {
|
|||
/* open UHD device */
|
||||
#ifndef DISABLE_UHD
|
||||
printf("Opening UHD device...\n");
|
||||
if (cuhd_open("addr=192.168.10.2",&uhd)) {
|
||||
if (cuhd_open(uhd_args,&uhd)) {
|
||||
fprintf(stderr, "Error opening uhd\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -287,7 +295,7 @@ int main(int argc, char **argv) {
|
|||
#ifndef DISABLE_UHD
|
||||
INFO("Setting sampling frequency %.2f MHz\n", (float) SAMP_FREQ/MHZ);
|
||||
cuhd_set_rx_srate(uhd, SAMP_FREQ);
|
||||
cuhd_set_rx_gain(uhd, gain);
|
||||
cuhd_set_rx_gain(uhd, uhd_gain);
|
||||
#endif
|
||||
|
||||
state = FIND;
|
||||
|
@ -301,10 +309,10 @@ int main(int argc, char **argv) {
|
|||
sync_force_N_id_2(&sfind, -1);
|
||||
|
||||
#ifndef DISABLE_UHD
|
||||
/* set freq */
|
||||
cuhd_set_rx_freq(uhd, (double) freq);
|
||||
/* set uhd_freq */
|
||||
cuhd_set_rx_freq(uhd, (double) uhd_freq);
|
||||
cuhd_rx_wait_lo_locked(uhd);
|
||||
DEBUG("Set freq to %.3f MHz\n", (double) freq);
|
||||
DEBUG("Set uhd_freq to %.3f MHz\n", (double) uhd_freq);
|
||||
|
||||
DEBUG("Starting receiver...\n",0);
|
||||
cuhd_start_rx_stream(uhd);
|
||||
|
|
|
@ -62,7 +62,7 @@ int *idx_v, *idx_valid, *t;
|
|||
float *p2a_v;
|
||||
void *uhd;
|
||||
int nof_bands;
|
||||
float gain = 20.0;
|
||||
float uhd_gain = 20.0;
|
||||
|
||||
#define MAX_EARFCN 1000
|
||||
lte_earfcn_t channels[MAX_EARFCN];
|
||||
|
@ -87,7 +87,7 @@ void usage(char *prog) {
|
|||
printf("\t-T pss_track_nof_frames [Default %d]\n", nof_frames_track);
|
||||
printf("\t-t pss_track_threshold [Default %.2f]\n", track_threshold);
|
||||
printf("\t-l pss_track_len [Default %d]\n", track_len);
|
||||
printf("\t-g gain [Default %.2f dB]\n", gain);
|
||||
printf("\t-g gain [Default %.2f dB]\n", uhd_gain);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ void parse_args(int argc, char **argv) {
|
|||
track_threshold = atof(argv[optind]);
|
||||
break;
|
||||
case 'g':
|
||||
gain = atof(argv[optind]);
|
||||
uhd_gain = atof(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
|
@ -303,7 +303,7 @@ int main(int argc, char **argv) {
|
|||
INFO("Setting sampling frequency %.2f MHz\n", (float) SAMP_FREQ/MHZ);
|
||||
cuhd_set_rx_srate(uhd, SAMP_FREQ);
|
||||
|
||||
cuhd_set_rx_gain(uhd, gain);
|
||||
cuhd_set_rx_gain(uhd, uhd_gain);
|
||||
|
||||
print_to_matlab();
|
||||
|
||||
|
|
Loading…
Reference in New Issue