Renamed CUHD module to RF. Added bladeRF module to CMake

master
ismagom 9 years ago
parent 815834f61b
commit ba5b14ee3d

@ -0,0 +1,27 @@
if(NOT BLADERF_FOUND)
pkg_check_modules (BLADERF_PKG libbladeRF)
find_path(BLADERF_INCLUDE_DIRS NAMES libbladeRF.h
PATHS
${BLADERF_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library(BLADERF_LIBRARIES NAMES bladeRF
PATHS
${BLADERF_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
if(BLADERF_INCLUDE_DIRS AND BLADERF_LIBRARIES)
set(BLADERF_FOUND TRUE CACHE INTERNAL "libbladeRF found")
message(STATUS "Found libbladeRF: ${BLADERF_INCLUDE_DIRS}, ${BLADERF_LIBRARIES}")
else(BLADERF_INCLUDE_DIRS AND BLADERF_LIBRARIES)
set(BLADERF_FOUND FALSE CACHE INTERNAL "libbladeRF found")
message(STATUS "libbladeRF not found.")
endif(BLADERF_INCLUDE_DIRS AND BLADERF_LIBRARIES)
mark_as_advanced(BLADERF_LIBRARIES BLADERF_INCLUDE_DIRS)
endif(NOT BLADERF_FOUND)

@ -1,52 +0,0 @@
# - Try to find openLTE's liblte
find_package(PkgConfig)
pkg_check_modules(PC_OPENLTE QUIET srslte)
set(OPENLTE_DEFINITIONS ${PC_OPENLTE_CFLAGS_OTHER})
FIND_PATH(
OPENLTE_LIBLTE_DIRS
NAMES liblte_common.h typedefs.h
HINTS ${PC_OPENLTE_SRCDIR}/liblte/hdr
${PC_OPENLTE_INCLUDEDIR}
${PC_OPENLTE_INCLUDE_DIRS}
$ENV{OPENLTE_DIR}/liblte/hdr
PATHS /usr/local/include
/usr/include
)
FIND_PATH(
OPENLTE_COMMON_DIRS
NAMES typedefs.h
HINTS ${PC_OPENLTE_SRCDIR}/cmn_hdr
${PC_OPENLTE_INCLUDEDIR}
${PC_OPENLTE_INCLUDE_DIRS}
$ENV{OPENLTE_DIR}/liblte/hdr
PATHS /usr/local/include
/usr/include
)
FIND_LIBRARY(
OPENLTE_LIBRARIES
NAMES lte
HINTS ${PC_OPENLTE_BUILDDIR}/liblte
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
$ENV{OPENLTE_DIR}/lib
PATHS /usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
)
IF(OPENLTE_LIBLTE_DIRS AND OPENLTE_COMMON_DIRS)
SET(OPENLTE_INCLUDE_DIRS ${OPENLTE_LIBLTE_DIRS} ${OPENLTE_COMMON_DIRS})
ENDIF(OPENLTE_LIBLTE_DIRS AND OPENLTE_COMMON_DIRS)
message(STATUS "OPENLTE LIBRARIES " ${OPENLTE_LIBRARIES})
message(STATUS "OPENLTE INCLUDE DIRS " ${OPENLTE_INCLUDE_DIRS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENLTE DEFAULT_MSG OPENLTE_LIBRARIES OPENLTE_INCLUDE_DIRS)
MARK_AS_ADVANCED(OPENLTE_LIBRARIES OPENLTE_INCLUDE_DIRS)

@ -43,6 +43,13 @@ ADD_CUSTOM_TARGET (add_srslte_headers SOURCES ${HEADERS_ALL})
# Find Dependencies # Find Dependencies
######################################################################## ########################################################################
FIND_PACKAGE(UHD) FIND_PACKAGE(UHD)
FIND_PACKAGE(bladeRF)
IF(BLADERF_FOUND OR UHD_FOUND)
set(RF_FOUND TRUE CACHE INTERNAL "RF frontend found")
ELSE(BLADERF_FOUND OR UHD_FOUND)
set(RF_FOUND FALSE CACHE INTERNAL "RF frontend found")
ENDIF(BLADERF_FOUND OR UHD_FOUND)
######################################################################## ########################################################################
# Add subdirectories # Add subdirectories

@ -40,12 +40,12 @@ target_link_libraries(pdsch_ue srslte pthread)
add_executable(pdsch_enodeb pdsch_enodeb.c) add_executable(pdsch_enodeb pdsch_enodeb.c)
target_link_libraries(pdsch_enodeb srslte pthread) target_link_libraries(pdsch_enodeb srslte pthread)
IF(UHD_FOUND) IF(RF_FOUND)
target_link_libraries(pdsch_ue srslte_uhd) target_link_libraries(pdsch_ue srslte_rf)
target_link_libraries(pdsch_enodeb srslte_uhd) target_link_libraries(pdsch_enodeb srslte_rf)
ELSE(UHD_FOUND) ELSE(RF_FOUND)
add_definitions(-DDISABLE_UHD) add_definitions(-DDISABLE_RF)
ENDIF(UHD_FOUND) ENDIF(RF_FOUND)
FIND_PACKAGE(SRSGUI) FIND_PACKAGE(SRSGUI)
@ -61,28 +61,28 @@ ENDIF(SRSGUI_FOUND)
# These examples need the UHD driver # These examples need the UHD driver
################################################################# #################################################################
IF(UHD_FOUND) IF(RF_FOUND)
add_executable(cell_search cell_search.c) add_executable(cell_search cell_search.c)
target_link_libraries(cell_search srslte srslte_uhd) target_link_libraries(cell_search srslte srslte_rf)
add_executable(cell_measurement cell_measurement.c) add_executable(cell_measurement cell_measurement.c)
target_link_libraries(cell_measurement srslte srslte_uhd) target_link_libraries(cell_measurement srslte srslte_rf)
add_executable(usrp_capture usrp_capture.c) add_executable(usrp_capture usrp_capture.c)
target_link_libraries(usrp_capture srslte srslte_uhd) target_link_libraries(usrp_capture srslte srslte_rf)
add_executable(usrp_capture_sync usrp_capture_sync.c) add_executable(usrp_capture_sync usrp_capture_sync.c)
target_link_libraries(usrp_capture_sync srslte srslte_uhd) target_link_libraries(usrp_capture_sync srslte srslte_rf)
add_executable(usrp_txrx usrp_txrx.c) add_executable(usrp_txrx usrp_txrx.c)
target_link_libraries(usrp_txrx srslte srslte_uhd) target_link_libraries(usrp_txrx srslte srslte_rf)
MESSAGE(STATUS " UHD examples will be installed.") MESSAGE(STATUS " examples will be installed.")
ELSE(UHD_FOUND) ELSE(RF_FOUND)
MESSAGE(STATUS " UHD examples NOT INSTALLED.") MESSAGE(STATUS " examples will NOT BE INSTALLED.")
ENDIF(UHD_FOUND) ENDIF(RF_FOUND)
# Add subdirectories # Add subdirectories
add_subdirectory(tutorial_examples) add_subdirectory(tutorial_examples)

@ -36,8 +36,8 @@
#include <signal.h> #include <signal.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/cuhd/cuhd_utils.h" #include "srslte/rf/rf_utils.h"
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
@ -123,9 +123,9 @@ void sig_int_handler(int signo)
} }
} }
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) { int rf_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);
return cuhd_recv(h, data, nsamples, 1); return rf_recv(h, data, nsamples, 1);
} }
enum receiver_state { DECODE_MIB, DECODE_SIB, MEASURE} state; enum receiver_state { DECODE_MIB, DECODE_SIB, MEASURE} state;
@ -160,18 +160,18 @@ int main(int argc, char **argv) {
if (prog_args.uhd_gain > 0) { if (prog_args.uhd_gain > 0) {
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(prog_args.uhd_args, &uhd)) { if (rf_open(prog_args.uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, prog_args.uhd_gain); rf_set_rx_gain(uhd, prog_args.uhd_gain);
} else { } else {
printf("Opening UHD device with threaded RX Gain control ...\n"); printf("Opening UHD device with threaded RX Gain control ...\n");
if (cuhd_open_th(prog_args.uhd_args, &uhd, false)) { if (rf_open_th(prog_args.uhd_args, &uhd, false)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, 50); rf_set_rx_gain(uhd, 50);
} }
sigset_t sigset; sigset_t sigset;
@ -180,16 +180,16 @@ int main(int argc, char **argv) {
sigprocmask(SIG_UNBLOCK, &sigset, NULL); sigprocmask(SIG_UNBLOCK, &sigset, NULL);
signal(SIGINT, sig_int_handler); signal(SIGINT, sig_int_handler);
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
/* set receiver frequency */ /* set receiver frequency */
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq); rf_set_rx_freq(uhd, (double) prog_args.uhd_freq);
cuhd_rx_wait_lo_locked(uhd); rf_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; uint32_t ntrial=0;
do { do {
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell); ret = rf_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 for cell\n"); fprintf(stderr, "Error searching for cell\n");
exit(-1); exit(-1);
@ -206,12 +206,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000); printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate); float srate_uhd = rf_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) { if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n"); fprintf(stderr, "Could not set sampling rate\n");
exit(-1); exit(-1);
@ -222,10 +222,10 @@ int main(int argc, char **argv) {
} }
INFO("Stopping UHD and flushing buffer...\n",0); INFO("Stopping UHD and flushing buffer...\n",0);
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
cuhd_flush_buffer(uhd); rf_flush_buffer(uhd);
if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
return -1; return -1;
} }
@ -261,7 +261,7 @@ int main(int argc, char **argv) {
ce[i] = srslte_vec_malloc(sizeof(cf_t) * sf_re); ce[i] = srslte_vec_malloc(sizeof(cf_t) * sf_re);
} }
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
float rx_gain_offset = 0; float rx_gain_offset = 0;
@ -333,10 +333,10 @@ int main(int argc, char **argv) {
if ((nframes%100) == 0 || rx_gain_offset == 0) { if ((nframes%100) == 0 || rx_gain_offset == 0) {
if (cuhd_has_rssi(uhd)) { if (rf_has_rssi(uhd)) {
rx_gain_offset = 10*log10(rssi)-cuhd_get_rssi(uhd); rx_gain_offset = 10*log10(rssi)-rf_get_rssi(uhd);
} else { } else {
rx_gain_offset = cuhd_get_rx_gain(uhd); rx_gain_offset = rf_get_rx_gain(uhd);
} }
} }
@ -373,7 +373,7 @@ int main(int argc, char **argv) {
} // Main loop } // Main loop
srslte_ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
cuhd_close(uhd); rf_close(uhd);
printf("\nBye\n"); printf("\nBye\n");
exit(0); exit(0);
} }

