2 # Copyright 2005,2006 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 from gnuradio import gr, gru, blks
23 from gnuradio import usrp
26 from pick_bitrate import pick_tx_bitrate
28 # /////////////////////////////////////////////////////////////////////////////
30 # /////////////////////////////////////////////////////////////////////////////
32 class transmit_path(gr.hier_block):
33 def __init__(self, fg, mod_class, tx_subdev_spec,
34 bitrate, interp, spb, gain,
37 self.normal_gain = gain
39 self.u = usrp.sink_c (fusb_block_size=options.fusb_block_size,
40 fusb_nblocks=options.fusb_nblocks)
41 dac_rate = self.u.dac_rate();
44 print mod_class.bits_per_baud()
45 (self._bitrate, self._spb, self._interp) = \
46 pick_tx_bitrate(bitrate, mod_class.bits_per_baud(), spb, interp, dac_rate)
48 self.u.set_interp_rate(self._interp)
50 # determine the daughterboard subdevice we're using
51 if tx_subdev_spec is None:
52 tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
53 self.u.set_mux(usrp.determine_tx_mux_value(self.u, tx_subdev_spec))
54 self.subdev = usrp.selected_subdev(self.u, tx_subdev_spec)
55 print "Using TX d'board %s" % (self.subdev.side_and_name(),)
58 self.packet_transmitter = \
60 mod_class(fg, spb=self._spb, **mod_kwargs),
65 self.amp = gr.multiply_const_cc (self.normal_gain)
67 fg.connect(self.packet_transmitter, self.amp, self.u)
68 gr.hier_block.__init__(self, fg, None, None)
70 self.set_gain(self.subdev.gain_range()[1]) # set max Tx gain
71 self.set_auto_tr(True) # enable Auto Transmit/Receive switching
73 def set_freq(self, target_freq):
75 Set the center frequency we're interested in.
77 @param target_freq: frequency in Hz
80 Tuning is a two step process. First we ask the front-end to
81 tune as close to the desired frequency as it can. Then we use
82 the result of that operation and our target_frequency to
83 determine the value for the digital up converter.
85 r = self.u.tune(self.subdev._which, self.subdev, target_freq)
91 def set_gain(self, gain):
93 self.subdev.set_gain(gain)
95 def set_auto_tr(self, enable):
96 return self.subdev.set_auto_tr(enable)
98 def send_pkt(self, payload='', eof=False):
99 return self.packet_transmitter.send_pkt(payload, eof)