aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp24
-rw-r--r--host/lib/usrp/usrp2/usrp2_fifo_ctrl.hpp7
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp5
3 files changed, 33 insertions, 3 deletions
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