|
|
|
@ -44,12 +44,13 @@ uint32_t preamble_format = 0;
|
|
|
|
|
uint32_t root_seq_idx = 0;
|
|
|
|
|
uint32_t seq_idx = 0;
|
|
|
|
|
uint32_t frequency_offset = 0;
|
|
|
|
|
uint32_t zero_corr_zone = 0;
|
|
|
|
|
uint32_t zero_corr_zone = 11;
|
|
|
|
|
uint32_t timeadv = 0;
|
|
|
|
|
uint32_t nof_frames = 20;
|
|
|
|
|
|
|
|
|
|
float uhd_gain=40, uhd_freq=2.4e9;
|
|
|
|
|
char *uhd_args="";
|
|
|
|
|
char *output_filename = NULL;
|
|
|
|
|
char *output_filename = "prach_rx";
|
|
|
|
|
|
|
|
|
|
void usage(char *prog) {
|
|
|
|
|
printf("Usage: %s \n", prog);
|
|
|
|
@ -58,15 +59,17 @@ void usage(char *prog) {
|
|
|
|
|
printf("\t-g UHD TX/RX gain [Default %.1f dB]\n", uhd_gain);
|
|
|
|
|
printf("\t-p Number of UL RB [Default %d]\n", nof_prb);
|
|
|
|
|
printf("\t-F Preamble format [Default %d]\n", preamble_format);
|
|
|
|
|
printf("\t-O Frequency offset [Default %d]\n", frequency_offset);
|
|
|
|
|
printf("\t-s sequence index [Default %d]\n", seq_idx);
|
|
|
|
|
printf("\t-r Root sequence index [Default %d]\n", root_seq_idx);
|
|
|
|
|
printf("\t-t Time advance (us) [Default %d]\n", timeadv);
|
|
|
|
|
printf("\t-z Zero correlation zone config [Default %d]\n", zero_corr_zone);
|
|
|
|
|
printf("\t-o Save transmitted PRACH in file [Default no]\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void parse_args(int argc, char **argv) {
|
|
|
|
|
int opt;
|
|
|
|
|
while ((opt = getopt(argc, argv, "apfFgrsoz")) != -1) {
|
|
|
|
|
while ((opt = getopt(argc, argv, "apfFgrstoPOz")) != -1) {
|
|
|
|
|
switch (opt) {
|
|
|
|
|
case 'a':
|
|
|
|
|
uhd_args = argv[optind];
|
|
|
|
@ -80,6 +83,15 @@ void parse_args(int argc, char **argv) {
|
|
|
|
|
case 'g':
|
|
|
|
|
uhd_gain = atof(argv[optind]);
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
preamble_format = atoi(argv[optind]);
|
|
|
|
|
break;
|
|
|
|
|
case 'O':
|
|
|
|
|
frequency_offset = atoi(argv[optind]);
|
|
|
|
|
break;
|
|
|
|
|
case 't':
|
|
|
|
|
timeadv = atoi(argv[optind]);
|
|
|
|
|
break;
|
|
|
|
|
case 'p':
|
|
|
|
|
nof_prb = atoi(argv[optind]);
|
|
|
|
|
if (!srslte_nofprb_isvalid(nof_prb)) {
|
|
|
|
@ -123,7 +135,8 @@ int main(int argc, char **argv) {
|
|
|
|
|
high_speed_flag,
|
|
|
|
|
zero_corr_zone);
|
|
|
|
|
|
|
|
|
|
uint32_t flen = srslte_sampling_freq_hz(nof_prb)/1000;
|
|
|
|
|
int srate = srslte_sampling_freq_hz(nof_prb);
|
|
|
|
|
uint32_t flen = srate/1000;
|
|
|
|
|
|
|
|
|
|
printf("Generating PRACH\n");
|
|
|
|
|
bzero(preamble, flen*sizeof(cf_t));
|
|
|
|
@ -133,7 +146,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
preamble);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t prach_len = p->N_seq;
|
|
|
|
|
uint32_t prach_len = p->N_seq+p->N_cp;
|
|
|
|
|
|
|
|
|
|
srslte_vec_save_file("generated",preamble,prach_len*sizeof(cf_t));
|
|
|
|
|
|
|
|
|
@ -147,11 +160,27 @@ int main(int argc, char **argv) {
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
printf("Subframe len: %d samples\n", flen);
|
|
|
|
|
printf("Set TX/RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
|
|
|
|
|
printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&uhd, uhd_gain));
|
|
|
|
|
printf("Set TX gain: %.1f dB\n", srslte_rf_set_tx_gain(&uhd, uhd_gain));
|
|
|
|
|
printf("Set TX/RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&uhd, uhd_freq) / 1000000);
|
|
|
|
|
srslte_rf_set_tx_srate(&uhd, srslte_sampling_freq_hz(nof_prb));
|
|
|
|
|
printf("Set RX gain: %.1f dB\n", uhd_gain);
|
|
|
|
|
printf("Set TX gain: %.1f dB\n", 20+uhd_gain);
|
|
|
|
|
printf("Set TX/RX freq: %.2f MHz\n", uhd_freq/ 1000000);
|
|
|
|
|
|
|
|
|
|
srslte_rf_set_rx_gain(&uhd, uhd_gain);
|
|
|
|
|
srslte_rf_set_tx_gain(&uhd, 10+uhd_gain);
|
|
|
|
|
srslte_rf_set_rx_freq(&uhd, uhd_freq);
|
|
|
|
|
srslte_rf_set_tx_freq(&uhd, uhd_freq);
|
|
|
|
|
|
|
|
|
|
if (srate < 10e6) {
|
|
|
|
|
srslte_rf_set_master_clock_rate(&uhd, 4*srate);
|
|
|
|
|
} else {
|
|
|
|
|
srslte_rf_set_master_clock_rate(&uhd, srate);
|
|
|
|
|
}
|
|
|
|
|
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
|
|
|
|
|
float srate_rf = srslte_rf_set_rx_srate(&uhd, (double) srate);
|
|
|
|
|
if (srate_rf != srate) {
|
|
|
|
|
fprintf(stderr, "Could not set sampling rate\n");
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
srslte_rf_set_tx_srate(&uhd, (double) srate);
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
|
|
cf_t *zeros = calloc(sizeof(cf_t),flen);
|
|
|
|
@ -171,7 +200,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
srslte_rf_recv_with_time(&uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
|
|
|
|
|
nframe++;
|
|
|
|
|
if (nframe==9 || nframe==8) {
|
|
|
|
|
srslte_timestamp_add(&tstamp, 0, 2e-3);
|
|
|
|
|
srslte_timestamp_add(&tstamp, 0, 2e-3-timeadv*1e-6);
|
|
|
|
|
if (nframe==8) {
|
|
|
|
|
srslte_rf_send_timed2(&uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
|
|
|
|
|
printf("Transmitting zeros\n");
|
|
|
|
@ -183,7 +212,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (f) {
|
|
|
|
|
fwrite(&buffer[10*flen], flen*sizeof(cf_t), 1, f);
|
|
|
|
|
fwrite(buffer, 11*flen*sizeof(cf_t), 1, f);
|
|
|
|
|
}
|
|
|
|
|
if (f) {
|
|
|
|
|
fclose(f);
|
|
|
|
|