summaryrefslogtreecommitdiff
path: root/gr-uhd/swig
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/swig')
-rw-r--r--gr-uhd/swig/__init__.py15
-rw-r--r--gr-uhd/swig/uhd_swig.i11
2 files changed, 26 insertions, 0 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py
index 1f82b4a26..7745b4b79 100644
--- a/gr-uhd/swig/__init__.py
+++ b/gr-uhd/swig/__init__.py
@@ -19,6 +19,12 @@
# 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
########################################################################
@@ -63,6 +69,15 @@ def _prepare_uhd_swig():
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):
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index f8381ae64..7e612907c 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -102,6 +102,17 @@ 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
////////////////////////////////////////////////////////////////////////
%{