uhd: flush initial receive samples
Occasionally, the E100 will have errant timestamps at start related to previous sessions. Early packets will be thrown out anyways, so do this explicitly so the timestamps don't royally fuck up the sample timing. Signed-off-by: Thomas Tsou <ttsou@vt.edu> git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2635 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
parent
965e757c53
commit
33f748f265
|
@ -200,6 +200,7 @@ private:
|
|||
TIMESTAMP ts_offset;
|
||||
smpl_buf *rx_smpl_buf;
|
||||
|
||||
bool flush_recv(size_t num_pkts);
|
||||
std::string str_code(uhd::rx_metadata_t metadata);
|
||||
std::string str_code(uhd::async_metadata_t metadata);
|
||||
|
||||
|
@ -323,6 +324,27 @@ bool uhd_device::open()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool uhd_device::flush_recv(size_t num_pkts)
|
||||
{
|
||||
uhd::rx_metadata_t metadata;
|
||||
size_t num_smpls;
|
||||
uint32_t buff[rx_spp];
|
||||
|
||||
for (size_t i = 0; i < num_pkts; i++) {
|
||||
num_smpls = usrp_dev->get_device()->recv(
|
||||
buff,
|
||||
rx_spp,
|
||||
metadata,
|
||||
uhd::io_type_t::COMPLEX_INT16,
|
||||
uhd::device::RECV_MODE_ONE_PACKET);
|
||||
|
||||
if (!num_smpls)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool uhd_device::start()
|
||||
{
|
||||
LOG(INFO) << "Starting USRP...";
|
||||
|
@ -345,6 +367,10 @@ bool uhd_device::start()
|
|||
if (!skip_rx)
|
||||
usrp_dev->issue_stream_cmd(cmd);
|
||||
|
||||
// Flush out any early garbage
|
||||
if (!flush_recv(20))
|
||||
return false;
|
||||
|
||||
// Display usrp time
|
||||
double time_now = usrp_dev->get_time_now().get_real_secs();
|
||||
LOG(INFO) << "The current time is " << time_now << " seconds";
|
||||
|
|
Loading…
Reference in New Issue