diff options
author | Josh Blum <josh@joshknows.com> | 2012-03-01 18:35:12 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2012-03-23 14:36:56 -0700 |
commit | b1d82758b0e98ab10c5ca2e65eed1ae90afd8d62 (patch) | |
tree | 8785ecaf8598c839fe15096f9dfad35f2eb11dd6 /host/lib | |
parent | f59ef44a43d0d16655cb67a3d0334e8cacd76f09 (diff) | |
download | uhd-b1d82758b0e98ab10c5ca2e65eed1ae90afd8d62.tar.gz uhd-b1d82758b0e98ab10c5ca2e65eed1ae90afd8d62.tar.bz2 uhd-b1d82758b0e98ab10c5ca2e65eed1ae90afd8d62.zip |
usrp2: implementation of timed commands working
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 20 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp | 24 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp | 7 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 5 |
4 files changed, 49 insertions, 7 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 42c654e6b..fd556c9f8 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -356,12 +356,24 @@ public: return true; } - void set_command_time(const time_spec_t &, size_t){ - throw uhd::not_implemented_error("Not implemented yet, but we have a very good idea of how to do it."); + void set_command_time(const time_spec_t &time_spec, size_t mboard){ + if (mboard != ALL_MBOARDS){ + _tree->access<time_spec_t>(mb_root(mboard) / "time/cmd").set(time_spec); + return; + } + for (size_t m = 0; m < get_num_mboards(); m++){ + set_command_time(time_spec, m); + } } - void clear_command_time(size_t){ - throw uhd::not_implemented_error("Not implemented yet, but we have a very good idea of how to do it."); + void clear_command_time(size_t mboard){ + if (mboard != ALL_MBOARDS){ + _tree->access<time_spec_t>(mb_root(mboard) / "time/cmd").set(time_spec_t(0.0)); + return; + } + for (size_t m = 0; m < get_num_mboards(); m++){ + clear_command_time(m); + } } void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan){ diff --git a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp index e19e7d5e7..e761e3d91 100644 --- a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp +++ b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp @@ -28,7 +28,8 @@ using namespace uhd::transport; static const size_t POKE32_CMD = (1 << 8); static const size_t PEEK32_CMD = 0; static const double ACK_TIMEOUT = 0.5; -static const boost::uint32_t MAX_SEQS_OUT = 16; +static const double MASSIVE_TIMEOUT = 10.0; //for when we wait on a timed command +static const boost::uint32_t MAX_SEQS_OUT = 64; class usrp2_fifo_ctrl_impl : public usrp2_fifo_ctrl{ public: @@ -38,6 +39,8 @@ public: _seq(0), _last_seq_ack(0) { while (_xport->get_recv_buff(0.0)){} //flush + this->set_time(uhd::time_spec_t(0.0)); + this->set_tick_rate(1.0); //something possible but bogus } UHD_INLINE void send_pkt(wb_addr_type addr, boost::uint32_t data, int cmd){ @@ -55,12 +58,13 @@ public: packet_info.num_payload_words32 = 2; packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(boost::uint32_t); packet_info.packet_count = _seq; + packet_info.tsf = _time.to_ticks(_tick_rate); packet_info.sob = false; packet_info.eob = false; packet_info.has_sid = false; packet_info.has_cid = false; packet_info.has_tsi = false; - packet_info.has_tsf = false; + packet_info.has_tsf = _use_time; packet_info.has_tlr = false; //load header @@ -94,7 +98,7 @@ public: boost::uint32_t wait_for_ack(const boost::int16_t seq_to_ack){ while (_last_seq_ack < seq_to_ack){ - managed_recv_buffer::sptr buff = _xport->get_recv_buff(ACK_TIMEOUT); + managed_recv_buffer::sptr buff = _xport->get_recv_buff(_use_time? MASSIVE_TIMEOUT : ACK_TIMEOUT); if (not buff){ throw uhd::runtime_error("fifo ctrl timed out looking for acks"); } @@ -119,11 +123,25 @@ public: throw uhd::not_implemented_error("peek16 not implemented in fifo ctrl module"); } + void set_time(const uhd::time_spec_t &time){ + boost::mutex::scoped_lock lock(_mutex); + _time = time; + _use_time = _time != uhd::time_spec_t(0.0); + } + + void set_tick_rate(const double rate){ + boost::mutex::scoped_lock lock(_mutex); + _tick_rate = rate; + } + private: zero_copy_if::sptr _xport; boost::mutex _mutex; boost::uint32_t _seq; boost::uint16_t _last_seq_ack; + uhd::time_spec_t _time; + bool _use_time; + double _tick_rate; }; diff --git a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp index 8cdfb11a2..0f52f523e 100644 --- a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp +++ b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp @@ -18,6 +18,7 @@ #ifndef INCLUDED_USRP2_FIFO_CTRL_HPP #define INCLUDED_USRP2_FIFO_CTRL_HPP +#include <uhd/types/time_spec.hpp> #include <uhd/transport/zero_copy.hpp> #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> @@ -34,6 +35,12 @@ public: //! Make a new FIFO control object static sptr make(uhd::transport::zero_copy_if::sptr xport); + + //! Set the command time that will activate + virtual void set_time(const uhd::time_spec_t &time) = 0; + + //! Set the tick rate (converting time into ticks) + virtual void set_tick_rate(const double rate) = 0; }; #endif /* INCLUDED_USRP2_FIFO_CTRL_HPP */ diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 59cf65828..68ee8044c 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -579,6 +579,11 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ .subscribe(boost::bind(&usrp2_impl::update_clock_source, this, mb, _1)); static const std::vector<std::string> clock_sources = boost::assign::list_of("internal")("external")("mimo"); _tree->create<std::vector<std::string> >(mb_path / "clock_source/options").set(clock_sources); + //plug timed commands into tree here + _tree->create<time_spec_t>(mb_path / "time/cmd") + .subscribe(boost::bind(&usrp2_fifo_ctrl::set_time, _mbc[mb].fifo_ctrl, _1)); + _tree->access<double>(mb_path / "tick_rate") + .subscribe(boost::bind(&usrp2_fifo_ctrl::set_tick_rate, _mbc[mb].fifo_ctrl, _1)); //////////////////////////////////////////////////////////////////// // create user-defined control objects |