Hi,
I am a newbie with GNURADIO and USRP. I am trying to capture data that
comes
thru the USB cable from the USRP board and transmit it back to the USRP
board. I was reading thru the email archives and I came across this:
To log data from the USRP: usrp.source_c -> gr.file_sink(complex)
To replay data to the USRP: gr.file_source(complex) -> usrp.sink_c
and some more information like use the usrp_rx_cfile.py to capture data
from
the USRP. I am facing a problem in implementing ‘gr.file_source(complex)
->
usrp.sink_c’.
output.dat in the code is the binary file that I got from running
usrp_rx_cfile.py with option ‘s’ and ‘f’. I am using the usrp.source_s
and
usrp.sink_s instead of usrp.source_c and usrp.sink_c. The code
implementing
the above is:
============================================================
class my_graph(gr.flow_graph):
def __init__(self):
gr.flow_graph.__init__(self)
usage="%prog: [options] output_filename"
parser = OptionParser(option_class=eng_option, usage=usage)
parser.add_option("-R", "--tx-subdev-spec", type="subdev",
default=(0, 0),
help=“select USRP Tx side A or B (default=A)”)
parser.add_option("-i", “–interp”, type=“intx”, default=16,
help=“set fgpa interpolation rate to INTERP
[default=%default]”)
parser.add_option("-f", “–freq”, type=“eng_float”,
default=None,
help=“set frequency to FREQ”, metavar=“FREQ”)
parser.add_option("-g", “–gain”, type=“eng_float”,
default=None,
help=“set gain in dB (default is midpoint)”)
(options, args) = parser.parse_args ()
if options.freq is None:
parser.print_help()
sys.stderr.write('You must specify the frequency with -f
FREQ\n’);
raise SystemExit, 1
# build the graph
self.u = usrp.sink_s(interp_rate=options.interp)
self.dst = gr.file_source(gr.sizeof_short, 'output.dat')
self.connect(self.dst, self.u)
dac_rate= self.u.dac_rate();
if options.tx_subdev_spec is None:
options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
self.u.set_mux(usrp.determine_tx_mux_value(self.u,
options.tx_subdev_spec))
# determine the daughterboard subdevice we're using
self.subdev = usrp.selected_subdev(self.u,
options.tx_subdev_spec)
print “Using TX d’board %s” % (self.subdev.side_and_name(),)
if options.gain is None:
# if no gain was specified, use the mid-point in dB
g = self.subdev.gain_range()
options.gain = float(g[0]+g[1])/2
self.subdev.set_gain(options.gain)
r = self.u.tune(0, self.subdev, options.freq)
if not r:
sys.stderr.write('Failed to set frequency\n')
raise SystemExit, 1
if name == ‘main’:
try:
my_graph().run()
except KeyboardInterrupt:
pass
and when I run it, I see the following:
…/python/usrp# ./txIQ.py -f 2.4G
Using TX d’board A: Flex 2400 Tx MIMO B
…/python/usrp#
…/python/usrp#
The script runs for a second or two and stops immediately.
The email archives are very useful but still I am not able to implement
what
I want. Looking for some help. I really appreciate any help and thanks
for
the email responses in the archive.
– Eliane