From e4291f1ddcf9f23e4449201fc2677c0379b13ca6 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 2 Jul 2020 16:22:57 +0200 Subject: multi_usrp: Add get_radio_control() API call This is an advanced API call that allows direct underlying access to the radio_control object for RFNoC devices. --- host/include/uhd/usrp/multi_usrp.hpp | 20 ++++++++++++++++++++ host/lib/usrp/multi_usrp.cpp | 6 ++++++ host/lib/usrp/multi_usrp_python.hpp | 1 + host/lib/usrp/multi_usrp_rfnoc.cpp | 5 +++++ host/tests/devtest/multi_usrp_test.py | 1 + 5 files changed, 33 insertions(+) (limited to 'host') diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 78b2e58df..1e2993bf4 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -587,6 +588,25 @@ public: */ virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0; + /*! Get direct access to the underlying RFNoC radio object. + * + * Note: This is an advanced API, created for corner cases where the + * application is using multi_usrp, but some special features from + * radio_control need to be used that are not exposed by multi_usrp. Note + * that it is possible to put the radio and multi_usrp into a broken state + * by directly accessing the radio. For typical radio operations (such as + * tuning, setting gain or antenna, etc.) it is therefore highly recommended + * to not use this API call, but use the native multi_usrp API calls. + * + * The lifetime of the radio is linked to the lifetime of the device object, + * so storing a reference from this function is not allowed. + * + * \param chan The channel index + * \returns A reference to the radio block matching the given channel + * \throws uhd::not_implemented_error if not on an RFNoC device. + */ + virtual uhd::rfnoc::radio_control& get_radio_control(const size_t chan = 0) = 0; + /******************************************************************* * RX methods ******************************************************************/ diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 04d054b60..b9a60a794 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -948,6 +948,12 @@ public: return nullptr; } + uhd::rfnoc::radio_control& get_radio_control(const size_t) + { + throw uhd::not_implemented_error( + "get_radio_control() not supported on this device!"); + } + /******************************************************************* * RX methods ******************************************************************/ diff --git a/host/lib/usrp/multi_usrp_python.hpp b/host/lib/usrp/multi_usrp_python.hpp index cf2db7690..6c2fd2ccf 100644 --- a/host/lib/usrp/multi_usrp_python.hpp +++ b/host/lib/usrp/multi_usrp_python.hpp @@ -85,6 +85,7 @@ void export_multi_usrp(py::module& m) .def("get_mboard_sensor" , &multi_usrp::get_mboard_sensor, py::arg("name"), py::arg("mboard") = 0) .def("get_mboard_sensor_names" , &multi_usrp::get_mboard_sensor_names, py::arg("mboard") = 0) .def("set_user_register" , &multi_usrp::set_user_register, py::arg("addr"), py::arg("data"), py::arg("mboard") = ALL_MBOARDS) + .def("get_radio_control" , &multi_usrp::get_radio_control, py::arg("chan") = 0) // RX methods .def("set_rx_subdev_spec" , &multi_usrp::set_rx_subdev_spec, py::arg("spec"), py::arg("mboard") = ALL_MBOARDS) diff --git a/host/lib/usrp/multi_usrp_rfnoc.cpp b/host/lib/usrp/multi_usrp_rfnoc.cpp index e35121994..4554f4e57 100644 --- a/host/lib/usrp/multi_usrp_rfnoc.cpp +++ b/host/lib/usrp/multi_usrp_rfnoc.cpp @@ -933,6 +933,11 @@ public: return nullptr; } + uhd::rfnoc::radio_control& get_radio_control(const size_t chan = 0) + { + return *_get_rx_chan(chan).radio; + } + /******************************************************************* * RX methods ******************************************************************/ diff --git a/host/tests/devtest/multi_usrp_test.py b/host/tests/devtest/multi_usrp_test.py index 4b9d6b6e2..7d78349de 100755 --- a/host/tests/devtest/multi_usrp_test.py +++ b/host/tests/devtest/multi_usrp_test.py @@ -588,6 +588,7 @@ def run_api_test(usrp): 'get_tx_dboard_iface', 'get_rx_dboard_iface', 'set_time_unknown_pps', + 'get_radio_control', ] success = True -- cgit v1.2.3