diff options
Diffstat (limited to 'gr-uhd/apps')
23 files changed, 237 insertions, 276 deletions
diff --git a/gr-uhd/apps/.gitignore b/gr-uhd/apps/.gitignore deleted file mode 100644 index 22a4e7292..000000000 --- a/gr-uhd/apps/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in - diff --git a/gr-uhd/apps/CMakeLists.txt b/gr-uhd/apps/CMakeLists.txt index 20ae8993f..1d68c00ac 100644 --- a/gr-uhd/apps/CMakeLists.txt +++ b/gr-uhd/apps/CMakeLists.txt @@ -23,12 +23,19 @@ include(GrPython) # Install some uhd apps ######################################################################## GR_PYTHON_INSTALL( + FILES + uhd_siggen_base.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/uhd + COMPONENT "uhd_python" +) + +GR_PYTHON_INSTALL( PROGRAMS - uhd_fft.py - uhd_rx_cfile.py - uhd_siggen.py - uhd_siggen_gui.py - uhd_rx_nogui.py + uhd_fft + uhd_rx_cfile + uhd_siggen + uhd_siggen_gui + uhd_rx_nogui DESTINATION ${GR_RUNTIME_DIR} COMPONENT "uhd_python" ) diff --git a/gr-uhd/apps/Makefile.am b/gr-uhd/apps/Makefile.am deleted file mode 100644 index c30a143c2..000000000 --- a/gr-uhd/apps/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright 2011 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. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST += \ - $(bin_SCRIPTS) - -SUBDIRS = hf_explorer hf_radio - -ourpythondir = $(grpythondir) - -bin_SCRIPTS = \ - uhd_fft.py \ - uhd_rx_cfile.py \ - uhd_siggen.py \ - uhd_siggen_gui.py \ - uhd_rx_nogui.py diff --git a/gr-uhd/apps/hf_explorer/.gitignore b/gr-uhd/apps/hf_explorer/.gitignore deleted file mode 100644 index b6950912c..000000000 --- a/gr-uhd/apps/hf_explorer/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/*.pyc diff --git a/gr-uhd/apps/hf_explorer/Makefile.am b/gr-uhd/apps/hf_explorer/Makefile.am deleted file mode 100644 index c8e7ecb25..000000000 --- a/gr-uhd/apps/hf_explorer/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright 2006,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. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/hf_explorer - -dist_ourdata_DATA = \ - README \ - hfx_help - -dist_ourdata_SCRIPTS = \ - hfx.py diff --git a/gr-uhd/apps/hf_explorer/hfx.py b/gr-uhd/apps/hf_explorer/hfx.py index 687adf82b..1f08bd8ba 100755 --- a/gr-uhd/apps/hf_explorer/hfx.py +++ b/gr-uhd/apps/hf_explorer/hfx.py @@ -56,7 +56,7 @@ # | # V # (dst) -# +# #---------------------------------------------------------------------- # # Versions 2.2.1 adds loop antenna automatic tuner @@ -65,7 +65,7 @@ # added more comments. # # 2.4.1 updates usrp interface to support auto subdev -# +# # 2.8.1 changed saved file format from 8-byte complex to # 4-byte short for obvious storage space savings. @@ -93,7 +93,7 @@ ID_BUTTON_3 = wx.NewId() # AM ID_BUTTON_4 = wx.NewId() # CW ID_BUTTON_5 = wx.NewId() # Powermate controls: Upper audio freq cutoff ID_BUTTON_6 = wx.NewId() # " Lower audio freq cutoff -ID_BUTTON_7 = wx.NewId() # " Frequency +ID_BUTTON_7 = wx.NewId() # " Frequency ID_BUTTON_8 = wx.NewId() # " Volume ID_BUTTON_9 = wx.NewId() # " Time ID_BUTTON_10 = wx.NewId() # Time Seek Forwards @@ -105,7 +105,7 @@ ID_TEXT_1 = wx.NewId() # Band Center, USRP ddc Freq ID_SPIN_1 = wx.NewId() # Frequency display and control ID_SLIDER_1 = wx.NewId() # Upper audio freq cutoff ID_SLIDER_2 = wx.NewId() # Lower audio freq cutoff -ID_SLIDER_3 = wx.NewId() # Frequency +ID_SLIDER_3 = wx.NewId() # Frequency ID_SLIDER_4 = wx.NewId() # Volume ID_SLIDER_5 = wx.NewId() # Programmable Gain Amp, PGA, RF gain ID_SLIDER_6 = wx.NewId() # AM Sync carrier level @@ -118,7 +118,7 @@ class MyFrame(wx.Frame): # begin wxGlade: MyFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) - + # Menu Bar self.frame_1_menubar = wx.MenuBar() self.SetMenuBar(self.frame_1_menubar) @@ -215,7 +215,7 @@ class MyFrame(wx.Frame): self.f_slider_scale = 10000 self.spin_ctrl_1.SetRange(self.f_lo,self.f_hi) self.text_ctrl_1.SetValue(str(int(self.usrp_center))) - self.slider_5.SetValue(0) + self.slider_5.SetValue(0) self.AM_mode = False self.slider_3.SetValue((self.frequency-self.f_slider_offset)/self.f_slider_scale) @@ -265,7 +265,7 @@ class MyFrame(wx.Frame): self.tb.connect((s2ss,1),s2f2) self.tb.connect(s2f1,(src_f2c,0)) self.tb.connect(s2f2,(src_f2c,1)) - + # save radio data to a file if SAVE_RADIO_TO_FILE: radio_file = gr.file_sink(gr.sizeof_short, options.radio_file) @@ -295,7 +295,7 @@ class MyFrame(wx.Frame): sample_rate=self.af_sample_rate, average=True, size=(640,240)) - # AM Sync carrier + # AM Sync carrier if AM_SYNC_DISPLAY: self.fft2 = fftsink.fft_sink_c(self.tb, self.panel_9, y_per_div=20, fft_size=512, @@ -698,10 +698,10 @@ class MyFrame(wx.Frame): if self.AM_mode: fRel = ( event.GetX() - 330. ) / 14.266666 - 7.5 else: - fRel = ( event.GetX() - 330. ) / 14.266666 + fRel = ( event.GetX() - 330. ) / 14.266666 self.fft.win.SetToolTip(wx.ToolTip(eng_notation.num_to_str(self.frequency + (fRel*1e3)))) - # Mouse clicked on fft display - change frequency + # Mouse clicked on fft display - change frequency def Click(self,event): fRel = ( event.GetX() - 330. ) / 14.266666 if self.AM_mode == False: @@ -752,7 +752,7 @@ class MyFrame(wx.Frame): dev.write_aux_dac(uhd.dboard_iface.UNIT_RX, uhd.dboard_iface.AUX_DAC_C, float(self.slider_7.GetValue())) - + # Timer events - check for web commands def OnUpdate(self): cmds = os.listdir("/var/www/cgi-bin/commands/") diff --git a/gr-uhd/apps/hf_explorer/hfx_help b/gr-uhd/apps/hf_explorer/hfx_help index 9a52dd2bb..c8fa28dbd 100644 --- a/gr-uhd/apps/hf_explorer/hfx_help +++ b/gr-uhd/apps/hf_explorer/hfx_help @@ -10,7 +10,7 @@ Default is 3.9e6 80 meter ham band. Example: - hfx.py -c 9500k + hfx.py -c 9500k starts up in the 31 meter band. @@ -49,15 +49,15 @@ usrp hardware needed. Tune about the 800kHz wide band. When playing a recorded file, time controls fast-forward and rewind are available. - + -d Decimation. Sets sample rate and bandwidth. This is the factor that the usrp sample rate, 64e6, is divided by. Default is 250 for 256kHz bandwidth - which is enough to record a ham band without + which is enough to record a ham band without eating up disk space too fast. The 64e6 sample rate limits the upper practical frequency to 32MHz. The Basic RX transformer limits the lower frequency - to about 200kHz. + to about 200kHz. Powermate Knob: @@ -145,12 +145,12 @@ amp I like is a Minicircuits ZHL-32A 29db amp but they are expensive and hard to find. Also it may help to use some filters to keep strong local signals from the ADC, or limit rf input - to the band of interest, etc. + to the band of interest, etc. Resonant outdoor antennas, like a dipole, in a low-noise (away from consumer electronics) environment are nice. Long random wires with a tuner work. I like a small indoor tuned loop made from 10ft of 1/4" copper tube, a 365pf tuning cap and a pickup loop connected - to rg-58. + to rg-58. Web Control: @@ -167,7 +167,7 @@ IF Output: - There is a provision for outputting un-demodulated complex + There is a provision for outputting un-demodulated complex through the audio out in stereo for use with Digital Radio Mondial (DRM) or using a seperate demodulation program like SDRadio (by I2PHD). diff --git a/gr-uhd/apps/hf_radio/.gitignore b/gr-uhd/apps/hf_radio/.gitignore deleted file mode 100644 index b6950912c..000000000 --- a/gr-uhd/apps/hf_radio/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/*.pyc diff --git a/gr-uhd/apps/hf_radio/Makefile.am b/gr-uhd/apps/hf_radio/Makefile.am deleted file mode 100644 index e514076f6..000000000 --- a/gr-uhd/apps/hf_radio/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright 2006,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. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/hf_radio - -dist_ourdata_DATA = \ - hfir.sci \ - radio.xml \ - input.py \ - output.py \ - README.TXT \ - ssbagc.py \ - ssbdemod.py \ - startup.py \ - ssb_taps - -dist_ourdata_SCRIPTS = \ - radio.py \ - ui.py diff --git a/gr-uhd/apps/hf_radio/README.TXT b/gr-uhd/apps/hf_radio/README.TXT index 7c7edf5e0..c5c57f847 100644 --- a/gr-uhd/apps/hf_radio/README.TXT +++ b/gr-uhd/apps/hf_radio/README.TXT @@ -1,17 +1,17 @@ # 2008-02-07 -# +# # These files have not yet been update to use the new top_block/hier_block2 # interfaces. Until someone does that, this files will no longer run. -# +# The files in this directory implement a fairly simple HF radio that works with the basic rx daughter board on the USRP. -Many thanks to the Gnu Radio folks for a great new way to waste large blocks +Many thanks to the Gnu Radio folks for a great new way to waste large blocks of time in infinitely tweaking a huge number of free parameters. -Start the receiver by running the radio.py in this directory. Or from the +Start the receiver by running the radio.py in this directory. Or from the Python prompt type "from radio import *" and you'll get the prompt back with the receiver running. You can then poke around to see what's going on. @@ -19,7 +19,7 @@ There are two spectrum displays. One is the output of the USRP and displays about 300KHz of bandwidth centered at the current tuning freq. The other displays the output spectrum of the demodulator. -The demodulator does AM demod using the complex modulus block from gr. It +The demodulator does AM demod using the complex modulus block from gr. It does SSB demod using the frequency translating fir filter as a complex hilbert transformer. The taps for this filter were generated using a program called Scilab and the Scilab program in the file hfir.sci. More details in @@ -39,7 +39,7 @@ The audio bandwidth can be similarly adjusted from about 50Hz to 10KHz. The GUI layout was produced using wxGlade. The file radio.xml is the GUI specification. It will produce a file called ui.py which is subclassed by classes defined in radio.py. The ui.py is purely generated by wxGlade -all app specific code for the GUI is in radio.py. +all app specific code for the GUI is in radio.py. Most of the actual signal processing code is built up in the other included files using the hierarchical block facilities. This organization should @@ -50,7 +50,7 @@ Known bugs weakness and other wxPython and wxGlade seem to conspire to insure that the layout can never be exactly what you have in mind. -Some of the controls don't behave as one might like. wx spin controls +Some of the controls don't behave as one might like. wx spin controls and spin boxes only support integers so it is rather a nuisance to make units come out nice. In the process of development I came up with a reasonable kluge so there is a mixture of approaches. diff --git a/gr-uhd/apps/hf_radio/hfir.sci b/gr-uhd/apps/hf_radio/hfir.sci index a2d5e2a62..64f5385d7 100644 --- a/gr-uhd/apps/hf_radio/hfir.sci +++ b/gr-uhd/apps/hf_radio/hfir.sci @@ -25,7 +25,7 @@ // This isn't as computationally efficient as using the hilbert transformer // and compensating delay but fascinating none the less. // -// This program is for the scilab language a very powerful free math +// This program is for the scilab language a very powerful free math // package similar to Matlab with infinitely better price/performace. // // compute the prototype lowpass fir diff --git a/gr-uhd/apps/hf_radio/input.py b/gr-uhd/apps/hf_radio/input.py index 2626ddfb5..78e800bb6 100644 --- a/gr-uhd/apps/hf_radio/input.py +++ b/gr-uhd/apps/hf_radio/input.py @@ -1,22 +1,22 @@ # Copyright 2011 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. -# +# # Basic USRP setup and control. # It's only ever been tried with a basic rx daughter card. @@ -24,7 +24,7 @@ # Imagine that the gnuradio boilerplate is here. # # M. Revnell 2005-Dec - + from gnuradio import gr from gnuradio import uhd @@ -33,7 +33,7 @@ class uhd_input(gr.hier_block2): gr.hier_block2.__init__(self, "uhd_input", gr.io_signature(0,0,0), gr.io_signature(1,1,gr.sizeof_gr_complex)) - + self.src = uhd.usrp_source(device_addr=address, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) @@ -65,7 +65,7 @@ class uhd_input(gr.hier_block2): self.gain = gain self.src.set_gain(gain, 0) - def add_options(parser): + def add_options(parser): parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", help="Address of UHD device, [default=%default]") diff --git a/gr-uhd/apps/hf_radio/output.py b/gr-uhd/apps/hf_radio/output.py index 8ee7dc54c..70add5b84 100644 --- a/gr-uhd/apps/hf_radio/output.py +++ b/gr-uhd/apps/hf_radio/output.py @@ -1,22 +1,22 @@ # Copyright 2011 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. -# +# # Audio output with a volume control. @@ -31,7 +31,7 @@ class output( gr.hier_block2 ): gr.hier_block2.__init__(self, "output", gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(0,0,0)) - + self.vol = gr.multiply_const_ff( 0.1 ) self.out = audio.sink( int(rate), device ) @@ -39,4 +39,4 @@ class output( gr.hier_block2 ): def set( self, val ): self.vol.set_k( val ) - + diff --git a/gr-uhd/apps/hf_radio/radio.py b/gr-uhd/apps/hf_radio/radio.py index 32e26c7eb..93d985067 100755 --- a/gr-uhd/apps/hf_radio/radio.py +++ b/gr-uhd/apps/hf_radio/radio.py @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2011 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. -# +# # GUI interactions and high level connections handled here. # @@ -107,7 +107,7 @@ class radio_frame( ui_frame ): agc_ref = self.block.agc.offs.k() self.agc_ref.SetValue( str( agc_ref ) ) self.agc_ref_s.SetValue( 5 ) - + self.fespectrum = fftsink2.fft_sink_c( self.fe_panel, fft_size=512, @@ -138,7 +138,7 @@ class radio_frame( ui_frame ): r = r + 5 self.agc_ref.SetValue( str( r ) ) self.block.agc.offs.set_k( r ) - + def agc_ref_down( self, event ): self.agc_ref_s.SetValue( 5 ) r = float( self.agc_ref.GetValue() ) @@ -184,7 +184,7 @@ class radio_frame( ui_frame ): def tune_evt( self, event ): f = self.freq_disp.GetValue() self.tune( f ) - + def tune( self, frequency ): self.freq_disp.SetValue( frequency ) self.block.tune( frequency ) @@ -247,13 +247,13 @@ class radio_frame( ui_frame ): def event_pga( self, event ): self.block.src.set_gain(self.pga.GetValue()) - + def event_vol( self, event ): self.block.out.set( self.volume.GetValue()/20.0 ) def set_usb( self, event ): self.block.demod.upper_sb() - + def set_lsb( self, event ): self.block.demod.lower_sb() @@ -310,9 +310,9 @@ def main(): thread2 = Thread( target = rssi_function ) thread2.start() - + radio_obj.MainLoop() - + if __name__ == "__main__": main() diff --git a/gr-uhd/apps/hf_radio/ssbagc.py b/gr-uhd/apps/hf_radio/ssbagc.py index 494712863..6a2e0a7cd 100644 --- a/gr-uhd/apps/hf_radio/ssbagc.py +++ b/gr-uhd/apps/hf_radio/ssbagc.py @@ -1,22 +1,22 @@ # Copyright 2011 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. - + # post detection agc processing # diff --git a/gr-uhd/apps/hf_radio/ssbdemod.py b/gr-uhd/apps/hf_radio/ssbdemod.py index 072d317a2..3c533f617 100644 --- a/gr-uhd/apps/hf_radio/ssbdemod.py +++ b/gr-uhd/apps/hf_radio/ssbdemod.py @@ -1,22 +1,22 @@ # Copyright 2011 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. -# +# # This tries to push the hilbert transform for ssb demod back into the # freq. xlating filter. @@ -45,7 +45,7 @@ class ssb_demod( gr.hier_block2 ): self.sideband = 1 self.xlate_taps = ([complex(v) for v in file('ssb_taps').readlines()]) - + self.audio_taps = gr.firdes.low_pass( 1.0, self.af_rate, @@ -69,7 +69,7 @@ class ssb_demod( gr.hier_block2 ): self.sb_sel = gr.multiply_const_ff( 1 ) self.mixer = gr.add_ff() self.am_det = gr.complex_to_mag() - + self.connect(self, self.xlate) self.connect(self.xlate, self.split) self.connect((self.split, 0), (self.sum, 0)) @@ -83,7 +83,7 @@ class ssb_demod( gr.hier_block2 ): self.connect(self.lpf, self) def upper_sb( self ): - self.xlate.set_taps([v.conjugate() for v in self.xlate_taps]) + self.xlate.set_taps([v.conjugate() for v in self.xlate_taps]) self.sb_sel.set_k( 1.0 ) self.am_sel.set_k( 0.0 ) @@ -91,7 +91,7 @@ class ssb_demod( gr.hier_block2 ): self.xlate.set_taps(self.xlate_taps) self.sb_sel.set_k( 1.0 ) self.am_sel.set_k( 0.0 ) - + def set_am( self ): taps = gr.firdes.low_pass( 1.0, self.if_rate, diff --git a/gr-uhd/apps/hf_radio/ui.py b/gr-uhd/apps/hf_radio/ui.py index 551a30415..a20ba4fab 100755 --- a/gr-uhd/apps/hf_radio/ui.py +++ b/gr-uhd/apps/hf_radio/ui.py @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2011 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. -# +# # -*- coding: UTF-8 -*- # generated by wxGlade 0.4 on Mon Jan 2 19:02:03 2006 diff --git a/gr-uhd/apps/uhd_fft.py b/gr-uhd/apps/uhd_fft index 2f2b0ebfa..8bb5e0d2b 100755 --- a/gr-uhd/apps/uhd_fft.py +++ b/gr-uhd/apps/uhd_fft @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2012 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 uhd @@ -44,7 +44,7 @@ class app_top_block(stdgui2.std_top_block): self.frame = frame self.panel = panel - + parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args , [default=%default]") @@ -74,8 +74,8 @@ class app_top_block(stdgui2.std_top_block): help="Set FFT update rate, [default=%default]") parser.add_option("", "--wire-format", type="string", default="sc16", help="Set wire format from USRP [default=%default]") - parser.add_option("", "--scalar", type="int", default=1024, - help="Set scalar multiplier value sc8 wire format [default=%default]") + parser.add_option("", "--stream-args", type="string", default="", + help="Set additional stream args [default=%default]") parser.add_option("", "--show-async-msg", action="store_true", default=False, help="Show asynchronous message notifications from UHD [default=%default]") (options, args) = parser.parse_args() @@ -84,11 +84,10 @@ class app_top_block(stdgui2.std_top_block): sys.exit(1) self.options = options self.show_debug_info = True - - scalar="scalar="+str(options.scalar) + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args(cpu_format='fc32', - otw_format=options.wire_format, args=scalar)) + otw_format=options.wire_format, args=options.stream_args)) # Set the subdevice spec if(options.spec): @@ -100,7 +99,7 @@ class app_top_block(stdgui2.std_top_block): self.u.set_samp_rate(options.samp_rate) input_rate = self.u.get_samp_rate() - + if options.waterfall: self.scope = \ waterfallsink2.waterfall_sink_c (panel, fft_size=1024, @@ -112,7 +111,7 @@ class app_top_block(stdgui2.std_top_block): else: self.scope = fftsink2.fft_sink_c (panel, fft_size=options.fft_size, - sample_rate=input_rate, + sample_rate=input_rate, ref_scale=options.ref_scale, ref_level=20.0, y_divs = 12, @@ -126,7 +125,7 @@ class app_top_block(stdgui2.std_top_block): self._build_gui(vbox) self._setup_events() - + # set initial values if options.gain is None: @@ -138,7 +137,7 @@ class app_top_block(stdgui2.std_top_block): # if no freq was specified, use the mid-point r = self.u.get_freq_range() options.freq = float(r.start()+r.stop())/2 - + self.set_gain(options.gain) if self.show_debug_info: @@ -166,9 +165,9 @@ class app_top_block(stdgui2.std_top_block): 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) @@ -185,11 +184,11 @@ class app_top_block(stdgui2.std_top_block): if g.stop() <= g.start(): glow = 0.0 ghigh = 1.0 - + else: glow = g.start() ghigh = g.stop() - + myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain", weight=3, @@ -235,7 +234,7 @@ class app_top_block(stdgui2.std_top_block): # 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_samp_rate(kv): return self.set_samp_rate(kv['samprate']) @@ -266,7 +265,7 @@ class app_top_block(stdgui2.std_top_block): vbox.Add(hbox, 0, wx.EXPAND) vbox.AddSpacer(5) - + def set_freq(self, target_freq): """ Set the center frequency we're interested in. @@ -300,12 +299,12 @@ class app_top_block(stdgui2.std_top_block): self.myform['samprate'].set_value(self.u.get_samp_rate()) # uhd set_samp_rate never fails; always falls back to closest requested. - return True + return True 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(): @@ -318,17 +317,17 @@ class app_top_block(stdgui2.std_top_block): 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) + 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, "UHD FFT", nstatus=1) app.MainLoop() diff --git a/gr-uhd/apps/uhd_rx_cfile.py b/gr-uhd/apps/uhd_rx_cfile index 718bb80b7..62874771c 100755 --- a/gr-uhd/apps/uhd_rx_cfile.py +++ b/gr-uhd/apps/uhd_rx_cfile @@ -1,28 +1,28 @@ #!/usr/bin/env python # # Copyright 2012 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. -# +# """ Read samples from a UHD device and write to file formatted as binary -outputs single precision complex float values or complex short values +outputs single precision complex float values or complex short values (interleaved 16 bit signed short integers). """ @@ -39,15 +39,14 @@ class rx_cfile_block(gr.top_block): def __init__(self, options, filename): gr.top_block.__init__(self) - scalar="scalar="+str(options.scalar) # Create a UHD device source if options.output_shorts: self._u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('sc16', - options.wire_format, args=scalar)) + options.wire_format, args=options.stream_args)) self._sink = gr.file_sink(gr.sizeof_short*2, filename) else: self._u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', - options.wire_format, args=scalar)) + options.wire_format, args=options.stream_args)) self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) # Set the subdevice spec @@ -90,9 +89,29 @@ class rx_cfile_block(gr.top_block): self.connect(self._u, self._head, self._sink) input_rate = self._u.get_samp_rate() - + if options.verbose: - print "Args: ", options.args + try: + info = self._u.get_usrp_info() + + mboard_id = info.get("mboard_id").split(" ")[0] + if info.get("mboard_serial") == "": + mboard_serial = "no serial" + else: + mboard_serial = info.get("mboard_serial") + + rx_id = info.get("rx_id").split(" ")[0] + if info.get("rx_serial") == "": + rx_serial = "no serial" + else: + rx_serial = info.get("rx_serial") + rx_antenna = info.get("rx_antenna") + rx_subdev_spec = info.get("rx_subdev_spec") + + print "Motherboard: %s (%s)" % (mboard_id, mboard_serial) + print "Daughterboard: %s (%s, %s, %s)" % (rx_id, rx_serial, rx_antenna, rx_subdev_spec) + except: + print "Args: ", options.args print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) @@ -117,7 +136,7 @@ class rx_cfile_block(gr.top_block): md = self.async_src.msg_to_async_metadata_t(msg) print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) - + def get_options(): usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) @@ -143,8 +162,8 @@ def get_options(): help="set daughterboard LO offset to OFFSET [default=hw default]") parser.add_option("", "--wire-format", type="string", default="sc16", help="set wire format from USRP [default=%default") - parser.add_option("", "--scalar", type="int", default=1024, - help="set scalar multiplier value for sc8 wire format [default=%default]") + parser.add_option("", "--stream-args", type="string", default="", + help="set stream arguments [default=%default]") parser.add_option("", "--show-async-msg", action="store_true", default=False, help="Show asynchronous message notifications from UHD [default=%default]") @@ -152,19 +171,19 @@ def get_options(): if len(args) != 1: parser.print_help() raise SystemExit, 1 - + if options.freq is None: parser.print_help() sys.stderr.write('You must specify the frequency with -f FREQ\n'); raise SystemExit, 1 - + return (options, args[0]) if __name__ == '__main__': (options, filename) = get_options() tb = rx_cfile_block(options, filename) - + try: tb.run() except KeyboardInterrupt: diff --git a/gr-uhd/apps/uhd_rx_nogui.py b/gr-uhd/apps/uhd_rx_nogui index bcb52c619..9977f55a3 100755 --- a/gr-uhd/apps/uhd_rx_nogui.py +++ b/gr-uhd/apps/uhd_rx_nogui @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2006,2007,2011,2012 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, uhd, optfir, audio, blks2 from gnuradio import eng_notation @@ -27,8 +27,8 @@ from optparse import OptionParser import sys """ -This example application demonstrates receiving and demodulating -different types of signals using the USRP. +This example application demonstrates receiving and demodulating +different types of signals using the USRP. A receive chain is built up of the following signal processing blocks: @@ -77,11 +77,11 @@ demod_params = { class uhd_src(gr.hier_block2): """ Create a UHD source object supplying complex floats. - + Selects user supplied subdevice or chooses first available one. - Calibration value is the offset from the tuned frequency to - the actual frequency. + Calibration value is the offset from the tuned frequency to + the actual frequency. """ def __init__(self, args, spec, antenna, samp_rate, gain=None, calibration=0.0): gr.hier_block2.__init__(self, "uhd_src", @@ -93,19 +93,19 @@ class uhd_src(gr.hier_block2): # Set the subdevice spec if(spec): self._src.set_subdev_spec(spec, 0) - + # Set the antenna if(antenna): self._src.set_antenna(antenna, 0) - + self._src.set_samp_rate(samp_rate) dev_rate = self._src.get_samp_rate() self._samp_rate = samp_rate - + # Resampler to get to exactly samp_rate no matter what dev_rate is self._rrate = samp_rate / dev_rate self._resamp = blks2.pfb_arb_resampler_ccf(self._rrate) - + # If no gain specified, set to midrange gain_range = self._src.get_gain_range() if gain is None: @@ -121,7 +121,7 @@ class uhd_src(gr.hier_block2): def rate(self): return self._samp_rate - + class app_top_block(gr.top_block): def __init__(self, options): gr.top_block.__init__(self) @@ -160,7 +160,7 @@ class app_top_block(gr.top_block): False) # Zero, not gate output AGC = gr.agc_cc(1.0/channel_rate, # Time constant - 1.0, # Reference power + 1.0, # Reference power 1.0, # Initial gain 1.0) # Maximum gain @@ -184,7 +184,7 @@ class app_top_block(gr.top_block): out_decim = int(out_lcm // options.output_rate) RSAMP = blks2.rational_resampler_fff(out_interp, out_decim) self.connect(tail, RSAMP) - tail = RSAMP + tail = RSAMP # Send to audio output device AUDIO = audio.sink(int(options.output_rate), @@ -201,7 +201,7 @@ class app_top_block(gr.top_block): md = self.async_src.msg_to_async_metadata_t(msg) print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) - + def main(): parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", @@ -244,7 +244,7 @@ def main(): if options.modulation is None: sys.stderr.write("Must supply a modulation type (AM, FM, WFM).\n") sys.exit(1) - + tb = app_top_block(options) try: tb.run() diff --git a/gr-uhd/apps/uhd_siggen b/gr-uhd/apps/uhd_siggen new file mode 100755 index 000000000..52fc24922 --- /dev/null +++ b/gr-uhd/apps/uhd_siggen @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright 2008,2009,2011,2012 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.uhd import uhd_siggen_base as uhd_siggen +import sys + +def main(): + if gr.enable_realtime_scheduling() != gr.RT_OK: + print "Note: failed to enable realtime scheduling, continuing" + + # Grab command line options and create top block + try: + (options, args) = uhd_siggen.get_options() + tb = uhd_siggen.top_block(options, args) + + except RuntimeError, e: + print e + sys.exit(1) + + tb.start() + raw_input('Press Enter to quit: ') + tb.stop() + tb.wait() + +# Make sure to create the top block (tb) within a function: +# That code in main will allow tb to go out of scope on return, +# which will call the decontructor on usrp and stop transmit. +# Whats odd is that grc works fine with tb in the __main__, +# perhaps its because the try/except clauses around tb. +if __name__ == "__main__": + main() diff --git a/gr-uhd/apps/uhd_siggen.py b/gr-uhd/apps/uhd_siggen_base.py index add8d1bf3..5fa881e42 100755..100644 --- a/gr-uhd/apps/uhd_siggen.py +++ b/gr-uhd/apps/uhd_siggen_base.py @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2008,2009,2011,2012 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. -# +# DESC_KEY = 'desc' SAMP_RATE_KEY = 'samp_rate' @@ -85,7 +85,7 @@ class top_block(gr.top_block, pubsub): self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys - for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, + for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] @@ -120,7 +120,7 @@ class top_block(gr.top_block, pubsub): dboard_serial = "no serial" subdev = self._u.get_subdev_spec() antenna = self._u.get_antenna() - + desc_key_str = "Motherboard: %s [%s]\n" % (mboard_id, mboard_serial) desc_key_str += "Daughterboard: %s [%s]\n" % (dboard_id, dboard_serial) desc_key_str += "Subdev: %s\n" % subdev @@ -172,7 +172,7 @@ class top_block(gr.top_block, pubsub): self._src2.set_sampling_freq(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY]) else: return True # Waveform not yet set - + if self._verbose: print "Set sample rate to:", sr @@ -211,7 +211,7 @@ class top_block(gr.top_block, pubsub): print "Tx RF frequency: %sHz" % (n2s(tr.actual_rf_freq),) print "Tx DSP frequency: %sHz" % (n2s(tr.actual_dsp_freq),) elif self._verbose: - print "Failed to set freq." + print "Failed to set freq." return tr def set_waveform_freq(self, freq): @@ -313,7 +313,7 @@ class top_block(gr.top_block, pubsub): self._src.set_k(amplitude) else: return True # Waveform not yet set - + if self._verbose: print "Set amplitude to:", amplitude return True @@ -342,7 +342,7 @@ def get_options(): parser.add_option("--sine", dest="type", action="store_const", const=gr.GR_SIN_WAVE, help="Generate a carrier modulated by a complex sine wave", default=gr.GR_SIN_WAVE) - parser.add_option("--const", dest="type", action="store_const", const=gr.GR_CONST_WAVE, + parser.add_option("--const", dest="type", action="store_const", const=gr.GR_CONST_WAVE, help="Generate a constant carrier") parser.add_option("--offset", type="eng_float", default=0, help="Set waveform phase offset to OFFSET [default=%default]") @@ -368,10 +368,10 @@ def get_options(): # If this script is executed, the following runs. If it is imported, # the below does not run. -def main(): +def test_main(): if gr.enable_realtime_scheduling() != gr.RT_OK: print "Note: failed to enable realtime scheduling, continuing" - + # Grab command line options and create top block try: (options, args) = get_options() @@ -392,4 +392,4 @@ def main(): # Whats odd is that grc works fine with tb in the __main__, # perhaps its because the try/except clauses around tb. if __name__ == "__main__": - main() + test_main() diff --git a/gr-uhd/apps/uhd_siggen_gui.py b/gr-uhd/apps/uhd_siggen_gui index 1f6a73c2c..70929b182 100755 --- a/gr-uhd/apps/uhd_siggen_gui.py +++ b/gr-uhd/apps/uhd_siggen_gui @@ -1,30 +1,30 @@ #!/usr/bin/env python # # Copyright 2009,2011,2012 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 wx from gnuradio import gr, uhd from gnuradio.gr.pubsub import pubsub from gnuradio.wxgui import gui, forms -import uhd_siggen +from gnuradio.uhd import uhd_siggen_base as uhd_siggen import sys, math class app_gui(pubsub): @@ -152,7 +152,7 @@ class app_gui(pubsub): key=uhd_siggen.TX_FREQ_KEY, ) freq_hbox.AddSpacer(10) - + forms.slider( parent=self.panel, sizer=freq_hbox, proportion=2, |