[USRP-users] managing variable processing load on stream

dave d.des at sbcglobal.net
Sat Feb 25 10:50:10 EST 2012


I am currently doing a fixed amount of processing on blocks of about a
million samples at a time and it's keeping up fine.  I'd like to
introduce some signal-dependent processing, though, and need to figure
out a way to gracefully handle cases where the processing doesn't keep
up with the stream.  The program would look for interesting things and
send snippets for further analysis.  

------------
:

    //create a receive streamer
    uhd::stream_args_t stream_args("fc32"); //complex floats
    uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);

    //allocate recv buffer and metatdata
    uhd::rx_metadata_t md;
    std::vector<std::complex<float> > buff(num_bins);
    usrp->issue_stream_cmd(
     uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);


    while(!done) {
        //read a buffer's worth of samples every iteration
        size_t num_rx_samps = rx_stream->recv(
            &buff.front(), buff.size(), md
        );
        if (num_rx_samps != buff.size()) continue;
        // sift through data and spawn snippet analysis threads
    }
    usrp->issue_stream_cmd(
     uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
:
------------------------

Continuity is more important than completeness, so I need the program to
sense that it's getting behind and kill off or at least stop spawning
low-priority analysis tasks before an overrun occurs.  I thought about
putting in a timer to measure how long the program sits waiting for the
next incoming block as a crude processing load measure, but that
wouldn't really fix the problem in the event of a sudden batch of
spawned snippet processing.

I'm assuming that behind the scenes is some sort of interrupt routine
filling a FIFO buffer on the pc side and that rx_stream->recv() pulls
from that buffer when it's called.  I guess I really want to watch that
buffer capacity and set the promiscuity of the analysis tasks
appropriately.  Any ideas or examples?






More information about the USRP-users mailing list