aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/include
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-05-08 13:13:32 -0700
committerMartin Braun <martin.braun@ettus.com>2019-08-22 10:35:13 -0700
commit227fe34217e5430f78c6b679ba215b68a6a5c1a0 (patch)
tree073d4d233b025ddaf1cf00b775919eb871ac1760 /mpm/include
parent78f453f8b59b2c4995e2aab584f3022715a2caaf (diff)
downloaduhd-227fe34217e5430f78c6b679ba215b68a6a5c1a0.tar.gz
uhd-227fe34217e5430f78c6b679ba215b68a6a5c1a0.tar.bz2
uhd-227fe34217e5430f78c6b679ba215b68a6a5c1a0.zip
n3xx: mg: Make set_freq() call asynchronous
This does not change the MPM/UHD API, but it makes the set_freq() call asynchronous on the MPM side. The upside is that it will release the GIL if the set_freq() call takes too long, e.g., because of MPM calibrations.
Diffstat (limited to 'mpm/include')
-rw-r--r--mpm/include/mpm/ad937x/ad937x_ctrl.hpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
index 6d28eccd1..cb4d0e060 100644
--- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
@@ -85,6 +85,7 @@ public:
// Async call handles
std::future<void> handle_finish_initialization;
std::future<void> handle_setup_cal;
+ std::future<double> handle_set_freq;
/*! \brief make a new AD9371 ctrl object using the specified SPI iface
*
@@ -344,6 +345,30 @@ void export_mykonos(py::module& top_module)
.def("set_clock_rate", &ad937x_ctrl::set_clock_rate)
.def("enable_channel", &ad937x_ctrl::enable_channel)
.def("set_freq", &ad937x_ctrl::set_freq)
+ .def("async__set_freq", +[](
+ ad937x_ctrl& self,
+ const std::string &which,
+ const double value,
+ const bool wait_for_lock
+ ){
+ self.handle_set_freq = std::async(std::launch::async,
+ &ad937x_ctrl::set_freq,
+ &self,
+ which,
+ value,
+ wait_for_lock
+ );
+ })
+ .def("await__set_freq", +[](
+ ad937x_ctrl& self
+ )->bool{
+ if (self.handle_set_freq.wait_for(std::chrono::seconds(0))
+ == std::future_status::ready){
+ self.handle_set_freq.get();
+ return true;
+ }
+ return false;
+ })
.def("get_freq", &ad937x_ctrl::get_freq)
.def("get_lo_locked", &ad937x_ctrl::get_lo_locked)
.def("set_fir", &ad937x_ctrl::set_fir)