aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-11-19 15:14:27 +0100
committermichael-west <michael.west@ettus.com>2020-11-23 14:35:15 -0800
commita0721d79e49637ec3d2c4319e408a2d00d4c6877 (patch)
tree9424316d090968d3d97537c2050a668dbb530696 /host/lib/types
parent5cbcdd93d3e5e69aa8ebda13ad6b02085a3fb5f7 (diff)
downloaduhd-a0721d79e49637ec3d2c4319e408a2d00d4c6877.tar.gz
uhd-a0721d79e49637ec3d2c4319e408a2d00d4c6877.tar.bz2
uhd-a0721d79e49637ec3d2c4319e408a2d00d4c6877.zip
python: Improve access to device_addr_t
This makes two changes: - Add device_addr_t as a type that the Python property tree access can handle - Add a to_dict() call to device_addr_t (in Python) that will return a regular dictionary from a device_addr_t for a more Pythonic access.
Diffstat (limited to 'host/lib/types')
-rw-r--r--host/lib/types/types_python.hpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/host/lib/types/types_python.hpp b/host/lib/types/types_python.hpp
index 0e5bd3cdc..54d1a2188 100644
--- a/host/lib/types/types_python.hpp
+++ b/host/lib/types/types_python.hpp
@@ -43,7 +43,10 @@ void export_types(py::module& m)
// Methods
.def("__str__", &uhd::device_addr_t::to_pp_string)
.def("to_string", &uhd::device_addr_t::to_string)
- .def("to_pp_string", &uhd::device_addr_t::to_pp_string);
+ .def("to_pp_string", &uhd::device_addr_t::to_pp_string)
+ .def("to_dict", [](uhd::device_addr_t& self) {
+ return static_cast<std::map<std::string, std::string>>(self);
+ });
// This will allow functions in Python that take a device_addr to also take
// a string:
py::implicitly_convertible<std::string, uhd::device_addr_t>();