uhd: use gr-uhd by default, fall back to built-in code if not found

This commit is contained in:
Dimitri Stolnikov 2013-08-04 10:16:06 +02:00
parent 6e29bf179f
commit bdc8f22132
14 changed files with 82 additions and 23 deletions

View File

@ -168,6 +168,7 @@ set(GR_REQUIRED_COMPONENTS RUNTIME PMT BLOCKS)
find_package(Gnuradio "3.7.0")
find_package(GnuradioIQBalance)
find_package(UHD)
find_package(GnuradioUHD)
find_package(GnuradioFCD)
find_package(GnuradioFCDPP)
find_package(LibOsmoSDR)
@ -197,6 +198,9 @@ if(NOT GNURADIO_RUNTIME_FOUND)
set(GNURADIO_BLOCKS_LIBRARY_DIRS "")
set(GNURADIO_BLOCKS_LIBRARIES "")
set(GNURADIO_UHD_INCLUDE_DIRS "")
set(GNURADIO_UHD_LIBRARIES "")
LIST(APPEND GR_OSMOSDR_PC_CFLAGS "-I\${includedir}/osmosdr/runtime")
# disable python bindings as long as we don't have any swig files for the runtime

View File

@ -32,10 +32,15 @@ install(FILES
gnuradio/thread/thread.h
gnuradio/thread/thread_body_wrapper.h
gnuradio/thread/thread_group.h
DESTINATION include/osmosdr/runtime/gnuradio/thread
)
install(FILES
gnuradio/uhd/api.h
gnuradio/uhd/usrp_sink.h
gnuradio/uhd/usrp_source.h
DESTINATION include/osmosdr/runtime/gnuradio/uhd
)
install(FILES
gnuradio/api.h
gnuradio/attributes.h

View File

@ -0,0 +1,33 @@
/*
* Copyright 2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_GR_UHD_API_H
#define INCLUDED_GR_UHD_API_H
#include <uhd/config.hpp>
#ifdef gnuradio_uhd_EXPORTS
# define GR_UHD_API UHD_EXPORT
#else
# define GR_UHD_API UHD_IMPORT
#endif
#endif /* INCLUDED_GR_UHD_API_H */

View File

@ -23,12 +23,13 @@
#ifndef INCLUDED_GR_UHD_USRP_SINK_H
#define INCLUDED_GR_UHD_USRP_SINK_H
#include <gnuradio/uhd/api.h>
#include <gnuradio/sync_block.h>
#include <uhd/usrp/multi_usrp.hpp>
#ifndef INCLUDED_UHD_STREAM_HPP
namespace uhd {
struct stream_args_t
struct GR_UHD_API stream_args_t
{
stream_args_t(const std::string &cpu = "",
const std::string &otw = "")
@ -52,7 +53,7 @@ namespace gr {
class uhd_usrp_sink;
class usrp_sink : virtual public sync_block
class GR_UHD_API usrp_sink : virtual public sync_block
{
public:
// gr::uhd::usrp_sink::sptr

View File

@ -23,12 +23,13 @@
#ifndef INCLUDED_GR_UHD_USRP_SOURCE_H
#define INCLUDED_GR_UHD_USRP_SOURCE_H
#include <gnuradio/uhd/api.h>
#include <gnuradio/sync_block.h>
#include <uhd/usrp/multi_usrp.hpp>
#ifndef INCLUDED_UHD_STREAM_HPP
namespace uhd {
struct stream_args_t
struct GR_UHD_API stream_args_t
{
stream_args_t(const std::string &cpu = "",
const std::string &otw = "")
@ -52,7 +53,7 @@ namespace gr {
class uhd_usrp_source;
class usrp_source : virtual public sync_block
class GR_UHD_API usrp_source : virtual public sync_block
{
public:
// gr::uhd::usrp_source::sptr

View File

@ -56,8 +56,11 @@ GR_REGISTER_COMPONENT("Built-in GNU Radio runtime" ENABLE_RUNTIME RUNTIME_MODE)
if(ENABLE_RUNTIME)
set(GNURADIO_BLOCKS_FOUND TRUE)
set(GNURADIO_UHD_FOUND TRUE)
ADD_DEFINITIONS(-Dgnuradio_runtime_EXPORTS -Dgnuradio_blocks_EXPORTS)
ADD_DEFINITIONS(-Dgnuradio_runtime_EXPORTS)
ADD_DEFINITIONS(-Dgnuradio_blocks_EXPORTS)
ADD_DEFINITIONS(-Dgnuradio_uhd_EXPORTS)
message(STATUS "")
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake)
@ -71,7 +74,7 @@ GR_OSMOSDR_APPEND_SRCS(
runtime/blocks/null_source_impl.cc
runtime/math/fast_atan2f.cc
runtime/math//fxpt.cc
runtime/math/fxpt.cc
runtime/math/random.cc
runtime/math/sincos.cc
@ -79,6 +82,9 @@ GR_OSMOSDR_APPEND_SRCS(
runtime/thread/thread_body_wrapper.cc
runtime/thread/thread_group.cc
runtime/uhd/usrp_sink_impl.cc
runtime/uhd/usrp_source_impl.cc
runtime/basic_block.cc
runtime/block.cc
runtime/block_detail.cc
@ -123,18 +129,30 @@ GR_OSMOSDR_APPEND_SRCS(
########################################################################
# Handle the generated constants
########################################################################
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"import time;print time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime())"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE
)
MACRO (TODAY RESULT)
IF (WIN32)
EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3"
${RESULT} ${${RESULT}})
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3"
${RESULT} ${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 00.00.0000)
ENDIF (WIN32)
ENDMACRO (TODAY)
TODAY(BUILD_DATE)
set(GR_VERSION "built-in")
message(STATUS "Loading prefix ${prefix} into constants...")
message(STATUS "Loading SYSCONFDIR ${SYSCONFDIR} into constants...")
message(STATUS "Loading GR_PREFSDIR ${GR_PREFSDIR} into constants...")
message(STATUS "Loading build date ${BUILD_DATE} into constants...")
message(STATUS "Loading version ${GR_VERSION} into constants...")
message(STATUS "Loading build date \"${BUILD_DATE}\" into constants...")
message(STATUS "Loading version \"${GR_VERSION}\" into constants...")
#double escape for windows backslash path separators
string(REPLACE "\\" "\\\\" prefix ${prefix})
@ -252,7 +270,7 @@ endif(ENABLE_RTL_TCP)
########################################################################
# Setup UHD component
########################################################################
GR_REGISTER_COMPONENT("Ettus USRP Devices" ENABLE_UHD UHD_FOUND)
GR_REGISTER_COMPONENT("Ettus USRP Devices" ENABLE_UHD UHD_FOUND GNURADIO_UHD_FOUND)
if(ENABLE_UHD)
GR_INCLUDE_SUBDIRECTORY(uhd)
endif(ENABLE_UHD)

View File

@ -20,7 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "usrp_sink.h"
#include <gnuradio/uhd/usrp_sink.h>
#include <uhd/convert.hpp>
#if 0
static const pmt::pmt_t SOB_KEY = pmt::string_to_symbol("tx_sob");

View File

@ -20,7 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "usrp_source.h"
#include <gnuradio/uhd/usrp_source.h>
#include <uhd/convert.hpp>
#if 0
static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("rx_time");

View File

@ -24,11 +24,10 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${UHD_INCLUDE_DIRS}
${GNURADIO_UHD_INCLUDE_DIRS}
)
set(uhd_srcs
${CMAKE_CURRENT_SOURCE_DIR}/usrp_sink_impl.cc
${CMAKE_CURRENT_SOURCE_DIR}/usrp_source_impl.cc
${CMAKE_CURRENT_SOURCE_DIR}/uhd_sink_c.cc
${CMAKE_CURRENT_SOURCE_DIR}/uhd_source_c.cc
)
@ -37,4 +36,4 @@ set(uhd_srcs
# Append gnuradio-osmosdr library sources
########################################################################
list(APPEND gr_osmosdr_srcs ${uhd_srcs})
list(APPEND gr_osmosdr_libs ${UHD_LIBRARIES})
list(APPEND gr_osmosdr_libs ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES})

View File

@ -21,8 +21,7 @@
#define UHD_SINK_C_H
#include <gnuradio/hier_block2.h>
#include "usrp_sink.h"
#include <gnuradio/uhd/usrp_sink.h>
#include "sink_iface.h"

View File

@ -21,8 +21,7 @@
#define UHD_SOURCE_C_H
#include <gnuradio/hier_block2.h>
#include "usrp_source.h"
#include <gnuradio/uhd/usrp_source.h>
#include "source_iface.h"