discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Overrun when there shouldn't be


From: Chris Stankevitz
Subject: [Discuss-gnuradio] Overrun when there shouldn't be
Date: Mon, 09 Feb 2009 19:07:56 -0800
User-agent: Thunderbird 2.0.0.19 (X11/20090202)

Hi,

I wrote a c++ program that grabs data from the USRP in an infinite loop
and does nothing with it.  It overruns.  Can anyone help me figure out why?

This runs on a 2.4GHz computer that isn't doing anything else.  I'm
sampling the A and B channel of a BasicRX at 4MHz with shorts.  CPU runs
about 15%.  I've tried many different values for NumBytes.  Profile
results show nothing abnormal.  This is driving me nuts!

Thank you,

Chris

#include <usrp_standard.h>
#include <iostream>

using namespace std;

static const unsigned DecimRate = 16;

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int main(int argc, char** argv)
{

  static const int UsrpNumber = 0;

  const unsigned Format = usrp_standard_rx::make_format(
    16,   // width across usb
    0,    // shift
    true, // want Q
    false // bypass halfband
    );

  usrp_standard_rx* rx = usrp_standard_rx::make(UsrpNumber, DecimRate);

  static const int Mux = 0x33221100;

  rx->set_decim_rate(DecimRate);

  static const double DdcFreq = -12000e3;

  static const int NumChannels = 2;

  rx->set_nchannels(NumChannels);

  for(int i = 0; i < NumChannels; ++i)
  {
    rx->set_rx_freq(i, DdcFreq);
  }

  rx->set_mux(Mux);
  rx->set_pga(0, 0);
  rx->set_pga(1, 0);

  rx->set_format(Format);

  static const unsigned NumBytes = 4096;

  char* Buffer = new char[NumBytes];

  rx->start();

  bool Overrun = false;

  // Throw away first 32kB of data because it's fouled up
  // with some kind of sinc
  int NumTossed = 0;
  while(NumTossed < 32768)
  {
    NumTossed +=  rx->read(Buffer, NumBytes, &Overrun);
  }

  while(true)
  {
    rx->read(Buffer, NumBytes, &Overrun);

    if(Overrun)
    {
      Overrun = false;
      cerr << "Overrun\n";
    }

    //std::cout.write(Buffer, NumBytes);
  }

  rx->stop();

  delete [] Buffer;

  return 0;
}




reply via email to

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