aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-11-01 14:53:16 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-04 09:57:49 -0800
commit00c3dc29c227b11c86ce3fc1854858e999f5cb76 (patch)
tree489fbab8346d0cf3a0d3049cd9610ceccc9e258c /host/lib/usrp
parent0014f5ba2947448703c9ba0afb1c9f1084f1fc50 (diff)
downloaduhd-00c3dc29c227b11c86ce3fc1854858e999f5cb76.tar.gz
uhd-00c3dc29c227b11c86ce3fc1854858e999f5cb76.tar.bz2
uhd-00c3dc29c227b11c86ce3fc1854858e999f5cb76.zip
python: Make multi_usrp::get_*_usrp_info() return a Python dict
By using the conversion ability to std::map<>, we can make the Python versions of get_?x_usrp_info() return a dict in Python. Sample Python session: >>> import uhd >>> U = uhd.usrp.MultiUsrp(args) >>> U.get_usrp_rx_info() {'mboard_id': 'B200', 'rx_subdev_name': 'FE-RX2', ...}
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/multi_usrp_python.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/host/lib/usrp/multi_usrp_python.hpp b/host/lib/usrp/multi_usrp_python.hpp
index ef0cb0097..48da794fb 100644
--- a/host/lib/usrp/multi_usrp_python.hpp
+++ b/host/lib/usrp/multi_usrp_python.hpp
@@ -48,8 +48,18 @@ void export_multi_usrp(py::module& m)
.def("set_tx_gain" , (void (multi_usrp::*)(double, const std::string&, size_t)) &multi_usrp::set_tx_gain, py::arg("gain"), py::arg("name"), py::arg("chan") = 0)
.def("set_tx_gain" , (void (multi_usrp::*)(double, size_t)) &multi_usrp::set_tx_gain, py::arg("gain"), py::arg("chan") = 0)
.def("set_tx_rate" , &multi_usrp::set_tx_rate, py::arg("rate"), py::arg("chan") = ALL_CHANS)
- .def("get_usrp_rx_info" , &multi_usrp::get_usrp_rx_info, py::arg("chan") = 0)
- .def("get_usrp_tx_info" , &multi_usrp::get_usrp_tx_info, py::arg("chan") = 0)
+ .def("get_usrp_rx_info",
+ [](multi_usrp& self, const size_t chan = 0) {
+ return static_cast<std::map<std::string, std::string>>(
+ self.get_usrp_rx_info(chan));
+ },
+ py::arg("chan") = 0)
+ .def("get_usrp_tx_info",
+ [](multi_usrp& self, const size_t chan = 0) {
+ return static_cast<std::map<std::string, std::string>>(
+ self.get_usrp_tx_info(chan));
+ },
+ py::arg("chan") = 0)
.def("set_master_clock_rate" , &multi_usrp::set_master_clock_rate, py::arg("rate"), py::arg("mboard") = ALL_MBOARDS)
.def("get_master_clock_rate" , &multi_usrp::get_master_clock_rate, py::arg("mboard") = 0)
.def("get_master_clock_rate_range", &multi_usrp::get_master_clock_rate_range, py::arg("mboard") = ALL_MBOARDS)