Skip to content

Commit

Permalink
uhd: Add uhd.find to the pybind11 interface
Browse files Browse the repository at this point in the history
`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 <demel@ant.uni-bremen.de>
  • Loading branch information
jdemel authored and mormj committed Sep 8, 2022
1 parent c1b88ff commit 9c64b6d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gr-uhd/python/uhd/bindings/usrp_block_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_<usrp_block,
gr::sync_block,
gr::block,
Expand Down

0 comments on commit 9c64b6d

Please sign in to comment.