uhd: remove device time read during alignment
Recent UHD firmware for the USRP2/N210 replaces the MicroBlaze with a slower ZPU in addition to changes to the control transactions. The effect is less predictable reading of the current time and Tx/Rx sample mis-alignment following underruns. After an underrun, this patch drops potentially stale packets with a fixed interval instead of relying on reading the current time from the device. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
This commit is contained in:
parent
753118031e
commit
5ed92311dc
|
@ -39,17 +39,11 @@
|
||||||
transmit timestamps. This value corrects for delays on
|
transmit timestamps. This value corrects for delays on
|
||||||
on the RF side of the timestamping point of the device.
|
on the RF side of the timestamping point of the device.
|
||||||
|
|
||||||
txDelayThreshold - During transmit alignment, the send packet must arrive
|
|
||||||
on the device before the current device time. This is
|
|
||||||
the minimum difference between current device time read
|
|
||||||
from the device and the time on the transmit packet.
|
|
||||||
|
|
||||||
sampleBufSize - The receive sample buffer size in bytes.
|
sampleBufSize - The receive sample buffer size in bytes.
|
||||||
*/
|
*/
|
||||||
const bool enableExternalRef = false;
|
const bool enableExternalRef = false;
|
||||||
const double masterClockRate = 100.0e6;
|
const double masterClockRate = 100.0e6;
|
||||||
const double rxTimingOffset = .00005;
|
const double rxTimingOffset = .00005;
|
||||||
const double txDelayThreshold = 0.0040;
|
|
||||||
const size_t sampleBufSize = (1 << 20);
|
const size_t sampleBufSize = (1 << 20);
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +169,8 @@ private:
|
||||||
bool aligned;
|
bool aligned;
|
||||||
bool skipRx;
|
bool skipRx;
|
||||||
|
|
||||||
|
size_t dropCount;
|
||||||
|
|
||||||
TIMESTAMP timestampOffset;
|
TIMESTAMP timestampOffset;
|
||||||
SampleBuffer *recvBuffer;
|
SampleBuffer *recvBuffer;
|
||||||
|
|
||||||
|
@ -197,7 +193,8 @@ void *AsyncEventServiceLoopAdapter(UHDDevice *dev)
|
||||||
|
|
||||||
UHDDevice::UHDDevice(double desiredSampleRate, bool skipRx)
|
UHDDevice::UHDDevice(double desiredSampleRate, bool skipRx)
|
||||||
: actualSampleRate(0), sendSamplesPerPacket(0), recvSamplesPerPacket(0),
|
: actualSampleRate(0), sendSamplesPerPacket(0), recvSamplesPerPacket(0),
|
||||||
started(false), aligned(false), timestampOffset(0), recvBuffer(NULL)
|
started(false), aligned(true), timestampOffset(0), recvBuffer(NULL),
|
||||||
|
dropCount(0)
|
||||||
{
|
{
|
||||||
this->desiredSampleRate = desiredSampleRate;
|
this->desiredSampleRate = desiredSampleRate;
|
||||||
this->skipRx = skipRx;
|
this->skipRx = skipRx;
|
||||||
|
@ -407,17 +404,17 @@ int UHDDevice::writeSamples(short *buf, int len, bool *underrun,
|
||||||
metadata.time_spec =
|
metadata.time_spec =
|
||||||
SampleBuffer::convertTime(timestamp, actualSampleRate);
|
SampleBuffer::convertTime(timestamp, actualSampleRate);
|
||||||
|
|
||||||
|
// Drop a fixed number of packets (magic value)
|
||||||
if (!aligned) {
|
if (!aligned) {
|
||||||
uhd::time_spec_t now = usrpDevice->get_time_now();
|
dropCount++;
|
||||||
uhd::time_spec_t diff = metadata.time_spec - now;
|
if (dropCount < 30) {
|
||||||
|
|
||||||
if (diff.get_real_secs() < txDelayThreshold) {
|
|
||||||
LOG(DEBUG) << "Realigning transmitter";
|
LOG(DEBUG) << "Realigning transmitter";
|
||||||
*underrun = true;
|
*underrun = true;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned = true;
|
aligned = true;
|
||||||
|
dropCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t samplesSent = usrpDevice->get_device()->send(buf,
|
size_t samplesSent = usrpDevice->get_device()->send(buf,
|
||||||
|
|
Reference in New Issue