diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-04-13 15:33:03 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-04-13 15:33:03 -0700 |
commit | 2790b51f3072b5ad5e3a5c4921a84f460096f92d (patch) | |
tree | c91809e9b289bbcb62c156d0f1af9f66c01d3f8c /host | |
parent | 068de67366777322a7a132c4739bee9889c2bf19 (diff) | |
parent | fae9468c3a2c00c4390a50679b5ae176c5f9a2a5 (diff) | |
download | uhd-2790b51f3072b5ad5e3a5c4921a84f460096f92d.tar.gz uhd-2790b51f3072b5ad5e3a5c4921a84f460096f92d.tar.bz2 uhd-2790b51f3072b5ad5e3a5c4921a84f460096f92d.zip |
Merge branch 'maint'
Diffstat (limited to 'host')
-rw-r--r-- | host/examples/test_clock_synch.cpp | 33 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/block_ctrl_base.hpp | 3 | ||||
-rw-r--r-- | host/lib/rfnoc/block_ctrl_base.cpp | 5 | ||||
-rw-r--r-- | host/lib/rfnoc/ddc_block_ctrl_impl.cpp | 9 | ||||
-rw-r--r-- | host/lib/rfnoc/duc_block_ctrl_impl.cpp | 9 | ||||
-rw-r--r-- | host/lib/rfnoc/radio_ctrl_impl.cpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_radio_ctrl_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_radio_ctrl_impl.hpp | 1 |
9 files changed, 37 insertions, 30 deletions
diff --git a/host/examples/test_clock_synch.cpp b/host/examples/test_clock_synch.cpp index 8774c0c00..b1af6790b 100644 --- a/host/examples/test_clock_synch.cpp +++ b/host/examples/test_clock_synch.cpp @@ -34,29 +34,8 @@ namespace po = boost::program_options; using namespace uhd::usrp_clock; using namespace uhd::usrp; -void wait_for_pps(multi_usrp::sptr usrp, size_t chan, double timeout){ - time_t last_pps_time = usrp->get_time_last_pps(chan).get_full_secs(); - time_t system_time = uhd::time_spec_t::get_system_time().get_full_secs(); - time_t exit_time = system_time + time_t(timeout); - bool detected_pps = false; - - //Otherwise, this would hang if the USRP doesn't detect any PPS - while(uhd::time_spec_t::get_system_time().get_full_secs() < exit_time){ - time_t time_now = usrp->get_time_last_pps(chan).get_full_secs(); - if(last_pps_time < time_now){ - detected_pps = true; - break; - } - else last_pps_time = time_now; - } - if(not detected_pps) throw uhd::runtime_error(str(boost::format("%s did not detect a PPS signal.") - % usrp->get_usrp_tx_info()["mboard_serial"])); - -} - -void get_usrp_time(multi_usrp::sptr usrp, size_t chan, std::vector<time_t> *times){ - wait_for_pps(usrp, chan, 2); - (*times)[chan] = usrp->get_time_now(chan).get_full_secs(); +void get_usrp_time(multi_usrp::sptr usrp, size_t mboard, std::vector<time_t> *times){ + (*times)[mboard] = usrp->get_time_now(mboard).get_full_secs(); } int UHD_SAFE_MAIN(int argc, char *argv[]){ @@ -125,14 +104,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //Get GPS time to initially set USRP devices std::cout << std::endl << "Querying Clock for time and setting USRP times..." << std::endl << std::endl; time_t clock_time = clock->get_time(); - usrp->set_time_unknown_pps(uhd::time_spec_t(double(clock_time+2))); - - //Wait for next PPS to start polling - wait_for_pps(usrp, 0, 2); - + usrp->set_time_next_pps(uhd::time_spec_t(double(clock_time+1))); srand((unsigned int)time(NULL)); - std::cout << boost::format("\nRunning %d comparisons at random intervals.") % num_tests << std::endl << std::endl; + std::cout << boost::format("Running %d comparisons at random intervals.") % num_tests << std::endl; uint32_t num_matches = 0; for(size_t i = 0; i < num_tests; i++){ //Wait random time before querying diff --git a/host/include/uhd/rfnoc/block_ctrl_base.hpp b/host/include/uhd/rfnoc/block_ctrl_base.hpp index 778ded043..87d9b3a71 100644 --- a/host/include/uhd/rfnoc/block_ctrl_base.hpp +++ b/host/include/uhd/rfnoc/block_ctrl_base.hpp @@ -379,6 +379,9 @@ protected: // than reset register SR_CLEAR_TX_FC. virtual void _clear(const size_t port = 0); + //! Override this function if your block needs to specially handle + // setting the command time + virtual void _set_command_time(const time_spec_t &time_spec, const size_t port = ANY_PORT); /*********************************************************************** * Protected members **********************************************************************/ diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp index efd723fcb..e9d6c0030 100644 --- a/host/lib/rfnoc/block_ctrl_base.cpp +++ b/host/lib/rfnoc/block_ctrl_base.cpp @@ -354,6 +354,7 @@ void block_ctrl_base::set_command_time( } iface_sptr->set_time(time_spec); + _set_command_time(time_spec, port); } time_spec_t block_ctrl_base::get_command_time( @@ -581,4 +582,8 @@ void block_ctrl_base::_clear(const size_t port) sr_write(SR_CLEAR_RX_FC, 0x00C1EA12, port); // 'CLEAR', but we can write anything, really } +void block_ctrl_base::_set_command_time(const time_spec_t & /*time_spec*/, const size_t /*port*/) +{ + UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::_set_command_time() "; +} // vim: sw=4 et: diff --git a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp index 830664e5c..b0b510cde 100644 --- a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp @@ -130,6 +130,15 @@ public: } } } + + // Wait, what? If this seems out of place to you, you're right. However, + // we need a function call that is called when the graph is complete, + // but streaming is not yet set up. + if (_tree->exists("tick_rate")) { + const double tick_rate = _tree->access<double>("tick_rate").get(); + set_command_tick_rate(tick_rate, port); + } + if (not (_rx_streamer_active.count(port) and _rx_streamer_active.at(port))) { return RATE_UNDEFINED; } diff --git a/host/lib/rfnoc/duc_block_ctrl_impl.cpp b/host/lib/rfnoc/duc_block_ctrl_impl.cpp index 07279ed47..d0742a6d0 100644 --- a/host/lib/rfnoc/duc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/duc_block_ctrl_impl.cpp @@ -113,6 +113,15 @@ public: double get_input_samp_rate(size_t port=ANY_PORT) { port = (port == ANY_PORT) ? 0 : port; + + // Wait, what? If this seems out of place to you, you're right. However, + // we need a function call that is called when the graph is complete, + // but streaming is not yet set up. + if (_tree->exists("tick_rate")) { + const double tick_rate = _tree->access<double>("tick_rate").get(); + set_command_tick_rate(tick_rate, port); + } + if (not (_tx_streamer_active.count(port) and _tx_streamer_active.at(port))) { return RATE_UNDEFINED; } diff --git a/host/lib/rfnoc/radio_ctrl_impl.cpp b/host/lib/rfnoc/radio_ctrl_impl.cpp index 1caa9bb99..5504efbb0 100644 --- a/host/lib/rfnoc/radio_ctrl_impl.cpp +++ b/host/lib/rfnoc/radio_ctrl_impl.cpp @@ -161,6 +161,7 @@ double radio_ctrl_impl::set_rate(double rate) _tick_rate = rate; _time64->set_tick_rate(_tick_rate); _time64->self_test(); + set_command_tick_rate(rate); return _tick_rate; } diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 1abbb9b0c..7c1963f85 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1444,7 +1444,7 @@ public: if (gain_range_width == 0.0) { return 0.0; } - double norm_gain = (get_rx_gain(ALL_GAINS, chan) - gain_range.start()) / gain_range_width; + double norm_gain = (get_tx_gain(ALL_GAINS, chan) - gain_range.start()) / gain_range_width; // Avoid rounding errors: if (norm_gain > 1.0) return 1.0; if (norm_gain < 0.0) return 0.0; diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp index 8692871b8..655385fd7 100644 --- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp +++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp @@ -1106,6 +1106,10 @@ void x300_radio_ctrl_impl::_set_db_eeprom(i2c_iface::sptr i2c, const size_t addr _db_eeproms[addr] = db_eeprom; } +void x300_radio_ctrl_impl::_set_command_time(const time_spec_t &spec, const size_t port) +{ + set_fe_cmd_time(spec, port); +} /**************************************************************************** * Helpers ***************************************************************************/ diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp index 27633fa9a..4340bcc4f 100644 --- a/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp +++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp @@ -176,6 +176,7 @@ private: void set_rx_fe_corrections(const uhd::fs_path &db_path, const uhd::fs_path &rx_fe_corr_path, const double lo_freq); void set_tx_fe_corrections(const uhd::fs_path &db_path, const uhd::fs_path &tx_fe_corr_path, const double lo_freq); + void _set_command_time(const uhd::time_spec_t &spec, const size_t port); void set_fe_cmd_time(const time_spec_t &time, const size_t chan); private: // members |