diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-04-27 15:27:13 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-04-30 14:36:29 -0700 |
commit | 546aa04355ff34924ce1d00fd003cb0ee63c8cf9 (patch) | |
tree | 7922390d41b4dbc90c1bd71f763b42e05ca85b44 /mpm/include | |
parent | 4e2fd551ad48e1ee13d2b7a203f624dd828c2c3b (diff) | |
download | uhd-546aa04355ff34924ce1d00fd003cb0ee63c8cf9.tar.gz uhd-546aa04355ff34924ce1d00fd003cb0ee63c8cf9.tar.bz2 uhd-546aa04355ff34924ce1d00fd003cb0ee63c8cf9.zip |
mpm: replace long execution function with async call
- Replace mykonos finish_initialization with async version
- Replace myknonos setup_cal with async version
- Remove disable_timeout on rpc_server init()
Diffstat (limited to 'mpm/include')
-rw-r--r-- | mpm/include/mpm/ad937x/ad937x_ctrl.hpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp index c7a31e92a..762bd2e0e 100644 --- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp +++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp @@ -20,6 +20,7 @@ #include <functional> #include <set> #include <mutex> +#include <future> namespace mpm { namespace chips { @@ -84,6 +85,10 @@ public: static const uint32_t DEFAULT_TRACKING_CALS_MASKS; static const uint32_t DEFAULT_INIT_CALS_TIMEOUT; + // Async call handles + std::future<void> handle_finish_initialization; + std::future<void> handle_setup_cal; + /*! \brief make a new AD9371 ctrl object using the specified SPI iface * * \param spi_mutex a mutex that will be locked whenever the SPI iface is to be used @@ -299,10 +304,48 @@ void export_mykonos(){ bp::class_<ad937x_ctrl, boost::noncopyable, std::shared_ptr<ad937x_ctrl>>("ad937x_ctrl", bp::no_init) .def("set_master_clock_rate", &ad937x_ctrl::set_master_clock_rate) .def("begin_initialization", &ad937x_ctrl::begin_initialization) - .def("finish_initialization", &ad937x_ctrl::finish_initialization) + .def("async__finish_initialization", +[]( + ad937x_ctrl& self + ){ + self.handle_finish_initialization = std::async(std::launch::async, + &ad937x_ctrl::finish_initialization, + &self + ); + }) + .def("await__finish_initialization", +[]( + ad937x_ctrl& self + )->bool{ + if (self.handle_finish_initialization.wait_for(std::chrono::seconds(0)) == std::future_status::ready){ + self.handle_finish_initialization.get(); + return true; + } + return false; + }) .def("set_lo_source", &ad937x_ctrl::set_lo_source) .def("get_lo_source", &ad937x_ctrl::get_lo_source) - .def("setup_cal", &ad937x_ctrl::setup_cal) + .def("async__setup_cal", +[]( + ad937x_ctrl& self, + const uint32_t init_cals_mask, + const uint32_t timeout, + const uint32_t tracking_cals_mask + ){ + self.handle_setup_cal = std::async(std::launch::async, + &ad937x_ctrl::setup_cal, + &self, + init_cals_mask, + timeout, + tracking_cals_mask + ); + }) + .def("await__setup_cal", +[]( + ad937x_ctrl& self + )->bool{ + if (self.handle_setup_cal.wait_for(std::chrono::seconds(0)) == std::future_status::ready){ + self.handle_setup_cal.get(); + return true; + } + return false; + }) .def("start_jesd_rx", &ad937x_ctrl::start_jesd_rx) .def("start_jesd_tx", &ad937x_ctrl::start_jesd_tx) .def("start_radio", &ad937x_ctrl::start_radio) |