📄 hfx2.py
字号:
#!/usr/bin/env python# -*- coding: ANSI_X3.4-1968 -*-# generated by wxGlade 0.4 on Tue Mar 14 10:16:06 2006## Copyright 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.##-----------------------------------------------------------------## +-->(fft)# |# (src)->(xlate)--+->(audio filter)--+-->(sel_am)-+--------------+# | | |# | (pll) |# | | |# | (pll_carrier_scale) |# | | |# | (pll_carrier_filter) |# | | |# | +--(fft2) |# | | |# | +--(c2f3)--+ |# | | | |# | (phaser1) (phaser2) |# | | | |# | +--(f2c)---+ |# | | V# V +---------->(am_det)# (c2f) |# | (c2f2)# | |# +-->(sel_sb)------------>(combine)# |# V# +--------------------------(scale)# | |# | |# | +++# V | |# (agc)<--(offset)<--(intr)<---(sqr1)# |# V# (dst)# #----------------------------------------------------------------------## Versions 2.2.1 adds loop antenna automatic tuner## 2.3.1 adds web control, made AM Sync display optional,# 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.# Web server control disabled by default. Do not enable# until directory structure and scripts are in place.WEB_CONTROL = False# Controls display of AM Sync Carrier - turn off for smaller# window if not neededAM_SYNC_DISPLAY = Falseimport os, wx, sys, mathimport wx.lib.evtmgr as emfrom gnuradio.wxgui import powermate, fftsink2from gnuradio import gr, audio, eng_notation, usrp, grufrom gnuradio.eng_option import eng_optionfrom optparse import OptionParserID_BUTTON_1 = wx.NewId() # LSB buttonID_BUTTON_2 = wx.NewId() # USBID_BUTTON_3 = wx.NewId() # AMID_BUTTON_4 = wx.NewId() # CWID_BUTTON_5 = wx.NewId() # Powermate controls: Upper audio freq cutoffID_BUTTON_6 = wx.NewId() # " Lower audio freq cutoffID_BUTTON_7 = wx.NewId() # " Frequency ID_BUTTON_8 = wx.NewId() # " VolumeID_BUTTON_9 = wx.NewId() # " TimeID_BUTTON_10 = wx.NewId() # Time Seek ForwardsID_BUTTON_11 = wx.NewId() # Time Seek BackwardsID_BUTTON_12 = wx.NewId() # Automatic Antenna Tune (AT) enableID_BUTTON_13 = wx.NewId() # AT Calibrate pointID_BUTTON_14 = wx.NewId() # AT ResetID_TEXT_1 = wx.NewId() # Band Center, USRP ddc FreqID_SPIN_1 = wx.NewId() # Frequency display and controlID_SLIDER_1 = wx.NewId() # Upper audio freq cutoffID_SLIDER_2 = wx.NewId() # Lower audio freq cutoffID_SLIDER_3 = wx.NewId() # Frequency ID_SLIDER_4 = wx.NewId() # VolumeID_SLIDER_5 = wx.NewId() # Programmable Gain Amp, PGA, RF gainID_SLIDER_6 = wx.NewId() # AM Sync carrier levelID_SLIDER_7 = wx.NewId() # AT control voltage outputID_EXIT = wx.NewId() # Menu Exitdef 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 MyFrame(wx.Frame): def __init__(self, *args, **kwds): # 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) wxglade_tmp_menu = wx.Menu() self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit", "Exit", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendItem(self.Exit) self.frame_1_menubar.Append(wxglade_tmp_menu, "File") # Menu Bar end self.panel_1 = wx.Panel(self, -1) self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB") self.button_2 = wx.Button(self, ID_BUTTON_2, "USB") self.button_3 = wx.Button(self, ID_BUTTON_3, "AM") self.button_4 = wx.Button(self, ID_BUTTON_4, "CW") self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper") self.slider_1 = wx.Slider(self, ID_SLIDER_1, 0, -15799, 15799, style=wx.SL_HORIZONTAL|wx.SL_LABELS) self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower") self.slider_2 = wx.Slider(self, ID_SLIDER_2, 0, -15799, 15799, style=wx.SL_HORIZONTAL|wx.SL_LABELS) self.panel_5 = wx.Panel(self, -1) self.label_1 = wx.StaticText(self, -1, " Band\nCenter") self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "") self.panel_6 = wx.Panel(self, -1) self.panel_7 = wx.Panel(self, -1) self.panel_2 = wx.Panel(self, -1) self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq") self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000) self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100) self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol") self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500) self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20) self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time") self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew") self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd") self.panel_3 = wx.Panel(self, -1) self.label_2 = wx.StaticText(self, -1, "PGA ") self.panel_4 = wx.Panel(self, -1) self.panel_8 = wx.Panel(self, -1) self.panel_9 = wx.Panel(self, -1) self.label_3 = wx.StaticText(self, -1, "AM Sync\nCarrier") self.slider_6 = wx.Slider(self, ID_SLIDER_6, 50, 0, 200, style=wx.SL_HORIZONTAL|wx.SL_LABELS) self.label_4 = wx.StaticText(self, -1, "Antenna Tune") self.slider_7 = wx.Slider(self, ID_SLIDER_7, 1575, 950, 2200, style=wx.SL_HORIZONTAL|wx.SL_LABELS) self.panel_10 = wx.Panel(self, -1) self.button_12 = wx.ToggleButton(self, ID_BUTTON_12, "Auto Tune") self.button_13 = wx.Button(self, ID_BUTTON_13, "Calibrate") self.button_14 = wx.Button(self, ID_BUTTON_14, "Reset") self.panel_11 = wx.Panel(self, -1) self.panel_12 = wx.Panel(self, -1) self.__set_properties() self.__do_layout() # end wxGlade parser = OptionParser (option_class=eng_option) parser.add_option ("-c", "--ddc-freq", type="eng_float", default=3.9e6, help="set Rx DDC frequency to FREQ", metavar="FREQ") parser.add_option ("-a", "--audio_file", default="", help="audio output file", metavar="FILE") parser.add_option ("-r", "--radio_file", default="", help="radio output file", metavar="FILE") parser.add_option ("-i", "--input_file", default="", help="radio input file", metavar="FILE") parser.add_option ("-d", "--decim", type="int", default=250, help="USRP decimation") 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)") (options, args) = parser.parse_args () self.usrp_center = options.ddc_freq usb_rate = 64e6 / options.decim self.slider_range = usb_rate * 0.9375 self.f_lo = self.usrp_center - (self.slider_range/2) self.f_hi = self.usrp_center + (self.slider_range/2) self.af_sample_rate = 32000 fir_decim = long (usb_rate / self.af_sample_rate) # data point arrays for antenna tuner self.xdata = [] self.ydata = [] self.tb = gr.top_block() # radio variables, initial conditions self.frequency = self.usrp_center # these map the frequency slider (0-6000) to the actual range self.f_slider_offset = self.f_lo self.f_slider_scale = 10000/options.decim 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.AM_mode = False self.slider_3.SetValue((self.frequency-self.f_slider_offset)/self.f_slider_scale) self.spin_ctrl_1.SetValue(int(self.frequency)) POWERMATE = True try: self.pm = powermate.powermate(self) except: sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n") POWERMATE = False if POWERMATE: powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate) powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton) self.active_button = 7 # command line options if options.audio_file == "": SAVE_AUDIO_TO_FILE = False else: SAVE_AUDIO_TO_FILE = True if options.radio_file == "": SAVE_RADIO_TO_FILE = False else: SAVE_RADIO_TO_FILE = True if options.input_file == "": self.PLAY_FROM_USRP = True else: self.PLAY_FROM_USRP = False if self.PLAY_FROM_USRP: self.src = usrp.source_s(decim_rate=options.decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.src) self.src.set_mux(usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) self.src.tune(0, self.subdev, self.usrp_center) self.tune_offset = 0 # -self.usrp_center - self.src.rx_freq(0) else: self.src = gr.file_source (gr.sizeof_short,options.input_file) self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band # save radio data to a file if SAVE_RADIO_TO_FILE: file = gr.file_sink(gr.sizeof_short, options.radio_file) self.tb.connect (self.src, file) # 2nd DDC xlate_taps = gr.firdes.low_pass ( \ 1.0, usb_rate, 16e3, 4e3, gr.firdes.WIN_HAMMING ) self.xlate = gr.freq_xlating_fir_filter_ccf ( \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -