[USRP-users] Blocking behavior of send() and recv() and keeping timing

Chris Evans chris.evans at azuresummit.com
Wed Apr 29 11:29:20 EDT 2015


All,

I am streaming data on a USRP B210. One channel TX, one channel RX -- each
running in their own threads. Something like this:

void runTXLoop(uhd::tx_streamer::sptr tx_stream, uhd::tx_metadata_t tx_md,
uint64_t& sharedCounter)
{
    while (1) {

        // Signal processing and filling tx_buff

        tx_stream->send(tx_buff, 2000, tx_md);
        tx_md.start_of_burst = false;
        tx_md.has_time_spec = false;

        std::cout << "TX loop incrementing counter to: " << sharedCounter++
<< std::endl;
    }
}

void runRXLoop(uhd::rx_streamer::sptr rx_stream, uhd::rx_metadata_t rx_md,
uint64_t& sharedCounter)
{
    while (1) {

        rx_stream->recv(rx_buff, 2000, rx_md);

        // Signal processing on contents of rx_buff

        std::cout << "RX loop sees: " << sharedCounter << std::endl;
    }
}


Becuase transmit and receive are working with the same number of samples
per buffer and because the streams are running at the same sample rate, I
would expect for each loop through runTXLoop's while(), there would be
exactly one loop through runRXLoop's while(). Instead, I see an output
along the lines of...

TX loop incrementing counter to: 0
TX loop incrementing counter to: 1
TX loop incrementing counter to: 2

...

TX loop incrementing counter to: 32
TX loop incrementing counter to: 33
RX loop sees: 34
TX loop incrementing counter to: 34
RX loop sees: 35
TX loop incrementing counter to: 35
RX loop sees: 36
TX loop incrementing counter to: 36
RX loop sees: 37
TX loop incrementing counter to: 37
RX loop sees: 38
TX loop incrementing counter to: 38
RX loop sees: 39
TX loop incrementing counter to: 39
RX loop sees: 40
TX loop incrementing counter to: 40
TX loop incrementing counter to: 41
TX loop incrementing counter to: 42
TX loop incrementing counter to: 43
TX loop incrementing counter to: 44
TX loop incrementing counter to: 45
TX loop incrementing counter to: 46
TX loop incrementing counter to: 47
TX loop incrementing counter to: 48
TX loop incrementing counter to: 49
RX loop sees: 50
TX loop incrementing counter to: 50
TX loop incrementing counter to: 51

...

TX loop incrementing counter to: 71
TX loop incrementing counter to: 72
RX loop sees: 73
TX loop incrementing counter to: 73

In other words, the TX loop appears to start before the RX loop up until
sharedCounter is 33, then the expected behavior of alternating print outs,
and then an unexpected behavior of many tx loops per rx loop.

Is it reasonable to use the blocking behavior of send() and recv() to keep
a shared notion of timing between the two threads?

Thanks

-- 
Chris Evans
Systems Engineer
Azure Summit Technology, Inc.
3050 Chain Bridge Road, Suite 600
Fairfax, VA 22030
919-428-6243 (cell)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20150429/0a884325/attachment-0002.html>


More information about the USRP-users mailing list