diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-21 15:14:31 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:06 -0800 |
commit | 96a2061a59c913bc48f50ba89471519809c7629a (patch) | |
tree | 88ff592862fb6c93a4dd0ae51a5dc8a249868ab8 /host/lib | |
parent | 048ad8fe27edd565cc56e6dcf093792689162f23 (diff) | |
download | uhd-96a2061a59c913bc48f50ba89471519809c7629a.tar.gz uhd-96a2061a59c913bc48f50ba89471519809c7629a.tar.bz2 uhd-96a2061a59c913bc48f50ba89471519809c7629a.zip |
mg: ad9371: Add shortcut for RPC requests
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp | 27 | ||||
-rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.hpp | 14 |
2 files changed, 19 insertions, 22 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp index e6ad6ab57..9a91a316a 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp @@ -51,12 +51,7 @@ double magnesium_ad9371_iface::set_frequency( ) { // Note: This sets the frequency for both channels (1 and 2). auto which = _get_which(dir, chan); - UHD_LOG_TRACE(_L, - "Calling " << _rpc_prefix << "set_freq on " - << which << " with " << freq); - auto actual_freq = - _rpcc->request_with_token<double>(_rpc_prefix + "set_freq", - which, freq, false); + auto actual_freq = request<double>("set_freq", which, freq, false); UHD_LOG_TRACE(_L, _rpc_prefix << "set_freq returned " << actual_freq); return actual_freq; @@ -68,8 +63,7 @@ double magnesium_ad9371_iface::set_gain( const direction_t dir ) { auto which = _get_which(dir, chan); - UHD_LOG_TRACE(_L, "Calling " << _rpc_prefix << "set_gain on " << which << " with " << gain); - auto retval = _rpcc->request_with_token<double>(_rpc_prefix + "set_gain", which, gain); + auto retval = request<double>("set_gain", which, gain); UHD_LOG_TRACE(_L, _rpc_prefix << "set_gain returned " << retval); return retval; @@ -89,8 +83,7 @@ double magnesium_ad9371_iface::get_frequency( const direction_t dir ) { auto which = _get_which(dir, chan); - UHD_LOG_TRACE(_L, "calling " << _rpc_prefix << "get_freq on " << which); - auto retval = _rpcc->request_with_token<double>(_rpc_prefix + "get_freq", which); + auto retval = request<double>("get_freq", which); UHD_LOG_TRACE(_L, _rpc_prefix << "get_freq returned " << retval); return retval; } @@ -98,8 +91,7 @@ double magnesium_ad9371_iface::get_frequency( double magnesium_ad9371_iface::get_gain(const size_t chan, const direction_t dir) { auto which = _get_which(dir, chan); - UHD_LOG_TRACE(_L, "calling " << _rpc_prefix << "get_gain on " << which); - auto retval = _rpcc->request_with_token<double>(_rpc_prefix + "get_gain", which); + auto retval = request<double>("get_gain", which); UHD_LOG_TRACE(_L, _rpc_prefix << "get_gain returned " << retval); return retval; } @@ -117,10 +109,7 @@ std::string magnesium_ad9371_iface::set_lo_source( ) { // There is only one LO for 2 channels. Using channel 0 for 'which' auto which = _get_which(dir, 0); - UHD_LOG_TRACE(_L, "calling " << _rpc_prefix << "set_lo_source " - << which << "with " << source); - auto retval = _rpcc->request_with_token<std::string>( - _rpc_prefix + "set_lo_source", which, source); + auto retval = request<std::string>("set_lo_source", which, source); UHD_LOG_TRACE(_L, _rpc_prefix << "set_lo_source returned " << retval); return retval; } @@ -129,10 +118,8 @@ std::string magnesium_ad9371_iface::get_lo_source( const uhd::direction_t dir ) { // There is only one LO for 2 channels. Using channel 0 for 'which' - auto which = _get_which(dir,0); - UHD_LOG_TRACE(_L, "calling " << _rpc_prefix << "get_lo_source " << which); - auto retval = _rpcc->request_with_token<std::string>( - _rpc_prefix + "get_lo_source", which); + auto which = _get_which(dir, 0); + auto retval = request<std::string>("get_lo_source", which); UHD_LOG_TRACE(_L, _rpc_prefix << "get_lo_source returned " << retval); return retval; } diff --git a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.hpp b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.hpp index 5598b2540..7d7942a46 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.hpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.hpp @@ -65,6 +65,18 @@ public: ); private: + /*! Shorthand to perform an RPC request. Saves some typing. + */ + template <typename return_type, typename... Args> + return_type request(std::string const& func_name, Args&&... args) + { + UHD_LOG_TRACE(_L, "[RPC] Calling " << func_name); + return _rpcc->request_with_token<return_type>( + _rpc_prefix + func_name, + std::forward<Args>(args)... + ); + }; + //! Reference to the RPC client uhd::rpc_client::sptr _rpcc; @@ -77,8 +89,6 @@ private: //! Logger prefix const std::string _L; - - }; #endif /* INCLUDED_LIBUHD_RFNOC_MAGNESIUM_AD9371_IFACE_HPP */ |