diff options
-rwxr-xr-x | gr-shd/apps/shd_fft.py | 68 | ||||
-rwxr-xr-x | gr-shd/apps/shd_rx_cfile.py | 31 |
2 files changed, 53 insertions, 46 deletions
diff --git a/gr-shd/apps/shd_fft.py b/gr-shd/apps/shd_fft.py index 4b9d13349..42f0e18b0 100755 --- a/gr-shd/apps/shd_fft.py +++ b/gr-shd/apps/shd_fft.py @@ -24,7 +24,8 @@ from gnuradio import gr, gru from gnuradio import shd from gnuradio import eng_notation from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider +from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2 +from gnuradio.wxgui import scopesink2, form, slider from optparse import OptionParser import wx import sys @@ -65,28 +66,27 @@ class app_top_block(stdgui2.std_top_block): self.options = options self.show_debug_info = True - self.u = shd.xmini_source(device_addr=options.address, + self.src = shd.xmini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) - self.u.set_samp_rate(options.samp_rate) - input_rate = self.u.get_samp_rate() - - print dir(self.u) - - print "Antenna: ", self.u.get_antenna() - print "Antennas: ", self.u.get_antennas() - print "Dboard: ", self.u.get_dboard_iface() - print "Device: ", self.u.get_device - print "Center Freq: ", self.u.get_center_freq() - print "Freq Range: ", self.u.get_freq_range() - print "Gain: ", self.u.get_gain() - print "Gain Names: ", self.u.get_gain_names() - print "Gain Range: ", self.u.get_gain_range() + self.src.set_samp_rate(options.samp_rate) + input_rate = self.src.get_samp_rate() + + print "Antenna: ", self.src.get_antenna() + print "Antennas: ", self.src.get_antennas() + print "Dboard: ", self.src.get_dboard_iface() + print "Device: ", self.src.get_device + print "Center Freq: ", self.src.get_center_freq() + print "Freq Range: ", self.src.get_freq_range() + print "Gain: ", self.src.get_gain() + print "Gain Names: ", self.src.get_gain_names() + print "Gain Range: ", self.src.get_gain_range() if options.waterfall: self.scope = \ - waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate) + waterfallsink2.waterfall_sink_c (panel, fft_size=1024, + sample_rate=input_rate) self.frame.SetMinSize((800, 420)) elif options.oscilloscope: self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) @@ -101,7 +101,7 @@ class app_top_block(stdgui2.std_top_block): avg_alpha=options.avg_alpha) self.frame.SetMinSize((800, 420)) - self.connect(self.u, self.scope) + self.connect(self.src, self.scope) self._build_gui(vbox) self._setup_events() @@ -111,21 +111,21 @@ class app_top_block(stdgui2.std_top_block): if options.gain is None: # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() + g = self.src.get_gain_range() options.gain = float(g.start()+g.stop())/2 if options.freq is None: # if no freq was specified, use the mid-point - r = self.u.get_freq_range() + r = self.src.get_freq_range() options.freq = float(r.start()+r.stop())/2 self.set_gain(options.gain) if(options.antenna): - self.u.set_antenna(options.antenna, 0) + self.src.set_antenna(options.antenna, 0) if self.show_debug_info: - self.myform['samprate'].set_value(self.u.get_samp_rate()) + self.myform['samprate'].set_value(self.src.get_samp_rate()) self.myform['fs@gbe'].set_value(input_rate) self.myform['baseband'].set_value(0) self.myform['ddc'].set_value(0) @@ -149,16 +149,19 @@ class app_top_block(stdgui2.std_top_block): 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)) + callback=myform.check_input_and_call(_form_set_freq, + self._set_status_msg)) hbox.Add((5,0), 0, 0) - g = self.u.get_gain_range() + g = self.src.get_gain_range() # some configurations don't have gain control if g.stop() > g.start(): - myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain", + myform['gain'] = form.slider_field(parent=self.panel, + sizer=hbox, label="Gain", weight=3, - min=int(g.start()), max=int(g.stop()), + min=int(g.start()), + max=int(g.stop()), callback=self.set_gain) hbox.Add((5,0), 0, 0) @@ -187,7 +190,8 @@ class app_top_block(stdgui2.std_top_block): hbox.Add((5,0), 0) myform['samprate'] = form.float_field( parent=panel, sizer=hbox, label="Sample Rate", - callback=myform.check_input_and_call(_form_set_samp_rate, self._set_status_msg)) + callback=myform.check_input_and_call(_form_set_samp_rate, + self._set_status_msg)) hbox.Add((5,0), 1) myform['fs@gbe'] = form.static_float_field( @@ -216,7 +220,7 @@ class app_top_block(stdgui2.std_top_block): the result of that operation and our target_frequency to determine the value for the digital down converter. """ - r = self.u.set_center_freq(target_freq, 0) + r = self.src.set_center_freq(target_freq, 0) if r: self.myform['freq'].set_value(target_freq) # update displayed value @@ -232,14 +236,14 @@ class app_top_block(stdgui2.std_top_block): def set_gain(self, gain): if self.myform.has_key('gain'): self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain, 0) + self.src.set_gain(gain, 0) def set_samp_rate(self, samp_rate): - ok = self.u.set_samp_rate(samp_rate) - input_rate = self.u.get_samp_rate() + ok = self.src.set_samp_rate(samp_rate) + input_rate = self.src.get_samp_rate() self.scope.set_sample_rate(input_rate) if self.show_debug_info: # update displayed values - self.myform['samprate'].set_value(self.u.get_samp_rate()) + self.myform['samprate'].set_value(self.src.get_samp_rate()) self.myform['fs@gbe'].set_value(input_rate) # shd set_samp_rate never fails; always falls back to closest requested. diff --git a/gr-shd/apps/shd_rx_cfile.py b/gr-shd/apps/shd_rx_cfile.py index a7f8ba467..7ba16b4c4 100755 --- a/gr-shd/apps/shd_rx_cfile.py +++ b/gr-shd/apps/shd_rx_cfile.py @@ -41,52 +41,55 @@ class rx_cfile_block(gr.top_block): # Create a SHD device source if options.output_shorts: - self._u = shd.xmini_source(device_addr=options.address, + self._src = shd.xmini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_INT16, num_channels=1) self._sink = gr.file_sink(gr.sizeof_short*2, filename) else: - self._u = shd.xmini_source(device_addr=options.address, + self._src = shd.xmini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) # Set receiver sample rate - self._u.set_samp_rate(options.samp_rate) + self._src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: - g = self._u.get_gain_range() + g = self._src.get_gain_range() options.gain = float(g.start()+g.stop())/2 - print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")" - self._u.set_gain(options.gain) + print "Using mid-point gain of", \ + options.gain, "(", g.start(), "-", g.stop(), ")" + self._src.set_gain(options.gain) # Set the antenna if(options.antenna): - self._u.set_antenna(options.antenna, 0) + self._src.set_antenna(options.antenna, 0) # Set frequency (tune request takes lo_offset) if(options.lo_offset is not None): treq = shd.tune_request(options.freq, options.lo_offset) else: treq = shd.tune_request(options.freq) - tr = self._u.set_center_freq(treq) + tr = self._src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 # Create head block if needed and wire it up if options.nsamples is None: - self.connect(self._u, self._sink) + self.connect(self._src, self._sink) else: if options.output_shorts: - self._head = gr.head(gr.sizeof_short*2, int(options.nsamples)) + self._head = gr.head(gr.sizeof_short*2, + int(options.nsamples)) else: - self._head = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) + self._head = gr.head(gr.sizeof_gr_complex, + int(options.nsamples)) - self.connect(self._u, self._head, self._sink) + self.connect(self._src, self._head, self._sink) - input_rate = self._u.get_samp_rate() + input_rate = self._src.get_samp_rate() if options.verbose: print "Address:", options.address @@ -107,7 +110,7 @@ class rx_cfile_block(gr.top_block): def get_options(): usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + parser.add_option("-a", "--address", type="string", default="type=xmini", help="Address of SHD device, [default=%default]") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") |