From 60fb5d5f1377f5a4af7e1e55b1ec83fed864153f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 4 Dec 2020 13:53:34 +0100 Subject: 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()) --- host/lib/device_python.cpp | 19 +++++++++++++++++++ host/lib/device_python.hpp | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 host/lib/device_python.cpp create mode 100644 host/lib/device_python.hpp (limited to 'host/lib') 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 +#include +#include + +namespace py = pybind11; + +#include "device_python.hpp" +#include + +void export_device(py::module& m) +{ + m.def("find", [](const uhd::device_addr_t& hint) { return uhd::device::find(hint); }); +} diff --git a/host/lib/device_python.hpp b/host/lib/device_python.hpp new file mode 100644 index 000000000..1cc0445cd --- /dev/null +++ b/host/lib/device_python.hpp @@ -0,0 +1,9 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +void export_device(py::module& m); -- cgit v1.2.3