#!/usr/bin/env python ################################################## # Gnuradio Python Flow Graph # Title: Uhd Test Tx # Generated: Tue Jun 15 14:26:18 2010 ################################################## from gnuradio import eng_notation from gnuradio import gr from gnuradio import uhd from gnuradio.eng_option import eng_option from gnuradio.gr import firdes from gnuradio.wxgui import forms from grc_gnuradio import wxgui as grc_wxgui from optparse import OptionParser import wx class uhd_test_tx(grc_wxgui.top_block_gui): def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Uhd Test Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.interpolation = interpolation = 16 self.tx_samp_rate = tx_samp_rate = 1e8/interpolation self.tx_gain = tx_gain = 0 self.tx_freq = tx_freq = 1.3e9 self.tx_bb_freq = tx_bb_freq = 1e6 self.tx_ant = tx_ant = "TX/RX" ################################################## # Controls ################################################## self._interpolation_text_box = forms.text_box( parent=self.GetWin(), value=self.interpolation, callback=self.set_interpolation, label='interpolation', converter=forms.int_converter(), ) self.Add(self._interpolation_text_box) _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_sizer, value=self.tx_gain, callback=self.set_tx_gain, label='tx_gain', converter=forms.float_converter(), proportion=0, ) self._tx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_sizer, value=self.tx_gain, callback=self.set_tx_gain, minimum=0, maximum=25, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) self._tx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label='tx_freq', converter=forms.float_converter(), ) self.Add(self._tx_freq_text_box) self._tx_bb_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.tx_bb_freq, callback=self.set_tx_bb_freq, label='tx_bb_freq', converter=forms.float_converter(), ) self.Add(self._tx_bb_freq_text_box) self._tx_ant_chooser = forms.drop_down( parent=self.GetWin(), value=self.tx_ant, callback=self.set_tx_ant, label='tx_ant', choices=["TX/RX"], labels=[], ) self.Add(self._tx_ant_chooser) ################################################## # Blocks ################################################## self.gr_sig_source_x_0 = gr.sig_source_c(tx_samp_rate, gr.GR_COS_WAVE, tx_bb_freq, 1.0, 0) self.uhd_simple_sink_0 = uhd.simple_sink("", uhd.io_type_t.COMPLEX_FLOAT32) self.uhd_simple_sink_0.set_samp_rate(tx_samp_rate) self.uhd_simple_sink_0.set_center_freq(tx_freq) self.uhd_simple_sink_0.set_gain(tx_gain) self.uhd_simple_sink_0.set_antenna(tx_ant) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.uhd_simple_sink_0, 0)) def set_interpolation(self, interpolation): self.interpolation = interpolation self.set_tx_samp_rate(1e8/self.interpolation) self._interpolation_text_box.set_value(self.interpolation) def set_tx_samp_rate(self, tx_samp_rate): self.tx_samp_rate = tx_samp_rate self.uhd_simple_sink_0.set_samp_rate(self.tx_samp_rate) self.gr_sig_source_x_0.set_sampling_freq(self.tx_samp_rate) def set_tx_gain(self, tx_gain): self.tx_gain = tx_gain self.uhd_simple_sink_0.set_gain(self.tx_gain) self._tx_gain_slider.set_value(self.tx_gain) self._tx_gain_text_box.set_value(self.tx_gain) def set_tx_freq(self, tx_freq): self.tx_freq = tx_freq self.uhd_simple_sink_0.set_center_freq(self.tx_freq) self._tx_freq_text_box.set_value(self.tx_freq) def set_tx_bb_freq(self, tx_bb_freq): self.tx_bb_freq = tx_bb_freq self._tx_bb_freq_text_box.set_value(self.tx_bb_freq) self.gr_sig_source_x_0.set_frequency(self.tx_bb_freq) def set_tx_ant(self, tx_ant): self.tx_ant = tx_ant self.uhd_simple_sink_0.set_antenna(self.tx_ant) self._tx_ant_chooser.set_value(self.tx_ant) if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") (options, args) = parser.parse_args() if gr.enable_realtime_scheduling() != gr.RT_OK: print "Error: failed to enable realtime scheduling." tb = uhd_test_tx() tb.Run(True)