diff options
Diffstat (limited to 'gnuradio-examples/python/usrp2')
-rw-r--r-- | gnuradio-examples/python/usrp2/.gitignore | 2 | ||||
-rw-r--r-- | gnuradio-examples/python/usrp2/Makefile.am | 32 | ||||
-rw-r--r-- | gnuradio-examples/python/usrp2/qt_wfm_interface.py | 99 | ||||
-rw-r--r-- | gnuradio-examples/python/usrp2/qt_wfm_interface.ui | 253 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp2/usrp2_wfm_qt.py | 355 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp2/usrp2_wfm_rcv.py | 289 |
6 files changed, 0 insertions, 1030 deletions
diff --git a/gnuradio-examples/python/usrp2/.gitignore b/gnuradio-examples/python/usrp2/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/python/usrp2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/python/usrp2/Makefile.am b/gnuradio-examples/python/usrp2/Makefile.am deleted file mode 100644 index cca813349..000000000 --- a/gnuradio-examples/python/usrp2/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2004,2005,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)/usrp2 -dist_ourdata_DATA = \ - qt_wfm_interface.ui \ - qt_wfm_interface.py - - -dist_ourdata_SCRIPTS = \ - usrp2_wfm_qt.py \ - usrp2_wfm_rcv.py diff --git a/gnuradio-examples/python/usrp2/qt_wfm_interface.py b/gnuradio-examples/python/usrp2/qt_wfm_interface.py deleted file mode 100644 index 4c4367ed0..000000000 --- a/gnuradio-examples/python/usrp2/qt_wfm_interface.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'qt_wfm_interface.ui' -# -# Created: Thu Jun 18 23:41:03 2009 -# by: PyQt4 UI code generator 4.4.3 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_InterfaceWindow(object): - def setupUi(self, InterfaceWindow): - InterfaceWindow.setObjectName("InterfaceWindow") - InterfaceWindow.resize(909, 711) - self.centralwidget = QtGui.QWidget(InterfaceWindow) - self.centralwidget.setObjectName("centralwidget") - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setGeometry(QtCore.QRect(790, 580, 101, 31)) - self.closeButton.setObjectName("closeButton") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - self.sinkFrame.setGeometry(QtCore.QRect(10, 10, 891, 501)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayoutWidget = QtGui.QWidget(self.sinkFrame) - self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 871, 481)) - self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") - self.sinkLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget) - self.sinkLayout.setObjectName("sinkLayout") - self.channelModeBox = QtGui.QGroupBox(self.centralwidget) - self.channelModeBox.setGeometry(QtCore.QRect(10, 520, 261, 131)) - self.channelModeBox.setObjectName("channelModeBox") - self.bandwidthabel = QtGui.QLabel(self.channelModeBox) - self.bandwidthabel.setGeometry(QtCore.QRect(10, 90, 101, 17)) - self.bandwidthabel.setObjectName("bandwidthabel") - self.bandwidthEdit = QtGui.QLineEdit(self.channelModeBox) - self.bandwidthEdit.setGeometry(QtCore.QRect(130, 90, 113, 23)) - self.bandwidthEdit.setObjectName("bandwidthEdit") - self.gainEdit = QtGui.QLineEdit(self.channelModeBox) - self.gainEdit.setGeometry(QtCore.QRect(130, 60, 113, 23)) - self.gainEdit.setObjectName("gainEdit") - self.gainLabel = QtGui.QLabel(self.channelModeBox) - self.gainLabel.setGeometry(QtCore.QRect(10, 60, 111, 20)) - self.gainLabel.setObjectName("gainLabel") - self.freqEdit = QtGui.QLineEdit(self.channelModeBox) - self.freqEdit.setGeometry(QtCore.QRect(130, 30, 113, 23)) - self.freqEdit.setObjectName("freqEdit") - self.freqLabel = QtGui.QLabel(self.channelModeBox) - self.freqLabel.setGeometry(QtCore.QRect(10, 30, 111, 17)) - self.freqLabel.setObjectName("freqLabel") - self.pauseButton = QtGui.QPushButton(self.centralwidget) - self.pauseButton.setGeometry(QtCore.QRect(790, 520, 101, 31)) - self.pauseButton.setObjectName("pauseButton") - self.fmBox = QtGui.QGroupBox(self.centralwidget) - self.fmBox.setGeometry(QtCore.QRect(290, 520, 251, 131)) - self.fmBox.setObjectName("fmBox") - self.volumeEdit = QtGui.QLineEdit(self.fmBox) - self.volumeEdit.setGeometry(QtCore.QRect(130, 20, 113, 23)) - self.volumeEdit.setObjectName("volumeEdit") - self.volumeLabel = QtGui.QLabel(self.fmBox) - self.volumeLabel.setGeometry(QtCore.QRect(10, 20, 111, 17)) - self.volumeLabel.setObjectName("volumeLabel") - InterfaceWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(InterfaceWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 909, 24)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - InterfaceWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(InterfaceWindow) - self.statusbar.setObjectName("statusbar") - InterfaceWindow.setStatusBar(self.statusbar) - self.actionExit = QtGui.QAction(InterfaceWindow) - self.actionExit.setObjectName("actionExit") - self.menuFile.addAction(self.actionExit) - self.menubar.addAction(self.menuFile.menuAction()) - - self.retranslateUi(InterfaceWindow) - QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), InterfaceWindow.close) - QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), InterfaceWindow.close) - QtCore.QMetaObject.connectSlotsByName(InterfaceWindow) - InterfaceWindow.setTabOrder(self.closeButton, self.gainEdit) - InterfaceWindow.setTabOrder(self.gainEdit, self.freqEdit) - InterfaceWindow.setTabOrder(self.freqEdit, self.bandwidthEdit) - - def retranslateUi(self, InterfaceWindow): - InterfaceWindow.setWindowTitle(QtGui.QApplication.translate("InterfaceWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("InterfaceWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.channelModeBox.setTitle(QtGui.QApplication.translate("InterfaceWindow", "USRP Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.bandwidthabel.setText(QtGui.QApplication.translate("InterfaceWindow", "Bandwidth (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.gainLabel.setText(QtGui.QApplication.translate("InterfaceWindow", "Gain (dB)", None, QtGui.QApplication.UnicodeUTF8)) - self.freqLabel.setText(QtGui.QApplication.translate("InterfaceWindow", "Frequency", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("InterfaceWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.fmBox.setTitle(QtGui.QApplication.translate("InterfaceWindow", "FM Tuner Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.volumeLabel.setText(QtGui.QApplication.translate("InterfaceWindow", "Volume", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("InterfaceWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("InterfaceWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/gnuradio-examples/python/usrp2/qt_wfm_interface.ui b/gnuradio-examples/python/usrp2/qt_wfm_interface.ui deleted file mode 100644 index 16902d9f4..000000000 --- a/gnuradio-examples/python/usrp2/qt_wfm_interface.ui +++ /dev/null @@ -1,253 +0,0 @@ -<ui version="4.0" > - <class>InterfaceWindow</class> - <widget class="QMainWindow" name="InterfaceWindow" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>909</width> - <height>711</height> - </rect> - </property> - <property name="windowTitle" > - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget" > - <widget class="QPushButton" name="closeButton" > - <property name="geometry" > - <rect> - <x>790</x> - <y>580</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="text" > - <string>Close</string> - </property> - </widget> - <widget class="QFrame" name="sinkFrame" > - <property name="geometry" > - <rect> - <x>10</x> - <y>10</y> - <width>891</width> - <height>501</height> - </rect> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <widget class="QWidget" name="horizontalLayoutWidget" > - <property name="geometry" > - <rect> - <x>10</x> - <y>10</y> - <width>871</width> - <height>481</height> - </rect> - </property> - <layout class="QHBoxLayout" name="sinkLayout" /> - </widget> - </widget> - <widget class="QGroupBox" name="channelModeBox" > - <property name="geometry" > - <rect> - <x>10</x> - <y>520</y> - <width>261</width> - <height>131</height> - </rect> - </property> - <property name="title" > - <string>USRP Parameters</string> - </property> - <widget class="QLabel" name="bandwidthabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>90</y> - <width>101</width> - <height>17</height> - </rect> - </property> - <property name="text" > - <string>Bandwidth (Hz)</string> - </property> - </widget> - <widget class="QLineEdit" name="bandwidthEdit" > - <property name="geometry" > - <rect> - <x>130</x> - <y>90</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLineEdit" name="gainEdit" > - <property name="geometry" > - <rect> - <x>130</x> - <y>60</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="gainLabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>60</y> - <width>111</width> - <height>20</height> - </rect> - </property> - <property name="text" > - <string>Gain (dB)</string> - </property> - </widget> - <widget class="QLineEdit" name="freqEdit" > - <property name="geometry" > - <rect> - <x>130</x> - <y>30</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="freqLabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>30</y> - <width>111</width> - <height>17</height> - </rect> - </property> - <property name="text" > - <string>Frequency</string> - </property> - </widget> - </widget> - <widget class="QPushButton" name="pauseButton" > - <property name="geometry" > - <rect> - <x>790</x> - <y>520</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="text" > - <string>Pause</string> - </property> - </widget> - <widget class="QGroupBox" name="fmBox" > - <property name="geometry" > - <rect> - <x>290</x> - <y>520</y> - <width>251</width> - <height>131</height> - </rect> - </property> - <property name="title" > - <string>FM Tuner Parameters</string> - </property> - <widget class="QLineEdit" name="volumeEdit" > - <property name="geometry" > - <rect> - <x>130</x> - <y>20</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="volumeLabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>20</y> - <width>111</width> - <height>17</height> - </rect> - </property> - <property name="text" > - <string>Volume</string> - </property> - </widget> - </widget> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>909</width> - <height>24</height> - </rect> - </property> - <widget class="QMenu" name="menuFile" > - <property name="title" > - <string>&File</string> - </property> - <addaction name="actionExit" /> - </widget> - <addaction name="menuFile" /> - </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="actionExit" > - <property name="text" > - <string>E&xit</string> - </property> - </action> - </widget> - <tabstops> - <tabstop>closeButton</tabstop> - <tabstop>gainEdit</tabstop> - <tabstop>freqEdit</tabstop> - <tabstop>bandwidthEdit</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>closeButton</sender> - <signal>clicked()</signal> - <receiver>InterfaceWindow</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel" > - <x>322</x> - <y>623</y> - </hint> - <hint type="destinationlabel" > - <x>66</x> - <y>561</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionExit</sender> - <signal>triggered()</signal> - <receiver>InterfaceWindow</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel" > - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel" > - <x>617</x> - <y>327</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py b/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py deleted file mode 100755 index 0c7476921..000000000 --- a/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py +++ /dev/null @@ -1,355 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007,2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, eng_notation, optfir -from gnuradio import audio -from gnuradio import usrp2 -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys -import math - - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from qt_wfm_interface import Ui_InterfaceWindow -except ImportError: - print "Error: could not find qt_wfm_interface.py:" - print "\tPlease run: \"pyuic4 qt_wfm_interface.ui -o qt_wfm_interface.py\"" - sys.exit(1) - -print "This program is not in a proper working state. Comment this out if you want to play." -sys.exit(1) - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class dialog_box(QtGui.QMainWindow): - def __init__(self, snk_usrp, snk_vol, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_InterfaceWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Set USRP parameters - self.set_bw(self.fg.usrp_bw()) - self.set_freq(self.fg.freq()) - self.set_gain(self.fg.gain()) - self.set_volume(self.fg.volume()) - - # Add the qtsnk widgets to the hlayout box - self.gui.sinkLayout.addWidget(snk_usrp) - self.gui.sinkLayout.addWidget(snk_vol) - - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bwEditText) - self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"), - self.freqEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - - self.connect(self.gui.volumeEdit, QtCore.SIGNAL("editingFinished()"), - self.volumeEditText) - - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.gui.pauseButton.setText("Pause") - - - # Accessor functions for Gui to manipulate USRP - def set_bw(self, bw): - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(bw)) - - def set_freq(self, freq): - self.gui.freqEdit.setText(QtCore.QString("%1").arg(freq)) - - def set_gain(self, gain): - self.gui.gainEdit.setText(QtCore.QString("%1").arg(gain)) - - def set_volume(self, vol): - self.gui.volumeEdit.setText(QtCore.QString("%1").arg(vol)) - - def bwEditText(self): - try: - bw = self.gui.bandwidthEdit.text().toDouble()[0] - self.fg.set_usrp_bw(bw) - except RuntimeError: - pass - - def freqEditText(self): - try: - freq = self.gui.freqEdit.text().toDouble()[0] - self.fg.set_freq(freq) - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = self.gui.gainEdit.text().toDouble()[0] - self.fg.set_gain(gain) - except RuntimeError: - pass - - def volumeEditText(self): - try: - vol = self.gui.volumeEdit.text().toDouble()[0] - self.fg.set_volume(vol) - except RuntimeError: - pass - - - - -# //////////////////////////////////////////////////////////////////// -# Define the GNU Radio Top Block -# //////////////////////////////////////////////////////////////////// - - -class wfm_rx_block (gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - #parser.add_option("-A", "--antenna", default=None, - # help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-f", "--freq", type="eng_float", default=100.1, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self._volume = options.volume - self._usrp_freq = options.freq - self._usrp_gain = options.gain - self._audio_rate = int(32e3) - - # build graph - - self.u = usrp2.source_32fc(options.interface, options.mac_addr) - - # calculate decimation values to get USRP BW at 320 kHz - self.calculate_usrp_bw(320e3) - - self.set_decim(self._usrp_decim) - - #FIXME: need named constants and text descriptions available to (gr-)usrp2 even - #when usrp(1) module is not built. A usrp_common module, perhaps? - dbid = self.u.daughterboard_id() - print "Using RX d'board 0x%04X" % (dbid,) - #if not (dbid == 0x0001 or #usrp_dbid.BASIC_RX - # dbid == 0x0003 or #usrp_dbid.TV_RX - # dbid == 0x000c or #usrp_dbid.TV_RX_REV_2 - # dbid == 0x0040 or #usrp_dbid.TV_RX_REV_3 - # dbid == 0x0043 or #usrp_dbid.TV_RX_MIMO - # dbid == 0x0044 or #usrp_dbid.TV_RX_REV_2_MIMO - # dbid == 0x0045 ): #usrp_dbid.TV_RX_REV_3_MIMO - # print "This daughterboard does not cover the required frequency range" - # print "for this application. Please use a BasicRX or TVRX daughterboard." - # raw_input("Press ENTER to continue anyway, or Ctrl-C to exit.") - - chan_filt_coeffs = optfir.low_pass (1, # gain - self._usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - #print len(chan_filt_coeffs) - chan_filt = gr.fir_filter_ccf (self._chanfilt_decim, chan_filt_coeffs) - - self.guts = blks2.wfm_rcv (self._demod_rate, self._audio_decim) - - self.volume_control = gr.multiply_const_ff(1) - - # sound card as final sink - #audio_sink = audio.sink (int (audio_rate), - # options.audio_output, - # False) # ok_to_block - audio_sink = audio.sink (self._audio_rate, - options.audio_output) - - - if self._usrp_gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.gain_range() - print "Gain range: ", g - self._usrp_gain = float(g[0]+g[1])/2 - - if self._volume is None: - g = self.volume_range() - self._volume = float(g[0]+g[1])/2 - - if abs(self._usrp_freq) < 1e6: - self._usrp_freq *= 1e6 - - # set initial values - self.set_gain(self._usrp_gain) - self.set_volume(self._volume) - if not(self.set_freq(self._usrp_freq)): - print ("Failed to set initial frequency") - - - # Define a GUI sink to display the received signal - self.qapp = QtGui.QApplication(sys.argv) - fftsize = 2048 - - self.usrp_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - -self._usrp_rate/2.0, self._usrp_rate/2.0, - "Received Signal", True, True, False, True, False, - use_openGL=False) - self.usrp_rx2 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - -self._usrp_rate/2.0, self._usrp_rate/2.0, - "Received Signal", True, True, False, True, False) - - # now wire it all together - self.connect (self.u, chan_filt, self.guts, self.volume_control, audio_sink) - self.connect (self.u, self.usrp_rx) - self.connect (self.volume_control, self.usrp_rx2) - - usrp_rx_widget = sip.wrapinstance(self.usrp_rx.pyqwidget(), QtGui.QWidget) - usrp_rx2_widget = sip.wrapinstance(self.usrp_rx2.pyqwidget(), QtGui.QWidget) - - self.main_box = dialog_box(usrp_rx_widget, usrp_rx2_widget, self) - self.main_box.show() - - - def calculate_usrp_bw(self, bw): - """ - Calculate the different decimation rates that make the USRP BW equal to the - input bandwidth parameter 'bw' and the audio bandwidth equal to the system- - wide bandwidth 'self._audio_rate' - """ - - adc_rate = self.u.adc_rate() - d_usrp = int(adc_rate/bw) - bw_real = adc_rate / float(d_usrp) - - d_chan = 1 - demod_rate = bw_real / d_chan - - d_audio = int(bw_real / self._audio_rate) - audio_rate = demod_rate / d_audio - - self._usrp_decim = d_usrp - self._chanfilt_decim = d_chan - self._audio_decim = d_audio - self._demod_rate = demod_rate - self._usrp_rate = bw_real - - print "USRP Decimation: ", self._usrp_decim - print "USRP Bandwidth: ", bw_real - print "Audio Decimation: ", self._audio_decim - print "Audio Bandwidth: ", audio_rate - - def set_volume (self, vol): - g = self.volume_range() - self._volume = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self._volume/10)) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - r = self.u.set_center_freq(target_freq) - if r: - self._usrp_freq = target_freq - return True - return False - - def set_usrp_bw(self, bw): - self.calculate_usrp_bw(bw) - - def set_gain(self, gain): - self._usrp_gain = gain - self.u.set_gain(gain) - - def set_decim(self, decim): - self._usrp_decim = int(decim) - self.u.set_decim(self._usrp_decim) - - def volume(self): - return self._volume - - def freq(self): - return self._usrp_freq - - def usrp_bw(self): - return self._usrp_rate - - def gain(self): - return self._usrp_gain - - def decim(self): - return self._usrp_decim - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - tb = wfm_rx_block() - tb.start() - tb.qapp.exec_() - diff --git a/gnuradio-examples/python/usrp2/usrp2_wfm_rcv.py b/gnuradio-examples/python/usrp2/usrp2_wfm_rcv.py deleted file mode 100755 index 2b94c458e..000000000 --- a/gnuradio-examples/python/usrp2/usrp2_wfm_rcv.py +++ /dev/null @@ -1,289 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007,2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, eng_notation, optfir -from gnuradio import audio -from gnuradio import usrp2 -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import math -import wx - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - #parser.add_option("-A", "--antenna", default=None, - # help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-f", "--freq", type="eng_float", default=100.1, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - # build graph - - self.u = usrp2.source_32fc(options.interface, options.mac_addr) - - adc_rate = self.u.adc_rate() # 100 MS/s - usrp_decim = 312 - self.u.set_decim(usrp_decim) - usrp_rate = adc_rate / usrp_decim # ~320 kS/s - chanfilt_decim = 1 - demod_rate = usrp_rate / chanfilt_decim - audio_decimation = 10 - audio_rate = demod_rate / audio_decimation # ~32 kHz - - #FIXME: need named constants and text descriptions available to (gr-)usrp2 even - #when usrp(1) module is not built. A usrp_common module, perhaps? - dbid = self.u.daughterboard_id() - print "Using RX d'board 0x%04X" % (dbid,) - if not (dbid == 0x0001 or #usrp_dbid.BASIC_RX - dbid == 0x0003 or #usrp_dbid.TV_RX - dbid == 0x000c or #usrp_dbid.TV_RX_REV_2 - dbid == 0x0040 or #usrp_dbid.TV_RX_REV_3 - dbid == 0x0043 or #usrp_dbid.TV_RX_MIMO - dbid == 0x0044 or #usrp_dbid.TV_RX_REV_2_MIMO - dbid == 0x0045 or #usrp_dbid.TV_RX_REV_3_MIMO - dbid == 0x0053 ): #usrp_dbid.WBX - print "This daughterboard does not cover the required frequency range" - print "for this application. Please use a BasicRX or TVRX daughterboard." - raw_input("Press ENTER to continue anyway, or Ctrl-C to exit.") - - chan_filt_coeffs = optfir.low_pass (1, # gain - usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - #print len(chan_filt_coeffs) - chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - - self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) - - self.volume_control = gr.multiply_const_ff(self.vol) - - # sound card as final sink - audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, chan_filt, self.guts, self.volume_control, audio_sink) - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.gain_range() - options.gain = float(g[0]+g[1])/2 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - if abs(options.freq) < 1e6: - options.freq *= 1e6 - - # set initial values - - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP2", - fft_size=512, sample_rate=usrp_rate, - ref_scale=1.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", - fft_size=1024, sample_rate=usrp_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.fm_demod, post_filt_fft) - vbox.Add (post_filt_fft.win, 4, wx.EXPAND) - - if 0: - post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.deemph, post_deemph_fft) - vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(87.9e6, 108.1e6, 0.1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=self.u.gain_range(), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - pass - #print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - r = self.u.set_center_freq(target_freq) - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "USRP2 WFM RX") - app.MainLoop () |