discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] MIMO cable and timestamps (raw ethernet)


From: Marc Epard
Subject: Re: [Discuss-gnuradio] MIMO cable and timestamps (raw ethernet)
Date: Wed, 25 Aug 2010 16:41:14 -0500

Oops. The code got cut off.  Here's the full routine.  -Marc

bool operator()(const uint32_t *items, size_t numItems, const usrp2::rx_metadata *metadata)
{
    if (_numFrames == 0)
    {
        // The expected time prediction for the second frame is always off by 19 ticks,
        // suggesting that the first frame is messed up somehow. 
        // As a work-around, we just ignore the first frame as if it never happened.
        ++_numFrames;
        return true;
    }
    
    if (_numFrames == 1)
        _startingSampleClock32 = metadata->timestamp;
    else
    {
        if (metadata->timestamp != _expectedSampleClock32)
        {
            ++_numTimeErrors;
            fprintf (stdout, "Time error in frame %llu. Off by %d ticks.\n", _numFrames, metadata->timestamp - _expectedSampleClock32);
        }
    }
    ++_numFrames;
    _expectedSampleClock32 = metadata->timestamp + numItems*_decimation;
    
    size_t  numRemaining = _buffer.size() - _numSamples;
    size_t  numToCopy = std::min(numItems, numRemaining);

    memcpy(&_buffer[_numSamples], items, numToCopy*sizeof(_buffer[0]));
    _numSamples += numToCopy;

    if (_numSamples == _buffer.size())
    {
        _endingSampleClock32 = metadata->timestamp + numToCopy*_decimation;
        return false;
    }
    return true;
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]