[Top][All Lists]

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

Re: [Discuss-gnuradio] USRP Sampling

From: Eric Blossom
Subject: Re: [Discuss-gnuradio] USRP Sampling
Date: Wed, 30 Mar 2005 14:43:06 -0800
User-agent: Mutt/1.5.6i

On Wed, Mar 30, 2005 at 03:15:38PM -0700, address@hidden wrote:
> I have the following program to capture USRP samples and write them to a 
> file.  What is a simple way to have the program capture for X number of 
> samples and then stop?
> Thanks


Use gr.head(...) to get the "head of the stream" and gr.run() instead of 



from gnuradio import gr
from gnuradio import audio
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser

def build_graph (IF_freq, filename, nsamples=0):

    fg = gr.flow_graph ()

    # 256K sample rate
    adc_rate = 64e6
    decim = 16
    mux = 0xf0f0f0f0

    src = usrp.source_c (0, decim, 1, mux)
    src.set_rx_freq (0, -IF_freq)
    src.set_pga (0, 20)
    dst = gr.file_sink (gr.sizeof_gr_complex, filename)

    if nsamples > 0:
        head = gr.head(gr.sizeof_gr_complex, nsamples)
        fg.connect(src, head, dst)
        fg.connect (src, dst)

    return fg

def main ():
    samples = 256000
    fg = build_graph (10.7e6, "if_sample_4m_complex.dat", samples)

if __name__ == '__main__':
    main ()

reply via email to

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