Graphics/UHD optional to compile enodeb_bch/mib_track examples

master
ismagom 11 years ago
parent adf5260e29
commit 10c6cfef12

@ -77,7 +77,6 @@ IF(MSVC)
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
)
LIST(APPEND IRIS_CORE_COMMON_FLAGS_AND_DEFINES -DHAVE_CONFIG_H)
ADD_DEFINITIONS(/MP) #build with multiple processors
ENDIF(MSVC)
@ -87,52 +86,6 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
########################################################################
# Setup Boost
########################################################################
MESSAGE(STATUS "")
MESSAGE(STATUS "Configuring Boost C++ Libraries...")
SET(BOOST_REQUIRED_COMPONENTS
program_options
system
thread
unit_test_framework
)
IF(UNIX AND EXISTS "/usr/lib64")
LIST(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
ENDIF(UNIX AND EXISTS "/usr/lib64")
IF(MSVC)
SET(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
IF(BOOST_ALL_DYN_LINK)
ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
ELSE(BOOST_ALL_DYN_LINK)
UNSET(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
ENDIF(BOOST_ALL_DYN_LINK)
ENDIF(MSVC)
SET(Boost_ADDITIONAL_VERSIONS
"1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" "1.40.0" "1.40"
"1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
"1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" "1.45.0" "1.45"
"1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53")
FIND_PACKAGE(Boost 1.37 REQUIRED ${BOOST_REQUIRED_COMPONENTS})
MESSAGE(STATUS "Boost version: ${Boost_VERSION}")
IF(Boost_VERSION LESS 104600)
ADD_DEFINITIONS( -DBOOST_FILESYSTEM_VERSION=2 ) #use filesystem version 2 in boost < 1.46
MESSAGE(STATUS "Using Boost Filesystem V2")
ENDIF(Boost_VERSION LESS 104600)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
MESSAGE(STATUS "Boost include directories: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Boost library directories: ${Boost_LIBRARY_DIRS}")
MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}")
########################################################################
# Create uninstall targets

@ -19,7 +19,9 @@
# and at http://www.gnu.org/licenses/.
#
#################################################################
# TO BE MOVED TO UNIT TESTS
#################################################################
add_executable(hl_example hl_example.c)
target_link_libraries(hl_example lte)
@ -39,20 +41,47 @@ target_link_libraries(viterbi_test lte)
add_executable(mib_test mib_test.c)
target_link_libraries(mib_test lte)
#################################################################
# Check if UHD C-API and Graphics library are available
#################################################################
LIST(FIND OPTIONAL_LIBS cuhd CUHD_FIND)
LIST(FIND OPTIONAL_LIBS graphics GRAPHICS_FIND)
#################################################################
# These two can be compiled without UHD or graphics support
#################################################################
add_executable(mib_track mib_track.c)
target_link_libraries(mib_track lte)
add_executable(enodeb_bch enodeb_bch.c)
target_link_libraries(enodeb_bch lte)
IF(${CUHD_FIND} EQUAL -1)
SET_TARGET_PROPERTIES(mib_track PROPERTIES COMPILE_DEFINITIONS "DISABLE_UHD")
SET_TARGET_PROPERTIES(enodeb_bch PROPERTIES COMPILE_DEFINITIONS "DISABLE_UHD")
ELSE(${CUHD_FIND} EQUAL -1)
target_link_libraries(mib_track cuhd)
target_link_libraries(enodeb_bch cuhd)
ENDIF(${CUHD_FIND} EQUAL -1)
IF(${GRAPHICS_FIND} EQUAL -1)
SET_TARGET_PROPERTIES(mib_track PROPERTIES COMPILE_DEFINITIONS "DISABLE_GRAPHICS")
SET_TARGET_PROPERTIES(enodeb_bch PROPERTIES COMPILE_DEFINITIONS "DISABLE_GRAPHICS")
ELSE(${GRAPHICS_FIND} EQUAL -1)
target_link_libraries(mib_track graphics)
target_link_libraries(enodeb_bch graphics)
ENDIF(${GRAPHICS_FIND} EQUAL -1)
#################################################################
# These examples need the UHD driver
#################################################################
IF(${CUHD_FIND} GREATER -1)
IF(${GRAPHICS_FIND} GREATER -1)
add_executable(mib_track mib_track.c)
target_link_libraries(mib_track lte cuhd graphics)
ELSE(${GRAPHICS_FIND} GREATER -1)
MESSAGE(STATUS " mib_track is ignored: GRAPHICS library not compiled.")
ENDIF(${GRAPHICS_FIND} GREATER -1)
add_executable(enodeb_bch enodeb_bch.c)
target_link_libraries(enodeb_bch lte cuhd )
add_executable(rssi_scan_usrp rssi_scan_usrp.c)
target_link_libraries(rssi_scan_usrp lte cuhd )

@ -33,11 +33,9 @@
#include "lte.h"
#define ENABLE_UHD
#ifdef ENABLE_UHD
#include "cuhd.h"
void *uhd;
#ifndef DISABLE_UHD
#include "cuhd.h"
void *uhd;
#endif
char *output_file_name = NULL;
@ -59,10 +57,14 @@ int slot_n_re, slot_n_samples;
void usage(char *prog) {
printf("Usage: %s [agmfoncvp]\n", prog);
#ifndef DISABLE_UHD
printf("\t-a UHD args [Default %s]\n", uhd_args);
printf("\t-g UHD TX gain [Default %.2f dB]\n", uhd_gain);
printf("\t-m UHD signal amplitude [Default %.2f]\n", uhd_amp);
printf("\t-f UHD TX frequency [Default %.1f MHz]\n", uhd_freq/1000000);
#else
printf("\t UHD is disabled. CUHD library not available\n");
#endif
printf("\t-o output_file [Default USRP]\n");
printf("\t-n number of frames [Default %d]\n", nof_frames);
printf("\t-c cell id [Default %d]\n", cell_id);
@ -106,7 +108,7 @@ void parse_args(int argc, char **argv) {
exit(-1);
}
}
#ifndef ENABLE_UHD
#ifdef DISABLE_UHD
if (!output_file_name) {
usage(argv[0]);
exit(-1);
@ -133,16 +135,18 @@ void base_init() {
exit(-1);
}
} else {
#ifdef ENABLE_UHD
#ifndef DISABLE_UHD
printf("Opening UHD device...\n");
if (cuhd_open(uhd_args,&uhd)) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
#else
exit(-1); // not supposed to be here
printf("Error UHD not available. Select an output file\n");
exit(-1);
#endif
}
/* create ifft object */
if (lte_ifft_init(&ifft, CPNORM, nof_prb)) {
fprintf(stderr, "Error creating iFFT object\n");
@ -169,7 +173,7 @@ void base_free() {
if (output_file_name) {
filesink_free(&fsink);
} else {
#ifdef ENABLE_UHD
#ifndef DISABLE_UHD
cuhd_close(&uhd);
#endif
}
@ -186,7 +190,7 @@ int main(int argc, char **argv) {
cf_t *slot1_symbols[MAX_PORTS_CTRL];
#ifndef ENABLE_UHD
#ifdef DISABLE_UHD
if (argc < 3) {
usage(argv[0]);
exit(-1);
@ -224,7 +228,7 @@ int main(int argc, char **argv) {
slot1_symbols[i] = slot_buffer;
}
#ifdef ENABLE_UHD
#ifndef DISABLE_UHD
if (!output_file_name) {
printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, UHD_SAMP_FREQ)/1000000);
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
@ -260,8 +264,9 @@ int main(int argc, char **argv) {
/* send to file or usrp */
if (output_file_name) {
filesink_write(&fsink, output_buffer, slot_n_samples);
usleep(5000);
} else {
#ifdef ENABLE_UHD
#ifndef DISABLE_UHD
vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, slot_n_samples);
cuhd_send(uhd, output_buffer, slot_n_samples, 1);
#endif

@ -35,12 +35,19 @@
#include <unistd.h>
#include <assert.h>
#include "lte.h"
#ifndef DISABLE_UHD
#include "cuhd.h"
#include "cuhd.h"
void *uhd;
#endif
#include "lte.h"
#include "plot.h"
#ifndef DISABLE_GRAPHICS
#include "plot.h"
plot_real_t poutfft;
plot_complex_t pce;
plot_scatter_t pscatrecv, pscatequal;
#endif
#define MHZ 1000000
#define SAMP_FREQ 1920000
@ -66,22 +73,25 @@ chest_t chest;
sync_t sfind, strack;
cfo_t cfocorr;
plot_real_t poutfft;
plot_complex_t pce;
plot_scatter_t pscatrecv, pscatequal;
void *uhd;
enum sync_state {FIND, TRACK};
void usage(char *prog) {
printf("Usage: %s [iagfndv]\n", prog);
printf("\t-i input_file [Default use USRP]\n");
#ifndef DISABLE_UHD
printf("\t-a UHD args [Default %s]\n", uhd_args);
printf("\t-g UHD RX gain [Default %.2f dB]\n", uhd_gain);
printf("\t-f UHD RX frequency [Default %.1f MHz]\n", uhd_freq/1000000);
#else
printf("\t UHD is disabled. CUHD library not available\n");
#endif
printf("\t-n nof_frames [Default %d]\n", nof_frames);
#ifndef DISABLE_GRAPHICS
printf("\t-d disable plots [Default enabled]\n");
#else
printf("\t plots are disabled. Graphics library not available\n");
#endif
printf("\t-v [set verbose to debug, default none]\n");
}
@ -117,6 +127,8 @@ void parse_args(int argc, char **argv) {
}
}
#ifndef DISABLE_GRAPHICS
void init_plots() {
plot_init();
plot_real_init(&poutfft);
@ -141,15 +153,20 @@ void init_plots() {
plot_scatter_setTitle(&pscatequal, "Equalized Symbols");
plot_scatter_setXAxisScale(&pscatequal, -1, 1);
plot_scatter_setYAxisScale(&pscatequal, -1, 1);
}
#endif
int base_init(int frame_length) {
int i;
#ifndef DISABLE_GRAPHICS
if (!disable_plots) {
init_plots();
}
#else
printf("-- PLOTS are disabled. Graphics library not available --\n\n");
#endif
if (input_file_name) {
if (filesource_init(&fsrc, input_file_name, COMPLEX_FLOAT_BIN)) {
@ -164,7 +181,7 @@ int base_init(int frame_length) {
return -1;
}
#else
printf("Error UHD not configured. Select an input file\n");
printf("Error UHD not available. Select an input file\n");
return -1;
#endif
}
@ -257,7 +274,6 @@ int mib_decoder_init(int cell_id) {
int mib_decoder_run(cf_t *input, pbch_mib_t *mib) {
int i, n;
lte_fft_run(&fft, input, fft_buffer);
float tmp[72*7];
/* Get channel estimates for each port */
for (i=0;i<NOF_PORTS;i++) {
@ -267,6 +283,9 @@ int mib_decoder_run(cf_t *input, pbch_mib_t *mib) {
DEBUG("Decoding PBCH\n", 0);
n = pbch_decode(&pbch, fft_buffer, ce, 6, 1, mib);
#ifndef DISABLE_GRAPHICS
float tmp[72*7];
if (!disable_plots) {
for (i=0;i<72*7;i++) {
tmp[i] = 10*log10f(cabsf(fft_buffer[i]));
@ -278,6 +297,7 @@ int mib_decoder_run(cf_t *input, pbch_mib_t *mib) {
plot_scatter_setNewData(&pscatequal, pbch.pbch_d, pbch.nof_symbols);
}
}
#endif
return n;
}
@ -294,6 +314,13 @@ int main(int argc, char **argv) {
int n;
int nof_found_mib = 0;
#ifdef DISABLE_UHD
if (argc < 3) {
usage(argv[0]);
exit(-1);
}
#endif
parse_args(argc,argv);
if (base_init(FLEN)) {

@ -35,7 +35,54 @@ IF(QT4_FOUND AND QWT_FOUND)
ENDIF(QT4_FOUND AND QWT_FOUND)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
########################################################################
# Setup Boost
########################################################################
MESSAGE(STATUS "")
MESSAGE(STATUS "Configuring Boost C++ Libraries...")
SET(BOOST_REQUIRED_COMPONENTS
program_options
system
thread
unit_test_framework
)
IF(UNIX AND EXISTS "/usr/lib64")
LIST(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
ENDIF(UNIX AND EXISTS "/usr/lib64")
IF(MSVC)
SET(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
IF(BOOST_ALL_DYN_LINK)
ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
ELSE(BOOST_ALL_DYN_LINK)
UNSET(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
ENDIF(BOOST_ALL_DYN_LINK)
ENDIF(MSVC)
SET(Boost_ADDITIONAL_VERSIONS
"1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" "1.40.0" "1.40"
"1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
"1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" "1.45.0" "1.45"
"1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53")
FIND_PACKAGE(Boost 1.37 REQUIRED ${BOOST_REQUIRED_COMPONENTS})
MESSAGE(STATUS "Boost version: ${Boost_VERSION}")
IF(Boost_VERSION LESS 104600)
ADD_DEFINITIONS( -DBOOST_FILESYSTEM_VERSION=2 ) #use filesystem version 2 in boost < 1.46
MESSAGE(STATUS "Using Boost Filesystem V2")
ENDIF(Boost_VERSION LESS 104600)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
MESSAGE(STATUS "Boost include directories: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Boost library directories: ${Boost_LIBRARY_DIRS}")
MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}")
########################################################################
# Build the graphics library
@ -51,7 +98,10 @@ FOREACH (_module ${modules})
ENDIF(IS_DIRECTORY ${_module})
ENDFOREACH(_module ${modules})
IF(QT4_FOUND AND QWT_FOUND)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
IF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND)
QT4_WRAP_CPP(lineplotwraps common/Lineplot.h)
QT4_WRAP_CPP(pointplotwraps common/Pointplot.h)
QT4_WRAP_CPP(spectrogramplotwraps common/Spectrogramplot.h)
@ -60,7 +110,7 @@ IF(QT4_FOUND AND QWT_FOUND)
QT4_WRAP_CPP(scatter scatterplot/ScatterWidget.h scatterplot/ScatterplotWrapper.h)
QT4_WRAP_CPP(waterfall waterfallplot/WaterfallWidget.h waterfallplot/WaterfallplotWrapper.h)
INCLUDE_DIRECTORIES(common complexplot realplot scatterplot waterfallplot)
INCLUDE_DIRECTORIES(common complexplot realplot scatterplot waterfallplot ${Boost_INCLUDE_DIRS})
ADD_LIBRARY(graphics ${eventwraps} ${lineplotwraps} ${pointplotwraps} ${spectrogramplotwraps} ${complex} ${real} ${scatter} ${waterfall} ${SOURCES_ALL} )
TARGET_LINK_LIBRARIES(graphics pthread ${QT_LIBRARIES} ${QWT_LIBRARIES})
@ -69,18 +119,21 @@ IF(QT4_FOUND AND QWT_FOUND)
APPEND_INTERNAL_LIST(OPTIONAL_LIBS graphics)
MESSAGE(STATUS " graphics library will be installed.")
ELSE(QT4_FOUND AND QWT_FOUND)
ADD_SUBDIRECTORY(complexplot/test)
ADD_SUBDIRECTORY(realplot/test)
ADD_SUBDIRECTORY(scatterplot/test)
ADD_SUBDIRECTORY(waterfallplot/test)
MESSAGE(STATUS " QT4/Qwt not found. GRAPHICS library is not generated")
MESSAGE(STATUS " GRAPHICS library will be installed.")
ENDIF(QT4_FOUND AND QWT_FOUND)
ELSE(QT4_FOUND AND QWT_FOUND AND Boost_FOUND)
MESSAGE(STATUS " QT4/Qwt or Boost not found. GRAPHICS library is not generated")
ENDIF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND)
ADD_SUBDIRECTORY(complexplot/test)
ADD_SUBDIRECTORY(realplot/test)
ADD_SUBDIRECTORY(scatterplot/test)
ADD_SUBDIRECTORY(waterfallplot/test)

@ -7,8 +7,7 @@
#include <vector>
#include <algorithm>
#include <cmath>
#include "irisapi/Exceptions.h"
#include <assert.h>
class WaterfallData
:public QwtRasterData
@ -34,8 +33,7 @@ public:
void appendData(double* data, int n)
{
if(n != nData_)
throw iris::InvalidDataException("WaterfallData: invalid data length");
assert(n == nData_);
VecPtr v = data_.front();
v->assign(data, data+n);

@ -4,10 +4,8 @@
#include <qlayout.h>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
namespace bl = boost::lambda;
ComplexWidget::ComplexWidget(QWidget *parent)
:QWidget(parent)

@ -4,10 +4,8 @@
#include <qlayout.h>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
namespace bl = boost::lambda;
RealWidget::RealWidget(QWidget *parent)
:QWidget(parent)

@ -4,7 +4,6 @@
#include <qlayout.h>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;

@ -6,10 +6,8 @@
#include <qlayout.h>
#include <qpushbutton.h>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
namespace bl = boost::lambda;
WaterfallWidget::WaterfallWidget(int numDataPoints, int numRows, QWidget *parent)

Loading…
Cancel
Save