diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-19 16:37:33 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-10-19 16:37:33 -0700 |
commit | be300d920fe1b7a3eb738565cddd10624ec62a75 (patch) | |
tree | 45bb49c4a4acd7c93bb218c84b94de4c90f198c5 /gr-uhd/swig | |
parent | a57f7484a1b1ba18b66334675ce6458b00d40626 (diff) | |
parent | e30b824e9165bff69f09121631c3d5a706cbbd39 (diff) |
Merge branch 'next' of http://gnuradio.org/git/gnuradio into next
Diffstat (limited to 'gr-uhd/swig')
-rw-r--r-- | gr-uhd/swig/__init__.py | 9 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index c63d3cc571..7745b4b797 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -69,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 f8381ae64b..7e612907c2 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 //////////////////////////////////////////////////////////////////////// %{ |