@ -37,11 +37,11 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd_utils.h" #include "srslte/rf/rf_utils.h"
#ifndef DISABLE_UHD #ifndef DISABLE_RF
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#endif #endif
#define MHZ 1000000 #define MHZ 1000000
@ -123,9 +123,9 @@ void parse_args(int argc, char **argv) {
} }
} }
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) { int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return cuhd_recv(h, data, nsamples, 1); return rf_recv(h, data, nsamples, 1);
} }
bool go_exit = false; bool go_exit = false;
@ -152,24 +152,24 @@ int main(int argc, char **argv) {
if (!config.init_agc) { if (!config.init_agc) {
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, uhd_gain); rf_set_rx_gain(uhd, uhd_gain);
} else { } else {
printf("Opening UHD device with threaded RX Gain control ...\n"); printf("Opening UHD device with threaded RX Gain control ...\n");
if (cuhd_open_th(uhd_args, &uhd, false)) { if (rf_open_th(uhd_args, &uhd, false)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, 50); rf_set_rx_gain(uhd, 50);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
// Supress UHD messages // Supress UHD messages
cuhd_suppress_stdout(); rf_suppress_stdout();
nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN);
if (nof_freqs < 0) { if (nof_freqs < 0) {
@ -186,8 +186,8 @@ int main(int argc, char **argv) {
for (freq=0;freq<nof_freqs && !go_exit;freq++) { for (freq=0;freq<nof_freqs && !go_exit;freq++) {
/* set uhd_freq */ /* set uhd_freq */
cuhd_set_rx_freq(uhd, (double) channels[freq].fd * MHZ); rf_set_rx_freq(uhd, (double) channels[freq].fd * MHZ);
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
INFO("Set uhd_freq to %.3f MHz\n", (double) channels[freq].fd * MHZ/1000000); INFO("Set uhd_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, printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS.\n", freq, nof_freqs,
@ -199,7 +199,7 @@ int main(int argc, char **argv) {
bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t)); bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (srslte_ue_cellsearch_init(&cs, cuhd_recv_wrapper, uhd)) { if (srslte_ue_cellsearch_init(&cs, rf_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating UE cell detect\n"); fprintf(stderr, "Error initiating UE cell detect\n");
exit(-1); exit(-1);
} }
@ -211,13 +211,13 @@ int main(int argc, char **argv) {
srslte_ue_cellsearch_set_threshold(&cs, config.threshold); srslte_ue_cellsearch_set_threshold(&cs, config.threshold);
} }
if (config.init_agc) { if (config.init_agc) {
srslte_ue_sync_start_agc(&cs.ue_sync, cuhd_set_rx_gain, config.init_agc); srslte_ue_sync_start_agc(&cs.ue_sync, rf_set_rx_gain, config.init_agc);
} }
INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000);
cuhd_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ); rf_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0); INFO("Starting receiver...\n", 0);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL); n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL);
if (n < 0) { if (n < 0) {
@ -229,7 +229,7 @@ int main(int argc, char **argv) {
srslte_cell_t cell; srslte_cell_t cell;
cell.id = found_cells[i].cell_id; cell.id = found_cells[i].cell_id;
cell.cp = found_cells[i].cp; cell.cp = found_cells[i].cp;
int ret = cuhd_mib_decoder(uhd, &config, &cell); int ret = rf_mib_decoder(uhd, &config, &cell);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error decoding MIB\n"); fprintf(stderr, "Error decoding MIB\n");
exit(-1); exit(-1);
@ -266,7 +266,7 @@ int main(int argc, char **argv) {
printf("\nBye\n"); printf("\nBye\n");
cuhd_close(uhd); rf_close(uhd);
exit(0); exit(0);
} }

@ -40,8 +40,8 @@
#define UE_CRNTI 0x1234 #define UE_CRNTI 0x1234
#ifndef DISABLE_UHD #ifndef DISABLE_RF
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
void *uhd; void *uhd;
#else #else
#warning Compiling pdsch_ue with no UHD support #warning Compiling pdsch_ue with no UHD support
@ -101,7 +101,7 @@ int prbset_orig = 0;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [agmfoncvpu]\n", prog); printf("Usage: %s [agmfoncvpu]\n", prog);
#ifndef DISABLE_UHD #ifndef DISABLE_RF
printf("\t-a UHD args [Default %s]\n", uhd_args); printf("\t-a UHD args [Default %s]\n", uhd_args);
printf("\t-l UHD amplitude [Default %.2f]\n", uhd_amp); printf("\t-l UHD amplitude [Default %.2f]\n", uhd_amp);
printf("\t-g UHD TX gain [Default %.2f dB]\n", uhd_gain); printf("\t-g UHD TX gain [Default %.2f dB]\n", uhd_gain);
@ -160,7 +160,7 @@ void parse_args(int argc, char **argv) {
exit(-1); exit(-1);
} }
} }
#ifdef DISABLE_UHD #ifdef DISABLE_RF
if (!output_file_name) { if (!output_file_name) {
usage(argv[0]); usage(argv[0]);
exit(-1); exit(-1);
@ -193,9 +193,9 @@ void base_init() {
null_file_sink = true; null_file_sink = true;
} }
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_RF
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
@ -287,8 +287,8 @@ void base_free() {
srslte_filesink_free(&fsink); srslte_filesink_free(&fsink);
} }
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_RF
cuhd_close(&uhd); rf_close(&uhd);
#endif #endif
} }
@ -464,7 +464,7 @@ int main(int argc, char **argv) {
uint32_t sfn; uint32_t sfn;
srslte_chest_dl_t est; srslte_chest_dl_t est;
#ifdef DISABLE_UHD #ifdef DISABLE_RF
if (argc < 3) { if (argc < 3) {
usage(argv[0]); usage(argv[0]);
exit(-1); exit(-1);
@ -502,7 +502,7 @@ int main(int argc, char **argv) {
slot1_symbols[i] = &sf_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)]; slot1_symbols[i] = &sf_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)];
} }
#ifndef DISABLE_UHD #ifndef DISABLE_RF
sigset_t sigset; sigset_t sigset;
@ -516,12 +516,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000); printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_tx_srate(uhd, (double) srate); float srate_uhd = rf_set_tx_srate(uhd, (double) srate);
if (srate_uhd != srate) { if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n"); fprintf(stderr, "Could not set sampling rate\n");
exit(-1); exit(-1);
@ -530,9 +530,9 @@ int main(int argc, char **argv) {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1); exit(-1);
} }
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain)); printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(uhd, uhd_gain));
printf("Set TX freq: %.2f MHz\n", printf("Set TX freq: %.2f MHz\n",
cuhd_set_tx_freq(uhd, uhd_freq) / 1000000); rf_set_tx_freq(uhd, uhd_freq) / 1000000);
} }
#endif #endif
@ -642,11 +642,11 @@ int main(int argc, char **argv) {
} }
usleep(1000); usleep(1000);
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_RF
// FIXME // FIXME
float norm_factor = (float) cell.nof_prb/15/sqrtf(pdsch_cfg.grant.nof_prb); float norm_factor = (float) cell.nof_prb/15/sqrtf(pdsch_cfg.grant.nof_prb);
srslte_vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); srslte_vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
cuhd_send2(uhd, output_buffer, sf_n_samples, true, start_of_burst, false); rf_send2(uhd, output_buffer, sf_n_samples, true, start_of_burst, false);
start_of_burst=false; start_of_burst=false;
#endif #endif
} }

