aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2014-03-27 13:52:58 -0400
committerThomas Tsou <tom@tsou.cc>2014-03-27 13:57:18 -0400
commitc283916e418a46ad60dfa3eb40eff1654df90043 (patch)
treea3f7520392925074bca1ab276ae5f977a826227a
parentcecfb2e8f97af26fe307bee8f70682dbc3208fc3 (diff)
Transceiver52M: Allow startup delay for stream alignment
UHD requires a small amount of time to align multiple streams at startup. Delay the startup by 100 ms relative to the queried device time (actual delay inclusive of control latencies will be less). The following error is only relevant to dual-channel UHD devices (e.g. Fairwaves UmTRX and Ettus B210). UHD Error: The receive packet handler failed to time-align packets. 1002 received packets were processed by the handler. However, a timestamp match could not be determined. Signed-off-by: Thomas Tsou <tom@tsou.cc>
-rw-r--r--Transceiver52M/UHDDevice.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 875fe47..a15e5f1 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -263,7 +263,7 @@ public:
int open(const std::string &args, bool extref);
bool start();
bool stop();
- void restart(uhd::time_spec_t ts);
+ void restart();
void setPriority(float prio);
enum TxWindowType getWindowType() { return tx_window; }
@@ -737,12 +737,18 @@ bool uhd_device::flush_recv(size_t num_pkts)
return true;
}
-void uhd_device::restart(uhd::time_spec_t)
+void uhd_device::restart()
{
+ /* Allow 100 ms delay to align multi-channel streams */
+ double delay = 0.1;
+
aligned = false;
+ uhd::time_spec_t current = usrp_dev->get_time_now();
+
uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
- cmd.stream_now = true;
+ cmd.stream_now = false;
+ cmd.time_spec = uhd::time_spec_t(current.get_real_secs() + delay);
usrp_dev->issue_stream_cmd(cmd);
@@ -765,7 +771,7 @@ bool uhd_device::start()
async_event_thrd.start((void * (*)(void*))async_event_loop, (void*)this);
// Start streaming
- restart(uhd::time_spec_t(0.0));
+ restart();
// Display usrp time
double time_now = usrp_dev->get_time_now().get_real_secs();
@@ -886,7 +892,7 @@ int uhd_device::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
LOG(ALERT) << "UHD: Unrecoverable error, exiting...";
exit(-1);
case ERROR_TIMING:
- restart(prev_ts);
+ restart();
case ERROR_UNHANDLED:
continue;
}