diff options
author | kurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-11-26 03:17:28 +0000 |
---|---|---|
committer | kurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597> | 2011-11-26 03:17:28 +0000 |
commit | 68292106afb1bb7ad741becf70642ebd021fbc30 (patch) | |
tree | e21ec96b13aa34d6f59895900fad3656d968601f /Transceiver52M | |
parent | c7cb817cb18a3c281021e975b5a44cfcdf851386 (diff) |
uhd: rework handling of timestamp errors
On a lapses of time monotonicity (and possibly other errors),
stop and restart the receive streaming with a buffer flush
in between. This is a cleaner replacement to the previous
clock reset with that didn't attempt to stop steaming.
Signed-off-by: Thomas Tsou <ttsou@vt.edu>
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2647 19bc5d8c-e614-43d4-8b26-e1612bc8e597
Diffstat (limited to 'Transceiver52M')
-rw-r--r-- | Transceiver52M/UHDDevice.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index b41d49e..f0d43f6 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -141,6 +141,7 @@ public: bool open(); bool start(); bool stop(); + void restart(uhd::time_spec_t ts); void setPriority(); int readSamples(short *buf, int len, bool *overrun, @@ -205,7 +206,6 @@ private: void init_gains(); void set_ref_clk(bool ext_clk); - void reset_clk(uhd::time_spec_t ts); double set_rates(double rate); bool flush_recv(size_t num_pkts); @@ -387,13 +387,19 @@ bool uhd_device::flush_recv(size_t num_pkts) return true; } -void uhd_device::reset_clk(uhd::time_spec_t ts) +void uhd_device::restart(uhd::time_spec_t ts) { - double time; + uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS; + usrp_dev->issue_stream_cmd(cmd); - usrp_dev->set_time_now(uhd::time_spec_t(ts)); - time = usrp_dev->get_time_now().get_real_secs(); - LOG(INFO) << "Reset USRP clock to " << time << " seconds"; + flush_recv(50); + + usrp_dev->set_time_now(ts); + aligned = false; + + cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS; + cmd.stream_now = true; + usrp_dev->issue_stream_cmd(cmd); } bool uhd_device::start() @@ -515,7 +521,7 @@ int uhd_device::readSamples(short *buf, int len, bool *overrun, // Other metadata timing checks if (check_rx_md_err(metadata, prev_ts) < 0) { - reset_clk(prev_ts); + restart(prev_ts); return 0; } |