From 9c64b6df0bffe1fd87965e6766e7ae762e5e9117 Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Mon, 5 Sep 2022 12:09:56 +0200 Subject: [PATCH] uhd: Add uhd.find to the pybind11 interface `uhd_find_devices` would be the default shell function to discover available USRPs. PyUHD provides a function `uhd.find("")` that does the job. Besides, in `gr-uhd/python/uhd/__init__.py` there is a definition of `find_devices`. However, this function is broken at the moment because it tries to use a `find_devices_raw` function from the gr-uhd pybind11 interface that is not available. With this commit, we may be able to fix `find_devices` as well. The actual change is just copied from UHD `host/lib/device_python.cpp`. Alternative solutions would include a new function in C++ and a pybind11 wrapper. Signed-off-by: Johannes Demel --- gr-uhd/python/uhd/bindings/usrp_block_python.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gr-uhd/python/uhd/bindings/usrp_block_python.cc b/gr-uhd/python/uhd/bindings/usrp_block_python.cc index 5f15a14f8f1..432e605afed 100644 --- a/gr-uhd/python/uhd/bindings/usrp_block_python.cc +++ b/gr-uhd/python/uhd/bindings/usrp_block_python.cc @@ -25,6 +25,8 @@ void bind_usrp_block(py::module& m) m.attr("ALL_MBOARDS") = py::int_(::uhd::usrp::multi_usrp::ALL_MBOARDS); m.attr("ALL_LOS") = py::str(::uhd::usrp::multi_usrp::ALL_LOS); + m.def("find", [](const uhd::device_addr_t& hint) { return uhd::device::find(hint); }); + py::class_