diff options
-rw-r--r-- | gr-pager/apps/Makefile.am | 8 | ||||
-rw-r--r-- | gr-pager/apps/usrp_rx_flex.grc | 1063 | ||||
-rwxr-xr-x | gr-pager/apps/usrp_rx_flex.py | 357 |
3 files changed, 1426 insertions, 2 deletions
diff --git a/gr-pager/apps/Makefile.am b/gr-pager/apps/Makefile.am index 64a79f594..0e9f1215b 100644 --- a/gr-pager/apps/Makefile.am +++ b/gr-pager/apps/Makefile.am @@ -26,6 +26,10 @@ if PYTHON dist_bin_SCRIPTS = \ usrp_flex.py \ usrp_flex_all.py \ - usrp_flex_band.py - + usrp_flex_band.py \ + usrp_rx_flex.py endif + +EXTRA_DIST = \ + usrp_rx_flex.grc + diff --git a/gr-pager/apps/usrp_rx_flex.grc b/gr-pager/apps/usrp_rx_flex.grc new file mode 100644 index 000000000..c324eaa3e --- /dev/null +++ b/gr-pager/apps/usrp_rx_flex.grc @@ -0,0 +1,1063 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Sun Oct 11 14:19:38 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>usrp_rx_flex</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>USRP FLEX Pager Receiver (Single Channel)</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>adc_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64e6</value> + </param> + <param> + <key>_coordinate</key> + <value>(225, 12)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>16</value> + </param> + <param> + <key>_coordinate</key> + <value>(310, 11)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sample_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>adc_rate/decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(382, 12)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>channel_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>25e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(751, 13)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>freq</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>band_freq+(channel-61)*25e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(480, 11)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>channel_decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>int(sample_rate/channel_rate)</value> + </param> + <param> + <key>_coordinate</key> + <value>(854, 11)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>channel_taps</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>firdes.low_pass(10**1, sample_rate, 10e3, 2.5e3)</value> + </param> + <param> + <key>_coordinate</key> + <value>(588, 12)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>FLEX Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>sample_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>band_freq</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>65536</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>30</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>grid_pos</key> + <value>0,0,1,1</value> + </param> + <param> + <key>notebook</key> + <value>displays,0</value> + </param> + <param> + <key>_coordinate</key> + <value>(34, 508)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>usrp_simple_source_x</key> + <param> + <key>id</key> + <value>usrp_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>format</key> + <value></value> + </param> + <param> + <key>which</key> + <value>0</value> + </param> + <param> + <key>decimation</key> + <value>decim</value> + </param> + <param> + <key>frequency</key> + <value>band_freq</value> + </param> + <param> + <key>lo_offset</key> + <value>float('inf')</value> + </param> + <param> + <key>gain</key> + <value>rx_gain</value> + </param> + <param> + <key>side</key> + <value>A</value> + </param> + <param> + <key>rx_ant</key> + <value>RXA</value> + </param> + <param> + <key>hb_filters</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(32, 734)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import os</value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 76)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>config_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>os.environ["HOME"]+"/.gnuradio/config.conf"</value> + </param> + <param> + <key>_coordinate</key> + <value>(9, 133)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_band_freq</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>930.5125e6</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>gr-pager</value> + </param> + <param> + <key>option</key> + <value>band_center</value> + </param> + <param> + <key>writeback</key> + <value>band_freq</value> + </param> + <param> + <key>_coordinate</key> + <value>(228, 311)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>gr-pager</value> + </param> + <param> + <key>option</key> + <value>freq_offset</value> + </param> + <param> + <key>writeback</key> + <value>offset</value> + </param> + <param> + <key>_coordinate</key> + <value>(547, 312)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_rx_gain</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>40</value> + </param> + <param> + <key>type</key> + <value>int</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>gr-pager</value> + </param> + <param> + <key>option</key> + <value>rx_gain</value> + </param> + <param> + <key>writeback</key> + <value>rx_gain</value> + </param> + <param> + <key>_coordinate</key> + <value>(706, 312)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_freq_xlating_fir_filter_xxx</key> + <param> + <key>id</key> + <value>gr_freq_xlating_fir_filter_xxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>ccc</value> + </param> + <param> + <key>decim</key> + <value>channel_decim</value> + </param> + <param> + <key>taps</key> + <value>channel_taps</value> + </param> + <param> + <key>center_freq</key> + <value>band_freq-freq+offset</value> + </param> + <param> + <key>samp_rate</key> + <value>sample_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(321, 750)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>notebook</key> + <param> + <key>id</key> + <value>displays</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>style</key> + <value>wx.NB_TOP</value> + </param> + <param> + <key>labels</key> + <value>['RX Spectrum','Baseband']</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 0, 1, 5</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(9, 209)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>rx_gain</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Analog Gain</value> + </param> + <param> + <key>value</key> + <value>saved_rx_gain</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>100</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 4, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(658, 122)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Freq. Offset</value> + </param> + <param> + <key>value</key> + <value>saved_offset</value> + </param> + <param> + <key>min</key> + <value>-10e3</value> + </param> + <param> + <key>max</key> + <value>10e3</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 3, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(518, 118)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_static_text</key> + <param> + <key>id</key> + <value>freq_text</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Ch. Freq</value> + </param> + <param> + <key>value</key> + <value>freq</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>None</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 2, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(801, 124)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>channel</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Channel</value> + </param> + <param> + <key>value</key> + <value>saved_channel</value> + </param> + <param> + <key>min</key> + <value>1</value> + </param> + <param> + <key>max</key> + <value>120</value> + </param> + <param> + <key>num_steps</key> + <value>119</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 1, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(376, 120)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_text_box</key> + <param> + <key>id</key> + <value>band_freq</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Band Freq.</value> + </param> + <param> + <key>value</key> + <value>saved_band_freq</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>None</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(225, 121)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>wxgui_scopesink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Baseband Waveform</value> + </param> + <param> + <key>samp_rate</key> + <value>channel_rate</value> + </param> + <param> + <key>v_scale</key> + <value>1e3</value> + </param> + <param> + <key>t_scale</key> + <value>20.0/channel_rate</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value>displays, 1</value> + </param> + <param> + <key>_coordinate</key> + <value>(593, 551)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Channel Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>channel_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>freq</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>65536</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>30</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value>displays, 0</value> + </param> + <param> + <key>_coordinate</key> + <value>(344, 511)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_channel</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>25</value> + </param> + <param> + <key>type</key> + <value>int</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>gr-pager</value> + </param> + <param> + <key>option</key> + <value>channel</value> + </param> + <param> + <key>writeback</key> + <value>channel</value> + </param> + <param> + <key>_coordinate</key> + <value>(387, 312)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>gr_freq_xlating_fir_filter_xxx_0</source_block_id> + <sink_block_id>wxgui_fftsink2_1</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>usrp_source</source_block_id> + <sink_block_id>gr_freq_xlating_fir_filter_xxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>usrp_source</source_block_id> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_freq_xlating_fir_filter_xxx_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-pager/apps/usrp_rx_flex.py b/gr-pager/apps/usrp_rx_flex.py new file mode 100755 index 000000000..7d6345279 --- /dev/null +++ b/gr-pager/apps/usrp_rx_flex.py @@ -0,0 +1,357 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: USRP FLEX Pager Receiver (Single Channel) +# Generated: Sun Oct 11 14:15:06 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import fftsink2 +from gnuradio.wxgui import forms +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import usrp as grc_usrp +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import ConfigParser +import os +import wx + +class usrp_rx_flex(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="USRP FLEX Pager Receiver (Single Channel)") + + ################################################## + # Variables + ################################################## + self.config_filename = config_filename = os.environ["HOME"]+"/.gnuradio/config.conf" + self._saved_channel_config = ConfigParser.ConfigParser() + self._saved_channel_config.read(config_filename) + try: saved_channel = self._saved_channel_config.getint("gr-pager", "channel") + except: saved_channel = 25 + self.saved_channel = saved_channel + self._saved_band_freq_config = ConfigParser.ConfigParser() + self._saved_band_freq_config.read(config_filename) + try: saved_band_freq = self._saved_band_freq_config.getfloat("gr-pager", "band_center") + except: saved_band_freq = 930.5125e6 + self.saved_band_freq = saved_band_freq + self.decim = decim = 16 + self.channel = channel = saved_channel + self.band_freq = band_freq = saved_band_freq + self.adc_rate = adc_rate = 64e6 + self._saved_rx_gain_config = ConfigParser.ConfigParser() + self._saved_rx_gain_config.read(config_filename) + try: saved_rx_gain = self._saved_rx_gain_config.getint("gr-pager", "rx_gain") + except: saved_rx_gain = 40 + self.saved_rx_gain = saved_rx_gain + self._saved_offset_config = ConfigParser.ConfigParser() + self._saved_offset_config.read(config_filename) + try: saved_offset = self._saved_offset_config.getfloat("gr-pager", "freq_offset") + except: saved_offset = 0 + self.saved_offset = saved_offset + self.sample_rate = sample_rate = adc_rate/decim + self.freq = freq = band_freq+(channel-61)*25e3 + self.channel_rate = channel_rate = 25e3 + self.rx_gain = rx_gain = saved_rx_gain + self.offset = offset = saved_offset + self.freq_text = freq_text = freq + self.channel_taps = channel_taps = firdes.low_pass(10**1, sample_rate, 10e3, 2.5e3) + self.channel_decim = channel_decim = int(sample_rate/channel_rate) + + ################################################## + # Notebooks + ################################################## + self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) + self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX Spectrum") + self.displays.AddPage(grc_wxgui.Panel(self.displays), "Baseband") + self.GridAdd(self.displays, 1, 0, 1, 5) + + ################################################## + # Controls + ################################################## + _channel_sizer = wx.BoxSizer(wx.VERTICAL) + self._channel_text_box = forms.text_box( + parent=self.GetWin(), + sizer=_channel_sizer, + value=self.channel, + callback=self.set_channel, + label="Channel", + converter=forms.float_converter(), + proportion=0, + ) + self._channel_slider = forms.slider( + parent=self.GetWin(), + sizer=_channel_sizer, + value=self.channel, + callback=self.set_channel, + minimum=1, + maximum=120, + num_steps=119, + style=wx.SL_HORIZONTAL, + cast=float, + proportion=1, + ) + self.GridAdd(_channel_sizer, 0, 1, 1, 1) + self._band_freq_text_box = forms.text_box( + parent=self.GetWin(), + value=self.band_freq, + callback=self.set_band_freq, + label="Band Freq.", + converter=forms.float_converter(), + ) + self.GridAdd(self._band_freq_text_box, 0, 0, 1, 1) + _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) + self._rx_gain_text_box = forms.text_box( + parent=self.GetWin(), + sizer=_rx_gain_sizer, + value=self.rx_gain, + callback=self.set_rx_gain, + label="Analog Gain", + converter=forms.float_converter(), + proportion=0, + ) + self._rx_gain_slider = forms.slider( + parent=self.GetWin(), + sizer=_rx_gain_sizer, + value=self.rx_gain, + callback=self.set_rx_gain, + minimum=0, + maximum=100, + num_steps=100, + style=wx.SL_HORIZONTAL, + cast=float, + proportion=1, + ) + self.GridAdd(_rx_gain_sizer, 0, 4, 1, 1) + _offset_sizer = wx.BoxSizer(wx.VERTICAL) + self._offset_text_box = forms.text_box( + parent=self.GetWin(), + sizer=_offset_sizer, + value=self.offset, + callback=self.set_offset, + label="Freq. Offset", + converter=forms.float_converter(), + proportion=0, + ) + self._offset_slider = forms.slider( + parent=self.GetWin(), + sizer=_offset_sizer, + value=self.offset, + callback=self.set_offset, + minimum=-10e3, + maximum=10e3, + num_steps=100, + style=wx.SL_HORIZONTAL, + cast=float, + proportion=1, + ) + self.GridAdd(_offset_sizer, 0, 3, 1, 1) + self._freq_text_static_text = forms.static_text( + parent=self.GetWin(), + value=self.freq_text, + callback=self.set_freq_text, + label="Ch. Freq", + converter=forms.float_converter(), + ) + self.GridAdd(self._freq_text_static_text, 0, 2, 1, 1) + + ################################################## + # Blocks + ################################################## + self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(channel_decim, (channel_taps), band_freq-freq+offset, sample_rate) + self.usrp_source = grc_usrp.simple_source_c(which=0, side="A", rx_ant="RXA") + self.usrp_source.set_decim_rate(decim) + self.usrp_source.set_frequency(band_freq, verbose=True) + self.usrp_source.set_gain(rx_gain) + self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( + self.displays.GetPage(0).GetWin(), + baseband_freq=band_freq, + y_per_div=10, + y_divs=10, + ref_level=0, + ref_scale=65536, + sample_rate=sample_rate, + fft_size=1024, + fft_rate=30, + average=False, + avg_alpha=None, + title="FLEX Spectrum", + peak_hold=False, + ) + self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 1, 1) + self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( + self.displays.GetPage(0).GetWin(), + baseband_freq=freq, + y_per_div=10, + y_divs=10, + ref_level=0, + ref_scale=65536, + sample_rate=channel_rate, + fft_size=1024, + fft_rate=30, + average=False, + avg_alpha=None, + title="Channel Spectrum", + peak_hold=False, + ) + self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_1.win, 1, 0, 1, 1) + self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( + self.displays.GetPage(1).GetWin(), + title="Baseband Waveform", + sample_rate=channel_rate, + v_scale=1e3, + t_scale=20.0/channel_rate, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.displays.GetPage(1).GridAdd(self.wxgui_scopesink2_0.win, 0, 0, 1, 1) + + ################################################## + # Connections + ################################################## + self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_1, 0)) + self.connect((self.usrp_source, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) + self.connect((self.usrp_source, 0), (self.wxgui_fftsink2_0, 0)) + self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0)) + + def set_config_filename(self, config_filename): + self.config_filename = config_filename + self._saved_band_freq_config = ConfigParser.ConfigParser() + self._saved_band_freq_config.read(self.config_filename) + if not self._saved_band_freq_config.has_section("gr-pager"): + self._saved_band_freq_config.add_section("gr-pager") + self._saved_band_freq_config.set("gr-pager", "band_center", str(self.band_freq)) + self._saved_band_freq_config.write(open(self.config_filename, 'w')) + self._saved_channel_config = ConfigParser.ConfigParser() + self._saved_channel_config.read(self.config_filename) + if not self._saved_channel_config.has_section("gr-pager"): + self._saved_channel_config.add_section("gr-pager") + self._saved_channel_config.set("gr-pager", "channel", str(self.channel)) + self._saved_channel_config.write(open(self.config_filename, 'w')) + self._saved_offset_config = ConfigParser.ConfigParser() + self._saved_offset_config.read(self.config_filename) + if not self._saved_offset_config.has_section("gr-pager"): + self._saved_offset_config.add_section("gr-pager") + self._saved_offset_config.set("gr-pager", "freq_offset", str(self.offset)) + self._saved_offset_config.write(open(self.config_filename, 'w')) + self._saved_rx_gain_config = ConfigParser.ConfigParser() + self._saved_rx_gain_config.read(self.config_filename) + if not self._saved_rx_gain_config.has_section("gr-pager"): + self._saved_rx_gain_config.add_section("gr-pager") + self._saved_rx_gain_config.set("gr-pager", "rx_gain", str(self.rx_gain)) + self._saved_rx_gain_config.write(open(self.config_filename, 'w')) + + def set_saved_channel(self, saved_channel): + self.saved_channel = saved_channel + self.set_channel(self.saved_channel) + + def set_saved_band_freq(self, saved_band_freq): + self.saved_band_freq = saved_band_freq + self.set_band_freq(self.saved_band_freq) + + def set_decim(self, decim): + self.decim = decim + self.set_sample_rate(self.adc_rate/self.decim) + self.usrp_source.set_decim_rate(self.decim) + + def set_channel(self, channel): + self.channel = channel + self.set_freq(self.band_freq+(self.channel-61)*25e3) + self._saved_channel_config = ConfigParser.ConfigParser() + self._saved_channel_config.read(self.config_filename) + if not self._saved_channel_config.has_section("gr-pager"): + self._saved_channel_config.add_section("gr-pager") + self._saved_channel_config.set("gr-pager", "channel", str(self.channel)) + self._saved_channel_config.write(open(self.config_filename, 'w')) + self._channel_slider.set_value(self.channel) + self._channel_text_box.set_value(self.channel) + + def set_band_freq(self, band_freq): + self.band_freq = band_freq + self.set_freq(self.band_freq+(self.channel-61)*25e3) + self.wxgui_fftsink2_0.set_baseband_freq(self.band_freq) + self.usrp_source.set_frequency(self.band_freq) + self._saved_band_freq_config = ConfigParser.ConfigParser() + self._saved_band_freq_config.read(self.config_filename) + if not self._saved_band_freq_config.has_section("gr-pager"): + self._saved_band_freq_config.add_section("gr-pager") + self._saved_band_freq_config.set("gr-pager", "band_center", str(self.band_freq)) + self._saved_band_freq_config.write(open(self.config_filename, 'w')) + self.gr_freq_xlating_fir_filter_xxx_0.set_center_freq(self.band_freq-self.freq+self.offset) + self._band_freq_text_box.set_value(self.band_freq) + + def set_adc_rate(self, adc_rate): + self.adc_rate = adc_rate + self.set_sample_rate(self.adc_rate/self.decim) + + def set_saved_rx_gain(self, saved_rx_gain): + self.saved_rx_gain = saved_rx_gain + self.set_rx_gain(self.saved_rx_gain) + + def set_saved_offset(self, saved_offset): + self.saved_offset = saved_offset + self.set_offset(self.saved_offset) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_channel_decim(int(self.sample_rate/self.channel_rate)) + self.set_channel_taps(firdes.low_pass(10**1, self.sample_rate, 10e3, 2.5e3)) + self.wxgui_fftsink2_0.set_sample_rate(self.sample_rate) + + def set_freq(self, freq): + self.freq = freq + self.wxgui_fftsink2_1.set_baseband_freq(self.freq) + self.gr_freq_xlating_fir_filter_xxx_0.set_center_freq(self.band_freq-self.freq+self.offset) + self.set_freq_text(self.freq) + + def set_channel_rate(self, channel_rate): + self.channel_rate = channel_rate + self.set_channel_decim(int(self.sample_rate/self.channel_rate)) + self.wxgui_fftsink2_1.set_sample_rate(self.channel_rate) + self.wxgui_scopesink2_0.set_sample_rate(self.channel_rate) + + def set_rx_gain(self, rx_gain): + self.rx_gain = rx_gain + self.usrp_source.set_gain(self.rx_gain) + self._saved_rx_gain_config = ConfigParser.ConfigParser() + self._saved_rx_gain_config.read(self.config_filename) + if not self._saved_rx_gain_config.has_section("gr-pager"): + self._saved_rx_gain_config.add_section("gr-pager") + self._saved_rx_gain_config.set("gr-pager", "rx_gain", str(self.rx_gain)) + self._saved_rx_gain_config.write(open(self.config_filename, 'w')) + self._rx_gain_slider.set_value(self.rx_gain) + self._rx_gain_text_box.set_value(self.rx_gain) + + def set_offset(self, offset): + self.offset = offset + self._saved_offset_config = ConfigParser.ConfigParser() + self._saved_offset_config.read(self.config_filename) + if not self._saved_offset_config.has_section("gr-pager"): + self._saved_offset_config.add_section("gr-pager") + self._saved_offset_config.set("gr-pager", "freq_offset", str(self.offset)) + self._saved_offset_config.write(open(self.config_filename, 'w')) + self.gr_freq_xlating_fir_filter_xxx_0.set_center_freq(self.band_freq-self.freq+self.offset) + self._offset_slider.set_value(self.offset) + self._offset_text_box.set_value(self.offset) + + def set_freq_text(self, freq_text): + self.freq_text = freq_text + self._freq_text_static_text.set_value(self.freq_text) + + def set_channel_taps(self, channel_taps): + self.channel_taps = channel_taps + self.gr_freq_xlating_fir_filter_xxx_0.set_taps((self.channel_taps)) + + def set_channel_decim(self, channel_decim): + self.channel_decim = channel_decim + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = usrp_rx_flex() + tb.Run(True) + |