@ -40,9 +40,9 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
#ifndef DISABLE_UHD #ifndef DISABLE_RF
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/cuhd/cuhd_utils.h" #include "srslte/rf/rf_utils.h"
cell_search_cfg_t cell_detect_config = { cell_search_cfg_t cell_detect_config = {
5000, 5000,
@ -118,7 +118,7 @@ void args_default(prog_args_t *args) {
void usage(prog_args_t *args, char *prog) { void usage(prog_args_t *args, char *prog) {
printf("Usage: %s [agpPoOcildDnruv] -f rx_frequency (in Hz) | -i input_file\n", prog); printf("Usage: %s [agpPoOcildDnruv] -f rx_frequency (in Hz) | -i input_file\n", prog);
#ifndef DISABLE_UHD #ifndef DISABLE_RF
printf("\t-a UHD args [Default %s]\n", args->uhd_args); printf("\t-a UHD args [Default %s]\n", args->uhd_args);
printf("\t-g UHD fix RX gain [Default AGC]\n"); printf("\t-g UHD fix RX gain [Default AGC]\n");
#else #else
@ -240,10 +240,10 @@ void sig_int_handler(int signo)
} }
} }
#ifndef DISABLE_UHD #ifndef DISABLE_RF
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) { int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return cuhd_recv(h, data, nsamples, 1); return rf_recv(h, data, nsamples, 1);
} }
#endif #endif
@ -264,7 +264,7 @@ int main(int argc, char **argv) {
srslte_cell_t cell; srslte_cell_t cell;
int64_t sf_cnt; int64_t sf_cnt;
srslte_ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
#ifndef DISABLE_UHD #ifndef DISABLE_RF
void *uhd; void *uhd;
#endif #endif
uint32_t nof_trials = 0; uint32_t nof_trials = 0;
@ -290,24 +290,24 @@ int main(int argc, char **argv) {
srslte_netsink_set_nonblocking(&net_sink_signal); srslte_netsink_set_nonblocking(&net_sink_signal);
} }
#ifndef DISABLE_UHD #ifndef DISABLE_RF
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
/* Set receiver gain */ /* Set receiver gain */
if (prog_args.uhd_gain > 0) { if (prog_args.uhd_gain > 0) {
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(prog_args.uhd_args, &uhd)) { if (rf_open(prog_args.uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, prog_args.uhd_gain); rf_set_rx_gain(uhd, prog_args.uhd_gain);
} else { } else {
printf("Opening UHD device with threaded RX Gain control ...\n"); printf("Opening UHD device with threaded RX Gain control ...\n");
if (cuhd_open_th(prog_args.uhd_args, &uhd, false)) { if (rf_open_th(prog_args.uhd_args, &uhd, false)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_rx_gain(uhd, 50); rf_set_rx_gain(uhd, 50);
cell_detect_config.init_agc = 50; cell_detect_config.init_agc = 50;
} }
@ -317,16 +317,16 @@ int main(int argc, char **argv) {
sigprocmask(SIG_UNBLOCK, &sigset, NULL); sigprocmask(SIG_UNBLOCK, &sigset, NULL);
signal(SIGINT, sig_int_handler); signal(SIGINT, sig_int_handler);
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
/* set receiver frequency */ /* set receiver frequency */
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq); rf_set_rx_freq(uhd, (double) prog_args.uhd_freq);
cuhd_rx_wait_lo_locked(uhd); rf_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; uint32_t ntrial=0;
do { do {
ret = cuhd_search_and_decode_mib(uhd, &cell_detect_config, prog_args.force_N_id_2, &cell); ret = rf_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 for cell\n"); fprintf(stderr, "Error searching for cell\n");
exit(-1); exit(-1);
@ -342,12 +342,12 @@ int main(int argc, char **argv) {
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000); printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate); float srate_uhd = rf_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) { if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n"); fprintf(stderr, "Could not set sampling rate\n");
exit(-1); exit(-1);
@ -358,8 +358,8 @@ int main(int argc, char **argv) {
} }
INFO("Stopping UHD and flushing buffer...\r",0); INFO("Stopping UHD and flushing buffer...\r",0);
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
cuhd_flush_buffer(uhd); rf_flush_buffer(uhd);
} }
#endif #endif
@ -380,8 +380,8 @@ int main(int argc, char **argv) {
} }
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_RF
if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
@ -413,9 +413,9 @@ int main(int argc, char **argv) {
} }
#endif #endif
#ifndef DISABLE_UHD #ifndef DISABLE_RF
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
} }
#endif #endif
@ -424,9 +424,9 @@ int main(int argc, char **argv) {
float rsrp=0.0, rsrq=0.0, noise=0.0; float rsrp=0.0, rsrq=0.0, noise=0.0;
bool decode_pdsch = false; bool decode_pdsch = false;
#ifndef DISABLE_UHD #ifndef DISABLE_RF
if (prog_args.uhd_gain < 0) { if (prog_args.uhd_gain < 0) {
srslte_ue_sync_start_agc(&ue_sync, cuhd_set_rx_gain_th, cell_detect_config.init_agc); srslte_ue_sync_start_agc(&ue_sync, rf_set_rx_gain_th, cell_detect_config.init_agc);
} }
#endif #endif
#ifdef PRINT_CHANGE_SCHEDULIGN #ifdef PRINT_CHANGE_SCHEDULIGN
@ -589,10 +589,10 @@ int main(int argc, char **argv) {
srslte_ue_dl_free(&ue_dl); srslte_ue_dl_free(&ue_dl);
srslte_ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
#ifndef DISABLE_UHD #ifndef DISABLE_RF
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
srslte_ue_mib_free(&ue_mib); srslte_ue_mib_free(&ue_mib);
cuhd_close(uhd); rf_close(uhd);
} }
#endif #endif
printf("\nBye\n"); printf("\nBye\n");

@ -26,10 +26,10 @@
IF(SRSGUI_FOUND AND UHD_FOUND) IF(SRSGUI_FOUND AND UHD_FOUND)
add_executable(pss pss.c) add_executable(pss pss.c)
target_link_libraries(pss srslte ${SRSGUI_LIBRARIES} srslte_uhd) target_link_libraries(pss srslte ${SRSGUI_LIBRARIES} srslte_rf)
add_executable(simple_tx simple_tx.c) add_executable(simple_tx simple_tx.c)
target_link_libraries(simple_tx srslte srslte_uhd) target_link_libraries(simple_tx srslte srslte_rf)
ENDIF(SRSGUI_FOUND AND UHD_FOUND) ENDIF(SRSGUI_FOUND AND UHD_FOUND)

@ -35,7 +35,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
@ -177,16 +177,16 @@ int main(int argc, char **argv) {
srslte_sss_synch_set_N_id_2(&sss, N_id_2); srslte_sss_synch_set_N_id_2(&sss, N_id_2);
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
printf("N_id_2: %d\n", N_id_2); printf("N_id_2: %d\n", N_id_2);
printf("Set RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, flen*2*100) / 1000000); printf("Set RX rate: %.2f MHz\n", rf_set_rx_srate(uhd, flen*2*100) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(uhd, uhd_gain));
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
printf("Frame length %d samples\n", flen); printf("Frame length %d samples\n", flen);
printf("PSS detection threshold: %.2f\n", threshold); 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) { while(frame_cnt < nof_frames || nof_frames == -1) {
peak_offset = 0; peak_offset = 0;
n = cuhd_recv(uhd, buffer, flen - peak_offset, 1); n = rf_recv(uhd, buffer, flen - peak_offset, 1);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error receiving samples\n"); fprintf(stderr, "Error receiving samples\n");
exit(-1); exit(-1);
@ -320,7 +320,7 @@ int main(int argc, char **argv) {
srslte_pss_synch_free(&pss); srslte_pss_synch_free(&pss);
free(buffer); free(buffer);
cuhd_close(uhd); rf_close(uhd);
printf("Ok\n"); printf("Ok\n");
exit(0); exit(0);

@ -116,7 +116,7 @@ void parse_args(int argc, char **argv) {
exit(-1); exit(-1);
} }
} }
#ifdef DISABLE_UHD #ifdef DISABLE_RF
if (!output_file_name) { if (!output_file_name) {
usage(argv[0]); usage(argv[0]);
exit(-1); exit(-1);
@ -138,7 +138,7 @@ void base_init() {
exit(-1); exit(-1);
} }
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
@ -161,7 +161,7 @@ void base_free() {
if (output_buffer) { if (output_buffer) {
free(output_buffer); free(output_buffer);
} }
cuhd_close(&uhd); rf_close(&uhd);
} }
@ -172,7 +172,7 @@ int main(int argc, char **argv) {
float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5
int i; int i;
#ifdef DISABLE_UHD #ifdef DISABLE_RF
if (argc < 3) { if (argc < 3) {
usage(argv[0]); usage(argv[0]);
exit(-1); exit(-1);
@ -196,10 +196,10 @@ int main(int argc, char **argv) {
srslte_sss_generate(sss_signal0, sss_signal5, cell.id); srslte_sss_generate(sss_signal0, sss_signal5, cell.id);
printf("Set TX rate: %.2f MHz\n", printf("Set TX rate: %.2f MHz\n",
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000); rf_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain)); printf("Set TX gain: %.1f dB\n", rf_set_tx_gain(uhd, uhd_gain));
printf("Set TX freq: %.2f MHz\n", printf("Set TX freq: %.2f MHz\n",
cuhd_set_tx_freq(uhd, uhd_freq) / 1000000); rf_set_tx_freq(uhd, uhd_freq) / 1000000);
uint32_t nbits; uint32_t nbits;
@ -249,7 +249,7 @@ int main(int argc, char **argv) {
/* send to usrp */ /* send to usrp */
srslte_vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples); srslte_vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples);
cuhd_send(uhd, output_buffer, sf_n_samples, true); rf_send(uhd, output_buffer, sf_n_samples, true);
} }
} }

