Renamed module rf_ to srslte_rf_

master
ismagom 9 years ago
parent a0a730b1de
commit fe6f7580cd

@ -123,9 +123,9 @@ void sig_int_handler(int signo)
}
}
int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
int srslte_rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return rf_recv(h, data, nsamples, 1);
return srslte_rf_recv(h, data, nsamples, 1);
}
enum receiver_state { DECODE_MIB, DECODE_SIB, MEASURE} state;
@ -141,7 +141,7 @@ int main(int argc, char **argv) {
int64_t sf_cnt;
srslte_ue_sync_t ue_sync;
srslte_ue_mib_t ue_mib;
rf_t rf;
srslte_rf_t rf;
srslte_ue_dl_t ue_dl;
srslte_ofdm_t fft;
srslte_chest_dl_t chest;
@ -160,18 +160,18 @@ int main(int argc, char **argv) {
if (prog_args.rf_gain > 0) {
printf("Opening RF device...\n");
if (rf_open(&rf, prog_args.rf_args)) {
if (srslte_rf_open(&rf, prog_args.rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, prog_args.rf_gain);
srslte_rf_set_rx_gain(&rf, prog_args.rf_gain);
} else {
printf("Opening RF device with threaded RX Gain control ...\n");
if (rf_open_th(&rf, prog_args.rf_args, false)) {
if (srslte_rf_open_th(&rf, prog_args.rf_args, false)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, 50);
srslte_rf_set_rx_gain(&rf, 50);
}
sigset_t sigset;
@ -180,11 +180,11 @@ int main(int argc, char **argv) {
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
signal(SIGINT, sig_int_handler);
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
/* set receiver frequency */
rf_set_rx_freq(&rf, (double) prog_args.rf_freq);
rf_rx_wait_lo_locked(&rf);
srslte_rf_set_rx_freq(&rf, (double) prog_args.rf_freq);
srslte_rf_rx_wait_lo_locked(&rf);
printf("Tunning receiver to %.3f MHz\n", (double ) prog_args.rf_freq/1000000);
cell_detect_config.init_agc = (prog_args.rf_gain<0);
@ -208,12 +208,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_rf = rf_set_rx_srate(&rf, (double) srate);
float srate_rf = srslte_rf_set_rx_srate(&rf, (double) srate);
if (srate_rf != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
@ -224,10 +224,10 @@ int main(int argc, char **argv) {
}
INFO("Stopping RF and flushing buffer...\n",0);
rf_stop_rx_stream(&rf);
rf_flush_buffer(&rf);
srslte_rf_stop_rx_stream(&rf);
srslte_rf_flush_buffer(&rf);
if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, (void*) &rf)) {
if (srslte_ue_sync_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*) &rf)) {
fprintf(stderr, "Error initiating ue_sync\n");
return -1;
}
@ -263,7 +263,7 @@ int main(int argc, char **argv) {
ce[i] = srslte_vec_malloc(sizeof(cf_t) * sf_re);
}
rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf);
float rx_gain_offset = 0;
@ -335,10 +335,10 @@ int main(int argc, char **argv) {
if ((nframes%100) == 0 || rx_gain_offset == 0) {
if (rf_has_rssi(&rf)) {
rx_gain_offset = 10*log10(rssi)-rf_get_rssi(&rf);
if (srslte_rf_has_rssi(&rf)) {
rx_gain_offset = 10*log10(rssi)-srslte_rf_get_rssi(&rf);
} else {
rx_gain_offset = rf_get_rx_gain(&rf);
rx_gain_offset = srslte_rf_get_rx_gain(&rf);
}
}
@ -375,7 +375,7 @@ int main(int argc, char **argv) {
} // Main loop
srslte_ue_sync_free(&ue_sync);
rf_close(&rf);
srslte_rf_close(&rf);
printf("\nBye\n");
exit(0);
}

@ -123,9 +123,9 @@ void parse_args(int argc, char **argv) {
}
}
int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
int srslte_rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return rf_recv((rf_t*) h, data, nsamples, 1);
return srslte_rf_recv((srslte_rf_t*) h, data, nsamples, 1);
}
bool go_exit = false;
@ -138,13 +138,13 @@ void sig_int_handler(int signo)
}
}
double rf_set_rx_gain_wrapper(void *h, double f) {
return rf_set_rx_gain((rf_t*) h, f);
double srslte_rf_set_rx_gain_wrapper(void *h, double f) {
return srslte_rf_set_rx_gain((srslte_rf_t*) h, f);
}
int main(int argc, char **argv) {
int n;
rf_t rf;
srslte_rf_t rf;
srslte_ue_cellsearch_t cs;
srslte_ue_cellsearch_result_t found_cells[3];
int nof_freqs;
@ -156,24 +156,24 @@ int main(int argc, char **argv) {
if (!config.init_agc) {
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, rf_gain);
srslte_rf_set_rx_gain(&rf, rf_gain);
} else {
printf("Opening RF device with threaded RX Gain control ...\n");
if (rf_open_th(&rf, rf_args, false)) {
if (srslte_rf_open_th(&rf, rf_args, false)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, 50);
srslte_rf_set_rx_gain(&rf, 50);
}
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
// Supress RF messages
rf_suppress_stdout(&rf);
srslte_rf_suppress_stdout(&rf);
nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN);
if (nof_freqs < 0) {
@ -190,8 +190,8 @@ int main(int argc, char **argv) {
for (freq=0;freq<nof_freqs && !go_exit;freq++) {
/* set rf_freq */
rf_set_rx_freq(&rf, (double) channels[freq].fd * MHZ);
rf_rx_wait_lo_locked(&rf);
srslte_rf_set_rx_freq(&rf, (double) channels[freq].fd * MHZ);
srslte_rf_rx_wait_lo_locked(&rf);
INFO("Set rf_freq to %.3f MHz\n", (double) channels[freq].fd * MHZ/1000000);
printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS.\n", freq, nof_freqs,
@ -203,7 +203,7 @@ int main(int argc, char **argv) {
bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (srslte_ue_cellsearch_init(&cs, rf_recv_wrapper, (void*) &rf)) {
if (srslte_ue_cellsearch_init(&cs, srslte_rf_recv_wrapper, (void*) &rf)) {
fprintf(stderr, "Error initiating UE cell detect\n");
exit(-1);
}
@ -215,13 +215,13 @@ int main(int argc, char **argv) {
srslte_ue_cellsearch_set_threshold(&cs, config.threshold);
}
if (config.init_agc) {
srslte_ue_sync_start_agc(&cs.ue_sync, rf_set_rx_gain_wrapper, config.init_agc);
srslte_ue_sync_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, config.init_agc);
}
INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000);
rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ);
srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0);
rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf);
n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL);
if (n < 0) {
@ -270,7 +270,7 @@ int main(int argc, char **argv) {
printf("\nBye\n");
rf_close(&rf);
srslte_rf_close(&rf);
exit(0);
}

@ -42,7 +42,7 @@
#ifndef DISABLE_RF
#include "srslte/rf/rf.h"
rf_t rf;
srslte_rf_t rf;
#else
#warning Compiling pdsch_ue with no RF support
#endif
@ -64,7 +64,7 @@ srslte_cell_t cell = {
SRSLTE_PHICH_NORM // PHICH length
};
int net_port = -1; // -1 generates random data
int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device
uint32_t cfi=2;
uint32_t mcs_idx = 1, last_mcs_idx = 1;
@ -195,7 +195,7 @@ void base_init() {
} else {
#ifndef DISABLE_RF
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
@ -288,7 +288,7 @@ void base_free() {
}
} else {
#ifndef DISABLE_RF
rf_close(&rf);
srslte_rf_close(&rf);
#endif
}
@ -516,12 +516,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_rf = rf_set_tx_srate(&rf, (double) srate);
float srate_rf = srslte_rf_set_tx_srate(&rf, (double) srate);
if (srate_rf != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
@ -530,9 +530,9 @@ int main(int argc, char **argv) {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1);
}
printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(&rf, rf_gain));
printf("Set TX gain: %.1f dB\n", srslte_rf_set_tx_gain(&rf, rf_gain));
printf("Set TX freq: %.2f MHz\n",
rf_set_tx_freq(&rf, rf_freq) / 1000000);
srslte_rf_set_tx_freq(&rf, rf_freq) / 1000000);
}
#endif
@ -646,7 +646,7 @@ int main(int argc, char **argv) {
// FIXME
float norm_factor = (float) cell.nof_prb/15/sqrtf(pdsch_cfg.grant.nof_prb);
srslte_vec_sc_prod_cfc(output_buffer, rf_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
rf_send2(&rf, output_buffer, sf_n_samples, true, start_of_burst, false);
srslte_rf_send2(&rf, output_buffer, sf_n_samples, true, start_of_burst, false);
start_of_burst=false;
#endif
}

@ -241,13 +241,13 @@ void sig_int_handler(int signo)
}
#ifndef DISABLE_RF
int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
int srslte_rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return rf_recv(h, data, nsamples, 1);
return srslte_rf_recv(h, data, nsamples, 1);
}
double rf_set_rx_gain_th_wrapper(void *h, double f) {
return rf_set_rx_gain_th((rf_t*) h, f);
double srslte_rf_set_rx_gain_th_wrapper(void *h, double f) {
return srslte_rf_set_rx_gain_th((srslte_rf_t*) h, f);
}
#endif
@ -270,7 +270,7 @@ int main(int argc, char **argv) {
int64_t sf_cnt;
srslte_ue_mib_t ue_mib;
#ifndef DISABLE_RF
rf_t rf;
srslte_rf_t rf;
#endif
uint32_t nof_trials = 0;
int n;
@ -301,18 +301,18 @@ int main(int argc, char **argv) {
/* Set receiver gain */
if (prog_args.rf_gain > 0) {
printf("Opening RF device...\n");
if (rf_open(&rf, prog_args.rf_args)) {
if (srslte_rf_open(&rf, prog_args.rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, prog_args.rf_gain);
srslte_rf_set_rx_gain(&rf, prog_args.rf_gain);
} else {
printf("Opening RF device with threaded RX Gain control ...\n");
if (rf_open_th(&rf, prog_args.rf_args, false)) {
if (srslte_rf_open_th(&rf, prog_args.rf_args, false)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_rx_gain(&rf, 50);
srslte_rf_set_rx_gain(&rf, 50);
cell_detect_config.init_agc = 50;
}
@ -322,12 +322,12 @@ int main(int argc, char **argv) {
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
signal(SIGINT, sig_int_handler);
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
/* set receiver frequency */
printf("Tunning receiver to %.3f MHz\n", (double ) prog_args.rf_freq/1000000);
rf_set_rx_freq(&rf, (double) prog_args.rf_freq);
rf_rx_wait_lo_locked(&rf);
srslte_rf_set_rx_freq(&rf, (double) prog_args.rf_freq);
srslte_rf_rx_wait_lo_locked(&rf);
uint32_t ntrial=0;
do {
@ -347,12 +347,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_rf = rf_set_rx_srate(&rf, (double) srate);
float srate_rf = srslte_rf_set_rx_srate(&rf, (double) srate);
if (srate_rf != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
@ -363,8 +363,8 @@ int main(int argc, char **argv) {
}
INFO("Stopping RF and flushing buffer...\r",0);
rf_stop_rx_stream(&rf);
rf_flush_buffer(&rf);
srslte_rf_stop_rx_stream(&rf);
srslte_rf_flush_buffer(&rf);
}
#endif
@ -386,7 +386,7 @@ int main(int argc, char **argv) {
} else {
#ifndef DISABLE_RF
if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, (void*) &rf)) {
if (srslte_ue_sync_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*) &rf)) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}
@ -420,7 +420,7 @@ int main(int argc, char **argv) {
#ifndef DISABLE_RF
if (!prog_args.input_file_name) {
rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf);
}
#endif
@ -431,7 +431,7 @@ int main(int argc, char **argv) {
#ifndef DISABLE_RF
if (prog_args.rf_gain < 0) {
srslte_ue_sync_start_agc(&ue_sync, rf_set_rx_gain_th_wrapper, cell_detect_config.init_agc);
srslte_ue_sync_start_agc(&ue_sync, srslte_rf_set_rx_gain_th_wrapper, cell_detect_config.init_agc);
}
#endif
#ifdef PRINT_CHANGE_SCHEDULIGN
@ -597,7 +597,7 @@ int main(int argc, char **argv) {
#ifndef DISABLE_RF
if (!prog_args.input_file_name) {
srslte_ue_mib_free(&ue_mib);
rf_close(&rf);
srslte_rf_close(&rf);
}
#endif
printf("\nBye\n");

@ -124,7 +124,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) {
cf_t *buffer;
int frame_cnt, n;
rf_t rf;
srslte_rf_t rf;
srslte_pss_synch_t pss;
srslte_cfo_t cfocorr, cfocorr64;
srslte_sss_synch_t sss;
@ -177,16 +177,16 @@ int main(int argc, char **argv) {
srslte_sss_synch_set_N_id_2(&sss, N_id_2);
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
printf("N_id_2: %d\n", N_id_2);
printf("Set RX rate: %.2f MHz\n", rf_set_rx_srate(&rf, flen*2*100) / 1000000);
printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(&rf, rf_gain));
printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(&rf, rf_freq) / 1000000);
rf_rx_wait_lo_locked(&rf);
rf_start_rx_stream(&rf);
printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, flen*2*100) / 1000000);
printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf, rf_gain));
printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, rf_freq) / 1000000);
srslte_rf_rx_wait_lo_locked(&rf);
srslte_rf_start_rx_stream(&rf);
printf("Frame length %d samples\n", flen);
printf("PSS detection threshold: %.2f\n", threshold);
@ -208,7 +208,7 @@ int main(int argc, char **argv) {
while(frame_cnt < nof_frames || nof_frames == -1) {
peak_offset = 0;
n = rf_recv(&rf, buffer, flen - peak_offset, 1);
n = srslte_rf_recv(&rf, buffer, flen - peak_offset, 1);
if (n < 0) {
fprintf(stderr, "Error receiving samples\n");
exit(-1);
@ -320,7 +320,7 @@ int main(int argc, char **argv) {
srslte_pss_synch_free(&pss);
free(buffer);
rf_close(&rf);
srslte_rf_close(&rf);
printf("Ok\n");
exit(0);

@ -36,7 +36,7 @@
#include "srslte/srslte.h"
#include "srslte/rf/rf.h"
rf_t rf;
srslte_rf_t rf;
char *output_file_name = NULL;
@ -138,7 +138,7 @@ void base_init() {
exit(-1);
}
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
@ -161,7 +161,7 @@ void base_free() {
if (output_buffer) {
free(output_buffer);
}
rf_close(&rf);
srslte_rf_close(&rf);
}
@ -196,10 +196,10 @@ int main(int argc, char **argv) {
srslte_sss_generate(sss_signal0, sss_signal5, cell.id);
printf("Set TX rate: %.2f MHz\n",
rf_set_tx_srate(&rf, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(&rf, rf_gain));
srslte_rf_set_tx_srate(&rf, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
printf("Set TX gain: %.1f dB\n", srslte_rf_set_tx_gain(&rf, rf_gain));
printf("Set TX freq: %.2f MHz\n",
rf_set_tx_freq(&rf, rf_freq) / 1000000);
srslte_rf_set_tx_freq(&rf, rf_freq) / 1000000);
uint32_t nbits;
@ -249,7 +249,7 @@ int main(int argc, char **argv) {
/* send to usrp */
srslte_vec_sc_prod_cfc(output_buffer, rf_amp, output_buffer, sf_n_samples);
rf_send(&rf, output_buffer, sf_n_samples, true);
srslte_rf_send(&rf, output_buffer, sf_n_samples, true);
}
}

@ -97,7 +97,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) {
cf_t *buffer;
int sample_count, n;
rf_t rf;
srslte_rf_t rf;
srslte_filesink_t sink;
int32_t buflen;
@ -117,27 +117,27 @@ int main(int argc, char **argv) {
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGINT);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(&rf, rf_freq) / 1000000);
printf("Set RX gain: %.2f dB\n", rf_set_rx_gain(&rf, rf_gain));
float srate = rf_set_rx_srate(&rf, rf_rate);
printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, rf_freq) / 1000000);
printf("Set RX gain: %.2f dB\n", srslte_rf_set_rx_gain(&rf, rf_gain));
float srate = srslte_rf_set_rx_srate(&rf, rf_rate);
if (srate != rf_rate) {
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*rf_rate);
srslte_rf_set_master_clock_rate(&rf, 4*rf_rate);
} else {
rf_set_master_clock_rate(&rf, rf_rate);
srslte_rf_set_master_clock_rate(&rf, rf_rate);
}
srate = rf_set_rx_srate(&rf, rf_rate);
srate = srslte_rf_set_rx_srate(&rf, rf_rate);
if (srate != rf_rate) {
fprintf(stderr, "Errror setting samplign frequency %.2f MHz\n", rf_rate*1e-6);
exit(-1);
@ -145,13 +145,13 @@ int main(int argc, char **argv) {
}
printf("Correctly RX rate: %.2f MHz\n", srate*1e-6);
rf_rx_wait_lo_locked(&rf);
rf_start_rx_stream(&rf);
srslte_rf_rx_wait_lo_locked(&rf);
srslte_rf_start_rx_stream(&rf);
while((sample_count < nof_samples || nof_samples == -1)
&& keep_running){
n = rf_recv(&rf, buffer, buflen, 1);
n = srslte_rf_recv(&rf, buffer, buflen, 1);
if (n < 0) {
fprintf(stderr, "Error receiving samples\n");
exit(-1);
@ -163,7 +163,7 @@ int main(int argc, char **argv) {
srslte_filesink_free(&sink);
free(buffer);
rf_close(&rf);
srslte_rf_close(&rf);
printf("Ok - wrote %d samples\n", sample_count);
exit(0);

@ -98,15 +98,15 @@ void parse_args(int argc, char **argv) {
}
}
int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
int srslte_rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return rf_recv(h, data, nsamples, 1);
return srslte_rf_recv(h, data, nsamples, 1);
}
int main(int argc, char **argv) {
cf_t *buffer;
int n;
rf_t rf;
srslte_rf_t rf;
srslte_filesink_t sink;
srslte_ue_sync_t ue_sync;
srslte_cell_t cell;
@ -118,28 +118,28 @@ int main(int argc, char **argv) {
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGINT);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
printf("Set RX freq: %.6f MHz\n", rf_set_rx_freq(&rf, rf_freq) / 1000000);
printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(&rf, rf_gain));
printf("Set RX freq: %.6f MHz\n", srslte_rf_set_rx_freq(&rf, rf_freq) / 1000000);
printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf, rf_gain));
int srate = srslte_sampling_freq_hz(nof_prb);
if (srate != -1) {
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_rf = rf_set_rx_srate(&rf, (double) srate);
float srate_rf = srslte_rf_set_rx_srate(&rf, (double) srate);
if (srate_rf != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
@ -148,15 +148,15 @@ int main(int argc, char **argv) {
fprintf(stderr, "Invalid number of PRB %d\n", nof_prb);
exit(-1);
}
rf_rx_wait_lo_locked(&rf);
rf_start_rx_stream(&rf);
srslte_rf_rx_wait_lo_locked(&rf);
srslte_rf_start_rx_stream(&rf);
cell.cp = SRSLTE_CP_NORM;
cell.id = N_id_2;
cell.nof_prb = nof_prb;
cell.nof_ports = 1;
if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, (void*) &rf)) {
if (srslte_ue_sync_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*) &rf)) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}
@ -191,7 +191,7 @@ int main(int argc, char **argv) {
}
srslte_filesink_free(&sink);
rf_close(&rf);
srslte_rf_close(&rf);
srslte_ue_sync_free(&ue_sync);
printf("Ok - wrote %d subframes\n", subframe_count);

