#!/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, gru, gr_unittest, usrp import rad import os import types def pick_subdevice(u): """ The user didn't specify a subdevice on the command line. If there's a daughterboard on A, select A. If there's a daughterboard on B, select B. Otherwise, select A. """ if u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem return (0, 0) if u.db[1][0].dbid() >= 0: return (1, 0) return (0, 0) class qa_lee (gr_unittest.TestCase): def setUp (self): self.fg = gr.flow_graph () def tearDown (self): self.fg = None def test_002_rad (self): use_usrp = True ifile = '../../../dat/test.dat' ofile = '../../../dat/output.dat' if_freq = 100e3; rf_freq = 2400.0e6 rx_decim = 16 if use_usrp: u_src = usrp.source_c(decim_rate=rx_decim) rx_subdev_spec = pick_subdevice(u_src) u_src.set_mux(usrp.determine_rx_mux_value(u_src, rx_subdev_spec)) subdev = usrp.selected_subdev(u_src, rx_subdev_spec) g = subdev.gain_range() gain = float(g[0]+g[1])/2 subdev.set_gain(gain) tune = u_src.tune(0, subdev, rf_freq) tx_interp = 32 if use_usrp: u_snk = usrp.sink_c(interp_rate=tx_interp) u_snk.set_tx_freq(0, if_freq) (success,actual_freq)=usrp.selected_subdev(u_snk, (0,0)).set_freq( rf_freq) if not success: print "Failed on Tx. RF frequency ", rf_freq print "Tx. RF Frequency: %s" % rf_freq D = 20000 src = rad.wvfm_source_c( ifile, 1332, D); dst = rad.wvfm_sink_c( ofile, src, 0, 0, 39) fg = gr.flow_graph () if use_usrp: fg.connect ( src, u_snk) fg.connect ( u_src, dst) else: fg.connect ( src, dst); fg.run() return if __name__ == '__main__': gr_unittest.main ()