1 # Copyright 2009 Free Software Foundation, Inc.
3 # This file is part of GNU Radio
5 # GNU Radio is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
10 # GNU Radio is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Radio; see the file COPYING. If not, write to
17 # the Free Software Foundation, Inc., 51 Franklin Street,
18 # Boston, MA 02110-1301, USA.
22 from gnuradio import gr, usrp
24 ####################################################################
26 ####################################################################
27 class _simple_source(gr.hier_block2):
28 """A single usrp source of IO type short or complex."""
30 def __init__(self, number, side='A', rx_ant='RXA'):
32 USRP simple source contructor.
33 @param number the unit number
34 @param side the usrp side A or B
35 @param rx_ant the antenna choice
37 #initialize hier2 block
38 gr.hier_block2.__init__(
39 self, 'usrp_simple_source',
40 gr.io_signature(0, 0, 0),
41 gr.io_signature(1, 1, self._get_io_size()),
44 self._u = self._get_usrp_constructor()(number, nchan=1)
45 subdev_spec = common.to_spec(side, rx_ant)
46 self._u.set_mux(usrp.determine_rx_mux_value(self._u, subdev_spec))
47 self._subdev = usrp.selected_subdev(self._u, subdev_spec)
48 if common.is_flex(rx_ant): self._subdev.select_rx_antenna(rx_ant)
50 self.connect(self._u, self)
52 def set_decim_rate(self, decim): self._u.set_decim_rate(int(decim))
53 def set_frequency(self, frequency, verbose=False):
61 def set_gain(self, gain): self._subdev.set_gain(gain)
62 def set_auto_tr(self, auto_tr): self._subdev.set_auto_tr(auto_tr)
64 class simple_source_c(_simple_source, common.usrp_source_c): pass
65 class simple_source_s(_simple_source, common.usrp_source_s): pass
67 ####################################################################
69 ####################################################################
70 class _simple_sink(gr.hier_block2):
71 """A single usrp sink of IO type short or complex."""
73 def __init__(self, number, side='A'):
75 USRP simple sink contructor.
76 @param number the unit number
77 @param side the usrp side A or B
79 #initialize hier2 block
80 gr.hier_block2.__init__(
81 self, 'usrp_simple_sink',
82 gr.io_signature(1, 1, self._get_io_size()),
83 gr.io_signature(0, 0, 0),
86 self._u = self._get_usrp_constructor()(number, nchan=1)
87 subdev_spec = common.to_spec(side)
88 self._u.set_mux(usrp.determine_tx_mux_value(self._u, subdev_spec))
89 self._subdev = usrp.selected_subdev(self._u, subdev_spec)
91 self.connect(self, self._u)
93 def set_interp_rate(self, interp): self._u.set_interp_rate(int(interp))
94 def set_frequency(self, frequency, verbose=False):
97 which=self._subdev.which(),
102 def set_gain(self, gain): self._subdev.set_gain(gain)
103 def set_enable(self, enable): self._subdev.set_enable(enable)
104 def set_auto_tr(self, auto_tr): self._subdev.set_auto_tr(auto_tr)
106 class simple_sink_c(_simple_sink, common.usrp_sink_c): pass
107 class simple_sink_s(_simple_sink, common.usrp_sink_s): pass