summaryrefslogtreecommitdiff
path: root/gr-uhd/python/uhd
diff options
context:
space:
mode:
authorJohannes Demel <demel@ant.uni-bremen.de>2020-06-26 12:41:30 +0200
committermormj <34754695+mormj@users.noreply.github.com>2020-06-27 16:15:47 -0400
commit467f3c127bc9059d8d210dbae72350627b732f8b (patch)
treeea3024e247be71989d825dd92694743feb0d7ced /gr-uhd/python/uhd
parent8483ad2be672669713acf1ab95a0cad2a6beb035 (diff)
uhd: Fix missing bindings
uhd python bindings were missing a couple of functions. 1. `uhd.ALL_MBOARDS` was not defined. 2. `uhd.streams_args` was incomplete. Instead of import magic, we define a pybind constructor which supports all cases. This should ease the maintainance burden as well. Be aware: some notes that `this file was generated with bindtool` were removed because this files contain manual edits. The foundations were probably generated with bindtool once.
Diffstat (limited to 'gr-uhd/python/uhd')
-rw-r--r--gr-uhd/python/uhd/__init__.py23
-rw-r--r--gr-uhd/python/uhd/bindings/uhd_types_python.cc16
-rw-r--r--gr-uhd/python/uhd/bindings/usrp_block_python.cc3
3 files changed, 14 insertions, 28 deletions
diff --git a/gr-uhd/python/uhd/__init__.py b/gr-uhd/python/uhd/__init__.py
index 85a8f2c142..f03dd60808 100644
--- a/gr-uhd/python/uhd/__init__.py
+++ b/gr-uhd/python/uhd/__init__.py
@@ -13,9 +13,6 @@ Used to send and receive data between the Ettus Research, LLC product
line.
'''
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
import uhd # TODO: verify uhd python is installed as a dependency for gr-uhd with python
########################################################################
@@ -46,26 +43,6 @@ def _prepare_uhd_python():
for key, val in list(kwargs.items()): setattr(self, key, val)
setattr(uhd_python, 'tune_request_t', tune_request_t)
- #make the streamer args take **kwargs on init
- class stream_args_t(uhd_python.stream_args_t):
- def __init__(self, *args, **kwargs):
- # UHD Python API doesn't have default args for stream_args_t
- # If empty args, then append empty str's
- while len(args) < 2:
- args += ("",)
- super(stream_args_t, self).__init__(*args)
- for key, val in list(kwargs.items()):
- #for some reason, I can't 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 = uhd_python.device_addr_t(val)
- else: setattr(self, key, val)
-
- # FIXME: stream_args_t.channels.append does not work due to copy operation of STL vectors
- setattr(uhd_python, 'stream_args_t', stream_args_t)
-
#handle general things on all uhd_python attributes
#Install the __str__ and __repr__ handlers if applicable
#Create aliases for uhd swig attributes to avoid the "_t"
diff --git a/gr-uhd/python/uhd/bindings/uhd_types_python.cc b/gr-uhd/python/uhd/bindings/uhd_types_python.cc
index 3be7aa84ca..13f92c7483 100644
--- a/gr-uhd/python/uhd/bindings/uhd_types_python.cc
+++ b/gr-uhd/python/uhd/bindings/uhd_types_python.cc
@@ -7,8 +7,6 @@
*
*/
-/* This file is automatically generated using bindtool */
-
#include <pybind11/complex.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
@@ -42,7 +40,19 @@ void bind_uhd_types(py::module& m)
using stream_args_t = ::uhd::stream_args_t;
py::class_<stream_args_t>(m, "stream_args_t")
- .def(py::init<const std::string&, const std::string&>())
+ .def(py::init([](const std::string& cpu,
+ const std::string& otw,
+ const ::uhd::device_addr_t& args,
+ const std::vector<size_t>& channels) {
+ auto s = ::uhd::stream_args_t(cpu, otw);
+ s.args = args;
+ s.channels = channels;
+ return s;
+ }),
+ py::arg("cpu_format") = "",
+ py::arg("otw_format") = "",
+ py::arg("args") = ::uhd::device_addr_t(""),
+ py::arg("channels") = std::vector<size_t>())
// Properties
.def_readwrite("cpu_format", &stream_args_t::cpu_format)
.def_readwrite("otw_format", &stream_args_t::otw_format)
diff --git a/gr-uhd/python/uhd/bindings/usrp_block_python.cc b/gr-uhd/python/uhd/bindings/usrp_block_python.cc
index 7d25ce1a34..d816a1668d 100644
--- a/gr-uhd/python/uhd/bindings/usrp_block_python.cc
+++ b/gr-uhd/python/uhd/bindings/usrp_block_python.cc
@@ -7,8 +7,6 @@
*
*/
-/* This file is automatically generated using bindtool */
-
#include <pybind11/complex.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
@@ -24,6 +22,7 @@ void bind_usrp_block(py::module& m)
using usrp_block = ::gr::uhd::usrp_block;
+ m.attr("ALL_MBOARDS") = py::int_(::uhd::usrp::multi_usrp::ALL_MBOARDS);
py::class_<usrp_block,
gr::sync_block,