diff options
Diffstat (limited to 'gr-uhd/swig')
-rw-r--r-- | gr-uhd/swig/CMakeLists.txt | 61 | ||||
-rw-r--r-- | gr-uhd/swig/__init__.py | 130 | ||||
-rw-r--r-- | gr-uhd/swig/gnuradio/uhd.scm | 27 | ||||
-rwxr-xr-x | gr-uhd/swig/qa_uhd.py | 40 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 140 |
5 files changed, 0 insertions, 398 deletions
diff --git a/gr-uhd/swig/CMakeLists.txt b/gr-uhd/swig/CMakeLists.txt deleted file mode 100644 index 3a5132e7f..000000000 --- a/gr-uhd/swig/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# 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. - -######################################################################## -# Setup swig generation -######################################################################## -include(GrPython) -include(GrSwig) - -set(GR_SWIG_FLAGS -DGR_HAVE_UHD) #needed to parse uhd_swig.i - -set(GR_SWIG_INCLUDE_DIRS - ${GR_UHD_INCLUDE_DIRS} - ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} - ${GRUEL_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${UHD_INCLUDE_DIRS} -) - -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/uhd_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) - -link_directories(${UHD_LIBRARY_DIRS}) -set(GR_SWIG_LIBRARIES gnuradio-uhd ${UHD_LIBRARIES}) - -GR_SWIG_MAKE(uhd_swig uhd_swig.i) - -GR_SWIG_INSTALL( - TARGETS uhd_swig - DESTINATION ${GR_PYTHON_DIR}/gnuradio/uhd - COMPONENT "uhd_python" -) - -install( - FILES uhd_swig.i - ${CMAKE_CURRENT_BINARY_DIR}/uhd_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "uhd_swig" -) - -GR_PYTHON_INSTALL( - FILES __init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/uhd - COMPONENT "uhd_python" -) diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py deleted file mode 100644 index 54a058c45..000000000 --- a/gr-uhd/swig/__init__.py +++ /dev/null @@ -1,130 +0,0 @@ -# -# Copyright 2010-2012 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. -# - -''' -This is the GNU Radio UHD package. It is the interface to the UHD -library to connect to and send and receive data between the Ettus -Research, LLC product line. -''' - -######################################################################## -# Prepare uhd swig module to make it more pythonic -######################################################################## -def _prepare_uhd_swig(): - import uhd_swig - - #some useful typedefs for the user - setattr(uhd_swig, 'freq_range_t', uhd_swig.meta_range_t) - setattr(uhd_swig, 'gain_range_t', uhd_swig.meta_range_t) - - #Make the python tune request object inherit from float - #so that it can be passed in GRC as a frequency parameter. - #The type checking in GRC will accept the tune request. - #Also use kwargs to construct individual struct elements. - class tune_request_t(uhd_swig.tune_request_t, float): - def __new__(self, *args, **kwargs): return float.__new__(self) - def __float__(self): return self.target_freq - def __init__(self, *args, **kwargs): - super(tune_request_t, self).__init__(*args) - for key, val in kwargs.iteritems(): setattr(self, key, val) - setattr(uhd_swig, 'tune_request_t', tune_request_t) - - #Make the python tune request object inherit from string - #so that it can be passed in GRC as a string parameter. - #The type checking in GRC will accept the device address. - #Define the set/get item special methods for dict access. - class device_addr_t(uhd_swig.device_addr_t, str): - def __new__(self, *args): return str.__new__(self) - def __getitem__(self, key): return self.get(key) - def __setitem__(self, key, val): self.set(key, val) - def __init__(self, *args, **kwargs): - super(device_addr_t, self).__init__(*args) - if args and isinstance(args[0], device_addr_t): - for key in args[0].keys(): self[key] = args[0][key] - setattr(uhd_swig, 'device_addr_t', device_addr_t) - - #make the streamer args take **kwargs on init - class stream_args_t(uhd_swig.stream_args_t): - def __init__(self, *args, **kwargs): - super(stream_args_t, self).__init__(*args) - for key, val in kwargs.iteritems(): - #for some reason, i cant assign a list in the constructor - #but what i can do is append the elements individually - if key == 'channels': - for v in val: self.channels.append(v) - elif key == 'args': - self.args = device_addr_t(val) - else: setattr(self, key, val) - setattr(uhd_swig, 'stream_args_t', stream_args_t) - - #handle general things on all uhd_swig attributes - #Install the __str__ and __repr__ handlers if applicable - #Create aliases for uhd swig attributes to avoid the "_t" - for attr in dir(uhd_swig): - myobj = getattr(uhd_swig, attr) - if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda o: o.to_string().strip() - if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda o: o.to_pp_string().strip() - if hasattr(myobj, 'to_bool'): myobj.__nonzero__ = lambda o: o.to_bool() - if hasattr(myobj, 'to_int'): myobj.__int__ = lambda o: o.to_int() - if hasattr(myobj, 'to_real'): myobj.__float__ = lambda o: o.to_real() - if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj) - - #make a new find devices that casts everything with the pythonized device_addr_t which has __str__ - def find_devices(*args, **kwargs): - def to_pythonized_dev_addr(dev_addr): - new_dev_addr = uhd_swig.device_addr_t() - for key in dev_addr.keys(): new_dev_addr[key] = dev_addr.get(key) - return new_dev_addr - return map(to_pythonized_dev_addr, uhd_swig.find_devices_raw(*args, **kwargs)) - setattr(uhd_swig, 'find_devices', find_devices) - - #Cast constructor args (FIXME swig handle overloads?) - for attr in ('usrp_source', 'usrp_sink', 'amsg_source'): - def constructor_factory(old_constructor): - def constructor_interceptor(*args, **kwargs): - args = list(args) - kwargs = dict(kwargs) - for index, key, cast in ( - (0, 'device_addr', device_addr), - (1, 'io_type', io_type), - ): - try: - if len(args) > index: args[index] = cast(args[index]) - if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) - except: pass - #dont pass kwargs, it confuses swig, map into args list: - for key in ('device_addr', 'stream_args', 'io_type', 'num_channels'): - if kwargs.has_key(key): args.append(kwargs[key]) - return old_constructor(*args) - return constructor_interceptor - setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) - - #Aliases for deprecated constructors - setattr(uhd_swig, 'single_usrp_source', uhd_swig.usrp_source) - setattr(uhd_swig, 'single_usrp_sink', uhd_swig.usrp_sink) - setattr(uhd_swig, 'multi_usrp_source', uhd_swig.usrp_source) - setattr(uhd_swig, 'multi_usrp_sink', uhd_swig.usrp_sink) - -######################################################################## -# Initialize this module with the contents of uhd swig -######################################################################## -_prepare_uhd_swig() -from uhd_swig import * diff --git a/gr-uhd/swig/gnuradio/uhd.scm b/gr-uhd/swig/gnuradio/uhd.scm deleted file mode 100644 index 906aef2a6..000000000 --- a/gr-uhd/swig/gnuradio/uhd.scm +++ /dev/null @@ -1,27 +0,0 @@ -;;; -;;; Copyright 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; Semi bogus module that just reexports the uhd_swig module - -(define-module (gnuradio uhd) - #:use-module (gnuradio export-safely) - #:use-module (gnuradio uhd_swig) - #:duplicates (merge-generics replace check)) - -(re-export-all '(gnuradio uhd_swig)) diff --git a/gr-uhd/swig/qa_uhd.py b/gr-uhd/swig/qa_uhd.py deleted file mode 100755 index 00757369f..000000000 --- a/gr-uhd/swig/qa_uhd.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2008,2010 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. -# - -from gnuradio import gr, gr_unittest -import uhd_swig - -class test_uhd(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have a UHD device connected, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_uhd, "test_uhd.xml") diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i deleted file mode 100644 index 342b8279b..000000000 --- a/gr-uhd/swig/uhd_swig.i +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010-2012 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. - */ - -%module uhd_swig - -// Defined during configure; avoids trying to locate -// header files if UHD was not installed. -#ifdef GR_HAVE_UHD - -#define GR_UHD_API - -//suppress 319. No access specifier given for base class name (ignored). -#pragma SWIG nowarn=319 - -//////////////////////////////////////////////////////////////////////// -// standard includes -//////////////////////////////////////////////////////////////////////// -%include "gnuradio.i" - -//load generated python docstrings -%include "uhd_swig_doc.i" - -//////////////////////////////////////////////////////////////////////// -// block headers -//////////////////////////////////////////////////////////////////////// -%{ -#include <gr_uhd_usrp_source.h> -#include <gr_uhd_usrp_sink.h> -#include <gr_uhd_amsg_source.h> -%} - -//////////////////////////////////////////////////////////////////////// -// used types -//////////////////////////////////////////////////////////////////////// -%template(string_vector_t) std::vector<std::string>; - -%template(size_vector_t) std::vector<size_t>; - -%include <uhd/config.hpp> - -%include <uhd/utils/pimpl.hpp> - -%ignore uhd::dict::operator[]; //ignore warnings about %extend -%include <uhd/types/dict.hpp> -%template(string_string_dict_t) uhd::dict<std::string, std::string>; //define after dict - -%include <uhd/types/device_addr.hpp> - -%include <uhd/types/io_type.hpp> - -%template(range_vector_t) std::vector<uhd::range_t>; //define before range -%include <uhd/types/ranges.hpp> - -%include <uhd/types/tune_request.hpp> - -%include <uhd/types/tune_result.hpp> - -%include <uhd/types/io_type.hpp> - -%include <uhd/types/time_spec.hpp> - -%include <uhd/types/stream_cmd.hpp> - -%include <uhd/types/clock_config.hpp> - -%include <uhd/types/metadata.hpp> - -%template(device_addr_vector_t) std::vector<uhd::device_addr_t>; - -%include <uhd/types/sensors.hpp> - -//////////////////////////////////////////////////////////////////////// -// swig dboard_iface for python access -//////////////////////////////////////////////////////////////////////// -%include stdint.i -%include <uhd/types/serial.hpp> -%template(byte_vector_t) std::vector<uint8_t>; -%include <uhd/usrp/dboard_iface.hpp> - -%template(dboard_iface_sptr) boost::shared_ptr<uhd::usrp::dboard_iface>; - -//////////////////////////////////////////////////////////////////////// -// block magic -//////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(uhd,usrp_source) -%include <gr_uhd_usrp_source.h> - -GR_SWIG_BLOCK_MAGIC(uhd,usrp_sink) -%include <gr_uhd_usrp_sink.h> - -GR_SWIG_BLOCK_MAGIC(uhd,amsg_source) -%include <gr_uhd_amsg_source.h> - -//////////////////////////////////////////////////////////////////////// -// device discovery (no need to %include device.hpp) -//////////////////////////////////////////////////////////////////////// -%{ -static uhd::device_addrs_t find_devices_raw(const uhd::device_addr_t &dev_addr = uhd::device_addr_t()){ - return uhd::device::find(dev_addr); -} -%} - -static uhd::device_addrs_t find_devices_raw(const uhd::device_addr_t &dev_addr = uhd::device_addr_t()); - -//////////////////////////////////////////////////////////////////////// -// helpful constants -//////////////////////////////////////////////////////////////////////// -%{ -static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS; -%} -static const size_t ALL_MBOARDS; - -%{ -#include <uhd/version.hpp> -std::string get_version_string(void){ - return uhd::get_version_string(); -} -%} -std::string get_version_string(void); - -#endif /* GR_HAVE_UHD */ |