@ -36,7 +36,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/io/filesink.h" #include "srslte/io/filesink.h"
static bool keep_running = true; static bool keep_running = true;
@ -117,27 +117,27 @@ int main(int argc, char **argv) {
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
sigset_t sigset; sigset_t sigset;
sigemptyset(&sigset); sigemptyset(&sigset);
sigaddset(&sigset, SIGINT); sigaddset(&sigset, SIGINT);
sigprocmask(SIG_UNBLOCK, &sigset, NULL); sigprocmask(SIG_UNBLOCK, &sigset, NULL);
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set RX gain: %.2f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.2f dB\n", rf_set_rx_gain(uhd, uhd_gain));
float srate = cuhd_set_rx_srate(uhd, uhd_rate); float srate = rf_set_rx_srate(uhd, uhd_rate);
if (srate != uhd_rate) { if (srate != uhd_rate) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*uhd_rate); rf_set_master_clock_rate(uhd, 4*uhd_rate);
} else { } else {
cuhd_set_master_clock_rate(uhd, uhd_rate); rf_set_master_clock_rate(uhd, uhd_rate);
} }
srate = cuhd_set_rx_srate(uhd, uhd_rate); srate = rf_set_rx_srate(uhd, uhd_rate);
if (srate != uhd_rate) { if (srate != uhd_rate) {
fprintf(stderr, "Errror setting samplign frequency %.2f MHz\n", uhd_rate*1e-6); fprintf(stderr, "Errror setting samplign frequency %.2f MHz\n", uhd_rate*1e-6);
exit(-1); exit(-1);
@ -145,13 +145,13 @@ int main(int argc, char **argv) {
} }
printf("Correctly RX rate: %.2f MHz\n", srate*1e-6); printf("Correctly RX rate: %.2f MHz\n", srate*1e-6);
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
while((sample_count < nof_samples || nof_samples == -1) while((sample_count < nof_samples || nof_samples == -1)
&& keep_running){ && keep_running){
n = cuhd_recv(uhd, buffer, buflen, 1); n = rf_recv(uhd, buffer, buflen, 1);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error receiving samples\n"); fprintf(stderr, "Error receiving samples\n");
exit(-1); exit(-1);
@ -163,7 +163,7 @@ int main(int argc, char **argv) {
srslte_filesink_free(&sink); srslte_filesink_free(&sink);
free(buffer); free(buffer);
cuhd_close(uhd); rf_close(uhd);
printf("Ok - wrote %d samples\n", sample_count); printf("Ok - wrote %d samples\n", sample_count);
exit(0); exit(0);

@ -36,7 +36,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
static bool keep_running = true; static bool keep_running = true;
char *output_file_name = NULL; char *output_file_name = NULL;
@ -98,9 +98,9 @@ void parse_args(int argc, char **argv) {
} }
} }
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) { int rf_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return cuhd_recv(h, data, nsamples, 1); return rf_recv(h, data, nsamples, 1);
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
@ -118,28 +118,28 @@ int main(int argc, char **argv) {
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
sigset_t sigset; sigset_t sigset;
sigemptyset(&sigset); sigemptyset(&sigset);
sigaddset(&sigset, SIGINT); sigaddset(&sigset, SIGINT);
sigprocmask(SIG_UNBLOCK, &sigset, NULL); sigprocmask(SIG_UNBLOCK, &sigset, NULL);
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.6f MHz\n", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(uhd, uhd_gain));
int srate = srslte_sampling_freq_hz(nof_prb); int srate = srslte_sampling_freq_hz(nof_prb);
if (srate != -1) { if (srate != -1) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000); printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate); float srate_uhd = rf_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) { if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n"); fprintf(stderr, "Could not set sampling rate\n");
exit(-1); exit(-1);
@ -148,15 +148,15 @@ int main(int argc, char **argv) {
fprintf(stderr, "Invalid number of PRB %d\n", nof_prb); fprintf(stderr, "Invalid number of PRB %d\n", nof_prb);
exit(-1); exit(-1);
} }
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
cell.cp = SRSLTE_CP_NORM; cell.cp = SRSLTE_CP_NORM;
cell.id = N_id_2; cell.id = N_id_2;
cell.nof_prb = nof_prb; cell.nof_prb = nof_prb;
cell.nof_ports = 1; cell.nof_ports = 1;
if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, rf_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
@ -191,7 +191,7 @@ int main(int argc, char **argv) {
} }
srslte_filesink_free(&sink); srslte_filesink_free(&sink);
cuhd_close(uhd); rf_close(uhd);
srslte_ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
printf("Ok - wrote %d subframes\n", subframe_count); printf("Ok - wrote %d subframes\n", subframe_count);