@ -41,7 +41,7 @@ uint32_t nof_frames = 20;
int time_adv_samples = 0;
float tone_offset_hz = 1e6;
float rf_rx_gain=40, rf_tx_gain=40, rf_freq=2.4e9;
float rf_rx_gain=40, srslte_rf_tx_gain=40, rf_freq=2.4e9;
char *rf_args="";
char *output_filename = NULL;
char *input_filename = NULL;
@ -51,7 +51,7 @@ void usage(char *prog) {
printf("\t-a RF args [Default %s]\n", rf_args);
printf("\t-f RF TX/RX frequency [Default %.2f MHz]\n", rf_freq/1e6);
printf("\t-g RF RX gain [Default %.1f dB]\n", rf_rx_gain);
printf("\t-G RF TX gain [Default %.1f dB]\n", rf_tx_gain);
printf("\t-G RF TX gain [Default %.1f dB]\n", srslte_rf_tx_gain);
printf("\t-t Single tone offset (Hz) [Default %f]\n", tone_offset_hz);
printf("\t-T Time advance samples [Default %d]\n", time_adv_samples);
printf("\t-i File name to read signal from [Default single tone]\n");
@ -84,7 +84,7 @@ void parse_args(int argc, char **argv) {
rf_rx_gain = atof(argv[optind]);
break;
case 'G':
rf_tx_gain = atof(argv[optind]);
srslte_rf_tx_gain = atof(argv[optind]);
break;
case 'p':
nof_prb = atoi(argv[optind]);
@ -136,31 +136,31 @@ int main(int argc, char **argv) {
float time_adv_sec = (float) time_adv_samples/srslte_sampling_freq_hz(nof_prb);
// Send through RF
rf_t rf;
srslte_rf_t rf;
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
rf_set_master_clock_rate(&rf, 30.72e6);
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
int srate = srslte_sampling_freq_hz(nof_prb);
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
rf_set_rx_srate(&rf, (double) srate);
rf_set_tx_srate(&rf, (double) srate);
srslte_rf_set_rx_srate(&rf, (double) srate);
srslte_rf_set_tx_srate(&rf, (double) srate);
printf("Subframe len: %d samples\n", flen);
printf("Time advance: %f us\n",time_adv_sec*1e6);
printf("Set TX/RX rate: %.2f MHz\n", (float) srate / 1000000);
printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(&rf, rf_rx_gain));
printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(&rf, rf_tx_gain));
printf("Set TX/RX freq: %.2f MHz\n", rf_set_rx_freq(&rf, rf_freq) / 1000000);
rf_set_tx_freq(&rf, rf_freq);
printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf, rf_rx_gain));
printf("Set TX gain: %.1f dB\n", srslte_rf_set_tx_gain(&rf, srslte_rf_tx_gain));
printf("Set TX/RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, rf_freq) / 1000000);
srslte_rf_set_tx_freq(&rf, rf_freq);
sleep(1);
@ -170,22 +170,22 @@ int main(int argc, char **argv) {
for (int i=0;i<flen-time_adv_samples;i++) {
tx_buffer[i+time_adv_samples] = 0.3*cexpf(_Complex_I*2*M_PI*tone_offset_hz*((float) i/(float) srate));
}
srslte_vec_save_file("rf_txrx_tone", tx_buffer, flen*sizeof(cf_t));
srslte_vec_save_file("srslte_rf_txrx_tone", tx_buffer, flen*sizeof(cf_t));
}
srslte_timestamp_t tstamp;
rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf);
uint32_t nframe=0;
while(nframe<nof_frames) {
printf("Rx subframe %d\n", nframe);
rf_recv_with_time(&rf, &rx_buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
srslte_rf_recv_with_time(&rf, &rx_buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
nframe++;
if (nframe==9) {
srslte_timestamp_add(&tstamp, 0, 2e-3-time_adv_sec);
rf_send_timed2(&rf, tx_buffer, flen+time_adv_samples, tstamp.full_secs, tstamp.frac_secs, true, true);
srslte_rf_send_timed2(&rf, tx_buffer, flen+time_adv_samples, tstamp.full_secs, tstamp.frac_secs, true, true);
printf("Transmitting Signal\n");
}

@ -35,116 +35,116 @@
typedef struct {
void *handler;
void *dev;
} rf_t;
} srslte_rf_t;
typedef void (*rf_msg_handler_t)(const char*);
typedef void (*srslte_rf_msg_handler_t)(const char*);
SRSLTE_API int rf_open(rf_t *h,
SRSLTE_API int srslte_rf_open(srslte_rf_t *h,
char *args);
SRSLTE_API int rf_open_th(rf_t *h,
SRSLTE_API int srslte_rf_open_th(srslte_rf_t *h,
char *args,
bool tx_gain_same_rx);
SRSLTE_API int rf_open_devname(rf_t *h,
SRSLTE_API int srslte_rf_open_devname(srslte_rf_t *h,
char *devname,
char *args,
bool agc_thread,
bool tx_gain_same_rx);
SRSLTE_API int rf_close(rf_t *h);
SRSLTE_API int srslte_rf_close(srslte_rf_t *h);
SRSLTE_API int rf_start_rx_stream(rf_t *h);
SRSLTE_API int srslte_rf_start_rx_stream(srslte_rf_t *h);
SRSLTE_API int rf_stop_rx_stream(rf_t *h);
SRSLTE_API int srslte_rf_stop_rx_stream(srslte_rf_t *h);
SRSLTE_API void rf_flush_buffer(rf_t *h);
SRSLTE_API void srslte_rf_flush_buffer(srslte_rf_t *h);
SRSLTE_API bool rf_has_rssi(rf_t *h);
SRSLTE_API bool srslte_rf_has_rssi(srslte_rf_t *h);
SRSLTE_API float rf_get_rssi(rf_t *h);
SRSLTE_API float srslte_rf_get_rssi(srslte_rf_t *h);
SRSLTE_API bool rf_rx_wait_lo_locked(rf_t *h);
SRSLTE_API bool srslte_rf_rx_wait_lo_locked(srslte_rf_t *h);
SRSLTE_API void rf_set_master_clock_rate(rf_t *h,
SRSLTE_API void srslte_rf_set_master_clock_rate(srslte_rf_t *h,
double rate);
SRSLTE_API bool rf_is_master_clock_dynamic(rf_t *h);
SRSLTE_API bool srslte_rf_is_master_clock_dynamic(srslte_rf_t *h);
SRSLTE_API double rf_set_rx_srate(rf_t *h,
SRSLTE_API double srslte_rf_set_rx_srate(srslte_rf_t *h,
double freq);
SRSLTE_API double rf_set_rx_gain(rf_t *h,
SRSLTE_API double srslte_rf_set_rx_gain(srslte_rf_t *h,
double gain);
SRSLTE_API void rf_set_tx_rx_gain_offset(rf_t *h,
SRSLTE_API void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *h,
double offset);
SRSLTE_API double rf_set_rx_gain_th(rf_t *h,
SRSLTE_API double srslte_rf_set_rx_gain_th(srslte_rf_t *h,
double gain);
SRSLTE_API double rf_get_rx_gain(rf_t *h);
SRSLTE_API double srslte_rf_get_rx_gain(srslte_rf_t *h);
SRSLTE_API double rf_get_tx_gain(rf_t *h);
SRSLTE_API double srslte_rf_get_tx_gain(srslte_rf_t *h);
SRSLTE_API void rf_suppress_stdout(rf_t *h);
SRSLTE_API void srslte_rf_suppress_stdout(srslte_rf_t *h);
SRSLTE_API void rf_register_msg_handler(rf_t *h,
rf_msg_handler_t msg_handler);
SRSLTE_API void srslte_rf_register_msg_handler(srslte_rf_t *h,
srslte_rf_msg_handler_t msg_handler);
SRSLTE_API double rf_set_rx_freq(rf_t *h,
SRSLTE_API double srslte_rf_set_rx_freq(srslte_rf_t *h,
double freq);
SRSLTE_API int rf_recv(rf_t *h,
SRSLTE_API int srslte_rf_recv(srslte_rf_t *h,
void *data,
uint32_t nsamples,
bool blocking);
SRSLTE_API int rf_recv_with_time(rf_t *h,
SRSLTE_API int srslte_rf_recv_with_time(srslte_rf_t *h,
void *data,
uint32_t nsamples,
bool blocking,
time_t *secs,
double *frac_secs);
SRSLTE_API double rf_set_tx_srate(rf_t *h,
SRSLTE_API double srslte_rf_set_tx_srate(srslte_rf_t *h,
double freq);
SRSLTE_API double rf_set_tx_gain(rf_t *h,
SRSLTE_API double srslte_rf_set_tx_gain(srslte_rf_t *h,
double gain);
SRSLTE_API double rf_set_tx_freq(rf_t *h,
SRSLTE_API double srslte_rf_set_tx_freq(srslte_rf_t *h,
double freq);
SRSLTE_API void rf_get_time(rf_t *h,
SRSLTE_API void srslte_rf_get_time(srslte_rf_t *h,
time_t *secs,
double *frac_secs);
SRSLTE_API int rf_send(rf_t *h,
SRSLTE_API int srslte_rf_send(srslte_rf_t *h,
void *data,
uint32_t nsamples,
bool blocking);
SRSLTE_API int rf_send2(rf_t *h,
SRSLTE_API int srslte_rf_send2(srslte_rf_t *h,
void *data,
uint32_t nsamples,
bool blocking,
bool start_of_burst,
bool end_of_burst);
SRSLTE_API int rf_send(rf_t *h,
SRSLTE_API int srslte_rf_send(srslte_rf_t *h,
void *data,
uint32_t nsamples,
bool blocking);
SRSLTE_API int rf_send_timed(rf_t *h,
SRSLTE_API int srslte_rf_send_timed(srslte_rf_t *h,
void *data,
int nsamples,
time_t secs,
double frac_secs);
SRSLTE_API int rf_send_timed2(rf_t *h,
SRSLTE_API int srslte_rf_send_timed2(srslte_rf_t *h,
void *data,
int nsamples,
time_t secs,

@ -35,23 +35,23 @@ typedef struct SRSLTE_API {
float init_agc; // 0 or negative to disable AGC
} cell_search_cfg_t;
SRSLTE_API int rf_rssi_scan(rf_t *rf,
SRSLTE_API int rf_rssi_scan(srslte_rf_t *rf,
float *freqs,
float *rssi,
int nof_bands,
double fs,
int nsamp);
SRSLTE_API int rf_mib_decoder(rf_t *rf,
SRSLTE_API int rf_mib_decoder(srslte_rf_t *rf,
cell_search_cfg_t *config,
srslte_cell_t *cell);
SRSLTE_API int rf_cell_search(rf_t *rf,
SRSLTE_API int rf_cell_search(srslte_rf_t *rf,
cell_search_cfg_t *config,
int force_N_id_2,
srslte_cell_t *cell);
SRSLTE_API int rf_search_and_decode_mib(rf_t *rf,
SRSLTE_API int rf_search_and_decode_mib(srslte_rf_t *rf,
cell_search_cfg_t *config,
int force_N_id_2,
srslte_cell_t *cell);

@ -140,18 +140,18 @@ int main(int argc, char **argv) {
cf_t *buffer = malloc(sizeof(cf_t)*flen*nof_frames);
// Send through UHD
rf_t uhd;
srslte_rf_t uhd;
printf("Opening UHD device...\n");
if (rf_open(&uhd, uhd_args)) {
if (srslte_rf_open(&uhd, uhd_args)) {
fprintf(stderr, "Error opening &uhd\n");
exit(-1);
}
printf("Subframe len: %d samples\n", flen);
printf("Set TX/RX rate: %.2f MHz\n", rf_set_rx_srate(&uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(&uhd, uhd_gain));
printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(&uhd, uhd_gain));
printf("Set TX/RX freq: %.2f MHz\n", rf_set_rx_freq(&uhd, uhd_freq) / 1000000);
rf_set_tx_srate(&uhd, srslte_sampling_freq_hz(nof_prb));
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));
sleep(1);
cf_t *zeros = calloc(sizeof(cf_t),flen);
@ -163,20 +163,20 @@ int main(int argc, char **argv) {
srslte_timestamp_t tstamp;
rf_start_rx_stream(&uhd);
srslte_rf_start_rx_stream(&uhd);
uint32_t nframe=0;
while(nframe<nof_frames) {
printf("Rx subframe %d\n", nframe);
rf_recv_with_time(&uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
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);
if (nframe==8) {
rf_send_timed2(&uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
srslte_rf_send_timed2(&uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
printf("Transmitting zeros\n");
} else {
rf_send_timed2(&uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, true, true);
srslte_rf_send_timed2(&uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, true, true);
printf("Transmitting PRACH\n");
}
}

@ -35,7 +35,7 @@
#include "srslte/rf/rf.h"
#define CONVERT_BUFFER_SIZE 24*1024
#define CONVERT_BUFFER_SIZE 240*1024
typedef struct {
struct bladerf *dev;
@ -50,7 +50,7 @@ void rf_blade_suppress_stdout(void *h) {
bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_SILENT);
}
void rf_blade_register_msg_handler(void *notused, rf_msg_handler_t new_handler)
void rf_blade_register_msg_handler(void *notused, srslte_rf_msg_handler_t new_handler)
{
}

@ -78,7 +78,7 @@ SRSLTE_API double rf_blade_get_tx_gain(void *h);
SRSLTE_API void rf_blade_suppress_stdout(void *h);
SRSLTE_API void rf_blade_register_msg_handler(void *h, rf_msg_handler_t msg_handler);
SRSLTE_API void rf_blade_register_msg_handler(void *h, srslte_rf_msg_handler_t msg_handler);
SRSLTE_API double rf_blade_set_rx_freq(void *h,
double freq);

@ -28,32 +28,32 @@
/* RF frontend API */
typedef struct {
const char *name;
bool (*rf_rx_wait_lo_locked) (void*);
int (*rf_start_rx_stream)(void *h);
int (*rf_stop_rx_stream)(void *h);
void (*rf_flush_buffer)(void *h);
bool (*rf_has_rssi)(void *h);
float (*rf_get_rssi)(void *h);
double (*rf_set_rx_gain_th)(void *h, double gain);
void (*rf_set_tx_rx_gain_offset)(void *h, double offset);
void (*rf_suppress_stdout)(void *h);
void (*rf_register_msg_handler)(void *h, rf_msg_handler_t msg_handler);
int (*rf_open)(char *args, void **h, bool agc_thread, bool tx_gain_same_rx);
int (*rf_close)(void *h);
void (*rf_set_master_clock_rate)(void *h, double rate);
bool (*rf_is_master_clock_dynamic)(void *h);
double (*rf_set_rx_srate)(void *h, double freq);
double (*rf_set_rx_gain)(void *h, double gain);
double (*rf_set_tx_gain)(void *h, double gain);
double (*rf_get_rx_gain)(void *h);
double (*rf_get_tx_gain)(void *h);
double (*rf_set_rx_freq)(void *h, double freq);
double (*rf_set_tx_srate)(void *h, double freq);
double (*rf_set_tx_freq)(void *h, double freq);
void (*rf_get_time)(void *h, time_t *secs, double *frac_secs);
int (*rf_recv_with_time)(void *h, void *data, uint32_t nsamples,
bool (*srslte_rf_rx_wait_lo_locked) (void*);
int (*srslte_rf_start_rx_stream)(void *h);
int (*srslte_rf_stop_rx_stream)(void *h);
void (*srslte_rf_flush_buffer)(void *h);
bool (*srslte_rf_has_rssi)(void *h);
float (*srslte_rf_get_rssi)(void *h);
double (*srslte_rf_set_rx_gain_th)(void *h, double gain);
void (*srslte_rf_set_tx_rx_gain_offset)(void *h, double offset);
void (*srslte_rf_suppress_stdout)(void *h);
void (*srslte_rf_register_msg_handler)(void *h, srslte_rf_msg_handler_t msg_handler);
int (*srslte_rf_open)(char *args, void **h, bool agc_thread, bool tx_gain_same_rx);
int (*srslte_rf_close)(void *h);
void (*srslte_rf_set_master_clock_rate)(void *h, double rate);
bool (*srslte_rf_is_master_clock_dynamic)(void *h);
double (*srslte_rf_set_rx_srate)(void *h, double freq);
double (*srslte_rf_set_rx_gain)(void *h, double gain);
double (*srslte_rf_set_tx_gain)(void *h, double gain);
double (*srslte_rf_get_rx_gain)(void *h);
double (*srslte_rf_get_tx_gain)(void *h);
double (*srslte_rf_set_rx_freq)(void *h, double freq);
double (*srslte_rf_set_tx_srate)(void *h, double freq);
double (*srslte_rf_set_tx_freq)(void *h, double freq);
void (*srslte_rf_get_time)(void *h, time_t *secs, double *frac_secs);
int (*srslte_rf_recv_with_time)(void *h, void *data, uint32_t nsamples,
bool blocking, time_t *secs,double *frac_secs);
int (*rf_send_timed)(void *h, void *data, int nsamples,
int (*srslte_rf_send_timed)(void *h, void *data, int nsamples,
time_t secs, double frac_secs, bool has_time_spec,
bool blocking, bool is_start_of_burst, bool is_end_of_burst);
} rf_dev_t;

@ -40,14 +40,14 @@ int rf_get_available_devices(char **devnames, int max_strlen) {
}
int rf_open_devname(rf_t *rf, char *devname, char *args, bool agc_thread, bool tx_gain_same_rx) {
int srslte_rf_open_devname(srslte_rf_t *rf, char *devname, char *args, bool agc_thread, bool tx_gain_same_rx) {
/* Try to open the device if name is provided */
if (devname) {
int i=0;
while(available_devices[i] != NULL) {
if (!strcmp(available_devices[i]->name, devname)) {
rf->dev = available_devices[i];
return available_devices[i]->rf_open(args, &rf->handler, agc_thread, tx_gain_same_rx);
return available_devices[i]->srslte_rf_open(args, &rf->handler, agc_thread, tx_gain_same_rx);
}
i++;
}
@ -57,7 +57,7 @@ int rf_open_devname(rf_t *rf, char *devname, char *args, bool agc_thread, bool t
/* If in auto mode or provided device not found, try to open in order of apperance in available_devices[] array */
int i=0;
while(available_devices[i] != NULL) {
if (!available_devices[i]->rf_open(args, &rf->handler, agc_thread, tx_gain_same_rx)) {
if (!available_devices[i]->srslte_rf_open(args, &rf->handler, agc_thread, tx_gain_same_rx)) {
rf->dev = available_devices[i];
return 0;
}
@ -68,144 +68,144 @@ int rf_open_devname(rf_t *rf, char *devname, char *args, bool agc_thread, bool t
}
bool rf_rx_wait_lo_locked(rf_t *rf)
bool srslte_rf_rx_wait_lo_locked(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_rx_wait_lo_locked(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_rx_wait_lo_locked(rf->handler);
}
int rf_start_rx_stream(rf_t *rf)
int srslte_rf_start_rx_stream(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_start_rx_stream(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_start_rx_stream(rf->handler);
}
int rf_stop_rx_stream(rf_t *rf)
int srslte_rf_stop_rx_stream(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_stop_rx_stream(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_stop_rx_stream(rf->handler);
}
void rf_flush_buffer(rf_t *rf)
void srslte_rf_flush_buffer(srslte_rf_t *rf)
{
((rf_dev_t*) rf->dev)->rf_flush_buffer(rf->handler);
((rf_dev_t*) rf->dev)->srslte_rf_flush_buffer(rf->handler);
}
bool rf_has_rssi(rf_t *rf)
bool srslte_rf_has_rssi(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_has_rssi(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_has_rssi(rf->handler);
}
float rf_get_rssi(rf_t *rf)
float srslte_rf_get_rssi(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_get_rssi(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_get_rssi(rf->handler);
}
double rf_set_rx_gain_th(rf_t *rf, double gain)
double srslte_rf_set_rx_gain_th(srslte_rf_t *rf, double gain)
{
return ((rf_dev_t*) rf->dev)->rf_set_rx_gain_th(rf->handler, gain);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_rx_gain_th(rf->handler, gain);
}
void rf_set_tx_rx_gain_offset(rf_t *rf, double offset)
void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *rf, double offset)
{
((rf_dev_t*) rf->dev)->rf_set_tx_rx_gain_offset(rf->handler, offset);
((rf_dev_t*) rf->dev)->srslte_rf_set_tx_rx_gain_offset(rf->handler, offset);
}
void rf_suppress_stdout(rf_t *rf)
void srslte_rf_suppress_stdout(srslte_rf_t *rf)
{
((rf_dev_t*) rf->dev)->rf_suppress_stdout(rf->handler);
((rf_dev_t*) rf->dev)->srslte_rf_suppress_stdout(rf->handler);
}
void rf_register_msg_handler(rf_t *rf, rf_msg_handler_t msg_handler)
void srslte_rf_register_msg_handler(srslte_rf_t *rf, srslte_rf_msg_handler_t msg_handler)
{
((rf_dev_t*) rf->dev)->rf_register_msg_handler(rf->handler, msg_handler);
((rf_dev_t*) rf->dev)->srslte_rf_register_msg_handler(rf->handler, msg_handler);
}
int rf_open(rf_t *h, char *args)
int srslte_rf_open(srslte_rf_t *h, char *args)
{
return rf_open_devname(h, NULL, args, false, false);
return srslte_rf_open_devname(h, NULL, args, false, false);
}
int rf_open_th(rf_t *h, char *args, bool tx_gain_same_rx)
int srslte_rf_open_th(srslte_rf_t *h, char *args, bool tx_gain_same_rx)
{
return rf_open_devname(h, NULL, args, true, tx_gain_same_rx);
return srslte_rf_open_devname(h, NULL, args, true, tx_gain_same_rx);
}
int rf_close(rf_t *rf)
int srslte_rf_close(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_close(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_close(rf->handler);
}
void rf_set_master_clock_rate(rf_t *rf, double rate)
void srslte_rf_set_master_clock_rate(srslte_rf_t *rf, double rate)
{
((rf_dev_t*) rf->dev)->rf_set_master_clock_rate(rf->handler, rate);
((rf_dev_t*) rf->dev)->srslte_rf_set_master_clock_rate(rf->handler, rate);
}
bool rf_is_master_clock_dynamic(rf_t *rf)
bool srslte_rf_is_master_clock_dynamic(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_is_master_clock_dynamic(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_is_master_clock_dynamic(rf->handler);
}
double rf_set_rx_srate(rf_t *rf, double freq)
double srslte_rf_set_rx_srate(srslte_rf_t *rf, double freq)
{
return ((rf_dev_t*) rf->dev)->rf_set_rx_srate(rf->handler, freq);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_rx_srate(rf->handler, freq);
}
double rf_set_rx_gain(rf_t *rf, double gain)
double srslte_rf_set_rx_gain(srslte_rf_t *rf, double gain)
{
return ((rf_dev_t*) rf->dev)->rf_set_rx_gain(rf->handler, gain);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_rx_gain(rf->handler, gain);
}
double rf_get_rx_gain(rf_t *rf)
double srslte_rf_get_rx_gain(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_get_rx_gain(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_get_rx_gain(rf->handler);
}
double rf_get_tx_gain(rf_t *rf)
double srslte_rf_get_tx_gain(srslte_rf_t *rf)
{
return ((rf_dev_t*) rf->dev)->rf_get_tx_gain(rf->handler);
return ((rf_dev_t*) rf->dev)->srslte_rf_get_tx_gain(rf->handler);
}
double rf_set_rx_freq(rf_t *rf, double freq)
double srslte_rf_set_rx_freq(srslte_rf_t *rf, double freq)
{
return ((rf_dev_t*) rf->dev)->rf_set_rx_freq(rf->handler, freq);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_rx_freq(rf->handler, freq);
}
int rf_recv(rf_t *rf, void *data, uint32_t nsamples, bool blocking)
int srslte_rf_recv(srslte_rf_t *rf, void *data, uint32_t nsamples, bool blocking)
{
return rf_recv_with_time(rf, data, nsamples, blocking, NULL, NULL);
return srslte_rf_recv_with_time(rf, data, nsamples, blocking, NULL, NULL);
}
int rf_recv_with_time(rf_t *rf,
int srslte_rf_recv_with_time(srslte_rf_t *rf,
void *data,
uint32_t nsamples,
bool blocking,
time_t *secs,
double *frac_secs)
{
return ((rf_dev_t*) rf->dev)->rf_recv_with_time(rf->handler, data, nsamples, blocking, secs, frac_secs);
return ((rf_dev_t*) rf->dev)->srslte_rf_recv_with_time(rf->handler, data, nsamples, blocking, secs, frac_secs);
}
double rf_set_tx_gain(rf_t *rf, double gain)
double srslte_rf_set_tx_gain(srslte_rf_t *rf, double gain)
{
return ((rf_dev_t*) rf->dev)->rf_set_tx_gain(rf->handler, gain);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_tx_gain(rf->handler, gain);
}
double rf_set_tx_srate(rf_t *rf, double freq)
double srslte_rf_set_tx_srate(srslte_rf_t *rf, double freq)
{
return ((rf_dev_t*) rf->dev)->rf_set_tx_srate(rf->handler, freq);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_tx_srate(rf->handler, freq);
}
double rf_set_tx_freq(rf_t *rf, double freq)
double srslte_rf_set_tx_freq(srslte_rf_t *rf, double freq)
{
return ((rf_dev_t*) rf->dev)->rf_set_tx_freq(rf->handler, freq);
return ((rf_dev_t*) rf->dev)->srslte_rf_set_tx_freq(rf->handler, freq);
}
void rf_get_time(rf_t *rf, time_t *secs, double *frac_secs)
void srslte_rf_get_time(srslte_rf_t *rf, time_t *secs, double *frac_secs)
{
return ((rf_dev_t*) rf->dev)->rf_get_time(rf->handler, secs, frac_secs);
return ((rf_dev_t*) rf->dev)->srslte_rf_get_time(rf->handler, secs, frac_secs);
}
int rf_send_timed3(rf_t *rf,
int srslte_rf_send_timed3(srslte_rf_t *rf,
void *data,
int nsamples,
time_t secs,
@ -216,31 +216,31 @@ int rf_send_timed3(rf_t *rf,
bool is_end_of_burst)
{
return ((rf_dev_t*) rf->dev)->rf_send_timed(rf->handler, data, nsamples, secs, frac_secs,
return ((rf_dev_t*) rf->dev)->srslte_rf_send_timed(rf->handler, data, nsamples, secs, frac_secs,
has_time_spec, blocking, is_start_of_burst, is_end_of_burst);
}
int rf_send(rf_t *rf, void *data, uint32_t nsamples, bool blocking)
int srslte_rf_send(srslte_rf_t *rf, void *data, uint32_t nsamples, bool blocking)
{
return rf_send2(rf, data, nsamples, blocking, true, true);
return srslte_rf_send2(rf, data, nsamples, blocking, true, true);
}
int rf_send2(rf_t *rf, void *data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst)
int srslte_rf_send2(srslte_rf_t *rf, void *data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst)
{
return rf_send_timed3(rf, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst);
return srslte_rf_send_timed3(rf, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst);
}
int rf_send_timed(rf_t *rf,
int srslte_rf_send_timed(srslte_rf_t *rf,
void *data,
int nsamples,
time_t secs,
double frac_secs)
{
return rf_send_timed2(rf, data, nsamples, secs, frac_secs, true, true);
return srslte_rf_send_timed2(rf, data, nsamples, secs, frac_secs, true, true);
}
int rf_send_timed2(rf_t *rf,
int srslte_rf_send_timed2(srslte_rf_t *rf,
void *data,
int nsamples,
time_t secs,
@ -248,5 +248,5 @@ int rf_send_timed2(rf_t *rf,
bool is_start_of_burst,
bool is_end_of_burst)
{
return rf_send_timed3(rf, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst);
return srslte_rf_send_timed3(rf, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst);
}

@ -67,7 +67,7 @@ void rf_uhd_suppress_stdout(void *h) {
rf_uhd_register_msg_handler(h, suppress_handler);
}
void rf_uhd_register_msg_handler(void *notused, rf_msg_handler_t new_handler)
void rf_uhd_register_msg_handler(void *notused, srslte_rf_msg_handler_t new_handler)
{
rf_uhd_register_msg_handler_c(new_handler);
}

@ -80,7 +80,7 @@ SRSLTE_API double rf_uhd_get_tx_gain(void *h);
SRSLTE_API void rf_uhd_suppress_stdout(void *h);
SRSLTE_API void rf_uhd_register_msg_handler(void *h, rf_msg_handler_t msg_handler);
SRSLTE_API void rf_uhd_register_msg_handler(void *h, srslte_rf_msg_handler_t msg_handler);
SRSLTE_API double rf_uhd_set_rx_freq(void *h,
double freq);

@ -39,7 +39,7 @@
#include "srslte/rf/rf.h"
#include "srslte/rf/rf_utils.h"
int rf_rssi_scan(rf_t *rf, float *freqs, float *rssi, int nof_bands, double fs, int nsamp) {
int rf_rssi_scan(srslte_rf_t *rf, float *freqs, float *rssi, int nof_bands, double fs, int nsamp) {
int i, j;
int ret = -1;
cf_t *buffer;
@ -50,21 +50,21 @@ int rf_rssi_scan(rf_t *rf, float *freqs, float *rssi, int nof_bands, double fs,
goto free_and_exit;
}
rf_set_rx_gain(rf, 20.0);
rf_set_rx_srate(rf, fs);
srslte_rf_set_rx_gain(rf, 20.0);
srslte_rf_set_rx_srate(rf, fs);
for (i=0;i<nof_bands;i++) {
rf_stop_rx_stream(rf);
srslte_rf_stop_rx_stream(rf);
f = (double) freqs[i];
rf_set_rx_freq(rf, f);
rf_rx_wait_lo_locked(rf);
srslte_rf_set_rx_freq(rf, f);
srslte_rf_rx_wait_lo_locked(rf);
usleep(10000);
rf_start_rx_stream(rf);
srslte_rf_start_rx_stream(rf);
/* discard first samples */
for (j=0;j<2;j++) {
if (rf_recv(rf, buffer, nsamp, 1) != nsamp) {
if (srslte_rf_recv(rf, buffer, nsamp, 1) != nsamp) {
goto free_and_exit;
}
}
@ -74,7 +74,7 @@ int rf_rssi_scan(rf_t *rf, float *freqs, float *rssi, int nof_bands, double fs,
printf("\n");
}
}
rf_stop_rx_stream(rf);
srslte_rf_stop_rx_stream(rf);
ret = 0;
free_and_exit:
@ -83,38 +83,38 @@ free_and_exit:
}
int rf_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
int srslte_rf_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return rf_recv(h, data, nsamples, 1);
return srslte_rf_recv(h, data, nsamples, 1);
}
double rf_set_rx_gain_th_wrapper(void *h, double f) {
return rf_set_rx_gain_th((rf_t*) h, f);
double srslte_rf_set_rx_gain_th_wrapper(void *h, double f) {
return srslte_rf_set_rx_gain_th((srslte_rf_t*) h, f);
}
/** This function is simply a wrapper to the ue_cell_search module for rf devices
* Return 1 if the MIB is decoded, 0 if not or -1 on error.
*/
int rf_mib_decoder(rf_t *rf, cell_search_cfg_t *config, srslte_cell_t *cell) {
int rf_mib_decoder(srslte_rf_t *rf, cell_search_cfg_t *config, srslte_cell_t *cell) {
int ret = SRSLTE_ERROR;
srslte_ue_mib_sync_t ue_mib;
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, rf_recv_wrapper_cs, (void*) rf)) {
if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, srslte_rf_recv_wrapper_cs, (void*) rf)) {
fprintf(stderr, "Error initiating srslte_ue_mib_sync\n");
goto clean_exit;
}
if (config->init_agc > 0) {
srslte_ue_sync_start_agc(&ue_mib.ue_sync, rf_set_rx_gain_th_wrapper, config->init_agc);
srslte_ue_sync_start_agc(&ue_mib.ue_sync, srslte_rf_set_rx_gain_th_wrapper, config->init_agc);
}
int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB);
INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000);
rf_set_rx_srate(rf, (float) srate);
srslte_rf_set_rx_srate(rf, (float) srate);
INFO("Starting receiver...\n", 0);
rf_start_rx_stream(rf);
srslte_rf_start_rx_stream(rf);
/* Find and decody MIB */
ret = srslte_ue_mib_sync_decode(&ue_mib, config->max_frames_pss, bch_payload, &cell->nof_ports, NULL);
@ -133,7 +133,7 @@ int rf_mib_decoder(rf_t *rf, cell_search_cfg_t *config, srslte_cell_t *cell) {
clean_exit:
rf_stop_rx_stream(rf);
srslte_rf_stop_rx_stream(rf);
srslte_ue_mib_sync_free(&ue_mib);
return ret;
@ -141,7 +141,7 @@ clean_exit:
/** This function is simply a wrapper to the ue_cell_search module for rf devices
*/
int rf_cell_search(rf_t *rf, cell_search_cfg_t *config,
int rf_cell_search(srslte_rf_t *rf, cell_search_cfg_t *config,
int force_N_id_2, srslte_cell_t *cell)
{
int ret = SRSLTE_ERROR;
@ -150,7 +150,7 @@ int rf_cell_search(rf_t *rf, cell_search_cfg_t *config,
bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (srslte_ue_cellsearch_init(&cs, rf_recv_wrapper_cs, (void*) rf)) {
if (srslte_ue_cellsearch_init(&cs, srslte_rf_recv_wrapper_cs, (void*) rf)) {
fprintf(stderr, "Error initiating UE cell detect\n");
return SRSLTE_ERROR;
}
@ -163,14 +163,14 @@ int rf_cell_search(rf_t *rf, cell_search_cfg_t *config,
}
if (config->init_agc > 0) {
srslte_ue_sync_start_agc(&cs.ue_sync, rf_set_rx_gain_th_wrapper, config->init_agc);
srslte_ue_sync_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_th_wrapper, config->init_agc);
}
INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000);
rf_set_rx_srate(rf, SRSLTE_CS_SAMP_FREQ);
srslte_rf_set_rx_srate(rf, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0);
rf_start_rx_stream(rf);
srslte_rf_start_rx_stream(rf);
/* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */
uint32_t max_peak_cell = 0;
@ -211,7 +211,7 @@ int rf_cell_search(rf_t *rf, cell_search_cfg_t *config,
config->init_agc = srslte_agc_get_gain(&cs.ue_sync.agc);
}
rf_stop_rx_stream(rf);
srslte_rf_stop_rx_stream(rf);
srslte_ue_cellsearch_free(&cs);
return ret;
@ -223,7 +223,7 @@ int rf_cell_search(rf_t *rf, cell_search_cfg_t *config,
* 0 if no cell was found or MIB could not be decoded,
* -1 on error
*/
int rf_search_and_decode_mib(rf_t *rf, cell_search_cfg_t *config, int force_N_id_2, srslte_cell_t *cell)
int rf_search_and_decode_mib(srslte_rf_t *rf, cell_search_cfg_t *config, int force_N_id_2, srslte_cell_t *cell)
{
int ret = SRSLTE_ERROR;

@ -9,7 +9,7 @@ extern "C" {
#include "uhd_c_api.h"
}
static rf_msg_handler_t msg_handler;
static srslte_rf_msg_handler_t msg_handler;
void translate_handler(uhd::msg::type_t type, const std::string & msg)
{
@ -17,7 +17,7 @@ void translate_handler(uhd::msg::type_t type, const std::string & msg)
msg_handler(msg.c_str());
}
void rf_uhd_register_msg_handler_c(rf_msg_handler_t new_handler)
void rf_uhd_register_msg_handler_c(srslte_rf_msg_handler_t new_handler)
{
msg_handler = new_handler;
uhd::msg::register_handler(translate_handler);

@ -4,7 +4,7 @@
#include "srslte/rf/rf.h"
/* Declare functions not currently provided by the C-API */
SRSLTE_API void rf_uhd_register_msg_handler_c(rf_msg_handler_t new_handler);
SRSLTE_API void rf_uhd_register_msg_handler_c(srslte_rf_msg_handler_t new_handler);
SRSLTE_API void uhd_tx_metadata_set_time_spec(uhd_tx_metadata_handle *md, time_t secs, double frac_secs);
SRSLTE_API void uhd_tx_metadata_set_start(uhd_tx_metadata_handle *md, bool is_start_of_burst);
SRSLTE_API void uhd_tx_metadata_set_end(uhd_tx_metadata_handle *md, bool is_end_of_burst);

@ -124,7 +124,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) {
cf_t *buffer;
int frame_cnt, n;
rf_t rf;
srslte_rf_t rf;
srslte_pss_synch_t pss;
srslte_cfo_t cfocorr, cfocorr64;
srslte_sss_synch_t sss;
@ -153,21 +153,21 @@ int main(int argc, char **argv) {
flen = srate*5/1000;
printf("Opening RF device...\n");
if (rf_open(&rf, rf_args)) {
if (srslte_rf_open(&rf, rf_args)) {
fprintf(stderr, "Error opening rf\n");
exit(-1);
}
if (srate < 10e6) {
rf_set_master_clock_rate(&rf, 4*srate);
srslte_rf_set_master_clock_rate(&rf, 4*srate);
} else {
rf_set_master_clock_rate(&rf, srate);
srslte_rf_set_master_clock_rate(&rf, srate);
}
printf("Set RX rate: %.2f MHz\n", rf_set_rx_srate(&rf, srate) / 1000000);
printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(&rf, rf_gain));
printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(&rf, rf_freq) / 1000000);
rf_rx_wait_lo_locked(&rf);
printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000);
printf("Set RX gain: %.1f dB\n", srslte_rf_set_rx_gain(&rf, rf_gain));
printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, rf_freq) / 1000000);
srslte_rf_rx_wait_lo_locked(&rf);
buffer = malloc(sizeof(cf_t) * flen * 2);
if (!buffer) {
@ -197,7 +197,7 @@ int main(int argc, char **argv) {
printf("N_id_2: %d\n", N_id_2);
rf_start_rx_stream(&rf);
srslte_rf_start_rx_stream(&rf);
printf("Frame length %d samples\n", flen);
printf("PSS detection threshold: %.2f\n", threshold);
@ -218,7 +218,7 @@ int main(int argc, char **argv) {
ssync.fft_size = fft_size;
while(frame_cnt < nof_frames || nof_frames == -1) {
n = rf_recv(&rf, buffer, flen - peak_offset, 1);
n = srslte_rf_recv(&rf, buffer, flen - peak_offset, 1);
if (n < 0) {
fprintf(stderr, "Error receiving samples\n");
exit(-1);
@ -330,7 +330,7 @@ int main(int argc, char **argv) {
srslte_pss_synch_free(&pss);
free(buffer);
rf_close(&rf);
srslte_rf_close(&rf);
printf("Ok\n");
exit(0);

Loading…
Cancel
Save