|
|
@ -40,23 +40,26 @@
|
|
|
|
uint32_t nof_prb = 25;
|
|
|
|
uint32_t nof_prb = 25;
|
|
|
|
uint32_t nof_frames = 20;
|
|
|
|
uint32_t nof_frames = 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float tone_offset_hz = 0;
|
|
|
|
float uhd_rx_gain=40, uhd_tx_gain=40, uhd_freq=2.4e9;
|
|
|
|
float uhd_rx_gain=40, uhd_tx_gain=40, uhd_freq=2.4e9;
|
|
|
|
char *uhd_args="";
|
|
|
|
char *uhd_args="";
|
|
|
|
char *output_filename = NULL;
|
|
|
|
char *output_filename = NULL;
|
|
|
|
char *input_filename = NULL;
|
|
|
|
char *input_filename = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
void usage(char *prog) {
|
|
|
|
void usage(char *prog) {
|
|
|
|
printf("Usage: %s -i [tx_signal_file] -o [rx_signal_file]\n", prog);
|
|
|
|
printf("Usage: %s -o [rx_signal_file]\n", prog);
|
|
|
|
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
|
|
|
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
|
|
|
printf("\t-f UHD TX/RX frequency [Default %.2f MHz]\n", uhd_freq/1e6);
|
|
|
|
printf("\t-f UHD TX/RX frequency [Default %.2f MHz]\n", uhd_freq/1e6);
|
|
|
|
printf("\t-g UHD RX gain [Default %.1f dB]\n", uhd_rx_gain);
|
|
|
|
printf("\t-g UHD RX gain [Default %.1f dB]\n", uhd_rx_gain);
|
|
|
|
printf("\t-G UHD TX gain [Default %.1f dB]\n", uhd_tx_gain);
|
|
|
|
printf("\t-G UHD TX gain [Default %.1f dB]\n", uhd_tx_gain);
|
|
|
|
|
|
|
|
printf("\t-t Single tone offset (Hz) [Default %f]\n", tone_offset_hz);
|
|
|
|
|
|
|
|
printf("\t-i File name to read signal from [Default single tone]\n");
|
|
|
|
printf("\t-p Number of UL RB [Default %d]\n", nof_prb);
|
|
|
|
printf("\t-p Number of UL RB [Default %d]\n", nof_prb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void parse_args(int argc, char **argv) {
|
|
|
|
void parse_args(int argc, char **argv) {
|
|
|
|
int opt;
|
|
|
|
int opt;
|
|
|
|
while ((opt = getopt(argc, argv, "ioafgp")) != -1) {
|
|
|
|
while ((opt = getopt(argc, argv, "ioafgpt")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'a':
|
|
|
|
case 'a':
|
|
|
|
uhd_args = argv[optind];
|
|
|
|
uhd_args = argv[optind];
|
|
|
@ -67,6 +70,9 @@ void parse_args(int argc, char **argv) {
|
|
|
|
case 'i':
|
|
|
|
case 'i':
|
|
|
|
input_filename = argv[optind];
|
|
|
|
input_filename = argv[optind];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 't':
|
|
|
|
|
|
|
|
tone_offset_hz = atof(argv[optind]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
case 'f':
|
|
|
|
uhd_freq = atof(argv[optind]);
|
|
|
|
uhd_freq = atof(argv[optind]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -88,7 +94,7 @@ void parse_args(int argc, char **argv) {
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!input_filename || !output_filename) {
|
|
|
|
if (!output_filename) {
|
|
|
|
usage(argv[0]);
|
|
|
|
usage(argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,17 +133,33 @@ int main(int argc, char **argv) {
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
|
|
|
cuhd_set_master_clock_rate(uhd, 30.72e6);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int srate = srslte_sampling_freq_hz(nof_prb);
|
|
|
|
|
|
|
|
if (srate < 10e6) {
|
|
|
|
|
|
|
|
cuhd_set_master_clock_rate(uhd, 4*srate);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cuhd_set_master_clock_rate(uhd, srate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cuhd_set_rx_srate(uhd, (double) srate);
|
|
|
|
|
|
|
|
cuhd_set_tx_srate(uhd, (double) srate);
|
|
|
|
|
|
|
|
|
|
|
|
printf("Subframe len: %d samples\n", flen);
|
|
|
|
printf("Subframe len: %d samples\n", flen);
|
|
|
|
printf("Set TX/RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
|
|
|
|
printf("Set TX/RX rate: %.2f MHz\n", (float) srate / 1000000);
|
|
|
|
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));
|
|
|
|
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));
|
|
|
|
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_tx_gain));
|
|
|
|
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_tx_gain));
|
|
|
|
printf("Set TX/RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
|
|
|
|
printf("Set TX/RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
|
|
|
|
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(nof_prb));
|
|
|
|
|
|
|
|
cuhd_set_tx_freq_offset(uhd, uhd_freq, 8e6);
|
|
|
|
cuhd_set_tx_freq_offset(uhd, uhd_freq, 8e6);
|
|
|
|
sleep(1);
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
|
|
|
|
srslte_vec_load_file(input_filename, &tx_buffer[nsamples_adv], flen*sizeof(cf_t));
|
|
|
|
if (input_filename) {
|
|
|
|
|
|
|
|
srslte_vec_load_file(input_filename, &tx_buffer[nsamples_adv], flen*sizeof(cf_t));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for (int i=0;i<flen-nsamples_adv;i++) {
|
|
|
|
|
|
|
|
tx_buffer[i+nsamples_adv] = cexpf(_Complex_I*2*M_PI*tone_offset_hz*(float) i/(float) srate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
srslte_vec_save_file("uhd_txrx_tone", tx_buffer, flen*sizeof(cf_t));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
srslte_timestamp_t tstamp;
|
|
|
|
srslte_timestamp_t tstamp;
|
|
|
|
|
|
|
|
|
|
|
|