diff options
author | Josh Blum | 2011-11-03 18:13:39 -0700 |
---|---|---|
committer | Josh Blum | 2011-11-03 18:13:39 -0700 |
commit | 6532f8bdaaf9f35ffd1a7b8701ef09f0fcc21758 (patch) | |
tree | bee7fe902506d28960e32a6b0566fda8147f40fb | |
parent | 640e859f564361270d8cd30d7fbff582ad228110 (diff) | |
download | gnuradio-6532f8bdaaf9f35ffd1a7b8701ef09f0fcc21758.tar.gz gnuradio-6532f8bdaaf9f35ffd1a7b8701ef09f0fcc21758.tar.bz2 gnuradio-6532f8bdaaf9f35ffd1a7b8701ef09f0fcc21758.zip |
uhd: added buffer flush when source block is stopped
This is useful for re-running the flowgraph,
and avoids the problem of old data on the next run.
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 62da83d96..a3369ade0 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -252,8 +252,27 @@ public: return true; } + void flush(void){ + const size_t nbytes = 4096; + gr_vector_void_star outputs; + std::vector<std::vector<char> > buffs(_nchan, std::vector<char>(nbytes)); + for (size_t i = 0; i < _nchan; i++){ + outputs.push_back(&buffs[i].front()); + } + while (true){ + const size_t num_samps = _dev->get_device()->recv( + outputs, nbytes/_type.size, _metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF, 0.0 + ); + if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; + } + } + bool stop(void){ _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + + this->flush(); + return true; } |