@ -33,7 +33,7 @@
#include <time.h> #include <time.h>
#include <complex.h> #include <complex.h>
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
uint32_t nof_prb = 25; uint32_t nof_prb = 25;
@ -127,28 +127,28 @@ int main(int argc, char **argv) {
// Send through UHD // Send through UHD
void *uhd; void *uhd;
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6); rf_set_master_clock_rate(uhd, 30.72e6);
int srate = srslte_sampling_freq_hz(nof_prb); int srate = srslte_sampling_freq_hz(nof_prb);
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
cuhd_set_rx_srate(uhd, (double) srate); rf_set_rx_srate(uhd, (double) srate);
cuhd_set_tx_srate(uhd, (double) srate); rf_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", (float) srate / 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", rf_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", rf_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", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_set_tx_freq_offset(uhd, uhd_freq, 8e6); rf_set_tx_freq_offset(uhd, uhd_freq, 8e6);
sleep(1); sleep(1);
if (input_filename) { if (input_filename) {
@ -162,7 +162,7 @@ int main(int argc, char **argv) {
srslte_timestamp_t tstamp; srslte_timestamp_t tstamp;
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
uint32_t nframe=0; uint32_t nframe=0;
float burst_settle_time = (float) nsamples_adv/srslte_sampling_freq_hz(nof_prb); float burst_settle_time = (float) nsamples_adv/srslte_sampling_freq_hz(nof_prb);
@ -171,15 +171,15 @@ int main(int argc, char **argv) {
while(nframe<nof_frames) { while(nframe<nof_frames) {
printf("Rx subframe %d\n", nframe); printf("Rx subframe %d\n", nframe);
cuhd_recv_with_time(uhd, &rx_buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); rf_recv_with_time(uhd, &rx_buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
nframe++; nframe++;
if (nframe==9 || nframe==8) { if (nframe==9 || nframe==8) {
srslte_timestamp_add(&tstamp, 0, 2e-3-burst_settle_time); srslte_timestamp_add(&tstamp, 0, 2e-3-burst_settle_time);
if (nframe==8) { if (nframe==8) {
//cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false); //rf_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
printf("Transmitting zeros\n"); printf("Transmitting zeros\n");
} else { } else {
cuhd_send_timed2(uhd, tx_buffer, flen+nsamples_adv, tstamp.full_secs, tstamp.frac_secs, true, true); rf_send_timed2(uhd, tx_buffer, flen+nsamples_adv, tstamp.full_secs, tstamp.frac_secs, true, true);
printf("Transmitting Signal\n"); printf("Transmitting Signal\n");
} }
} }

@ -34,127 +34,127 @@ extern "C" {
#include "srslte/config.h" #include "srslte/config.h"
typedef void (*cuhd_msg_handler_t)(const char*); typedef void (*rf_msg_handler_t)(const char*);
SRSLTE_API int cuhd_open(char *args, SRSLTE_API int rf_open(char *args,
void **handler); void **handler);
SRSLTE_API int cuhd_open_th(char *args, SRSLTE_API int rf_open_th(char *args,
void **handler, void **handler,
bool tx_gain_same_rx); bool tx_gain_same_rx);
SRSLTE_API int cuhd_close(void *h); SRSLTE_API int rf_close(void *h);
SRSLTE_API int cuhd_start_rx_stream(void *h); SRSLTE_API int rf_start_rx_stream(void *h);
SRSLTE_API int cuhd_start_rx_stream_nsamples(void *h, SRSLTE_API int rf_start_rx_stream_nsamples(void *h,
uint32_t nsamples); uint32_t nsamples);
SRSLTE_API int cuhd_stop_rx_stream(void *h); SRSLTE_API int rf_stop_rx_stream(void *h);
SRSLTE_API void cuhd_flush_buffer(void *h); SRSLTE_API void rf_flush_buffer(void *h);
SRSLTE_API bool cuhd_has_rssi(void *h); SRSLTE_API bool rf_has_rssi(void *h);
SRSLTE_API float cuhd_get_rssi(void *h); SRSLTE_API float rf_get_rssi(void *h);
SRSLTE_API bool cuhd_rx_wait_lo_locked(void *h); SRSLTE_API bool rf_rx_wait_lo_locked(void *h);
SRSLTE_API void cuhd_set_master_clock_rate(void *h, SRSLTE_API void rf_set_master_clock_rate(void *h,
double rate); double rate);
SRSLTE_API bool cuhd_is_master_clock_dynamic(void *h); SRSLTE_API bool rf_is_master_clock_dynamic(void *h);
SRSLTE_API double cuhd_set_rx_srate(void *h, SRSLTE_API double rf_set_rx_srate(void *h,
double freq); double freq);
SRSLTE_API double cuhd_set_rx_gain(void *h, SRSLTE_API double rf_set_rx_gain(void *h,
double gain); double gain);
SRSLTE_API void cuhd_set_tx_rx_gain_offset(void *h, SRSLTE_API void rf_set_tx_rx_gain_offset(void *h,
double offset); double offset);
SRSLTE_API double cuhd_set_rx_gain_th(void *h, SRSLTE_API double rf_set_rx_gain_th(void *h,
double gain); double gain);
SRSLTE_API double cuhd_set_tx_gain_th(void *h, SRSLTE_API double rf_set_tx_gain_th(void *h,
double gain); double gain);
SRSLTE_API float cuhd_get_rx_gain_offset(void *h); SRSLTE_API float rf_get_rx_gain_offset(void *h);
SRSLTE_API double cuhd_get_rx_gain(void *h); SRSLTE_API double rf_get_rx_gain(void *h);
SRSLTE_API double cuhd_get_tx_gain(void *h); SRSLTE_API double rf_get_tx_gain(void *h);
SRSLTE_API void cuhd_suppress_stdout(); SRSLTE_API void rf_suppress_stdout();
SRSLTE_API void cuhd_register_msg_handler(cuhd_msg_handler_t h); SRSLTE_API void rf_register_msg_handler(rf_msg_handler_t h);
SRSLTE_API double cuhd_set_rx_freq(void *h, SRSLTE_API double rf_set_rx_freq(void *h,
double freq); double freq);
SRSLTE_API double cuhd_set_rx_freq_offset(void *h, SRSLTE_API double rf_set_rx_freq_offset(void *h,
double freq, double freq,
double off); double off);
SRSLTE_API double cuhd_set_rx_freq_offset(void *h, SRSLTE_API double rf_set_rx_freq_offset(void *h,
double freq, double freq,
double off); double off);
SRSLTE_API int cuhd_recv(void *h, SRSLTE_API int rf_recv(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking); bool blocking);
SRSLTE_API int cuhd_recv_with_time(void *h, SRSLTE_API int rf_recv_with_time(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking, bool blocking,
time_t *secs, time_t *secs,
double *frac_secs); double *frac_secs);
SRSLTE_API double cuhd_set_tx_srate(void *h, SRSLTE_API double rf_set_tx_srate(void *h,
double freq); double freq);
SRSLTE_API double cuhd_set_tx_gain(void *h, SRSLTE_API double rf_set_tx_gain(void *h,
double gain); double gain);
SRSLTE_API double cuhd_set_tx_freq(void *h, SRSLTE_API double rf_set_tx_freq(void *h,
double freq); double freq);
SRSLTE_API double cuhd_set_tx_freq_offset(void *h, SRSLTE_API double rf_set_tx_freq_offset(void *h,
double freq, double freq,
double offset); double offset);
SRSLTE_API void cuhd_get_time(void *h, SRSLTE_API void rf_get_time(void *h,
time_t *secs, time_t *secs,
double *frac_secs); double *frac_secs);
SRSLTE_API int cuhd_send(void *h, SRSLTE_API int rf_send(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking); bool blocking);
SRSLTE_API int cuhd_send2(void *h, SRSLTE_API int rf_send2(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking, bool blocking,
bool start_of_burst, bool start_of_burst,
bool end_of_burst); bool end_of_burst);
SRSLTE_API int cuhd_send(void *h, SRSLTE_API int rf_send(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking); bool blocking);
SRSLTE_API int cuhd_send_timed(void *h, SRSLTE_API int rf_send_timed(void *h,
void *data, void *data,
int nsamples, int nsamples,
time_t secs, time_t secs,
double frac_secs); double frac_secs);
SRSLTE_API int cuhd_send_timed2(void *h, SRSLTE_API int rf_send_timed2(void *h,
void *data, void *data,
int nsamples, int nsamples,
time_t secs, time_t secs,

@ -34,23 +34,23 @@ typedef struct SRSLTE_API {
float init_agc; // 0 or negative to disable AGC float init_agc; // 0 or negative to disable AGC
} cell_search_cfg_t; } cell_search_cfg_t;
SRSLTE_API int cuhd_rssi_scan(void *uhd, SRSLTE_API int rf_rssi_scan(void *uhd,
float *freqs, float *freqs,
float *rssi, float *rssi,
int nof_bands, int nof_bands,
double fs, double fs,
int nsamp); int nsamp);
SRSLTE_API int cuhd_mib_decoder(void *uhd, SRSLTE_API int rf_mib_decoder(void *uhd,
cell_search_cfg_t *config, cell_search_cfg_t *config,
srslte_cell_t *cell); srslte_cell_t *cell);
SRSLTE_API int cuhd_cell_search(void *uhd, SRSLTE_API int rf_cell_search(void *uhd,
cell_search_cfg_t *config, cell_search_cfg_t *config,
int force_N_id_2, int force_N_id_2,
srslte_cell_t *cell); srslte_cell_t *cell);
SRSLTE_API int cuhd_search_and_decode_mib(void *uhd, SRSLTE_API int rf_search_and_decode_mib(void *uhd,
cell_search_cfg_t *config, cell_search_cfg_t *config,
int force_N_id_2, int force_N_id_2,
srslte_cell_t *cell); srslte_cell_t *cell);

@ -59,26 +59,43 @@ FILE(GLOB modules *)
SET(SOURCES_ALL "") SET(SOURCES_ALL "")
FOREACH (_module ${modules}) FOREACH (_module ${modules})
IF(IS_DIRECTORY ${_module}) IF(IS_DIRECTORY ${_module})
IF (NOT ${_module} MATCHES "cuhd") IF (NOT ${_module} MATCHES "rf")
FILE(GLOB_RECURSE tmp "${_module}/src/*.c") FILE(GLOB_RECURSE tmp "${_module}/src/*.c")
LIST(APPEND SOURCES_ALL ${tmp}) LIST(APPEND SOURCES_ALL ${tmp})
FILE(GLOB_RECURSE tmp2 "${_module}/src/*.cpp") FILE(GLOB_RECURSE tmp2 "${_module}/src/*.cpp")
LIST(APPEND SOURCES_ALL ${tmp2}) LIST(APPEND SOURCES_ALL ${tmp2})
ENDIF (NOT ${_module} MATCHES "cuhd") ENDIF (NOT ${_module} MATCHES "rf")
ENDIF(IS_DIRECTORY ${_module}) ENDIF(IS_DIRECTORY ${_module})
ENDFOREACH() ENDFOREACH()
ADD_LIBRARY(srslte SHARED ${SOURCES_ALL}) ADD_LIBRARY(srslte SHARED ${SOURCES_ALL})
TARGET_LINK_LIBRARIES(srslte m ${FFTW3F_LIBRARIES}) TARGET_LINK_LIBRARIES(srslte m ${FFTW3F_LIBRARIES})
IF(UHD_FOUND) IF(RF_FOUND)
INCLUDE_DIRECTORIES(${UHD_INCLUDE_DIRS}) IF (UHD_FOUND)
LINK_DIRECTORIES(${UHD_LIBRARY_DIRS}) INCLUDE_DIRECTORIES(${UHD_INCLUDE_DIRS})
ADD_LIBRARY(srslte_uhd SHARED ${CMAKE_CURRENT_SOURCE_DIR}/cuhd/src/cuhd_imp.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cuhd/src/cuhd_utils.c) LINK_DIRECTORIES(${UHD_LIBRARY_DIRS})
TARGET_LINK_LIBRARIES(srslte_uhd ${UHD_LIBRARIES}) add_definitions(-DENABLE_UHD)
INSTALL(TARGETS srslte_uhd DESTINATION ${LIBRARY_DIR}) ENDIF (UHD_FOUND)
SRSLTE_SET_PIC(srslte_uhd)
ENDIF(UHD_FOUND) IF (BLADERF_FOUND)
INCLUDE_DIRECTORIES(${BLADERF_INCLUDE_DIRS})
add_definitions(-DENABLE_BLADERF)
ENDIF (BLADERF_FOUND)
ADD_LIBRARY(srslte_rf SHARED ${CMAKE_CURRENT_SOURCE_DIR}/rf/src/rf_imp.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rf/src/rf_utils.c)
IF (UHD_FOUND)
TARGET_LINK_LIBRARIES(srslte_rf ${UHD_LIBRARIES})
ENDIF (UHD_FOUND)
IF (BLADERF_FOUND)
TARGET_LINK_LIBRARIES(srslte_rf ${BLADERF_LIBRARIES})
ENDIF (BLADERF_FOUND)
INSTALL(TARGETS srslte_rf DESTINATION ${LIBRARY_DIR})
SRSLTE_SET_PIC(srslte_rf)
ENDIF(RF_FOUND)
INSTALL(TARGETS srslte DESTINATION ${LIBRARY_DIR}) INSTALL(TARGETS srslte DESTINATION ${LIBRARY_DIR})
SRSLTE_SET_PIC(srslte) SRSLTE_SET_PIC(srslte)

@ -195,5 +195,5 @@ BuildMex(MEXNAME prach SOURCES prach_test_mex.c LIBRARIES srslte srslte_mex)
IF(UHD_FOUND) IF(UHD_FOUND)
ADD_EXECUTABLE(prach_test_usrp prach_test_usrp.c) ADD_EXECUTABLE(prach_test_usrp prach_test_usrp.c)
TARGET_LINK_LIBRARIES(prach_test_usrp srslte_uhd srslte) TARGET_LINK_LIBRARIES(prach_test_usrp srslte_rf srslte)
ENDIF(UHD_FOUND) ENDIF(UHD_FOUND)

@ -33,7 +33,7 @@
#include <time.h> #include <time.h>
#include <complex.h> #include <complex.h>
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
#define MAX_LEN 70176 #define MAX_LEN 70176
@ -142,17 +142,17 @@ int main(int argc, char **argv) {
// Send through UHD // Send through UHD
void *uhd; void *uhd;
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
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", rf_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(uhd, uhd_gain));
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_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", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set TX/RX freq: %.2f MHz\n", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(nof_prb)); rf_set_tx_srate(uhd, srslte_sampling_freq_hz(nof_prb));
cuhd_set_tx_freq_offset(uhd, uhd_freq, 8e6); rf_set_tx_freq_offset(uhd, uhd_freq, 8e6);
sleep(1); sleep(1);
cf_t *zeros = calloc(sizeof(cf_t),flen); cf_t *zeros = calloc(sizeof(cf_t),flen);
@ -164,20 +164,20 @@ int main(int argc, char **argv) {
srslte_timestamp_t tstamp; srslte_timestamp_t tstamp;
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
uint32_t nframe=0; uint32_t nframe=0;
while(nframe<nof_frames) { while(nframe<nof_frames) {
printf("Rx subframe %d\n", nframe); printf("Rx subframe %d\n", nframe);
cuhd_recv_with_time(uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); rf_recv_with_time(uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
nframe++; nframe++;
if (nframe==9 || nframe==8) { if (nframe==9 || nframe==8) {
srslte_timestamp_add(&tstamp, 0, 2e-3); srslte_timestamp_add(&tstamp, 0, 2e-3);
if (nframe==8) { if (nframe==8) {
cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false); rf_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
printf("Transmitting zeros\n"); printf("Transmitting zeros\n");
} else { } else {
cuhd_send_timed2(uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, true, true); rf_send_timed2(uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, true, true);
printf("Transmitting PRACH\n"); printf("Transmitting PRACH\n");
} }
} }

@ -29,7 +29,7 @@
#include <uhd/usrp/multi_usrp.hpp> #include <uhd/usrp/multi_usrp.hpp>
#include <pthread.h> #include <pthread.h>
class cuhd_handler { class rf_handler {
public: public:
uhd::usrp::multi_usrp::sptr usrp; uhd::usrp::multi_usrp::sptr usrp;
uhd::rx_streamer::sptr rx_stream; uhd::rx_streamer::sptr rx_stream;

@ -32,13 +32,13 @@
#include <uhd/utils/msg.hpp> #include <uhd/utils/msg.hpp>
#include <sys/time.h> #include <sys/time.h>
#include "cuhd_handler.hpp" #include "rf_handler.hpp"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
//#define METADATA_VERBOSE //#define METADATA_VERBOSE
cuhd_msg_handler_t msg_handler; rf_msg_handler_t msg_handler;
void suppress_handler(uhd::msg::type_t type, const std::string & msg) void suppress_handler(uhd::msg::type_t type, const std::string & msg)
{ {
@ -57,7 +57,7 @@ typedef _Complex float complex_t;
bool isLocked(void *h) bool isLocked(void *h)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
std::vector < std::string > mb_sensors = std::vector < std::string > mb_sensors =
handler->usrp->get_mboard_sensor_names(); handler->usrp->get_mboard_sensor_names();
std::vector < std::string > rx_sensors = std::vector < std::string > rx_sensors =
@ -74,7 +74,7 @@ bool isLocked(void *h)
} }
} }
bool cuhd_rx_wait_lo_locked(void *h) bool rf_rx_wait_lo_locked(void *h)
{ {
double report = 0.0; double report = 0.0;
@ -85,9 +85,9 @@ bool cuhd_rx_wait_lo_locked(void *h)
return isLocked(h); return isLocked(h);
} }
int cuhd_start_rx_stream(void *h) int rf_start_rx_stream(void *h)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
cmd.time_spec = handler->usrp->get_time_now(); cmd.time_spec = handler->usrp->get_time_now();
cmd.stream_now = true; cmd.stream_now = true;
@ -95,9 +95,9 @@ int cuhd_start_rx_stream(void *h)
return 0; return 0;
} }
int cuhd_stop_rx_stream(void *h) int rf_stop_rx_stream(void *h)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
cmd.time_spec = handler->usrp->get_time_now(); cmd.time_spec = handler->usrp->get_time_now();
cmd.stream_now = true; cmd.stream_now = true;
@ -105,17 +105,17 @@ int cuhd_stop_rx_stream(void *h)
return 0; return 0;
} }
void cuhd_flush_buffer(void *h) void rf_flush_buffer(void *h)
{ {
int n; int n;
_Complex float tmp[1024]; _Complex float tmp[1024];
do { do {
n = cuhd_recv(h, tmp, 1024, 0); n = rf_recv(h, tmp, 1024, 0);
} while (n > 0); } while (n > 0);
} }
bool cuhd_has_rssi(void *h) { bool rf_has_rssi(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
std::vector < std::string > mb_sensors = handler->usrp->get_mboard_sensor_names(); std::vector < std::string > mb_sensors = handler->usrp->get_mboard_sensor_names();
std::vector < std::string > rx_sensors = handler->usrp->get_rx_sensor_names(0); std::vector < std::string > rx_sensors = handler->usrp->get_rx_sensor_names(0);
if (std::find(rx_sensors.begin(), rx_sensors.end(), "rssi") != rx_sensors.end()) { if (std::find(rx_sensors.begin(), rx_sensors.end(), "rssi") != rx_sensors.end()) {
@ -125,9 +125,9 @@ bool cuhd_has_rssi(void *h) {
} }
} }
float cuhd_get_rssi(void *h) { float rf_get_rssi(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
if (cuhd_has_rssi(h)) { if (rf_has_rssi(h)) {
uhd::sensor_value_t value = handler->usrp->get_rx_sensor("rssi"); uhd::sensor_value_t value = handler->usrp->get_rx_sensor("rssi");
return value.to_real(); return value.to_real();
} else { } else {
@ -135,9 +135,9 @@ float cuhd_get_rssi(void *h) {
} }
} }
int cuhd_start_rx_stream_nsamples(void *h, uint32_t nsamples) int rf_start_rx_stream_nsamples(void *h, uint32_t nsamples)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE); uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE);
cmd.time_spec = handler->usrp->get_time_now(); cmd.time_spec = handler->usrp->get_time_now();
cmd.stream_now = true; cmd.stream_now = true;
@ -146,9 +146,9 @@ int cuhd_start_rx_stream_nsamples(void *h, uint32_t nsamples)
return 0; return 0;
} }
double cuhd_set_rx_gain_th(void *h, double gain) double rf_set_rx_gain_th(void *h, double gain)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
gain = handler->rx_gain_range.clip(gain); gain = handler->rx_gain_range.clip(gain);
if (gain > handler->new_rx_gain + 0.5 || gain < handler->new_rx_gain - 0.5) { if (gain > handler->new_rx_gain + 0.5 || gain < handler->new_rx_gain - 0.5) {
pthread_mutex_lock(&handler->mutex); pthread_mutex_lock(&handler->mutex);
@ -159,9 +159,9 @@ double cuhd_set_rx_gain_th(void *h, double gain)
return gain; return gain;
} }
double cuhd_set_tx_gain_th(void *h, double gain) double rf_set_tx_gain_th(void *h, double gain)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
gain = handler->tx_gain_range.clip(gain); gain = handler->tx_gain_range.clip(gain);
if (gain > handler->new_tx_gain + 0.5 || gain < handler->new_tx_gain - 0.5) { if (gain > handler->new_tx_gain + 0.5 || gain < handler->new_tx_gain - 0.5) {
pthread_mutex_lock(&handler->mutex); pthread_mutex_lock(&handler->mutex);
@ -172,14 +172,14 @@ double cuhd_set_tx_gain_th(void *h, double gain)
return gain; return gain;
} }
void cuhd_set_tx_rx_gain_offset(void *h, double offset) { void rf_set_tx_rx_gain_offset(void *h, double offset) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->tx_rx_gain_offset = offset; handler->tx_rx_gain_offset = offset;
} }
/* This thread listens for set_rx_gain commands to the USRP */ /* This thread listens for set_rx_gain commands to the USRP */
static void* thread_gain_fcn(void *h) { static void* thread_gain_fcn(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
while(1) { while(1) {
pthread_mutex_lock(&handler->mutex); pthread_mutex_lock(&handler->mutex);
while(handler->cur_rx_gain == handler->new_rx_gain && while(handler->cur_rx_gain == handler->new_rx_gain &&
@ -189,33 +189,33 @@ static void* thread_gain_fcn(void *h) {
} }
if (handler->new_rx_gain != handler->cur_rx_gain) { if (handler->new_rx_gain != handler->cur_rx_gain) {
handler->cur_rx_gain = handler->new_rx_gain; handler->cur_rx_gain = handler->new_rx_gain;
cuhd_set_rx_gain(h, handler->cur_rx_gain); rf_set_rx_gain(h, handler->cur_rx_gain);
} }
if (handler->tx_gain_same_rx) { if (handler->tx_gain_same_rx) {
cuhd_set_tx_gain(h, handler->cur_rx_gain+handler->tx_rx_gain_offset); rf_set_tx_gain(h, handler->cur_rx_gain+handler->tx_rx_gain_offset);
} else if (handler->new_tx_gain != handler->cur_tx_gain) { } else if (handler->new_tx_gain != handler->cur_tx_gain) {
handler->cur_tx_gain = handler->new_tx_gain; handler->cur_tx_gain = handler->new_tx_gain;
cuhd_set_tx_gain(h, handler->cur_tx_gain); rf_set_tx_gain(h, handler->cur_tx_gain);
} }
pthread_mutex_unlock(&handler->mutex); pthread_mutex_unlock(&handler->mutex);
} }
} }
float cuhd_get_rx_gain_offset(void *h) { float rf_get_rx_gain_offset(void *h) {
return 15; return 15;
} }
void cuhd_suppress_stdout() { void rf_suppress_stdout() {
uhd::msg::register_handler(suppress_handler); uhd::msg::register_handler(suppress_handler);
} }
void cuhd_register_msg_handler(cuhd_msg_handler_t h) void rf_register_msg_handler(rf_msg_handler_t h)
{ {
msg_handler = h; msg_handler = h;
uhd::msg::register_handler(translate_handler); uhd::msg::register_handler(translate_handler);
} }
int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx) int rf_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx)
{ {
*h = NULL; *h = NULL;
@ -225,7 +225,7 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
/* Get multiusrp handler */ /* Get multiusrp handler */
cuhd_handler *handler = new cuhd_handler(); rf_handler *handler = new rf_handler();
std::string _args = std::string(args); std::string _args = std::string(args);
handler->usrp = uhd::usrp::multi_usrp::make(_args);// + ", recv_frame_size=9232,num_recv_frames=64,send_frame_size=9232,num_send_frames=64"); handler->usrp = uhd::usrp::multi_usrp::make(_args);// + ", recv_frame_size=9232,num_recv_frames=64,send_frame_size=9232,num_send_frames=64");
@ -285,86 +285,86 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
return 0; return 0;
} }
int cuhd_open(char *args, void **h) { int rf_open(char *args, void **h) {
return cuhd_open_(args, h, false, false); return rf_open_(args, h, false, false);
} }
int cuhd_open_th(char *args, void **h, bool tx_gain_same_rx) { int rf_open_th(char *args, void **h, bool tx_gain_same_rx) {
return cuhd_open_(args, h, true, tx_gain_same_rx); return rf_open_(args, h, true, tx_gain_same_rx);
} }
int cuhd_close(void *h) int rf_close(void *h)
{ {
cuhd_stop_rx_stream(h); rf_stop_rx_stream(h);
/** Something else to close the USRP?? */ /** Something else to close the USRP?? */
return 0; return 0;
} }
void cuhd_set_master_clock_rate(void *h, double rate) { void rf_set_master_clock_rate(void *h, double rate) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
if (handler->dynamic_rate) { if (handler->dynamic_rate) {
handler->usrp->set_master_clock_rate(rate); handler->usrp->set_master_clock_rate(rate);
} }
} }
bool cuhd_is_master_clock_dynamic(void *h) { bool rf_is_master_clock_dynamic(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
return handler->dynamic_rate; return handler->dynamic_rate;
} }
double cuhd_set_rx_srate(void *h, double freq) double rf_set_rx_srate(void *h, double freq)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_rx_rate(freq); handler->usrp->set_rx_rate(freq);
return handler->usrp->get_rx_rate(); return handler->usrp->get_rx_rate();
} }
double cuhd_set_rx_gain(void *h, double gain) double rf_set_rx_gain(void *h, double gain)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_rx_gain(gain); handler->usrp->set_rx_gain(gain);
return handler->usrp->get_rx_gain(); return handler->usrp->get_rx_gain();
} }
double cuhd_get_rx_gain(void *h) double rf_get_rx_gain(void *h)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
return handler->usrp->get_rx_gain(); return handler->usrp->get_rx_gain();
} }
double cuhd_get_tx_gain(void *h) double rf_get_tx_gain(void *h)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
return handler->usrp->get_tx_gain(); return handler->usrp->get_tx_gain();
} }
double cuhd_set_rx_freq(void *h, double freq) double rf_set_rx_freq(void *h, double freq)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_rx_freq(freq); handler->usrp->set_rx_freq(freq);
return freq; return freq;
} }
double cuhd_set_rx_freq_offset(void *h, double freq, double off) { double rf_set_rx_freq_offset(void *h, double freq, double off) {
cuhd_handler* handler = static_cast<cuhd_handler*>(h); rf_handler* handler = static_cast<rf_handler*>(h);
handler->usrp->set_rx_freq(uhd::tune_request_t(freq, off)); handler->usrp->set_rx_freq(uhd::tune_request_t(freq, off));
return handler->usrp->get_rx_freq(); return handler->usrp->get_rx_freq();
} }
int cuhd_recv(void *h, void *data, uint32_t nsamples, bool blocking) int rf_recv(void *h, void *data, uint32_t nsamples, bool blocking)
{ {
return cuhd_recv_with_time(h, data, nsamples, blocking, NULL, NULL); return rf_recv_with_time(h, data, nsamples, blocking, NULL, NULL);
} }
int cuhd_recv_with_time(void *h, int rf_recv_with_time(void *h,
void *data, void *data,
uint32_t nsamples, uint32_t nsamples,
bool blocking, bool blocking,
time_t *secs, time_t *secs,
double *frac_secs) double *frac_secs)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
uhd::rx_metadata_t md, md_first; uhd::rx_metadata_t md, md_first;
if (blocking) { if (blocking) {
int n = 0, p; int n = 0, p;
@ -397,37 +397,37 @@ int cuhd_recv_with_time(void *h,
} }
return nsamples; return nsamples;
} }
double cuhd_set_tx_gain(void *h, double gain) double rf_set_tx_gain(void *h, double gain)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_tx_gain(gain); handler->usrp->set_tx_gain(gain);
return gain; return gain;
} }
double cuhd_set_tx_srate(void *h, double freq) double rf_set_tx_srate(void *h, double freq)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_tx_rate(freq); handler->usrp->set_tx_rate(freq);
handler->tx_rate = handler->usrp->get_tx_rate(); handler->tx_rate = handler->usrp->get_tx_rate();
return handler->tx_rate; return handler->tx_rate;
} }
double cuhd_set_tx_freq(void *h, double freq) double rf_set_tx_freq(void *h, double freq)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
handler->usrp->set_tx_freq(freq); handler->usrp->set_tx_freq(freq);
return handler->usrp->get_tx_freq(); return handler->usrp->get_tx_freq();
} }
double cuhd_set_tx_freq_offset(void *h, double freq, double off) { double rf_set_tx_freq_offset(void *h, double freq, double off) {
cuhd_handler* handler = static_cast<cuhd_handler*>(h); rf_handler* handler = static_cast<rf_handler*>(h);
handler->usrp->set_tx_freq(uhd::tune_request_t(freq, off)); handler->usrp->set_tx_freq(uhd::tune_request_t(freq, off));
return handler->usrp->get_tx_freq(); return handler->usrp->get_tx_freq();
} }
void cuhd_get_time(void *h, time_t *secs, double *frac_secs) { void rf_get_time(void *h, time_t *secs, double *frac_secs) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); rf_handler *handler = static_cast < rf_handler * >(h);
uhd::time_spec_t now = handler->usrp->get_time_now(); uhd::time_spec_t now = handler->usrp->get_time_now();
if (secs) { if (secs) {
*secs = now.get_full_secs(); *secs = now.get_full_secs();
@ -438,7 +438,7 @@ void cuhd_get_time(void *h, time_t *secs, double *frac_secs) {
} }
int cuhd_send_timed3(void *h, int rf_send_timed3(void *h,
void *data, void *data,
int nsamples, int nsamples,
time_t secs, time_t secs,
@ -448,7 +448,7 @@ int cuhd_send_timed3(void *h,
bool is_start_of_burst, bool is_start_of_burst,
bool is_end_of_burst) bool is_end_of_burst)
{ {
cuhd_handler* handler = static_cast<cuhd_handler*>(h); rf_handler* handler = static_cast<rf_handler*>(h);
uhd::tx_metadata_t md; uhd::tx_metadata_t md;
md.has_time_spec = has_time_spec; md.has_time_spec = has_time_spec;
if (has_time_spec) { if (has_time_spec) {
@ -489,27 +489,27 @@ int cuhd_send_timed3(void *h,
} }
} }
int cuhd_send(void *h, void *data, uint32_t nsamples, bool blocking) int rf_send(void *h, void *data, uint32_t nsamples, bool blocking)
{ {
return cuhd_send2(h, data, nsamples, blocking, true, true); return rf_send2(h, data, nsamples, blocking, true, true);
} }
int cuhd_send2(void *h, void *data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst) int rf_send2(void *h, void *data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst)
{ {
return cuhd_send_timed3(h, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst); return rf_send_timed3(h, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst);
} }
int cuhd_send_timed(void *h, int rf_send_timed(void *h,
void *data, void *data,
int nsamples, int nsamples,
time_t secs, time_t secs,
double frac_secs) double frac_secs)
{ {
return cuhd_send_timed2(h, data, nsamples, secs, frac_secs, true, true); return rf_send_timed2(h, data, nsamples, secs, frac_secs, true, true);
} }
int cuhd_send_timed2(void *h, int rf_send_timed2(void *h,
void *data, void *data,
int nsamples, int nsamples,
time_t secs, time_t secs,
@ -517,5 +517,5 @@ int cuhd_send_timed2(void *h,
bool is_start_of_burst, bool is_start_of_burst,
bool is_end_of_burst) bool is_end_of_burst)
{ {
return cuhd_send_timed3(h, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst); return rf_send_timed3(h, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst);
} }

@ -36,10 +36,10 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#include "srslte/cuhd/cuhd_utils.h" #include "srslte/rf/rf_utils.h"
int cuhd_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double fs, int nsamp) { int rf_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double fs, int nsamp) {
int i, j; int i, j;
int ret = -1; int ret = -1;
_Complex float *buffer; _Complex float *buffer;
@ -50,21 +50,21 @@ int cuhd_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double f
goto free_and_exit; goto free_and_exit;
} }
cuhd_set_rx_gain(uhd, 20.0); rf_set_rx_gain(uhd, 20.0);
cuhd_set_rx_srate(uhd, fs); rf_set_rx_srate(uhd, fs);
for (i=0;i<nof_bands;i++) { for (i=0;i<nof_bands;i++) {
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
f = (double) freqs[i]; f = (double) freqs[i];
cuhd_set_rx_freq(uhd, f); rf_set_rx_freq(uhd, f);
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
usleep(10000); usleep(10000);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
/* discard first samples */ /* discard first samples */
for (j=0;j<2;j++) { for (j=0;j<2;j++) {
if (cuhd_recv(uhd, buffer, nsamp, 1) != nsamp) { if (rf_recv(uhd, buffer, nsamp, 1) != nsamp) {
goto free_and_exit; goto free_and_exit;
} }
} }
@ -74,7 +74,7 @@ int cuhd_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double f
printf("\n"); printf("\n");
} }
} }
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
ret = 0; ret = 0;
free_and_exit: free_and_exit:
@ -83,34 +83,34 @@ free_and_exit:
} }
int cuhd_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) { int rf_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *t) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- \n", nsamples);
return cuhd_recv(h, data, nsamples, 1); return rf_recv(h, data, nsamples, 1);
} }
/** This function is simply a wrapper to the ue_cell_search module for cuhd devices /** 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. * Return 1 if the MIB is decoded, 0 if not or -1 on error.
*/ */
int cuhd_mib_decoder(void *uhd, cell_search_cfg_t *config, srslte_cell_t *cell) { int rf_mib_decoder(void *uhd, cell_search_cfg_t *config, srslte_cell_t *cell) {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
srslte_ue_mib_sync_t ue_mib; srslte_ue_mib_sync_t ue_mib;
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) { if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, rf_recv_wrapper_cs, uhd)) {
fprintf(stderr, "Error initiating srslte_ue_mib_sync\n"); fprintf(stderr, "Error initiating srslte_ue_mib_sync\n");
goto clean_exit; goto clean_exit;
} }
if (config->init_agc > 0) { if (config->init_agc > 0) {
srslte_ue_sync_start_agc(&ue_mib.ue_sync, cuhd_set_rx_gain_th, config->init_agc); srslte_ue_sync_start_agc(&ue_mib.ue_sync, rf_set_rx_gain_th, config->init_agc);
} }
int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB); int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB);
INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000);
cuhd_set_rx_srate(uhd, (float) srate); rf_set_rx_srate(uhd, (float) srate);
INFO("Starting receiver...\n", 0); INFO("Starting receiver...\n", 0);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
/* Find and decody MIB */ /* Find and decody MIB */
ret = srslte_ue_mib_sync_decode(&ue_mib, config->max_frames_pss, bch_payload, &cell->nof_ports, NULL); ret = srslte_ue_mib_sync_decode(&ue_mib, config->max_frames_pss, bch_payload, &cell->nof_ports, NULL);
@ -129,15 +129,15 @@ int cuhd_mib_decoder(void *uhd, cell_search_cfg_t *config, srslte_cell_t *cell)
clean_exit: clean_exit:
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
srslte_ue_mib_sync_free(&ue_mib); srslte_ue_mib_sync_free(&ue_mib);
return ret; return ret;
} }
/** This function is simply a wrapper to the ue_cell_search module for cuhd devices /** This function is simply a wrapper to the ue_cell_search module for rf devices
*/ */
int cuhd_cell_search(void *uhd, cell_search_cfg_t *config, int rf_cell_search(void *uhd, cell_search_cfg_t *config,
int force_N_id_2, srslte_cell_t *cell) int force_N_id_2, srslte_cell_t *cell)
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
@ -146,7 +146,7 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t)); bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (srslte_ue_cellsearch_init(&cs, cuhd_recv_wrapper_cs, uhd)) { if (srslte_ue_cellsearch_init(&cs, rf_recv_wrapper_cs, uhd)) {
fprintf(stderr, "Error initiating UE cell detect\n"); fprintf(stderr, "Error initiating UE cell detect\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -159,14 +159,14 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
} }
if (config->init_agc > 0) { if (config->init_agc > 0) {
srslte_ue_sync_start_agc(&cs.ue_sync, cuhd_set_rx_gain_th, config->init_agc); srslte_ue_sync_start_agc(&cs.ue_sync, rf_set_rx_gain_th, config->init_agc);
} }
INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000);
cuhd_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ); rf_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0); INFO("Starting receiver...\n", 0);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
/* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ /* 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; uint32_t max_peak_cell = 0;
@ -207,7 +207,7 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
config->init_agc = srslte_agc_get_gain(&cs.ue_sync.agc); config->init_agc = srslte_agc_get_gain(&cs.ue_sync.agc);
} }
cuhd_stop_rx_stream(uhd); rf_stop_rx_stream(uhd);
srslte_ue_cellsearch_free(&cs); srslte_ue_cellsearch_free(&cs);
return ret; return ret;
@ -219,15 +219,15 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
* 0 if no cell was found or MIB could not be decoded, * 0 if no cell was found or MIB could not be decoded,
* -1 on error * -1 on error
*/ */
int cuhd_search_and_decode_mib(void *uhd, cell_search_cfg_t *config, int force_N_id_2, srslte_cell_t *cell) int rf_search_and_decode_mib(void *uhd, cell_search_cfg_t *config, int force_N_id_2, srslte_cell_t *cell)
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
printf("Searching for cell...\n"); printf("Searching for cell...\n");
ret = cuhd_cell_search(uhd, config, force_N_id_2, cell); ret = rf_cell_search(uhd, config, force_N_id_2, cell);
if (ret > 0) { if (ret > 0) {
printf("Decoding PBCH for cell %d (N_id_2=%d)\n", cell->id, cell->id%3); printf("Decoding PBCH for cell %d (N_id_2=%d)\n", cell->id, cell->id%3);
ret = cuhd_mib_decoder(uhd, config, cell); ret = rf_mib_decoder(uhd, config, cell);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Could not decode PBCH from CELL ID %d\n", cell->id); fprintf(stderr, "Could not decode PBCH from CELL ID %d\n", cell->id);
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -33,7 +33,7 @@ ENDIF(SRSGUI_FOUND)
IF(UHD_FOUND) IF(UHD_FOUND)
ADD_EXECUTABLE(pss_usrp pss_usrp.c) ADD_EXECUTABLE(pss_usrp pss_usrp.c)
TARGET_LINK_LIBRARIES(pss_usrp srslte srslte_uhd) TARGET_LINK_LIBRARIES(pss_usrp srslte srslte_rf)
IF(SRSGUI_FOUND) IF(SRSGUI_FOUND)
target_link_libraries(pss_usrp ${SRSGUI_LIBRARIES}) target_link_libraries(pss_usrp ${SRSGUI_LIBRARIES})
ELSE(SRSGUI_FOUND) ELSE(SRSGUI_FOUND)

@ -35,7 +35,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/rf/rf.h"
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
@ -153,21 +153,21 @@ int main(int argc, char **argv) {
flen = srate*5/1000; flen = srate*5/1000;
printf("Opening UHD device...\n"); printf("Opening UHD device...\n");
if (cuhd_open(uhd_args, &uhd)) { if (rf_open(uhd_args, &uhd)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); rf_set_master_clock_rate(uhd, 4*srate);
} else { } else {
cuhd_set_master_clock_rate(uhd, srate); rf_set_master_clock_rate(uhd, srate);
} }
printf("Set RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srate) / 1000000); printf("Set RX rate: %.2f MHz\n", rf_set_rx_srate(uhd, srate) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.1f dB\n", rf_set_rx_gain(uhd, uhd_gain));
printf("Set RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.2f MHz\n", rf_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_rx_wait_lo_locked(uhd); rf_rx_wait_lo_locked(uhd);
buffer = malloc(sizeof(cf_t) * flen * 2); buffer = malloc(sizeof(cf_t) * flen * 2);
if (!buffer) { if (!buffer) {
@ -197,7 +197,7 @@ int main(int argc, char **argv) {
printf("N_id_2: %d\n", N_id_2); printf("N_id_2: %d\n", N_id_2);
cuhd_start_rx_stream(uhd); rf_start_rx_stream(uhd);
printf("Frame length %d samples\n", flen); printf("Frame length %d samples\n", flen);
printf("PSS detection threshold: %.2f\n", threshold); printf("PSS detection threshold: %.2f\n", threshold);
@ -218,7 +218,7 @@ int main(int argc, char **argv) {
ssync.fft_size = fft_size; ssync.fft_size = fft_size;
while(frame_cnt < nof_frames || nof_frames == -1) { while(frame_cnt < nof_frames || nof_frames == -1) {
n = cuhd_recv(uhd, buffer, flen - peak_offset, 1); n = rf_recv(uhd, buffer, flen - peak_offset, 1);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error receiving samples\n"); fprintf(stderr, "Error receiving samples\n");
exit(-1); exit(-1);
@ -330,7 +330,7 @@ int main(int argc, char **argv) {
srslte_pss_synch_free(&pss); srslte_pss_synch_free(&pss);
free(buffer); free(buffer);
cuhd_close(uhd); rf_close(uhd);
printf("Ok\n"); printf("Ok\n");
exit(0); exit(0);

Loading…
Cancel
Save