On Wed, Mar 30, 2005 at 03:15:38PM -0700, [EMAIL PROTECTED] 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
Yes. Use gr.head(...) to get the "head of the stream" and gr.run() instead of start()/stop(). Eric ---------------------------------------------------------------- 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) else: fg.connect (src, dst) return fg def main (): samples = 256000 fg = build_graph (10.7e6, "if_sample_4m_complex.dat", samples) fg.run() if __name__ == '__main__': main () _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnuradio