#!/usr/bin/env python # # Copyright 2004 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # from gnuradio import gr from gnuradio import usrp from gnuradio.eng_option import eng_option import sys def build_graph (filename, IF_freq, decim_rate, sample_count): fg = gr.flow_graph () # 256K sample rate adc_rate = 64e6 decim = decim_rate 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) head = gr.head(gr.sizeof_gr_complex, sample_count) fg.connect(src, head, dst) return fg def main (args): nargs = len (args) if nargs == 4: filename = args[0] IF_freq_hz = float (args[1]) * 1e6 decim_rate = int (args[2]) samples = int(float(args[3]) * 64e6 / float(decim_rate)) else: sys.stderr.write ("usage: capture_to_file file_name IF_freq_MHz decim_rate duration_seconds\n") sys.exit (1) print "Capturing ", samples, " samples" fg = build_graph (filename, IF_freq_hz, decim_rate, samples) fg.run() if __name__ == '__main__': main (sys.argv[1:])