summaryrefslogtreecommitdiff
path: root/gr-msdd6000/src/python-examples
diff options
context:
space:
mode:
Diffstat (limited to 'gr-msdd6000/src/python-examples')
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_dynamics.py99
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_fft.py277
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_rcv.py287
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_rs_spec_an.py350
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_spectrum_sense.py296
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py306
-rwxr-xr-xgr-msdd6000/src/python-examples/new_msdd_fft.py299
-rwxr-xr-xgr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py184
-rwxr-xr-xgr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py268
-rw-r--r--gr-msdd6000/src/python-examples/ofdm/receive_path.py102
-rw-r--r--gr-msdd6000/src/python-examples/playback_samples.m12
-rw-r--r--gr-msdd6000/src/python-examples/read_complex_binary.m48
12 files changed, 0 insertions, 2528 deletions
diff --git a/gr-msdd6000/src/python-examples/msdd_dynamics.py b/gr-msdd6000/src/python-examples/msdd_dynamics.py
deleted file mode 100755
index 8cd1e52bc..000000000
--- a/gr-msdd6000/src/python-examples/msdd_dynamics.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2008 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-from gnuradio import msdd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import time
-
-class benchmark_msdd6000(gr.top_block):
- def __init__(self, address, options):
- gr.top_block.__init__(self)
-
- # Extract the initial options
- self.frequency = options.frequency
- self.filename = options.filename
- self.decim = options.decim
- self.gain = options.gain
- self.address = address
-
- # Set up and initialize the MSDD receiver
- self.port = 10001 # required port
- self.src = msdd.source_c(0, 1, self.address, self.port)
- self.src.set_decim_rate(self.decim)
- self.src.set_desired_packet_size(0, 1460)
- self.src.set_pga(0, self.gain)
- self.src.set_rx_freq(0, self.frequency)
-
- # Display some info
- print "Min PGA: ", self.src.pga_min()
- print "Max PGA: ", self.src.pga_max()
- print "PGA: ", self.src.pga(0)
- print "Decim: ", self.src.decim_rate()
- print "Freq: ", self.src.rx_freq(0)
-
- # Build a file sink to save the info for post analysis
- self.snk = gr.file_sink(gr.sizeof_gr_complex, self.filename)
-
- # Connect the reciever source to file sink
- self.connect(self.src, self.snk)
-
-def main():
- ''' This is a simple little script to play with retunning of the MSDD board.
- You can cycle through frequencies or the attenuation of the board here.
- '''
-
- usage="%prog: [options] host_address"
- parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve")
- parser.add_option("-f", "--frequency", type="eng_float", default=100e6,
- help="set frequency (Hz) [default=%default]")
- parser.add_option("-d", "--decim", type="int", default=256,
- help="set decimation rate [default=%default]")
- parser.add_option("-g", "--gain", type="int", default=32,
- help="set receiver gain (dB) [default=%default]")
- parser.add_option("-F", "--filename", type="string", default="output.dat",
- help="set output filename [default=%default]")
- (options, args) = parser.parse_args ()
- host_address = args[0]
-
- # Set up benchmark system that simply connects the MSDD source to a file sink
- tb = benchmark_msdd6000(host_address, options)
- tb.start() # start it here
-
- # Adjust your parameters here. Use the time.sleep(x) function to set a wait period
- # between adjusting the parameter.
- for i in range(7):
- time.sleep(0.5)
- if 0:
- freq = (tb.src.rx_freq(0) + 1) * 1e6
- tb.src.set_rx_freq(0, freq)
- print "Setting frequency: ", freq
- if 1:
- pga = tb.src.pga(0)+10
- tb.src.set_pga(0, pga)
- print "Setting PGA: ", pga
-
- tb.stop() # stop the radio
-
-if __name__ == '__main__':
- main()
diff --git a/gr-msdd6000/src/python-examples/msdd_fft.py b/gr-msdd6000/src/python-examples/msdd_fft.py
deleted file mode 100755
index 813a77d38..000000000
--- a/gr-msdd6000/src/python-examples/msdd_fft.py
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2004,2005,2007 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru
-from gnuradio import msdd
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider
-from optparse import OptionParser
-import wx
-import sys
-
-
-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 app_top_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.panel = panel
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-w", "--which", type="int", default=0,
- help="select which MSDD (0, 1, ...) default is %default",
- metavar="NUM")
- parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
- help="select MSDD Rx side A or B (default=first one with a daughterboard)")
- parser.add_option("-A", "--antenna", default=None,
- help="select Rx Antenna (only on RFX-series boards)")
- parser.add_option("-d", "--decim", type="int", default=16,
- help="set fgpa decimation rate to DECIM [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)")
- parser.add_option("-W", "--waterfall", action="store_true", default=False,
- help="Enable waterfall display")
- parser.add_option("-8", "--width-8", action="store_true", default=False,
- help="Enable 8-bit samples across USB")
- parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
- help="Enable oscilloscope display")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.show_debug_info = True
-
- # build the graph
-
- #self.u = MSDD.source_simo(which=options.which, decim_rate=options.decim)
- self.u = msdd.source_simple("192.168.1.200", 0)
- self.u.set_decim_rate(options.decim) #(16)
-
-# msdd_src = gr.file_source(gr.sizeof_gr_complex, 'msdd.dat')
-# thr = gr.throttle(gr.sizeof_gr_complex, 200000)
-# self.connect(msdd_src, thr)
-
-# if options.rx_subdev_spec is None:
-# options.rx_subdev_spec = pick_subdevice(self.u)
-# self.u.set_mux(MSDD.determine_rx_mux_value(self.u, options.rx_subdev_spec))
-
-# if options.width_8:
-# width = 8
-# shift = 8
-# format = self.u.make_format(width, shift)
-# print "format =", hex(format)
-# r = self.u.set_format(format)
-# print "set_format =", r
-
- # determine the daughterboard subdevice we're using
-# self.subdev = MSDD.selected_subdev(self.u, options.rx_subdev_spec)
-
-# print "Initial Freq", self.u.rx_freq(0), "deci: ", self.u.decim_rate()
-# input_rate = 50e6 / self.u.decim_rate()
- input_rate = 50e6 / options.decim;
-
- if options.waterfall:
- self.scope = \
- waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
- elif options.oscilloscope:
- self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
- else:
- self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate)
-
-# self.connect(self.u, self.scope)
-
- msdd_sink = gr.file_sink(gr.sizeof_gr_complex, 'schmen1.dat')
-
- self.conv = gr.interleaved_short_to_complex();
- self.connect(self.u, self.conv, msdd_sink)
- self._build_gui(vbox)
-
- # set initial values
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- #g = self.subdev.gain_range()
- self.gain_range = (20,70,.5);
- options.gain = float(self.gain_range[0]+self.gain_range[1])/2
-
- if options.freq is None:
- # if no freq was specified, use the mid-point
- #r = self.subdev.freq_range()
- r = (30e6,6e9,1e6)
- options.freq = float(r[0]+r[1])/2
-
- self.set_gain(options.gain)
-#
-# if options.antenna is not None:
-# print "Selecting antenna %s" % (options.antenna,)
-# self.subdev.select_rx_antenna(options.antenna)
-
- if self.show_debug_info:
- #self.myform['decim'].set_value(self.u.decim_rate())
- self.myform['decim'].set_value(options.decim)
- # self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
- # self.myform['dbname'].set_value(self.subdev.name())
- self.myform['baseband'].set_value(0)
- self.myform['ddc'].set_value(0)
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg):
- self.frame.GetStatusBar().SetStatusText(msg, 0)
-
- def _build_gui(self, vbox):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- vbox.Add(self.scope.win, 10, wx.EXPAND)
-
- # add control area at the bottom
- self.myform = myform = form.form()
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0, 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Center freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0, 0)
- g = self.gain_range = (20,50,.5);
- myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3,
- min=int(g[0]), max=int(g[1]),
- callback=self.set_gain)
-
- hbox.Add((5,0), 0, 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- self._build_subpanel(vbox)
-
- def _build_subpanel(self, vbox_arg):
- # build a secondary information panel (sometimes hidden)
-
- # FIXME figure out how to have this be a subpanel that is always
- # created, but has its visibility controlled by foo.Show(True/False)
-
- def _form_set_decim(kv):
- return self.set_decim(kv['decim'])
-
- if not(self.show_debug_info):
- return
-
- panel = self.panel
- vbox = vbox_arg
- myform = self.myform
-
- #panel = wx.Panel(self.panel, -1)
- #vbox = wx.BoxSizer(wx.VERTICAL)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['decim'] = form.int_field(
- parent=panel, sizer=hbox, label="Decim",
- callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg))
-
-# hbox.Add((5,0), 1)
-# myform['fs@usb'] = form.static_float_field(
-# parent=panel, sizer=hbox, label="Fs@USB")
-
- hbox.Add((5,0), 1)
- myform['dbname'] = form.static_text_field(
- parent=panel, sizer=hbox)
-
- hbox.Add((5,0), 1)
- myform['baseband'] = form.static_float_field(
- parent=panel, sizer=hbox, label="Analog BB")
-
- hbox.Add((5,0), 1)
- myform['ddc'] = form.static_float_field(
- parent=panel, sizer=hbox, label="DDC")
-
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- r = self.u.set_rx_freq (0, target_freq)
- #r = self.u.tune(0, self.subdev, target_freq)
- if r:
- self.myform['freq'].set_value(target_freq) # update displayed value
-# if self.show_debug_info:
-# self.myform['baseband'].set_value(r.baseband_freq)
-# self.myform['ddc'].set_value(r.dxc_freq)
- return True
-
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- #self.subdev.set_gain(gain)
- self.u.set_pga(0, gain)
-
- def set_decim(self, decim):
- ok = self.u.set_decim_rate(decim)
- if not ok:
- print "set_decim failed"
- #input_rate = 20e6 / self.u.decim_rate()
- #self.scope.set_sample_rate(input_rate)
- if self.show_debug_info: # update displayed values
- self.myform['decim'].set_value(decim)
- #self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
- return ok
-
-def main ():
- app = stdgui2.stdapp(app_top_block, "MSDD FFT", nstatus=1)
- app.MainLoop()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-msdd6000/src/python-examples/msdd_rcv.py b/gr-msdd6000/src/python-examples/msdd_rcv.py
deleted file mode 100755
index cc2f3e4a3..000000000
--- a/gr-msdd6000/src/python-examples/msdd_rcv.py
+++ /dev/null
@@ -1,287 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2006,2007 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, eng_notation
-from gnuradio import msdd
-from gnuradio import blks2
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, form
-from gnuradio.wxgui import fftsink2
-from optparse import OptionParser
-#from usrpm import usrp_dbid
-import sys
-import math
-import wx
-
-class wfm_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
-# parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
-# help="select MSDD Rx side A or B (default=A)")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=40,
- help="set gain in dB (default is midpoint)")
-# parser.add_option("-V", "--volume", type="eng_float", default=None,
-# help="set volume (default is midpoint)")
-# parser.add_option("-O", "--audio-output", type="string", default="",
-# help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.gain_range = (10, 70, .5)
- self.state = "FREQ"
- self.freq = 0
- msdd_decim = 2
-
- # build graph
- self.fft_size = 8192
- self.sample_rate = 200
- self.u = msdd.source_c(0, 1, "10.45.4.44", 10000)
- self.u.set_decim_rate(4)
- self.u.set_desired_packet_size(0, 1460*100)
-
-
- #self.u.set_decim_rate(msdd_decim)
-# usrp_rate = adc_rate / msdd_decim # 320 kS/s
-# chanfilt_decim = 1
-# demod_rate = usrp_rate / chanfilt_decim
-# audio_decimation = 10
-# audio_rate = demod_rate / audio_decimation # 32 kHz
-#
-# if options.rx_subdev_spec is None:
-# options.rx_subdev_spec = pick_subdevice(self.u)
-#
-# self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))
-# self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)
-# print "Using RX d'board %s" % (self.subdev.side_and_name(),)
-#
-#
-# chan_filt_coeffs = optfir.low_pass (1, # gain
-# usrp_rate, # sampling rate
-# 80e3, # passband cutoff
-# 115e3, # stopband cutoff
-# 0.1, # passband ripple
-# 60) # stopband attenuation
-# #print len(chan_filt_coeffs)
-# chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs)
-#
-# self.guts = blks2.wfm_rcv (demod_rate, audio_decimation)
-#
-# self.volume_control = gr.multiply_const_ff(self.vol)
-#
-# # sound card as final sink
-# audio_sink = audio.sink (int (audio_rate),
-# options.audio_output,
-# False) # ok_to_block
-
- # now wire it all together
- #self.connect (self.u, chan_filt, self.guts, self.volume_control, audio_sink)
-
- self._build_gui(vbox)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- #g = self.subdev.gain_range()
- g = self.gain_range
- options.gain = float(g[0]+g[1])/2
-#
-# if options.volume is None:
-# g = self.volume_range()
-# options.volume = float(g[0]+g[1])/2
-#
-# if abs(options.freq) < 1e6:
-# options.freq *= 1e6
-
- # set initial values
-#
- self.set_gain(options.gain)
-# self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
- print "Frequency: ", self.u.rx_freq(0)
-
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- self.src_fft = None
- if 1:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from MSDD",
- fft_size=512, sample_rate=512)
-# self.s2f1 = gr.short_to_float()
-# self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=self.sample_rate*self.fft_size)
-
- self.connect (self.u, self.src_fft)
- #self.connect (self.s2f1, self.scope)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-#
-# if 1:
-# post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod",
-# fft_size=1024, sample_rate=usrp_rate,
-# y_per_div=10, ref_level=0)
-# self.connect (self.guts.fm_demod, post_filt_fft)
-# vbox.Add (post_filt_fft.win, 4, wx.EXPAND)
-#
-# if 0:
-# post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph",
-# fft_size=512, sample_rate=audio_rate,
-# y_per_div=10, ref_level=-20)
-# self.connect (self.guts.deemph, post_deemph_fft)
-# vbox.Add (post_deemph_fft.win, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(30e6, 6e9, 1e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-#
-# myform['volume'] = \
-# form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
-# weight=3, range=self.volume_range(),
-# callback=self.set_vol)
-# hbox.Add((5,0), 1)
-
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=self.gain_range,
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-#
-# try:
-# self.knob = powermate.powermate(self.frame)
-# self.rot = 0
-# powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
-# powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
-# except:
-# print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-#
-#
-# def set_vol (self, vol):
-# g = self.volume_range()
-# self.vol = max(g[0], min(g[1], vol))
-# self.volume_control.set_k(10**(self.vol/10))
-# self.myform['volume'].set_value(self.vol)
-# self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- r = self.u.set_rx_freq(0, target_freq);
-
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_pga(0,gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- #self.src_fft.set_baseband_freq(self.freq)
-#
-# def volume_range(self):
-# return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_block, "MSDD FFT RX")
- app.MainLoop ()
diff --git a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py
deleted file mode 100755
index 4855375b8..000000000
--- a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py
+++ /dev/null
@@ -1,350 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2009 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-from gnuradio import msdd_rs
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.qtgui import qtgui
-from optparse import OptionParser
-import sys,time
-
-try:
- from gnuradio.qtgui import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Please install gr-qtgui."
- sys.exit(1)
-
-try:
- from msdd_display_qtgui import Ui_MainWindow
-except ImportError:
- print "Error: could not find msdd_display_qtgui.py:"
- print "\t\"pyuic4 msdd_display_qtgui.ui -o msdd_display_qtgui.py\""
- sys.exit(1)
-
-
-# ////////////////////////////////////////////////////////////////////
-# Define the QT Interface and Control Dialog
-# ////////////////////////////////////////////////////////////////////
-
-
-class main_window(QtGui.QMainWindow):
- def __init__(self, snk, fg, parent=None):
-
- QtGui.QWidget.__init__(self, parent)
- self.gui = Ui_MainWindow()
- self.gui.setupUi(self)
-
- self.fg = fg
-
- # Add the qtsnk widgets to the layout box
- self.gui.sinkLayout.addWidget(snk)
-
- self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001))
-
- # Connect up some signals
- self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
- self.pauseFg)
- self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"),
- self.frequencyEditText)
- self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"),
- self.gainEditText)
- self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"),
- self.bandwidthEditText)
- self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"),
- self.amplifierEditText)
-
- self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"),
- self.saveData)
- self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save)
-
- self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"),
- self.dcGainEditText)
- self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"),
- self.dcCancelClicked)
-
- def pauseFg(self):
- if(self.gui.pauseButton.text() == "Pause"):
- self.fg.stop()
- self.fg.wait()
- self.fg.stop_data()
- self.gui.pauseButton.setText("Unpause")
- else:
- self.fg.start()
- self.fg.start_data()
- self.gui.pauseButton.setText("Pause")
-
-
- # Functions to set the values in the GUI
- def set_frequency(self, freq):
- self.freq = freq
- sfreq = eng_notation.num_to_str(self.freq)
- self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq))
-
- def set_gain(self, gain):
- self.gain = gain
- self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain))
-
- def set_bandwidth(self, bw):
- self.bw = bw
- sbw = eng_notation.num_to_str(self.bw)
- self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw))
-
- def set_amplifier(self, amp):
- self.amp = amp
- self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp))
-
-
- # Functions called when signals are triggered in the GUI
- def frequencyEditText(self):
- try:
- freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii())
- self.fg.set_frequency(freq)
- self.freq = freq
- except RuntimeError:
- pass
-
- def gainEditText(self):
- try:
- gain = float(self.gui.gainEdit.text())
- self.fg.set_gain(gain)
- self.gain = gain
- except ValueError:
- pass
-
- def bandwidthEditText(self):
- try:
- bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii())
- self.fg.set_bandwidth(bw)
- self.bw = bw
- except ValueError:
- pass
-
- def amplifierEditText(self):
- try:
- amp = float(self.gui.amplifierEdit.text())
- self.fg.set_amplifier_gain(amp)
- self.amp = amp
- except ValueError:
- pass
-
- def saveData(self):
- fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", ".");
- if(len(fileName)):
- self.fg.save_to_file(str(fileName))
-
- def dcGainEditText(self):
- gain = float(self.gui.dcGainEdit.text())
- self.fg.set_dc_gain(gain)
-
- def dcCancelClicked(self, state):
- self.dcGainEditText()
- self.fg.cancel_dc(state)
-
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-e", "--interface", type="string", default="eth0",
- help="select Ethernet interface, default is eth0")
- parser.add_option("-m", "--mac-addr", type="string", default="",
- help="select USRP by MAC address, default is auto-select")
- parser.add_option("-W", "--bw", type="float", default=1e6,
- help="set bandwidth of receiver [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default="2.4G",
- 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)")
- parser.add_option("--fft-size", type="int", default=2048,
- help="Set number of FFT bins [default=%default]")
- (options, args) = parser.parse_args()
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
- self.options = options
- self.show_debug_info = True
-
- self.qapp = QtGui.QApplication(sys.argv)
-
-# self.u = usrp2.source_32fc(options.interface, options.mac_addr)
- self.u = msdd_rs.source_simple("192.168.1.20", 10000);
- self.conv = gr.interleaved_short_to_complex();
- self._adc_rate = self.u.pull_adc_freq()
- self.set_bandwidth(options.bw)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
-# g = self.u.gain_range()
- g = [0, 10]
- #options.gain = float(g[0]+g[1])/2
- options.gain = float(0)
- self.set_gain(options.gain)
-
- if options.freq is None:
- options.freq = 2.4e9;
-# # if no frequency was specified, use the mid-point of the subdev
-# f = self.u.freq_range()
-# options.freq = float(f[0]+f[1])/2
-
- self.set_frequency(options.freq)
-
- self._fftsize = options.fft_size
-
-
- self._freq = options.freq;
- self._bandwidth = 400;
-
- self.set_bandwidth(self._bandwidth);
-
- self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS,
- self._freq, self._bandwidth,
- "USRP2 Display",
- True, True, False, True, False)
-
- # Set up internal amplifier
- self.amp = gr.multiply_const_cc(0.0)
- self.set_amplifier_gain(0.01)
-
- # Create a single-pole IIR filter to remove DC
- # but don't connect it yet
- self.dc_gain = 0.001
- self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
- self.dc_sub = gr.sub_cc()
-
- self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10);
-
- self.connect(self.u, self.conv, self.snk)
- #self.connect(self.u, self.conv, self.amp, self.snk)
-
- if self.show_debug_info:
- print "Decimation rate: ", self._decim
- print "Bandwidth: ", self._bandwidth
-# print "D'board: ", self.u.daughterboard_id()
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
-
- self.main_win = main_window(self.pysink, self)
-
- self.main_win.set_frequency(self._freq)
- self.main_win.set_gain(self._gain)
- self.main_win.set_bandwidth(self._bandwidth)
- self.main_win.set_amplifier(self._amp_value)
-
- self.main_win.show()
-
-
- def save_to_file(self, name):
- self.lock()
-
- # Add file sink to save data
- self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name)
- self.connect(self.conv, self.file_sink)
-
- self.unlock()
-
- def set_gain(self, gain):
- self._gain = gain
- self.u.set_ddc_gain(self._gain)
-
- def set_frequency(self, freq):
- self._freq = freq
- r = self.u.set_rx_freq(freq)
-
- try:
- self.snk.set_frequency_range(self._freq, self._bandwidth)
- except:
- pass
-
- def set_bandwidth(self, bw):
- self._bandwidth = bw
- self._decim = int(self._adc_rate / self._bandwidth)
-# self.u.set_decim_rate(self._decim)
- r1 = self.u.set_ddc_samp_rate( bw );
- r2 = self.u.set_ddc_bw( bw );
- self.u.start_data();
-
- print r1
- print r2;
-
- time.sleep(0.05);
- bw = self.u.pull_ddc_bw();
- sr = self.u.pull_ddc_samp_rate();
- fc = self.u.pull_rx_freq();
-
- #self.snk.d_bandwidth = sr;
-
- print bw;
- print sr;
- print fc;
-
-# sys.exit(-1);
-
- try:
- self.snk.set_frequency_range(self._freq, self._bandwidth)
- except:
- pass
-
- def set_amplifier_gain(self, amp):
- self._amp_value = amp
- self.amp.set_k(self._amp_value)
-
- def set_dc_gain(self, gain):
- self.dc.set_taps(gain)
-
- def cancel_dc(self, state):
- self.lock()
-
- if(state):
- self.disconnect(self.u, self.amp)
- self.connect(self.u, (self.dc_sub,0))
- self.connect(self.u, self.dc, (self.dc_sub,1))
- self.connect(self.dc_sub, self.amp)
- else:
- self.disconnect(self.dc_sub, self.amp)
- self.disconnect(self.dc, (self.dc_sub,1))
- self.disconnect(self.u, self.dc)
- self.disconnect(self.u, (self.dc_sub,0))
- self.connect(self.u, self.amp)
-
- self.unlock()
-
-def main ():
- tb = my_top_block()
- tb.start()
- tb.u.start_data();
- tb.snk.exec_();
-
-if __name__ == '__main__':
- try:
- main ()
- except KeyboardInterrupt:
- pass
-
diff --git a/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py b/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py
deleted file mode 100755
index e3d182b03..000000000
--- a/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py
+++ /dev/null
@@ -1,296 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2008 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, eng_notation, optfir, window
-from gnuradio import msdd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-import math
-import struct
-from pylab import *
-from numpy import array
-import time
-
-matplotlib.interactive(True)
-matplotlib.use('TkAgg')
-
-class tune(gr.feval_dd):
- """
- This class allows C++ code to callback into python.
- """
- def __init__(self, tb):
- gr.feval_dd.__init__(self)
- self.tb = tb
-
- def eval(self, ignore):
- """
- This method is called from gr.bin_statistics_f when it wants to change
- the center frequency. This method tunes the front end to the new center
- frequency, and returns the new frequency as its result.
- """
- try:
- # We use this try block so that if something goes wrong from here
- # down, at least we'll have a prayer of knowing what went wrong.
- # Without this, you get a very mysterious:
- #
- # terminate called after throwing an instance of 'Swig::DirectorMethodException'
- # Aborted
- #
- # message on stderr. Not exactly helpful ;)
-
- new_freq = self.tb.set_next_freq()
- return new_freq
-
- except Exception, e:
- print "tune: Exception: ", e
-
-
-class parse_msg(object):
- def __init__(self, sample_rate, percent, alpha=0.01):
- self.axis_font_size = 16
- self.label_font_size = 18
- self.title_font_size = 20
- self.text_size = 22
-
- self.fig = figure(1, facecolor="w", figsize=(12,9))
- self.sp = self.fig.add_subplot(1,1,1)
- self.pl = self.sp.plot(range(100), 100*[1,])
-
- params = {'backend': 'ps',
- 'xtick.labelsize': self.axis_font_size,
- 'ytick.labelsize': self.axis_font_size,
- 'text.usetex': False}
- rcParams.update(params)
-
- self.sp.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold")
- self.sp.set_xlabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold")
- self.sp.set_ylabel("Magnitude (dB)", fontsize=self.label_font_size, fontweight="bold")
- self.text_alpha = figtext(0.10, 0.94, ('Moving average alpha: %s' % alpha), weight="heavy", size=self.text_size)
-
- self.cfreqs = list()
- self.freqrange = list()
- self.data = list() #array('f')
-
- self.alpha = alpha
-
- self.index = 0
- self.full = False
- self.last_cfreq = 0
-
- self.sample_rate = sample_rate
- self.percent = (1.0-percent)/2.0
-
- def parse(self, msg):
- self.center_freq = msg.arg1()
- self.vlen = int(msg.arg2())
- assert(msg.length() == self.vlen * gr.sizeof_float)
-
-
- if(self.center_freq < self.last_cfreq):
- print "Plotting spectrum\n"
- self.full = True
-
- self.pl[0].set_data([self.freqrange, self.data])
- self.sp.set_ylim([min(self.data), max(self.data)])
- self.sp.set_xlim([min(self.freqrange), max(self.freqrange)])
- draw()
-
- self.index = 0
- del self.freqrange
- self.freqrange = list()
- #raw_input()
-
- self.last_cfreq = self.center_freq
-
- startind = int(self.percent * self.vlen)
- endind = int((1.0 - self.percent) * self.vlen)
-
- fstep = self.sample_rate / self.vlen
- f = [self.center_freq - self.sample_rate/2.0 + i*fstep for i in range(startind, endind)]
- self.freqrange += f
-
- t = msg.to_string()
- d = struct.unpack('%df' % (self.vlen,), t)
-
- if self.full:
- for i in range(startind, endind):
- self.data[self.index] = (1.0-self.alpha)*self.data[self.index] + (self.alpha)*d[i]
- self.index += 1
- else:
- self.data += [di for di in d[startind:endind]]
-
-
-class my_top_block(gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- usage = "usage: %prog [options] host min_freq max_freq"
- parser = OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS",
- help="time to delay (in seconds) after changing frequency [default=%default]")
- parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS",
- help="time to dwell (in seconds) at a given frequncy [default=%default]")
- parser.add_option("-F", "--fft-size", type="int", default=256,
- help="specify number of FFT bins [default=%default]")
- parser.add_option("-d", "--decim", type="intx", default=16,
- help="set decimation to DECIM [default=%default]")
- parser.add_option("", "--real-time", action="store_true", default=False,
- help="Attempt to enable real-time scheduling")
-
- (options, args) = parser.parse_args()
- if len(args) != 3:
- parser.print_help()
- sys.exit(1)
-
- self.address = args[0]
- self.min_freq = eng_notation.str_to_num(args[1])
- self.max_freq = eng_notation.str_to_num(args[2])
-
- self.decim = options.decim
- self.gain = options.gain
-
- if self.min_freq > self.max_freq:
- self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them
-
- self.fft_size = options.fft_size
-
- if not options.real_time:
- realtime = False
- else:
- # Attempt to enable realtime scheduling
- r = gr.enable_realtime_scheduling()
- if r == gr.RT_OK:
- realtime = True
- else:
- realtime = False
- print "Note: failed to enable realtime scheduling"
-
- adc_rate = 102.4e6
- self.int_rate = adc_rate / self.decim
- print "Sampling rate: ", self.int_rate
-
- # build graph
- self.port = 10001
- self.src = msdd.source_simple(self.address, self.port)
- self.src.set_decim_rate(self.decim)
-
- self.set_gain(self.gain)
- self.set_freq(self.min_freq)
-
- s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
-
- mywindow = window.blackmanharris(self.fft_size)
- fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
- power = 0
- for tap in mywindow:
- power += tap*tap
-
- norm = gr.multiply_const_cc(1.0/self.fft_size)
- c2mag = gr.complex_to_mag_squared(self.fft_size)
-
- # FIXME the log10 primitive is dog slow
- log = gr.nlog10_ff(10, self.fft_size,
- -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
-
- # Set the freq_step to % of the actual data throughput.
- # This allows us to discard the bins on both ends of the spectrum.
- self.percent = 0.4
-
- self.freq_step = self.percent * self.int_rate
- self.min_center_freq = self.min_freq + self.freq_step/2
- nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
- self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)
-
- self.next_freq = self.min_center_freq
-
- tune_delay = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size))) # in fft_frames
- dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames
-
- self.msgq = gr.msg_queue(16)
- self._tune_callback = tune(self) # hang on to this to keep it from being GC'd
- stats = gr.bin_statistics_f(self.fft_size, self.msgq,
- self._tune_callback, tune_delay, dwell_delay)
-
- # FIXME leave out the log10 until we speed it up
- self.connect(self.src, s2v, fft, c2mag, log, stats)
-
-
- def set_next_freq(self):
- target_freq = self.next_freq
- self.next_freq = self.next_freq + self.freq_step
- if self.next_freq >= self.max_center_freq:
- self.next_freq = self.min_center_freq
-
- if not self.set_freq(target_freq):
- print "Failed to set frequency to", target_freq
-
- return target_freq
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- """
- return self.src.set_rx_freq(0, target_freq)
-
-
- def set_gain(self, gain):
- self.src.set_pga(0, gain)
-
-
-def main_loop(tb):
- msgparser = parse_msg(tb.int_rate, tb.percent)
-
- while 1:
-
- # Get the next message sent from the C++ code (blocking call).
- # It contains the center frequency and the mag squared of the fft
- msgparser.parse(tb.msgq.delete_head())
-
- # Print center freq so we know that something is happening...
- print msgparser.center_freq
-
- # FIXME do something useful with the data...
-
- # m.data are the mag_squared of the fft output (they are in the
- # standard order. I.e., bin 0 == DC.)
- # You'll probably want to do the equivalent of "fftshift" on them
- # m.raw_data is a string that contains the binary floats.
- # You could write this as binary to a file.
-
-
-if __name__ == '__main__':
- tb = my_top_block()
- try:
- tb.start() # start executing flow graph in another thread...
- main_loop(tb)
-
- except KeyboardInterrupt:
- pass
diff --git a/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py b/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py
deleted file mode 100755
index 05f047e11..000000000
--- a/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py
+++ /dev/null
@@ -1,306 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2008 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, eng_notation, optfir, window
-from gnuradio import msdd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-import math
-import struct
-from pylab import *
-from numpy import array
-import time
-
-matplotlib.interactive(True)
-matplotlib.use('TkAgg')
-
-class tune(gr.feval_dd):
- """
- This class allows C++ code to callback into python.
- """
- def __init__(self, tb):
- gr.feval_dd.__init__(self)
- self.tb = tb
-
- def eval(self, ignore):
- """
- This method is called from gr.bin_statistics_f when it wants to change
- the center frequency. This method tunes the front end to the new center
- frequency, and returns the new frequency as its result.
- """
- try:
- # We use this try block so that if something goes wrong from here
- # down, at least we'll have a prayer of knowing what went wrong.
- # Without this, you get a very mysterious:
- #
- # terminate called after throwing an instance of 'Swig::DirectorMethodException'
- # Aborted
- #
- # message on stderr. Not exactly helpful ;)
-
- new_freq = self.tb.set_next_freq()
- return new_freq
-
- except Exception, e:
- print "tune: Exception: ", e
-
-
-class parse_msg(object):
- def __init__(self, sample_rate, percent):
- self.axis_font_size = 16
- self.label_font_size = 18
- self.title_font_size = 20
- self.text_size = 22
-
- # Set up figures and subplots
- self.fig = figure(1, facecolor="w", figsize=(12,9))
- self.sp = self.fig.add_subplot(1,1,1)
- self.pl = self.sp.matshow(100*[range(100),])
-
- params = {'xtick.labelsize': self.axis_font_size,
- 'ytick.labelsize': self.axis_font_size}
- rcParams.update(params)
-
- # Throw up some title info
- self.sp.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold")
- self.sp.set_xlabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold")
- self.sp.set_ylabel("Sample index (should be time)", fontsize=self.label_font_size, fontweight="bold")
-
- self.freqrange = list()
- self.data = list()
- self.data3 = list()
-
- self.index = 0
- self.last_cfreq = 0
-
- # So we know how to splice the data
- self.sample_rate = sample_rate
- self.percent = (1.0-percent)/2.0
-
- def parse(self, msg):
- self.center_freq = msg.arg1() # read the current center frequency
- self.vlen = int(msg.arg2()) # read the length of the data set received
-
- # wait until we wrap around before plotting the entire collected band
- if(self.center_freq < self.last_cfreq):
- #print "Plotting spectrum\n"
-
- # If we have 100 sets, start dropping the oldest
- if(len(self.data3) > 100):
- self.data3.pop(0)
- self.data3.append(self.data)
-
- # add the new data to the plot
- self.pl.set_data(self.data3)
- draw()
-
- # reset lists to collect next round
- self.index = 0
- del self.freqrange
- self.freqrange = list()
- del self.data
- self.data = list()
- #raw_input()
-
- self.last_cfreq = self.center_freq
-
- startind = int(self.percent * self.vlen)
- endind = int((1.0 - self.percent) * self.vlen)
-
- fstep = self.sample_rate / self.vlen
- f = [self.center_freq - self.sample_rate/2.0 + i*fstep for i in range(startind, endind)]
- self.freqrange += f
-
- t = msg.to_string();
-
- d = struct.unpack('%df' % (self.vlen,), t)
-
- self.data += [di for di in d[startind:endind]]
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- # Build an options parser to bring in information from the user on usage
- usage = "usage: %prog [options] host min_freq max_freq"
- parser = OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-g", "--gain", type="eng_float", default=32,
- help="set gain in dB (default is midpoint)")
- parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS",
- help="time to delay (in seconds) after changing frequency [default=%default]")
- parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS",
- help="time to dwell (in seconds) at a given frequncy [default=%default]")
- parser.add_option("-F", "--fft-size", type="int", default=256,
- help="specify number of FFT bins [default=%default]")
- parser.add_option("-d", "--decim", type="intx", default=16,
- help="set decimation to DECIM [default=%default]")
- parser.add_option("", "--real-time", action="store_true", default=False,
- help="Attempt to enable real-time scheduling")
-
- (options, args) = parser.parse_args()
- if len(args) != 3:
- parser.print_help()
- sys.exit(1)
-
- # get user-provided info on address of MSDD and frequency to sweep
- self.address = args[0]
- self.min_freq = eng_notation.str_to_num(args[1])
- self.max_freq = eng_notation.str_to_num(args[2])
-
- self.decim = options.decim
- self.gain = options.gain
-
- if self.min_freq > self.max_freq:
- self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them
-
- self.fft_size = options.fft_size
-
- if not options.real_time:
- realtime = False
- else:
- # Attempt to enable realtime scheduling
- r = gr.enable_realtime_scheduling()
- if r == gr.RT_OK:
- realtime = True
- else:
- realtime = False
- print "Note: failed to enable realtime scheduling"
-
- # Sampling rate is hardcoded and cannot be read off device
- adc_rate = 102.4e6
- self.int_rate = adc_rate / self.decim
- print "Sampling rate: ", self.int_rate
-
- # build graph
- self.port = 10001 # required port for UDP packets
-
- # which board, op mode, adx, port
-# self.src = msdd.source_c(0, 1, self.address, self.port) # build source object
-
- self.conv = gr.interleaved_short_to_complex();
-
- self.src = msdd.source_simple(self.address,self.port);
- self.src.set_decim_rate(self.decim) # set decimation rate
-# self.src.set_desired_packet_size(0, 1460) # set packet size to collect
-
- self.set_gain(self.gain) # set receiver's attenuation
- self.set_freq(self.min_freq) # set receiver's rx frequency
-
- # restructure into vector format for FFT input
- s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
-
- # set up FFT processing block
- mywindow = window.blackmanharris(self.fft_size)
- fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
- power = 0
- for tap in mywindow:
- power += tap*tap
-
- # calculate magnitude squared of output of FFT
- c2mag = gr.complex_to_mag_squared(self.fft_size)
-
- # FIXME the log10 primitive is dog slow
- log = gr.nlog10_ff(10, self.fft_size,
- -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
-
- # Set the freq_step to % of the actual data throughput.
- # This allows us to discard the bins on both ends of the spectrum.
- self.percent = 0.4
-
- # Calculate the frequency steps to use in the collection over the whole bandwidth
- self.freq_step = self.percent * self.int_rate
- self.min_center_freq = self.min_freq + self.freq_step/2
- nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
- self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)
-
- self.next_freq = self.min_center_freq
-
- # use these values to set receiver settling time between samples and sampling time
- # the default values provided seem to work well with the MSDD over 100 Mbps ethernet
- tune_delay = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size))) # in fft_frames
- dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames
-
- # set up message callback routine to get data from bin_statistics_f block
- self.msgq = gr.msg_queue(16)
- self._tune_callback = tune(self) # hang on to this to keep it from being GC'd
-
- # FIXME this block doesn't like to work with negatives because of the "d_max[i]=0" on line
- # 151 of gr_bin_statistics_f.cc file. Set this to -10000 or something to get it to work.
- stats = gr.bin_statistics_f(self.fft_size, self.msgq,
- self._tune_callback, tune_delay, dwell_delay)
-
- # FIXME there's a concern over the speed of the log calculation
- # We can probably calculate the log inside the stats block
- self.connect(self.src, self.conv, s2v, fft, c2mag, log, stats)
-
-
- def set_next_freq(self):
- ''' Find and set the next frequency of the reciver. After going past the maximum frequency,
- the frequency is wrapped around to the start again'''
- target_freq = self.next_freq
- self.next_freq = self.next_freq + self.freq_step
- if self.next_freq >= self.max_center_freq:
- self.next_freq = self.min_center_freq
-
- if not self.set_freq(target_freq):
- print "Failed to set frequency to", target_freq
-
- return target_freq
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- """
- return self.src.set_rx_freq(0, target_freq)
-
-
- def set_gain(self, gain):
- self.src.set_pga(0, gain)
-
-
-def main_loop(tb):
- # Set up parser to get data from stats block and display them.
- msgparser = parse_msg(tb.int_rate, tb.percent)
-
- while 1:
- # Get the next message sent from the C++ code (blocking call).
- # It contains the center frequency and the mag squared of the fft
- d = tb.msgq.delete_head();
- print d.to_string();
- msgparser.parse(d)
- #print msgparser.center_freq
-
-if __name__ == '__main__':
- tb = my_top_block()
- try:
- tb.start() # start executing flow graph in another thread...
- main_loop(tb)
-
- except KeyboardInterrupt:
- pass
diff --git a/gr-msdd6000/src/python-examples/new_msdd_fft.py b/gr-msdd6000/src/python-examples/new_msdd_fft.py
deleted file mode 100755
index 782ecb66e..000000000
--- a/gr-msdd6000/src/python-examples/new_msdd_fft.py
+++ /dev/null
@@ -1,299 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2004,2005,2007,2008,2010 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru
-from gnuradio import usrp
-from gnuradio import msdd
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider
-from optparse import OptionParser
-import wx
-import sys
-import numpy
-
-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.
- """
- return (0, 0)
-
-
-class app_top_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.panel = panel
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-w", "--which", type="int", default=0,
- help="select which USRP (0, 1, ...) default is %default",
- metavar="NUM")
- parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
- help="select USRP Rx side A or B (default=first one with a daughterboard)")
- parser.add_option("-A", "--antenna", default=None,
- help="select Rx Antenna (only on RFX-series boards)")
- parser.add_option("-d", "--decim", type="int", default=16,
- help="set fgpa decimation rate to DECIM [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)")
- parser.add_option("-W", "--waterfall", action="store_true", default=False,
- help="Enable waterfall display")
- parser.add_option("-8", "--width-8", action="store_true", default=False,
- help="Enable 8-bit samples across USB")
- parser.add_option( "--no-hb", action="store_true", default=False,
- help="don't use halfband filter in usrp")
- parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
- help="Enable oscilloscope display")
- parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
- help="Set fftsink averaging factor, default=[%default]")
- parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
- help="Set dBFS=0dB input value, default=[%default]")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
- self.options = options
- self.show_debug_info = True
-
- # build the graph
- if options.no_hb or (options.decim<8):
- #Min decimation of this firmware is 4.
- #contains 4 Rx paths without halfbands and 0 tx paths.
- self.fpga_filename="std_4rx_0tx.rbf"
-# self.u = usrp.source_c(which=options.which, decim_rate=options.decim, fpga_filename=self.fpga_filename)
- self.u = msdd.source_simple("192.168.1.200",0);
- else:
- #Min decimation of standard firmware is 8.
- #standard fpga firmware "std_2rxhb_2tx.rbf"
- #contains 2 Rx paths with halfband filters and 2 tx paths (the default)
- #self.u = usrp.source_c(which=options.which, decim_rate=options.decim)
- self.u = msdd.source_simple("192.168.1.200",0);
-
-
- input_rate = self.u.adc_freq() / self.u.decim_rate()
-
- if options.waterfall:
- self.scope = \
- waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
- elif options.oscilloscope:
- self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
- else:
- self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate,
- ref_scale=options.ref_scale, ref_level=0.0, y_divs = 10,
- avg_alpha=options.avg_alpha)
-
- self.conv = gr.interleaved_short_to_complex();
- self.connect(self.u, self.conv, self.scope)
-
- self._build_gui(vbox)
- self._setup_events()
-
- # set initial values
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- #g = self.subdev.gain_range()
- #g = self.u.gain_range()
- g = [0,10]
- options.gain = float(g[0]+g[1])/2
-
- if options.freq is None:
- # if no freq was specified, use the mid-point
- #r = self.subdev.freq_range()
- #r = self.u.freq_range()
- r = [30e6, 6e9]
- options.freq = float(r[0]+r[1])/2
-
- self.set_gain(options.gain)
-
- if options.antenna is not None:
- print "Selecting antenna %s" % (options.antenna,)
- self.subdev.select_rx_antenna(options.antenna)
-
- if self.show_debug_info:
- self.myform['decim'].set_value(self.u.decim_rate())
- self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
- self.myform['dbname'].set_value("no subdevs used")
- self.myform['baseband'].set_value(0)
- self.myform['ddc'].set_value(0)
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg):
- self.frame.GetStatusBar().SetStatusText(msg, 0)
-
- def _build_gui(self, vbox):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- vbox.Add(self.scope.win, 10, wx.EXPAND)
-
- # add control area at the bottom
- self.myform = myform = form.form()
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0, 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Center freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0, 0)
- #g = self.subdev.gain_range()
- #g = self.u.gain_range()
- g = [0,10]
- myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3,
- min=int(g[0]), max=int(g[1]),
- callback=self.set_gain)
-
- hbox.Add((5,0), 0, 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- self._build_subpanel(vbox)
-
- def _build_subpanel(self, vbox_arg):
- # build a secondary information panel (sometimes hidden)
-
- # FIXME figure out how to have this be a subpanel that is always
- # created, but has its visibility controlled by foo.Show(True/False)
-
- def _form_set_decim(kv):
- return self.set_decim(kv['decim'])
-
- if not(self.show_debug_info):
- return
-
- panel = self.panel
- vbox = vbox_arg
- myform = self.myform
-
- #panel = wx.Panel(self.panel, -1)
- #vbox = wx.BoxSizer(wx.VERTICAL)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['decim'] = form.int_field(
- parent=panel, sizer=hbox, label="Decim",
- callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg))
-
- hbox.Add((5,0), 1)
- myform['fs@usb'] = form.static_float_field(
- parent=panel, sizer=hbox, label="Fs@gigE")
-
- hbox.Add((5,0), 1)
- myform['dbname'] = form.static_text_field(
- parent=panel, sizer=hbox)
-
- hbox.Add((5,0), 1)
- myform['baseband'] = form.static_float_field(
- parent=panel, sizer=hbox, label="Analog BB")
-
- hbox.Add((5,0), 1)
- myform['ddc'] = form.static_float_field(
- parent=panel, sizer=hbox, label="DDC")
-
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- #r = self.u.tune(0, self.subdev, target_freq)
- r = self.u.set_rx_freq(0, target_freq)
-
- if r:
- self.myform['freq'].set_value(target_freq) # update displayed value
-# if self.show_debug_info:
-# self.myform['baseband'].set_value(r.baseband_freq)
-# self.myform['ddc'].set_value(r.dxc_freq)
- if not self.options.waterfall and not self.options.oscilloscope:
- self.scope.set_baseband_freq(target_freq)
- return True
-
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_pga(0,gain)
-
- def set_decim(self, decim):
- ok = self.u.set_decim_rate(decim)
- if not ok:
- print "set_decim failed"
- input_rate = self.u.adc_freq() / self.u.decim_rate()
- self.scope.set_sample_rate(input_rate)
- if self.show_debug_info: # update displayed values
- self.myform['decim'].set_value(self.u.decim_rate())
- self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
- return ok
-
- def _setup_events(self):
- if not self.options.waterfall and not self.options.oscilloscope:
- self.scope.win.Bind(wx.EVT_LEFT_DCLICK, self.evt_left_dclick)
-
- def evt_left_dclick(self, event):
- (ux, uy) = self.scope.win.GetXY(event)
- if event.CmdDown():
- # Re-center on maximum power
- points = self.scope.win._points
- if self.scope.win.peak_hold:
- if self.scope.win.peak_vals is not None:
- ind = numpy.argmax(self.scope.win.peak_vals)
- else:
- ind = int(points.shape()[0]/2)
- else:
- ind = numpy.argmax(points[:,1])
- (freq, pwr) = points[ind]
- target_freq = freq/self.scope.win._scale_factor
- print ind, freq, pwr
- self.set_freq(target_freq)
- else:
- # Re-center on clicked frequency
- target_freq = ux/self.scope.win._scale_factor
- self.set_freq(target_freq)
-
-
-def main ():
- app = stdgui2.stdapp(app_top_block, "USRP FFT", nstatus=1)
- app.MainLoop()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py b/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py
deleted file mode 100755
index deb82e111..000000000
--- a/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006, 2007 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, blks2
-from gnuradio import msdd
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-
-import struct, sys
-
-# from current dir
-from receive_path import receive_path
-
-class my_top_block(gr.top_block):
- def __init__(self, address, callback, options):
- gr.top_block.__init__(self)
-
- self._address = address
- self._rx_freq = options.rx_freq # receiver's center frequency
- self._rx_gain = options.rx_gain # receiver's gain
- self._decim = options.decim # Decimating rate for the USRP (prelim)
-
- if self._rx_freq is None:
- sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
- raise SystemExit
-
- # Set up USRP source
- self._setup_source()
-
- #taps = gr.firdes.low_pass(1, 1, 0.4, 0.2)
- #self.resample = gr.rational_resampler_base_ccf(5, 8, taps)
- self.resample = blks2.rational_resampler_ccf(5, 8)
-
- # Set up receive path
- self.rxpath = receive_path(callback, options)
-
- self.connect(self.src, self.resample, self.rxpath)
- #self.connect(self.src, gr.file_sink(gr.sizeof_gr_complex, "receive.dat"))
- #self.connect(self.resample, gr.file_sink(gr.sizeof_gr_complex, "resampled.dat"))
-
- def _setup_source(self):
- # build graph
- self._port = 10001
- self.src = msdd.source_c(0, 1, self._address, self._port)
- self.src.set_decim_rate(self._decim)
- self.src.set_desired_packet_size(0, 1460)
-
- self.set_gain(self._rx_gain)
- self.set_freq(self._rx_freq)
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
- """
- r = self.src.set_rx_freq(0, target_freq)
- if r:
- return True
- return False
-
- def set_gain(self, gain):
- """
- Sets the analog gain in the USRP
- """
- return self.src.set_pga(0, gain)
-
- def decim(self):
- return self._decim
-
- def add_options(normal, expert):
- """
- Adds usrp-specific options to the Options Parser
- """
- add_freq_option(normal)
- normal.add_option("", "--rx-gain", type="eng_float", default=32, metavar="GAIN",
- help="set receiver gain in dB [default=%default].")
- normal.add_option("-v", "--verbose", action="store_true", default=False)
-
- expert.add_option("", "--rx-freq", type="eng_float", default=None,
- help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
- expert.add_option("-d", "--decim", type="intx", default=128,
- help="set fpga decimation rate to DECIM [default=%default]")
- expert.add_option("", "--snr", type="eng_float", default=30,
- help="set the SNR of the channel in dB [default=%default]")
-
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
-def add_freq_option(parser):
- """
- Hackery that has the -f / --freq option set both tx_freq and rx_freq
- """
- def freq_callback(option, opt_str, value, parser):
- parser.values.rx_freq = value
- parser.values.tx_freq = value
-
- if not parser.has_option('--freq'):
- parser.add_option('-f', '--freq', type="eng_float",
- action="callback", callback=freq_callback,
- help="set Tx and/or Rx frequency to FREQ [default=%default]",
- metavar="FREQ")
-
-# /////////////////////////////////////////////////////////////////////////////
-# main
-# /////////////////////////////////////////////////////////////////////////////
-
-def main():
-
- global n_rcvd, n_right
-
- n_rcvd = 0
- n_right = 0
-
- def rx_callback(ok, payload):
- global n_rcvd, n_right
- n_rcvd += 1
- (pktno,) = struct.unpack('!H', payload[0:2])
- if ok:
- n_right += 1
- print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right)
-
- if 0:
- printlst = list()
- for x in payload[2:]:
- t = hex(ord(x)).replace('0x', '')
- if(len(t) == 1):
- t = '0' + t
- printlst.append(t)
- printable = ''.join(printlst)
-
- print printable
- print "\n"
-
- usage = "usage: %prog [options] host"
- parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve")
- expert_grp = parser.add_option_group("Expert")
- parser.add_option("","--discontinuous", action="store_true", default=False,
- help="enable discontinuous")
-
- my_top_block.add_options(parser, expert_grp)
- receive_path.add_options(parser, expert_grp)
- blks2.ofdm_mod.add_options(parser, expert_grp)
- blks2.ofdm_demod.add_options(parser, expert_grp)
-
- (options, args) = parser.parse_args ()
- address = args[0]
-
- # build the graph
- tb = my_top_block(address, rx_callback, options)
-
- #r = gr.enable_realtime_scheduling()
- #if r != gr.RT_OK:
- # print "Warning: failed to enable realtime scheduling"
-
- tb.start() # start flow graph
- tb.wait() # wait for it to finish
-
-if __name__ == '__main__':
- try:
- main()
- except KeyboardInterrupt:
- pass
diff --git a/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py b/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py
deleted file mode 100755
index 0bca41037..000000000
--- a/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2007 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import scipy, pylab, math
-import struct, sys
-from pylab import *
-from matplotlib.font_manager import fontManager, FontProperties
-from optparse import OptionParser
-from scipy import fftpack
-from math import log10
-
-matplotlib.interactive(True)
-matplotlib.use('TkAgg')
-
-class draw_constellation:
- def __init__(self, options):
- derot_file = "ofdm_frame_sink_c.dat"
- acq_file = "ofdm_frame_acq_c.dat"
- fft_file = "fft_out_c.dat"
-
- self.h_derot_file = open(derot_file, "r")
- self.h_acq_file = open(acq_file, "r")
- self.h_fft_file = open(fft_file, "r")
-
- self.occ_tones = options.occ_tones
- self.fft_size = options.fft_size
- self.symbol = options.start
- self.sample_rate = options.sample_rate
-
- self.axis_font_size = 16
- self.label_font_size = 18
- self.title_font_size = 20
- self.text_size = 22
-
- # Setup PLOT
- self.fig = figure(1, figsize=(14, 9), facecolor='w')
- rcParams['xtick.labelsize'] = self.axis_font_size
- rcParams['ytick.labelsize'] = self.axis_font_size
-
- self.text_sym = figtext(0.05, 0.95, ("Symbol: %s" % self.symbol), weight="heavy", size=self.text_size)
-
- self.make_plots()
-
- self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True)
- self.button_left = Button(self.button_left_axes, "<")
- self.button_left_callback = self.button_left.on_clicked(self.button_left_click)
-
- self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True)
- self.button_right = Button(self.button_right_axes, ">")
- self.button_right_callback = self.button_right.on_clicked(self.button_right_click)
-
- self.xlim = self.sp_eq.get_xlim()
-
- self.manager = get_current_fig_manager()
- #connect('draw_event', self.zoom)
- connect('key_press_event', self.click)
- show()
-
- def get_data(self):
- self.text_sym.set_text("Symbol: %d" % (self.symbol))
-
- derot_data = scipy.fromfile(self.h_derot_file, dtype=scipy.complex64, count=self.occ_tones)
- acq_data = scipy.fromfile(self.h_acq_file, dtype=scipy.complex64, count=self.occ_tones)
- fft_data = scipy.fromfile(self.h_fft_file, dtype=scipy.complex64, count=self.fft_size)
- if(len(acq_data) == 0):
- print "End of File"
- else:
- self.acq_data_reals = [r.real for r in acq_data]
- self.acq_data_imags = [i.imag for i in acq_data]
- self.derot_data_reals = [r.real for r in derot_data]
- self.derot_data_imags = [i.imag for i in derot_data]
-
- self.unequalized_angle = [math.atan2(x.imag, x.real) for x in fft_data]
- self.equalized_angle = [math.atan2(x.imag, x.real) for x in acq_data]
- self.derot_equalized_angle = [math.atan2(x.imag, x.real) for x in derot_data]
-
- self.time = [i*(1/self.sample_rate) for i in range(len(acq_data))]
- ffttime = [i*(1/self.sample_rate) for i in range(len(fft_data))]
-
- self.freq = self.get_freq(ffttime, self.sample_rate)
-
- for i in range(len(fft_data)):
- if(abs(fft_data[i]) == 0.0):
- fft_data[i] = complex(1e-6,1e-6)
- self.fft_data = [20*log10(abs(f)) for f in fft_data]
-
- def get_freq(self, time, sample_rate, T=1):
- N = len(time)
- Fs = 1.0 / (max(time) - min(time))
- Fn = 0.5 * sample_rate
- freq = [-Fn + i*Fs for i in range(N)]
- return freq
-
- def make_plots(self):
- self.h_acq_file.seek(8*self.symbol*self.occ_tones, 0)
- self.h_fft_file.seek(8*self.symbol*self.fft_size, 0)
- self.h_derot_file.seek(8*self.symbol*self.occ_tones, 0)
-
- self.get_data()
-
- # Subplot: constellation of rotated symbols
- self.sp_const = self.fig.add_subplot(4,1,1, position=[0.15, 0.55, 0.3, 0.35])
- self.sp_const.set_title(("Constellation"), fontsize=self.title_font_size, fontweight="bold")
- self.sp_const.set_xlabel("Inphase", fontsize=self.label_font_size, fontweight="bold")
- self.sp_const.set_ylabel("Qaudrature", fontsize=self.label_font_size, fontweight="bold")
- self.plot_const = plot(self.acq_data_reals, self.acq_data_imags, 'bo')
- self.plot_const += plot(self.derot_data_reals, self.derot_data_imags, 'ro')
- self.sp_const.axis([-2, 2, -2, 2])
-
- # Subplot: unequalized angle
- self.sp_uneq = self.fig.add_subplot(4,2,1, position=[0.575, 0.55, 0.3, 0.35])
- self.sp_uneq.set_title(("Unequalized Angle"), fontsize=self.title_font_size, fontweight="bold")
- self.sp_uneq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold")
- self.sp_uneq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold")
- uneqscale = range(len(self.unequalized_angle))
- self.plot_uneq = plot(uneqscale, self.unequalized_angle, 'bo')
-
- # Subplot: equalized angle
- self.sp_eq = self.fig.add_subplot(4,1,2, position=[0.15, 0.1, 0.3, 0.35])
- self.sp_eq.set_title(("Equalized Angle"), fontsize=self.title_font_size, fontweight="bold")
- self.sp_eq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold")
- self.sp_eq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold")
- eqscale = range(len(self.equalized_angle))
- self.plot_eq = plot(eqscale, self.equalized_angle, 'bo')
- self.plot_eq += plot(eqscale, self.derot_equalized_angle, 'ro', markersize=4)
-
- # Subplot: FFT
- self.sp_fft = self.fig.add_subplot(4,2,2, position=[0.575, 0.1, 0.3, 0.35])
- self.sp_fft.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold")
- self.sp_fft.set_xlabel("Frequency (MHz)", fontsize=self.label_font_size, fontweight="bold")
- self.sp_fft.set_ylabel("Power (dBm)", fontsize=self.label_font_size, fontweight="bold")
- self.plot_fft = plot(self.freq, self.fft_data, '-bo')
-
- draw()
-
- def update_plots(self):
- eqscale = range(len(self.equalized_angle))
- uneqscale = range(len(self.unequalized_angle))
- self.plot_eq[0].set_data([eqscale, self.equalized_angle])
- self.plot_eq[1].set_data([eqscale, self.derot_equalized_angle])
- self.plot_uneq[0].set_data([uneqscale, self.unequalized_angle])
- self.sp_eq.set_ylim([-4, 4])
- self.sp_uneq.set_ylim([-4, 4])
-
- #self.sp_iq.axis([min(self.time), max(self.time),
- # 1.5*min([min(self.acq_data_reals), min(self.acq_data_imags)]),
- # 1.5*max([max(self.acq_data_reals), max(self.acq_data_imags)])])
-
- self.plot_const[0].set_data([self.acq_data_reals, self.acq_data_imags])
- self.plot_const[1].set_data([self.derot_data_reals, self.derot_data_imags])
- self.sp_const.axis([-2, 2, -2, 2])
-
- self.plot_fft[0].set_data([self.freq, self.fft_data])
-
- draw()
-
- def zoom(self, event):
- newxlim = self.sp_eq.get_xlim()
- if(newxlim != self.xlim):
- self.xlim = newxlim
- r = self.reals[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))]
- i = self.imags[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))]
-
- self.plot_const[0].set_data(r, i)
- self.sp_const.axis([-2, 2, -2, 2])
- self.manager.canvas.draw()
- draw()
-
- def click(self, event):
- forward_valid_keys = [" ", "down", "right"]
- backward_valid_keys = ["up", "left"]
-
- if(find(event.key, forward_valid_keys)):
- self.step_forward()
-
- elif(find(event.key, backward_valid_keys)):
- self.step_backward()
-
- def button_left_click(self, event):
- self.step_backward()
-
- def button_right_click(self, event):
- self.step_forward()
-
- def step_forward(self):
- self.symbol += 1
- self.get_data()
- self.update_plots()
-
- def step_backward(self):
- # Step back in file position
- self.symbol -= 1
- if(self.h_acq_file.tell() >= 16*self.occ_tones):
- self.h_acq_file.seek(-16*self.occ_tones, 1)
- else:
- self.symbol = 0
- self.h_acq_file.seek(-self.h_acq_file.tell(),1)
-
-
- if(self.h_derot_file.tell() >= 16*self.occ_tones):
- self.h_derot_file.seek(-16*self.occ_tones, 1)
- else:
- self.symbol = 0
- self.h_derot_file.seek(-self.h_derot_file.tell(),1)
-
-
- if(self.h_fft_file.tell() >= 16*self.fft_size):
- self.h_fft_file.seek(-16*self.fft_size, 1)
- else:
- self.symbol = 0
- self.h_fft_file.seek(-self.h_fft_file.tell(),1)
-
- self.get_data()
- self.update_plots()
-
-
-
-#FIXME: there must be a way to do this with a Python builtin
-def find(item_in, list_search):
- for l in list_search:
- if item_in == l:
- return True
- return False
-
-def main():
- usage="%prog: [options]"
-
- parser = OptionParser(conflict_handler="resolve", usage=usage)
- parser.add_option("", "--fft-size", type="int", default=512,
- help="Specify the size of the FFT [default=%default]")
- parser.add_option("", "--occ-tones", type="int", default=200,
- help="Specify the number of occupied tones [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify the starting symbol to plot [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
-
- (options, args) = parser.parse_args ()
-
- dc = draw_constellation(options)
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- pass
-
-
-
diff --git a/gr-msdd6000/src/python-examples/ofdm/receive_path.py b/gr-msdd6000/src/python-examples/ofdm/receive_path.py
deleted file mode 100644
index 11c714aaf..000000000
--- a/gr-msdd6000/src/python-examples/ofdm/receive_path.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2006 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 3, 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., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, blks2
-from gnuradio import usrp
-from gnuradio import eng_notation
-import copy
-import sys
-
-# /////////////////////////////////////////////////////////////////////////////
-# receive path
-# /////////////////////////////////////////////////////////////////////////////
-
-class receive_path(gr.hier_block2):
- def __init__(self, rx_callback, options):
-
- gr.hier_block2.__init__(self, "receive_path",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(0, 0, 0)) # Output signature
-
-
- options = copy.copy(options) # make a copy so we can destructively modify
-
- self._verbose = options.verbose
- self._log = options.log
- self._rx_callback = rx_callback # this callback is fired when there's a packet available
-
- # receiver
- self.ofdm_rx = \
- blks2.ofdm_demod(options, callback=self._rx_callback)
-
- # Carrier Sensing Blocks
- alpha = 0.001
- thresh = 30 # in dB, will have to adjust
- self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
-
- self.connect(self, self.ofdm_rx)
- self.connect(self.ofdm_rx, self.probe)
-
- # Display some information about the setup
- if self._verbose:
- self._print_verbage()
-
- def carrier_sensed(self):
- """
- Return True if we think carrier is present.
- """
- #return self.probe.level() > X
- return self.probe.unmuted()
-
- def carrier_threshold(self):
- """
- Return current setting in dB.
- """
- return self.probe.threshold()
-
- def set_carrier_threshold(self, threshold_in_db):
- """
- Set carrier threshold.
-
- @param threshold_in_db: set detection threshold
- @type threshold_in_db: float (dB)
- """
- self.probe.set_threshold(threshold_in_db)
-
-
- def add_options(normal, expert):
- """
- Adds receiver-specific options to the Options Parser
- """
- normal.add_option("-v", "--verbose", action="store_true", default=False)
- expert.add_option("", "--log", action="store_true", default=False,
- help="Log all parts of flow graph to files (CAUTION: lots of data)")
-
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
-
- def _print_verbage(self):
- """
- Prints information about the receive path
- """
- pass
diff --git a/gr-msdd6000/src/python-examples/playback_samples.m b/gr-msdd6000/src/python-examples/playback_samples.m
deleted file mode 100644
index 332296e72..000000000
--- a/gr-msdd6000/src/python-examples/playback_samples.m
+++ /dev/null
@@ -1,12 +0,0 @@
-t = read_complex_binary('msdd.dat',10000000);
-
-fftsize=256;
-w = [0:pi/fftsize:pi];
-
-for i = 0:length(t)/fftsize
- fftdata = fft(i*fftsize:i*fftsize+fftsize);
- clear plot;
- plot(w,fftdata);
-endfor
-
-pause;
diff --git a/gr-msdd6000/src/python-examples/read_complex_binary.m b/gr-msdd6000/src/python-examples/read_complex_binary.m
deleted file mode 100644
index 67158b528..000000000
--- a/gr-msdd6000/src/python-examples/read_complex_binary.m
+++ /dev/null
@@ -1,48 +0,0 @@
-%
-% Copyright 2001 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 3, 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., 51 Franklin Street,
-% Boston, MA 02110-1301, USA.
-%
-
-function v = read_complex_binary (filename, count)
-
- %% usage: read_complex_binary (filename, [count])
- %%
- %% open filename and return the contents as a column vector,
- %% treating them as 32 bit complex numbers
- %%
-
- m = nargchk (1,2,nargin);
- if (m)
- usage (m);
- end
-
- if (nargin < 2)
- count = Inf;
- end
-
- f = fopen (filename, 'rb');
- if (f < 0)
- v = 0;
- else
- t = fread (f, [2, count], 'float');
- fclose (f);
- v = t(1,:) + t(2,:)*i;
- [r, c] = size (v);
- v = reshape (v, c, r);
- end