discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] C++ interface to USRP


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] C++ interface to USRP
Date: Sat, 21 Jun 2008 11:25:23 -0700
User-agent: Mutt/1.5.17 (2007-11-01)

On Sat, Jun 21, 2008 at 11:48:33AM -0400, Sebastiaan Heunis wrote:
> Hi
> 
> Can anyone please help me?  I want to use the C++ interface in order
> to use the Qwt C++ library to create contour plots, etc.
> UsrpFAQ/CppInterface has some code illustrating how to do this.  I
> just have a few questions concerning this.  I'm sorry, but my
> understanding of sampling is not what it is supposed to be.  In the
> code samples per read needs to be a multiple of 128.  So if I'm
> sampling at 500 000 samples per second in the USRP, I can only read in
> 499968 samples into the C++ program?  Is the rest just discarded and
> if I read again, do I read in 499968 samples of the next time sampling
> time?  I would ideally like to sample at 500000.  Can I set the USRP
> to this, read in more than 500000 samples and just discard the rest?
> 
> Thank you very much.
> Sebastiaan

Sebastian,

With regard to your question about sampling rate, if you set the
decimation to 128, the USRP will deliver complex baseband samples at
64M / 128 = 500K complex samples / second.  Completely independent of
that, you should be issuing reads that are a multiple of 512 bytes.
The raw data you'll be receiving will be little-endian 16-bit I & Q.
That is, I0, Q0, I1, Q1, ... 

from usrp_basic.h:

  /*!
   * \brief read data from the D/A's via the FPGA.
   * \p len must be a multiple of 512 bytes.
   *
   * \returns the number of bytes read, or -1 on error.
   *
   * If overrun is non-NULL it will be set true iff an RX overrun is detected.
   */
  int read (void *buf, int len, bool *overrun);


If you try to read all 500K samples in one call, you'll probably see
overruns since there's not enough buffering to hold that amount.  Try
reading in smaller increment such as 64KB.  

I think you'd be better off if you just used usrp_rx_cfile.py as
described in my reply to your earlier posting.  You could use popen(3)
from within your C++ program and read the samples with fread and avoid
all these low level concerns.  You'd be done already ;)

Eric




reply via email to

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