diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-12-04 13:53:34 +0100 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2020-12-07 11:53:35 -0800 |
commit | 60fb5d5f1377f5a4af7e1e55b1ec83fed864153f (patch) | |
tree | a9e12d953cad5de20be2270fb9504a9b0c6c83fe /host/lib/device_python.cpp | |
parent | eaf006225425e146657a09c7360aca1f9615886d (diff) | |
download | uhd-60fb5d5f1377f5a4af7e1e55b1ec83fed864153f.tar.gz uhd-60fb5d5f1377f5a4af7e1e55b1ec83fed864153f.tar.bz2 uhd-60fb5d5f1377f5a4af7e1e55b1ec83fed864153f.zip |
python: Add find() to the Python API
This a mapping of uhd::device::find() into uhd.find() on the Python
side. The uhd::device is intentionally not mapped into Python (prefer
MultiUSRP or RfnocGraph instead), so the namespace is moved up one
level.
Example:
>>> import uhd
>>> # Now print the device args for all found B200s:
>>> for dev_args in uhd.find("type=b200")): print(dev_args.to_string())
Diffstat (limited to 'host/lib/device_python.cpp')
-rw-r--r-- | host/lib/device_python.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/host/lib/device_python.cpp b/host/lib/device_python.cpp new file mode 100644 index 000000000..43147a09c --- /dev/null +++ b/host/lib/device_python.cpp @@ -0,0 +1,19 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include "device_python.hpp" +#include <uhd/device.hpp> + +void export_device(py::module& m) +{ + m.def("find", [](const uhd::device_addr_t& hint) { return uhd::device::find(hint); }); +} |