From 227fe34217e5430f78c6b679ba215b68a6a5c1a0 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 8 May 2019 13:13:32 -0700 Subject: 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. --- mpm/include/mpm/ad937x/ad937x_ctrl.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mpm/include') 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 handle_finish_initialization; std::future handle_setup_cal; + std::future 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) -- cgit v1.2.3