From 0a89472e5235bb9d3b6872271c23cb167c5d430c Mon Sep 17 00:00:00 2001 From: Josh Morman <mormjb@gmail.com> Date: Fri, 26 Jun 2020 09:08:55 -0400 Subject: uhd: wrap get_usrp_info to compatible return type - Move get_usrp_info() to usrp_block - Casts the return value to std::map so PyBind11 can turn it into a dictionary in Python This fixes an issue where get_usrp_info() would cause an Exception with PyBind11. Co-authored-by: Martin Braun <martin.braun@ettus.com> --- gr-uhd/python/uhd/bindings/usrp_block_python.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gr-uhd/python/uhd/bindings/usrp_block_python.cc') diff --git a/gr-uhd/python/uhd/bindings/usrp_block_python.cc b/gr-uhd/python/uhd/bindings/usrp_block_python.cc index d816a1668d..876dfb52d0 100644 --- a/gr-uhd/python/uhd/bindings/usrp_block_python.cc +++ b/gr-uhd/python/uhd/bindings/usrp_block_python.cc @@ -388,7 +388,18 @@ void bind_usrp_block(py::module& m) py::arg("path"), D(usrp_block, get_filter)) - ; + .def( + "get_usrp_info", + [](usrp_block& self, const size_t chan = 0) { + std::map<std::string, std::string> new_map; + auto usrp_info = self.get_usrp_info(chan); + for (const auto& k : self.get_usrp_info(chan).keys()) { + new_map[k] = usrp_info[k]; + } + return new_map; + }, + py::arg("chan") = 0, + D(usrp_block, get_usrp_info)); m.def("cmd_chan_key", &::gr::uhd::cmd_chan_key, D(cmd_chan_key)); -- cgit v1.2.3