def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.remove_head = remove_head = 0 ################################################## # Blocks ################################################## self._remove_head_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.remove_head, callback=self.set_remove_head, label="Remove Head", choices=[0,1], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._remove_head_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.gr_udp_source_0 = gr.udp_source(gr.sizeof_short*1, "192.168.2.200", 9997, 590, False, True) self.gr_short_to_float_0_0 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_short*1, "/home/cgardner/sandbox/gr-csg/gr-fp/grc_testfp/test_fp_odd.bin") self.gr_file_sink_0_1_0.set_unbuffered(True) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short*1, "/home/cgardner/sandbox/gr-csg/gr-fp/grc_testfp/test_raw_even.bin") self.gr_file_sink_0_1.set_unbuffered(True) self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_short*1) self.fpgnu_fpdata_sink_0 = fpgnu_swig.fpdata_sink(remove_head) ################################################## # Connections ################################################## self.connect((self.gr_udp_source_0, 0), (self.fpgnu_fpdata_sink_0, 0)) self.connect((self.gr_short_to_float_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_deinterleave_0, 1), (self.gr_file_sink_0_1_0, 0)) self.connect((self.fpgnu_fpdata_sink_0, 0), (self.gr_deinterleave_0, 0)) self.connect((self.gr_deinterleave_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_short_to_float_0_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.gr_deinterleave_0, 1), (self.gr_short_to_float_0_0, 0)) self.connect((self.gr_deinterleave_0, 0), (self.gr_short_to_float_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="AM Transmission") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 480000 self.vol = vol = 1 self.transmit_type = transmit_type = 1 self.taps_rx = taps_rx = firdes.band_pass(1.0, samp_rate, 120e3, 180e3, 2000, firdes.WIN_HAMMING, 6.76) self.source = source = 0 self.level_signal = level_signal = 0 self.level_carrier = level_carrier = 0.1 self.fft_taps = fft_taps = firdes.low_pass(1.0, samp_rate, 180e3, 5000, firdes.WIN_HAMMING, 6.76) self.audio_taps = audio_taps = firdes.low_pass(2, samp_rate, 10e3, 1000, firdes.WIN_HAMMING, 6.76) ################################################## # Blocks ################################################## _vol_sizer = wx.BoxSizer(wx.VERTICAL) self._vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, label='Volume', converter=forms.float_converter(), proportion=0, ) self._vol_slider = forms.slider( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, minimum=0, maximum=2, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vol_sizer, 0, 40, 1, 10) self._transmit_type_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.transmit_type, callback=self.set_transmit_type, label='Type', choices=[0, 1], labels=["SC", "TC"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._transmit_type_chooser, 0, 30, 1, 10) self.tabs = self.tabs = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.tabs.AddPage(grc_wxgui.Panel(self.tabs), "Audio") self.tabs.AddPage(grc_wxgui.Panel(self.tabs), "Signal") self.tabs.AddPage(grc_wxgui.Panel(self.tabs), "Spectrum") self.tabs.AddPage(grc_wxgui.Panel(self.tabs), "Trap") self.Add(self.tabs) self._source_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.source, callback=self.set_source, label='Source', choices=[0, 1], labels=['Tone', 'Audio'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._source_chooser, 0, 0, 1, 10) _level_signal_sizer = wx.BoxSizer(wx.VERTICAL) self._level_signal_text_box = forms.text_box( parent=self.GetWin(), sizer=_level_signal_sizer, value=self.level_signal, callback=self.set_level_signal, label='Signal', converter=forms.float_converter(), proportion=0, ) self._level_signal_slider = forms.slider( parent=self.GetWin(), sizer=_level_signal_sizer, value=self.level_signal, callback=self.set_level_signal, minimum=0, maximum=1, num_steps=10, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_level_signal_sizer, 0, 20, 1, 10) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.tabs.GetPage(3).GetWin(), title='Trapezoid', sample_rate=samp_rate, v_scale=0.5, v_offset=0, t_scale=4, ac_couple=True, xy_mode=True, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.tabs.GetPage(3).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.tabs.GetPage(0).GetWin(), title='Audio Source', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=5e-3, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Amplitude', ) self.tabs.GetPage(0).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.tabs.GetPage(1).GetWin(), title='Transmit Signal', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=5e-3, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_NORM, y_axis_label='Amplitude', ) self.tabs.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.tabs.GetPage(2).GetWin(), baseband_freq=150e3, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate / 8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Transmit Spectrum', peak_hold=False, ) self.tabs.GetPage(2).Add(self.wxgui_fftsink2_0.win) self.msg_tone = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 800, level_signal, 0) _level_carrier_sizer = wx.BoxSizer(wx.VERTICAL) self._level_carrier_text_box = forms.text_box( parent=self.GetWin(), sizer=_level_carrier_sizer, value=self.level_carrier, callback=self.set_level_carrier, label='Carrier', converter=forms.float_converter(), proportion=0, ) self._level_carrier_slider = forms.slider( parent=self.GetWin(), sizer=_level_carrier_sizer, value=self.level_carrier, callback=self.set_level_carrier, minimum=0, maximum=1, num_steps=10, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_level_carrier_sizer, 0, 10, 1, 10) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( 30, (audio_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc( 8, (fft_taps), 150e3, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fcc(2, (taps_rx)) self.fir_filter_xxx_0.declare_sample_delay(0) self.carrier = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 150000, level_carrier, 0) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/akio/chop_sample.wav', True) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( 'fading.wav', 1, 48000, 16) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((vol, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (level_signal * 35, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((transmit_type, )) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=2, num_outputs=1, input_index=source, output_index=0, ) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate / 2, audio_decim=5, audio_pass=10000, audio_stop=11000, ) ################################################## # Connections ################################################## self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.blks2_selector_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_scopesink2_2, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.msg_tone, 0), (self.blks2_selector_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ofdm Rx") ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 - 64 self.samp_rate = samp_rate = 10e6 self.gain = gain = 0 self.freq = freq = 5.825e9 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[10e6, 20e6], labels=["10 Mhz", "20 Mhz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.ieee802_1_ofdm_sync_short_0 = gr_ieee802_11.ofdm_sync_short(0.8, 80 * 80, 2, False) self.ieee802_1_ofdm_sync_long_0 = gr_ieee802_11.ofdm_sync_long(sync_length, 100, False) self.ieee802_1_ofdm_equalize_symbols_0 = gr_ieee802_11.ofdm_equalize_symbols(False) self.ieee802_1_ofdm_decode_signal_0 = gr_ieee802_11.ofdm_decode_signal(False) self.ieee802_1_ofdm_decode_mac_0 = gr_ieee802_11.ofdm_decode_mac(False) self.ieee802_11_ofdm_parse_mac_0 = gr_ieee802_11.ofdm_parse_mac(True) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.gr_socket_pdu_0 = gr.socket_pdu("UDP_SERVER", "", "12345", 10000) self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, 20000000) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_divide_xx_0 = gr.divide_ff(1) self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, sync_length) self.gr_delay_0 = gr.delay(gr.sizeof_gr_complex*1, 16) self.gr_conjugate_cc_0 = gr.conjugate_cc() self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(1, ([1]*window_size)) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1]*window_size)) self.fft_vxx_0 = fft.fft_vcc(64, True, (), True, 1) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.gr_skiphead_0, 0)) self.connect((self.gr_skiphead_0, 0), (self.gr_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.gr_skiphead_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_complex_to_mag_0, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.gr_complex_to_mag_0, 0)) self.connect((self.gr_skiphead_0, 0), (self.gr_delay_0, 0)) self.connect((self.gr_delay_0, 0), (self.gr_conjugate_cc_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_1_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_1_ofdm_equalize_symbols_0, 0), (self.ieee802_1_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_1_ofdm_decode_signal_0, 0), (self.ieee802_1_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.gr_delay_0_0, 0)) self.connect((self.gr_delay_0, 0), (self.ieee802_1_ofdm_sync_short_0, 0)) self.connect((self.gr_divide_xx_0, 0), (self.ieee802_1_ofdm_sync_short_0, 1)) self.connect((self.gr_delay_0_0, 0), (self.ieee802_1_ofdm_sync_long_0, 1)) self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.ieee802_1_ofdm_sync_long_0, 0)) self.connect((self.ieee802_1_ofdm_sync_long_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.ieee802_1_ofdm_decode_mac_0, "out", self.ieee802_11_ofdm_parse_mac_0, "in") self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "out", self.gr_socket_pdu_0, "pdus")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Only Power") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.lo_offset = lo_offset = 11e6 self.gain = gain = 20 self.freq = freq = 5.805e9 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "FFT") self.Add(self.nb) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_scopesink1 = scopesink2.scope_sink_c( self.nb.GetPage(0).GetWin(), title="Scope Plot", sample_rate=12500, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(0).Add(self.wxgui_scopesink1.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=580.5*10e6, y_per_div=10, y_divs=10, ref_level=gain, ref_scale=2.0, sample_rate=samp_rate, fft_size=64, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, True, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(True, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 64) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 48) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/furonics/GNURadio/25Feb2016DataTransfer.dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/furonics/GNURadio/11thFeb2016_AtHome.pcap", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="FM Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 0 self.tuner = tuner = 93.9e6 self.samp_rate = samp_rate = 2e6 self.rfgain = rfgain = 15 self.down_rate = down_rate = 250e3 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 1, 5, 1, 8) self._tuner_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.tuner, callback=self.set_tuner, label='Station Select', choices=[93.9e6, 91.5e6, 97.9e6, 93.1e6], labels=["Hip-Hop", "Classical", "Rock", "Country"], style=wx.RA_HORIZONTAL, ) self.Add(self._tuner_chooser) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label='RF Gain', converter=forms.int_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=10, maximum=70, num_steps=12, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rfgain_sizer, 1, 0, 1, 4) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=tuner, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='Sampling Bandpass', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(tuner, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rfgain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=24, decimation=250, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( int(samp_rate / down_rate), firdes.low_pass(2, samp_rate, 100e3, 10e3, firdes.WIN_KAISER, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume / 100, )) self.audio_sink_0 = audio.sink(24000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=down_rate, audio_decimation=1, ) self.Demod_Out = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=down_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='Demod Out', peak_hold=False, ) self.Add(self.Demod_Out.win) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.Demod_Out, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="cdma_txrx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.N0est = N0est = 1.0 self.Esest = Esest = 1e-1 self.EsN0dB_est = EsN0dB_est = 10*numpy.log10( cp.epsilon+ abs(Esest)/ (abs(N0est)+cp.epsilon) ) self.symbol_rate = symbol_rate = 100e3 self.DataEsN0dBthreshold = DataEsN0dBthreshold = 10 self.DataEsN0dB_est = DataEsN0dB_est = EsN0dB_est + 10*numpy.log10( 1.0-cp.training_percent/100.0 ) self.samp_rate = samp_rate = symbol_rate*cp.chips_per_symbol self.onoff_manual = onoff_manual = 1 self.onoff_auto = onoff_auto = 0 if DataEsN0dB_est>DataEsN0dBthreshold else 1 self.manual = manual = 1 self.onoff = onoff = onoff_auto if manual==0 else onoff_manual self.freq_acq_est = freq_acq_est = 0 self.df = df = cp.df*samp_rate self.TrainingEsN0dB_est = TrainingEsN0dB_est = EsN0dB_est + 10*numpy.log10( cp.training_percent/100.0 ) self.EsN0dB = EsN0dB = 20 self.Es = Es = 1 self.variable_static_text = variable_static_text = 'Acquisition' if onoff==1 else 'Tracking' self.n_filt = n_filt = cp.n_filt self.freq_est_acq = freq_est_acq = freq_acq_est self.fmaxt = fmaxt = cp.freqs[-1]*samp_rate self.drift = drift = 0 self.dft = dft = df self.df_Hz = df_Hz = 0 self.delay = delay = 0 self.acq_threshold_dB = acq_threshold_dB = -8.5 self.TrainingEsN0dB = TrainingEsN0dB = TrainingEsN0dB_est self.N0 = N0 = 10**(-EsN0dB/10) * Es self.DataEsN0dB_estimated = DataEsN0dB_estimated = DataEsN0dB_est ################################################## # Blocks ################################################## _drift_sizer = wx.BoxSizer(wx.VERTICAL) self._drift_text_box = forms.text_box( parent=self.GetWin(), sizer=_drift_sizer, value=self.drift, callback=self.set_drift, label="drift (ppm)", converter=forms.float_converter(), proportion=0, ) self._drift_slider = forms.slider( parent=self.GetWin(), sizer=_drift_sizer, value=self.drift, callback=self.set_drift, minimum=0, maximum=2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_drift_sizer, 3, 0, 1, 1) _df_Hz_sizer = wx.BoxSizer(wx.VERTICAL) self._df_Hz_text_box = forms.text_box( parent=self.GetWin(), sizer=_df_Hz_sizer, value=self.df_Hz, callback=self.set_df_Hz, label="df_Hz", converter=forms.float_converter(), proportion=0, ) self._df_Hz_slider = forms.slider( parent=self.GetWin(), sizer=_df_Hz_sizer, value=self.df_Hz, callback=self.set_df_Hz, minimum=(cp.freqs[0]*samp_rate)-1e-6, maximum=cp.freqs[-1]*samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_df_Hz_sizer, 1, 0, 1, 1) _delay_sizer = wx.BoxSizer(wx.VERTICAL) self._delay_text_box = forms.text_box( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, label="delay", converter=forms.int_converter(), proportion=0, ) self._delay_slider = forms.slider( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, minimum=0, maximum=100-1, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_delay_sizer, 2, 0, 1, 1) self.blocks_probe_signal_n0 = blocks.probe_signal_f() self.blocks_probe_signal_amp = blocks.probe_signal_f() self.blocks_probe_freq = blocks.probe_signal_f() _acq_threshold_dB_sizer = wx.BoxSizer(wx.VERTICAL) self._acq_threshold_dB_text_box = forms.text_box( parent=self.GetWin(), sizer=_acq_threshold_dB_sizer, value=self.acq_threshold_dB, callback=self.set_acq_threshold_dB, label="acq_threshold_dB", converter=forms.float_converter(), proportion=0, ) self._acq_threshold_dB_slider = forms.slider( parent=self.GetWin(), sizer=_acq_threshold_dB_sizer, value=self.acq_threshold_dB, callback=self.set_acq_threshold_dB, minimum=-30, maximum=20, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_acq_threshold_dB_sizer, 7, 0, 1, 1) self._variable_static_text_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text, callback=self.set_variable_static_text, label="Ack/Tra Status", converter=forms.str_converter(), ) self.GridAdd(self._variable_static_text_static_text, 4, 0, 1, 1) self._onoff_manual_chooser = forms.button( parent=self.GetWin(), value=self.onoff_manual, callback=self.set_onoff_manual, label="Manual Acq/Tra", choices=[0,1], labels=['Tracking','Acquisition'], ) self.GridAdd(self._onoff_manual_chooser, 5, 0, 1, 1) self._n_filt_static_text = forms.static_text( parent=self.GetWin(), value=self.n_filt, callback=self.set_n_filt, label="n_filt", converter=forms.int_converter(), ) self.Add(self._n_filt_static_text) self._manual_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.manual, callback=self.set_manual, label="Manual/Auto", choices=[0,1], labels=['Auto','Manual'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._manual_chooser, 6, 0, 1, 1) self._freq_est_acq_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_est_acq, callback=self.set_freq_est_acq, label='freq_est_acq', converter=forms.float_converter(), ) self.Add(self._freq_est_acq_static_text) def _freq_acq_est_probe(): while True: val = self.blocks_probe_freq.level() try: self.set_freq_acq_est(val) except AttributeError: pass time.sleep(1.0 / (10)) _freq_acq_est_thread = threading.Thread(target=_freq_acq_est_probe) _freq_acq_est_thread.daemon = True _freq_acq_est_thread.start() self._fmaxt_static_text = forms.static_text( parent=self.GetWin(), value=self.fmaxt, callback=self.set_fmaxt, label="f_max (Hz)", converter=forms.float_converter(), ) self.Add(self._fmaxt_static_text) self._dft_static_text = forms.static_text( parent=self.GetWin(), value=self.dft, callback=self.set_dft, label="Deltaf (Hz)", converter=forms.float_converter(), ) self.Add(self._dft_static_text) self.channels_channel_model_0 = channels.channel_model( noise_voltage=(cp.chips_per_symbol*cp.samples_per_chip*N0/2)**0.5, frequency_offset=df_Hz/samp_rate, epsilon=1.0+drift*1e-6, taps=((delay)*(0,)+(1,)+(100-1-delay)*(0,)), noise_seed=0, block_tags=False ) self.cdma_tx_hier_0 = cdma_tx_hier() self.cdma_rx_hier_0 = cdma_rx_hier( acq=onoff, acq_threshold_dB=acq_threshold_dB, ) self.cdma_pac_err_cal_0 = cdma.pac_err_cal(1000, 2**cp.cdma_packet_num_bit, "cdma_packet_num") self.blocks_vector_source_x_0_1 = blocks.vector_source_b(map(int,numpy.random.randint(0,256,cp.payload_bytes_per_frame)), True, 1, tagged_streams.make_lengthtags((cp.payload_bytes_per_frame,), (0,), cp.length_tag_name)) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, (symbol_rate*cp.bits_per_uncoded_symbol)/8,True) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((samp_rate, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((Es**0.5, )) self._TrainingEsN0dB_static_text = forms.static_text( parent=self.GetWin(), value=self.TrainingEsN0dB, callback=self.set_TrainingEsN0dB, label="TrainingEsN0dB_est", converter=forms.float_converter(), ) self.Add(self._TrainingEsN0dB_static_text) def _N0est_probe(): while True: val = self.blocks_probe_signal_n0.level() try: self.set_N0est(val) except AttributeError: pass time.sleep(1.0 / (10)) _N0est_thread = threading.Thread(target=_N0est_probe) _N0est_thread.daemon = True _N0est_thread.start() def _Esest_probe(): while True: val = self.blocks_probe_signal_amp.level() try: self.set_Esest(val) except AttributeError: pass time.sleep(1.0 / (10)) _Esest_thread = threading.Thread(target=_Esest_probe) _Esest_thread.daemon = True _Esest_thread.start() _EsN0dB_sizer = wx.BoxSizer(wx.VERTICAL) self._EsN0dB_text_box = forms.text_box( parent=self.GetWin(), sizer=_EsN0dB_sizer, value=self.EsN0dB, callback=self.set_EsN0dB, label="EsN0dB", converter=forms.float_converter(), proportion=0, ) self._EsN0dB_slider = forms.slider( parent=self.GetWin(), sizer=_EsN0dB_sizer, value=self.EsN0dB, callback=self.set_EsN0dB, minimum=-20, maximum=80, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_EsN0dB_sizer, 0, 0, 1, 1) _DataEsN0dBthreshold_sizer = wx.BoxSizer(wx.VERTICAL) self._DataEsN0dBthreshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_DataEsN0dBthreshold_sizer, value=self.DataEsN0dBthreshold, callback=self.set_DataEsN0dBthreshold, label="DataEsN0dBthreshold", converter=forms.float_converter(), proportion=0, ) self._DataEsN0dBthreshold_slider = forms.slider( parent=self.GetWin(), sizer=_DataEsN0dBthreshold_sizer, value=self.DataEsN0dBthreshold, callback=self.set_DataEsN0dBthreshold, minimum=0, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_DataEsN0dBthreshold_sizer, 8, 0, 1, 1) self._DataEsN0dB_estimated_static_text = forms.static_text( parent=self.GetWin(), value=self.DataEsN0dB_estimated, callback=self.set_DataEsN0dB_estimated, label="DataEsN0dB_est", converter=forms.float_converter(), ) self.Add(self._DataEsN0dB_estimated_static_text) ################################################## # Connections ################################################## self.msg_connect((self.cdma_rx_hier_0, 'decoded_header'), (self.cdma_pac_err_cal_0, 'errCal')) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_probe_freq, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.cdma_rx_hier_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.cdma_tx_hier_0, 0)) self.connect((self.blocks_vector_source_x_0_1, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.cdma_rx_hier_0, 3), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.cdma_rx_hier_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.cdma_rx_hier_0, 2), (self.blocks_probe_signal_amp, 0)) self.connect((self.cdma_rx_hier_0, 0), (self.blocks_probe_signal_n0, 0)) self.connect((self.cdma_tx_hier_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_tag_gate_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq = offset_freq = 119e6 self.freq_corr = freq_corr = 65 self.freq = freq = 591.28e6 self.base_freq = base_freq = 560e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._offset_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq, callback=self.set_offset_freq, label="Frequency select", choices=[119e6,120.5e6,123.85e6,126.55e6,128.65e6,132.225e6,560e6], labels=["bradley 119M","worc tow 120.5M", "worc ground 123.85M","worc atais126.55M","worc clrnc 128.65M","logan twr 132.225M","560AM"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq_chooser) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(offset_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=48, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=500e6, maximum=1200e6, num_steps=700, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Loopback Ah") ################################################## # Variables ################################################## self.snr = snr = 20 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.interval = interval = 100 self.encoding = encoding = 0 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## _snr_sizer = wx.BoxSizer(wx.VERTICAL) self._snr_text_box = forms.text_box( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, label='snr', converter=forms.float_converter(), proportion=0, ) self._snr_slider = forms.slider( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, minimum=-15, maximum=30, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_snr_sizer) _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL) self._pdu_length_text_box = forms.text_box( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, label='pdu_length', converter=forms.int_converter(), proportion=0, ) self._pdu_length_slider = forms.slider( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, minimum=0, maximum=1500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_pdu_length_sizer) _interval_sizer = wx.BoxSizer(wx.VERTICAL) self._interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, label="PDU Interval (ms)", converter=forms.int_converter(), proportion=0, ) self._interval_slider = forms.slider( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, minimum=10, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_interval_sizer) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0,1,2,3,4,5,6,7,8], labels=["BPSK 1/2", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4", "64QAM 5/6", "256QAM 3/4" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=12500, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wifi_phy_hier_ah_0 = wifi_phy_hier_ah( chan_est=chan_est, encoding=encoding, sensitivity=0.56, ) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=1, frequency_offset=0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_ah_0, 'mac_in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_ah_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_ah_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 1), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx") ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.lo_offset = lo_offset = 0 self.gain = gain = 20 self.freq = freq = 2.412e9 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.Add(self.nb) self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, options): grc_wxgui.top_block_gui.__init__(self, title="DSSDR") self.initialized = False self.stopped = False self.options = copy.copy(options) self._constellation = digital.constellation_bpsk() self._excess_bw = options.excess_bw self._phase_bw = options.phase_bw self._freq_bw = options.freq_bw self._timing_bw = options.timing_bw self._if_freq = options.if_freq self._timing_max_dev= 1.5 self._demod_class = digital.bpsk_demod # the demodulator_class we're using self._chbw_factor = options.chbw_factor # channel filter bandwidth factor self._samples_per_second = 2e6 self._nav_samples_per_second = 16e6 self._down_decim = 1 self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim self._up_samples_per_second = 1e6 self._asm_threshold = 0 self._access_code = None self._tm_packet_id = 4 self._timestamp_id = 5 self._down_bitrate = options.bitrate self._up_bitrate = options.up_bitrate self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate self._down_sub_freq = options.down_sub_freq self._up_sub_freq = 25e3 self._tm_len = 8920 self._up_tm_len = 8920 self._coding_method = options.coding_method self._up_coding_method = 'None' self._up_subcarrier = 'Square' self._rs_i = 1 self._ccsds_channel = 38 self._uhd_carrier_offset = 10e3 self._turn_div = 749 self._turn_mult = 880 self._modulation_index = 'pi/3' self._up_modulation_index = 1.047 self._max_carrier_offset = 0.1 self._dssdr_mixer_freq = options.rf_freq self._up_coding_rate = '1' self._down_coding_rate = '1' self._down_conv_en = "False" self._down_randomizer_en = options.down_randomizer_en self._down_manchester_en = options.down_manchester_en self._up_conv_en = "False" self._up_idle_sequence = "\\x55" self._down_default_gain = 64 self._up_default_gain = 44 self._up_en = True if self._access_code is None: self._access_code = packet_utils.default_access_code #Construct the lookup table for parameter-setting functions self.param_setters = { "DSSDR_CHANNEL": self.setChannel, "DSSDR_LO_FREQ": self.setLOFreq, "DSSDR_REF_FREQ": self.setRefFreq, "DSSDR_TURN_MULT": self.setTurnMult, "DSSDR_TURN_DIV": self.setTurnDiv, "DSSDR_UP_GAIN": self.setUpGain, "DSSDR_DOWN_GAIN": self.setDownGain, "DSSDR_UP_BITRATE": self.setUpBitrate, "DSSDR_DOWN_BITRATE": self.setDownBitrate, "DSSDR_DOWN_SAMPLE_RATE": self.setSampRate, "DSSDR_UP_SUB_FREQ": self.setUpSubFreq, "DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq, "DSSDR_DOPPLER_REPORT": self.dopplerReport, "DSSDR_PN_RANGE": self.rangePN, "DSSDR_SEQUENTIAL_RANGE": self.rangeSequential, "DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod, "DSSDR_UP_CODING_METHOD": self.setUpCodingMethod, "DSSDR_DOWN_TM_LEN": self.setTMLen, "DSSDR_UP_TM_LEN": self.setUpTMLen, "DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex, "DSSDR_UP_MOD_IDX": self.setUpModulationIndex, "DSSDR_DOWN_CONV_EN": self.setDownConvEn, "DSSDR_UP_CONV_EN": self.setUpConvEn, "DSSDR_ASM_TOL": self.setASMThreshold, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_UP_IDLE": self.setUpIdleSequence, "DSSDR_UP_EN": self.setUpEn, "DSSDR_SYNC_TIME": self.syncSDRTime, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_DOWN_ACQUIRE": self.acquireCarrier, "DSSDR_INPUT_SELECT": self.setPanelSelect, "DSSDR_REF_SELECT": self.setRefSelect, "DSSDR_PPS_SELECT": self.setPPSSelect } #TODO:Add status fields for things like DSSDR_REF_LOCK self._dssdr_channels = { 3: [7149597994, 8400061729], 4: [7150753857, 8401419752], 5: [7151909723, 8402777779], 6: [7153065586, 8404135802], 7: [7154221449, 8405493825], 8: [7155377316, 8406851853], 9: [7156533179, 8408209877], 10: [7157689045, 8409567903], 11: [7158844908, 8410925927], 12: [7160000771, 8412283950], 13: [7161156637, 8413641977], 14: [7162312500, 8415000000], 15: [7163468363, 8416358023], 16: [7164624229, 8417716050], 17: [7165780092, 8419074073], 18: [7166935955, 8420432097], 19: [7168091821, 8421790123], 20: [7169247684, 8423148147], 21: [7170403551, 8424506175], 22: [7171559414, 8425864198], 23: [7172715277, 8427222221], 24: [7173871143, 8428580248], 25: [7175027006, 8429938271], 26: [7176182869, 8431296295], 27: [7177338735, 8432654321], 28: [7178494598, 8434012345], 29: [7179650464, 8435370372], 30: [7180806327, 8436728395], 31: [7181962190, 8438086418], 32: [7183118057, 8439444446], 33: [7184273920, 8440802469], 34: [7185429783, 8442160493], 35: [7186585649, 8443518520], 36: [7187741512, 8444876543], 37: [7188897378, 8446234570], 38: [7190000000, 8450000000], } #FLOWGRAPH STUFF if options.test == True: self.u = blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="", port=12905, server=True ) elif options.fromfile == True: self.u2 = blocks.file_meta_source("iq_in.dat") self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second) elif options.frombitlog == True: self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True) self.u2 = blocks.uchar_to_float() self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate) self.u = blocks.add_const_ff(-0.5) else: self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u.set_clock_source("external") self.u.set_time_source("external") self.u.set_samp_rate(self._samples_per_second) self.u.set_antenna("RX2") self.u.set_gain(self._down_default_gain) self.frontend = dfi.dssdrFrontendInterface(self.u) if options.debug_pps == True: self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time") if options.tofile == True: self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second) elif options.tonull == True: self.u_tx = blocks.null_sink(gr.sizeof_gr_complex) else: self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u_tx.set_clock_source("external") self.u_tx.set_time_source("external") self.u_tx.set_samp_rate(self._up_samples_per_second) self.u_tx.set_antenna("TX/RX") self.u_tx.set_gain(self._up_default_gain) #GUI STUFF if options.graphics == True: self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav") self.Add(self.nb0) self.constellation_scope = scopesink2.scope_sink_c( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.constellation_scope.win) #self.constellation_scope.win.set_marker('plus') self._scope_is_fft = False self.time_scope = scopesink2.scope_sink_f( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=.005, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.time_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win) self.fft_scope = fftsink2.fft_sink_c( self.nb0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=self._scope_sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb0.GetPage(0).Add(self.fft_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win) self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL) self.recording_onoff_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Off', callback=self.setRecording, label="IQ Recording", choices=['Off','On'], labels=[], style=wx.RA_HORIZONTAL, ) self.front_panel_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='RF', callback=self.setPanelSelect, label="Input Select", choices=['RF','IF'], labels=[], style=wx.RA_HORIZONTAL, ) self.ref_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setRefSelect, label="Ref Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.pps_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setPPSSelect, label="PPS Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.sync_button = forms.button( parent=self.nb0.GetPage(0).GetWin(), value='Sync to PPS', callback=self.syncSDRTime, choices=['Sync to PPS'], style=wx.RA_HORIZONTAL, ) self.ref_locked_text = forms.static_text( parent=self.nb0.GetPage(0).GetWin(), value="", callback=self.setRefLocked, label="", converter=forms.str_converter(), ) self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(0).Add(self.row1_sizer) self.complex_scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Constellation', callback=self.setComplexScopeStyle, label="Complex Scope", choices=['Constellation','FFT'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.complex_scope_chooser) self.scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='USRP', callback=self.setScopePoint, label="Scope Probe Point", choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.scope_chooser) self._bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_bitrate, callback=self.setDownBitrate, label="Symbol Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._bitrate_text_box) self._samprate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._samples_per_second, callback=self.setSampRate, label="Sampling Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._samprate_text_box) self._subcfreq_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_sub_freq, callback=self.setDownSubFreq, label="Downlink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._subcfreq_text_box) self._mod_index_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._modulation_index, callback=self.setDownModulationIndex, label="Modulation Index", choices=['pi/2', 'pi/3'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._mod_index_chooser) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._tm_len, callback=self.setTMLen, label="Downlink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._coding_method, callback=self.setDownCodingMethod, label="Coding", choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._down_conv_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_conv_en, callback=self.setDownConvEn, label="Convolutional Decode", true="True", false="False", ) self.nb0.GetPage(0).Add(self._down_conv_check_box) self._down_randomizer_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_randomizer_en, callback=self.setDownRandomizerEn, label="De-randomizer", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_randomizer_check_box) self._down_manchester_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_manchester_en, callback=self.setDownManchesterEn, label="Manchester Decode", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_manchester_check_box) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._asm_threshold, callback=self.setASMThreshold, label="ASM Error Tolerance (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._rs_i, callback=self.setRSI, label="Reed-Solomon Interleaving Depth", choices=[1,5], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._ccsds_chan_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._ccsds_channel, callback=self.setChannel, label="CCSDS Channel", converter=forms.int_converter(), ) self.nb0.GetPage(0).Add(self._ccsds_chan_text_box) self.setChannel(self._ccsds_channel) if options.test == True or options.fromfile == True or options.frombitlog == True: glow = 0.0 ghigh = 1.0 cur_g = 0.5 else: g = self.u.get_gain_range() cur_g = self._down_default_gain # some configurations don't have gain control if g.stop() <= g.start(): glow = 0.0 ghigh = 1.0 else: glow = g.start() ghigh = g.stop() self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(0).GetWin(), sizer=self._uhd_gain_slider, label="USRP RX Gain", weight=3, min=int(glow), max=int(ghigh), value=cur_g, callback=self.setDownGain ) self.nb0.GetPage(0).Add(self._uhd_gain_slider) #TX chain GUI components if options.test == True or options.tofile == True or options.tonull == True: gtxlow = 0.0 gtxhigh = 1.0 cur_gtx = 0.5 else: gtx = self.u_tx.get_gain_range() cur_gtx = self._up_default_gain # some configurations don't have gain control if gtx.stop() <= gtx.start(): gtxlow = 0.0 gtxhigh = 1.0 else: gtxlow = gtx.start() gtxhigh = gtx.stop() self._up_en_chooser = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value='True', callback=self.setUpEn, label="TX Enable", true='True', false='False', ) self.nb0.GetPage(1).Add(self._up_en_chooser) self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(1).GetWin(), sizer=self._uhd_tx_gain_slider, label="USRP TX Gain", weight=3, min=int(gtxlow), max=int(gtxhigh), value=cur_gtx, callback=self.setUpGain ) self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider) self._subcfreq_up_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_sub_freq, callback=self.setUpSubFreq, label="Uplink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._subcfreq_up_text_box) self._up_bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_bitrate, callback=self.setUpBitrate, label="Uplink Bitrate", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_bitrate_text_box) self._up_data_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="1234ABCD", callback=self.txData, label="TX Data", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._up_data_text_box) self._up_mod_index_chooser = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_modulation_index, callback=self.setUpModulationIndex, label="Uplink Modulation Index", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_mod_index_chooser) self._up_coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_coding_method, callback=self.setUpCodingMethod, label="Coding", choices=['None', 'RS'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._up_coding_chooser) self._subcarrier_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_subcarrier, callback=self.setUpSubcarrier, label="Subcarrier Type", choices=['Square','Sine'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._subcarrier_chooser) self._up_conv_check_box = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_conv_en, callback=self.setUpConvEn, label="Convolutional Encode", true="True", false="False", ) self.nb0.GetPage(1).Add(self._up_conv_check_box) self._up_pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_tm_len, callback=self.setUpTMLen, label="Uplink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_pktlen_text_box) self._uhd_offset_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._uhd_carrier_offset, callback=self.setUHDCarrierOffset, label="USRP Offset Frequency (Hz)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._uhd_offset_text_box) self._sweep_gen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="rf2_1", callback=self.freqSweep, label="Frequency Sweep Profile", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._sweep_gen_text_box) self._idle_sequence_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_idle_sequence, callback=self.setUpIdleSequence, label="Uplink Idle Sequence", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._idle_sequence_text_box) self._pn_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangePN, label="Queue PN Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._pn_ranging_text_box) self._sequential_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangeSequential, label="Queue Sequential Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._sequential_ranging_text_box) self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_acq_button = forms.button( parent=self.nb0.GetPage(2).GetWin(), value='Acquire Carrier Offset', callback=self.acquireCarrier, choices=['Acquire Carrier Offset'], style=wx.RA_HORIZONTAL, ) self.carrier_offset_text = forms.static_text( parent=self.nb0.GetPage(2).GetWin(), value="", label="", converter=forms.str_converter(), ) self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER) self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(2).Add(self.row2_sizer) self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second) self.file_sink.close() self.iq_recording_ctr = 0 # Selection logic to switch between recording and normal flowgraph routes # NOTE: u_valve logic is implemented backwards in GNURadio.... #self.u_valve = blks2.valve( # item_size=gr.sizeof_gr_complex, # open=False #) # Temporary code used to verify coherent turnaround self.turnaround_mixer = blocks.multiply_cc() self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0) self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001) self.turnaround_null = blocks.null_sink(gr.sizeof_float) # PLL and associated carrier for tracking carrier frequency if residual carrier is used self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples)) self.imag_to_float = blocks.complex_to_imag() #Suppressed carrier requires costas after subcarrier mixer self.subcarrier_costas = digital.costas_loop_cc(0.001, 2) self.real_to_float = blocks.complex_to_real() #Square wave subcarrier sync self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999) #Data sync self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999) #Data framing self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr") self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr") self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr") self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate) self.tm_framer.setFrameLength(self._tm_len) self._current_scope_block = None self._current_scoped_block = self.u self._current_scoped_block_port = 0 self._recording = 'Off' #TX path in flowgraph self.pkt_gen_msgq = gr.msg_queue(10) self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq) self.conj = blocks.conjugate_cc() #Sweep generator for transponder lock self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second) # DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate) self.up_subcarrier_mixer = blocks.multiply_ff() self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0) self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index) self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j)) #Add in bit recorder if needed if self.options.bitlog: self.bit_slicer = digital.binary_slicer_fb() self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out") self.setDownCodingMethod(self._coding_method) self.setUpCodingMethod("None") self.setUpSubcarrier(self._up_subcarrier) self.setDownBitrate(self._down_bitrate) self.setUpBitrate(self._up_bitrate) self.setDownModulationIndex(self._modulation_index) self.setUpModulationIndex(self._up_modulation_index) self.setDownConvEn(self._down_conv_en) self.setUpConvEn(self._up_conv_en) self.setUpIdleSequence(self._up_idle_sequence) self.setDownRandomizerEn(self._down_randomizer_en) self.setDownManchesterEn(self._down_manchester_en) #Connection to outside world self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000) self.sdrp_interpreter = sdrp.sdrp_packet_interpreter() self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in") self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus") self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in") self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in") if options.test == False and options.fromfile == False and options.frombitlog == False: _threading.Thread(target=self.watchRef).start() self.initialized = True print "DS-SDR Initialized"
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.freq = freq = 2.437e9 self.chan_est = chan_est = ieee802_11.LMS ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[1e6, 3e6, 5e6, 10e6, 15e6, 20e6], labels=["1 MHz", "3 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2.437e9, 5.805e9], labels=["Ch 6 | 2437", "Ch 161| 5805"], ) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ], labels=["LS", "LMS", "STA", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "") self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, False, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.rftap_rftap_encap_0, 'in')) self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, clock=100.0e6, dcg=1, decln=-28.0, devid="addr=192.168.10.2", fftsize=8192, frequency=1.406e9, maxg=50, rfgain=0.0, rxant="", spa=1, srate=10.0e6, subdev="A:0", tpint=2.0): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200 with Filter") ################################################## # Parameters ################################################## self.clock = clock self.dcg = dcg self.decln = decln self.devid = devid self.fftsize = fftsize self.frequency = frequency self.maxg = maxg self.rfgain = rfgain self.rxant = rxant self.spa = spa self.srate = srate self.subdev = subdev self.tpint = tpint ################################################## # Variables ################################################## self.israte = israte = srate self.samp_rate = samp_rate = int(israte) self.prefix = prefix = "tpr_" self.filter_band = filter_band = 500e3 self.variable_static_text_0_0_0_0 = variable_static_text_0_0_0_0 = clock self.variable_static_text_0_0_0 = variable_static_text_0_0_0 = devid self.variable_static_text_0_0 = variable_static_text_0_0 = subdev self.variable_static_text_0 = variable_static_text_0 = israte self.taps = taps = firdes.low_pass(1.0, samp_rate,filter_band, 1000) self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = int(spa) self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.integ = integ = tpint self.idecln = idecln = decln self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = int(dcg) self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_filter = add_filter = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) self._israte_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.israte, callback=self.set_israte, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._israte_chooser, 1, 3, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._add_filter_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_filter, callback=self.set_add_filter, label="Filter On/Off", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_filter_chooser, 3, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=israte, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0_0, callback=self.set_variable_static_text_0_0_0_0, label="N200 Clock", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_0_static_text, 2, 3, 1, 1) self._variable_static_text_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0, callback=self.set_variable_static_text_0_0_0, label="Device", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_static_text, 2, 2, 1, 1) self._variable_static_text_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0, callback=self.set_variable_static_text_0_0, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 2, 1, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 2, 0, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self._idecln_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.idecln, callback=self.set_idecln, label="Declination", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._idecln_text_box, 1, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=maxg, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) _filter_band_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_band_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, label="Filter Bandwidth", converter=forms.float_converter(), proportion=0, ) self._filter_band_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, minimum=100e3, maximum=9e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_filter_band_sizer, 3, 2, 1, 1) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (taps), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=add_filter, output_index=0, ) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .5, 0) self.TPR_0 = TPR( integ=integ, samp_rate=samp_rate, det_rate=det_rate, ) ################################################## # Connections ################################################## self.connect((self.TPR_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.TPR_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blks2_valve_2, 0)) self.connect((self.blks2_selector_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blks2_selector_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))
def __init__(self, param_samp_rate, param_freq, param_gain, address): grc_wxgui.top_block_gui.__init__(self, title="UHD FFT") ################################################## # Parameters ################################################## param_freq = 5.78666666667e9 self.param_samp_rate = param_samp_rate self.param_freq = param_freq self.param_gain = param_gain self.address = address ################################################## # Variables ################################################## self.chan0_lo_locked = chan0_lo_locked = uhd.sensor_value("", False, "") self.samp_rate = samp_rate = param_samp_rate self.lo_locked_probe = lo_locked_probe = chan0_lo_locked.to_bool() self.gain = gain = param_gain self.freq = freq = param_freq self.ant = ant = "J1" ################################################## # Blocks ################################################## self._samp_rate_text_box = forms.text_box( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", converter=forms.float_converter(), ) self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 3) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=112.5, num_steps=225, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 2, 0, 1, 8) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="RX Tune Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=50e6, maximum=6e9, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 3, 0, 1, 8) self._ant_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.ant, callback=self.set_ant, label="Antenna", choices=["J1","J2"], labels=["J1","J2"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._ant_chooser, 1, 4, 1, 2) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr=address, stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(ant, 0) self.uhd_usrp_source_0.set_bandwidth(samp_rate, 0) g = self.uhd_usrp_source_0.get_gain_range() print "rx gain range is (%f,%f)" % (g.start(),g.stop()) self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Scope") self.GridAdd(self.nb0, 0, 0, 1, 8) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", size=((-1, 400)), ) self.nb0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.nb0.GetPage(2).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(2).Add(self.wxgui_scopesink2_0.win) self._lo_locked_probe_static_text = forms.static_text( parent=self.GetWin(), value=self.lo_locked_probe, callback=self.set_lo_locked_probe, label="LO Locked", converter=forms.str_converter(formatter=lambda x: x and "True" or "False"), ) self.GridAdd(self._lo_locked_probe_static_text, 1, 7, 1, 1) self.fft = fftsink2.fft_sink_c( self.nb0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=15, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, size=((-1, 400)), ) self.nb0.GetPage(0).Add(self.fft.win) def _chan0_lo_locked_probe(): while True: val = self.uhd_usrp_source_0.get_sensor('lo_locked') try: self.set_chan0_lo_locked(val) except AttributeError, e: pass time.sleep(1.0/(10)) _chan0_lo_locked_thread = threading.Thread(target=_chan0_lo_locked_probe) _chan0_lo_locked_thread.daemon = True _chan0_lo_locked_thread.start() ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fft, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq = offset_freq = 119e6 self.freq_corr = freq_corr = 65 self.freq = freq = 591.28e6 self.base_freq = base_freq = 560e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._offset_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq, callback=self.set_offset_freq, label="Frequency select", choices=[ 119e6, 120.5e6, 123.85e6, 126.55e6, 128.65e6, 132.225e6, 560e6 ], labels=[ "bradley 119M", "worc tow 120.5M", "worc ground 123.85M", "worc atais126.55M", "worc clrnc 128.65M", "logan twr 132.225M", "560AM" ], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq_chooser) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(offset_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=48, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0, samp_rate) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=500e6, maximum=1200e6, num_steps=700, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "C:\gnuradio\share\icons\hicolor\48x48/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq = offset_freq = -300e3 self.freq_corr = freq_corr = 65 self.base_freq = base_freq = 119.4e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._offset_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq, callback=self.set_offset_freq, label="Frequency select", choices=[-800e3, -550e3, -300e3, 300e3, 500e3], labels=[ "meythet 118.2M", "TWR2 118.85M", "APP1 119.1M", "APP2 119.7M", "APP3 119.9M" ], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq_chooser) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(base_freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), offset_freq, samp_rate) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Radio") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1.024e6 self.noise_amplitude = noise_amplitude = 0.01 self.mode = mode = 0 self.decim = decim = 4 self.audio_gain = audio_gain = 1 self.WBFM_frequency = WBFM_frequency = 92.3e6 self.NBFM_frequency = NBFM_frequency = 162.475e6 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FFT Plot") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Waterfall Plot") self.Add(self.notebook_0) _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_amplitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, label='noise_amplitude', converter=forms.float_converter(), proportion=0, ) self._noise_amplitude_slider = forms.slider( parent=self.GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, minimum=0, maximum=0.1, num_steps=500, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_noise_amplitude_sizer, 2, 26, 2, 24) self._mode_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.mode, callback=self.set_mode, label='mode', choices=[0,1], labels=['WBFM','NBFM'], style=wx.RA_VERTICAL, ) self.GridAdd(self._mode_chooser, 0, 0, 1, 2) _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, label='audio_gain', converter=forms.float_converter(), proportion=0, ) self._audio_gain_slider = forms.slider( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_audio_gain_sizer, 2, 2, 2, 24) _WBFM_frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._WBFM_frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_WBFM_frequency_sizer, value=self.WBFM_frequency, callback=self.set_WBFM_frequency, label='WBFM_frequency', converter=forms.float_converter(), proportion=0, ) self._WBFM_frequency_slider = forms.slider( parent=self.GetWin(), sizer=_WBFM_frequency_sizer, value=self.WBFM_frequency, callback=self.set_WBFM_frequency, minimum=88.1e6, maximum=108.1e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_WBFM_frequency_sizer, 0, 2, 2, 24) _NBFM_frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._NBFM_frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_NBFM_frequency_sizer, value=self.NBFM_frequency, callback=self.set_NBFM_frequency, label='NBFM_frequency', converter=forms.float_converter(), proportion=0, ) self._NBFM_frequency_slider = forms.slider( parent=self.GetWin(), sizer=_NBFM_frequency_sizer, value=self.NBFM_frequency, callback=self.set_NBFM_frequency, minimum=146e6, maximum=170e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_NBFM_frequency_sizer, 0, 26, 2, 24) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", size=(480, 360), ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/decim, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, size=(480, 360), ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=0" ) self.osmosdr_source_0.set_time_source("gpsdo", 0) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(WBFM_frequency if mode==0 else NBFM_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(25, 0) self.osmosdr_source_0.set_if_gain(24, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=mode, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=mode, ) self.audio_sink_0 = audio.sink(32000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=256e3, audio_decimation=8, ) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amplitude, 0) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=32000, quad_rate=32000, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_1, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.blks2_selector_1, 0)) self.connect((self.blks2_selector_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.blks2_selector_0, 1), (self.rational_resampler_xxx_1, 0)) self.connect((self.blks2_selector_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_nbfm_rx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq1 = offset_freq1 = -300e3 self.freq_corr = freq_corr = 0 self.base_freq = base_freq = 27.315e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(base_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(1, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self._offset_freq1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq1, callback=self.set_offset_freq1, label="Frequency select", choices=[-800e3,-550e3, -300e3,300e3,500e3], labels=["TWR1 118.6M","TWR2 118.85M", "APP1 119.1M","APP2 119.7M","APP3 119.9M"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq1_chooser) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), base_freq, samp_rate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="B200 VHF NBFM transceiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_rx_choice = tx_rx_choice = 1 self.tx_gain = tx_gain = .615 self.tune_minus_20 = tune_minus_20 = 0 self.tune_minus_10 = tune_minus_10 = 0 self.tune_20 = tune_20 = 0 self.tune_10 = tune_10 = 0 self.tone = tone = 100 self.squelch = squelch = -70.32 self.samp_rate = samp_rate = 4000000 self.rx_offset = rx_offset = 0 self.rit_tune = rit_tune = 0 self.offset = offset = 600000 self.chooser_fm = chooser_fm = 147.34e6 self.audio_gain = audio_gain = .7 ################################################## # Blocks ################################################## self._tx_rx_choice_chooser = forms.button( parent=self.GetWin(), value=self.tx_rx_choice, callback=self.set_tx_rx_choice, label="TX-RX", choices=[0, 1], labels=['TX', 'RX'], ) self.GridAdd(self._tx_rx_choice_chooser, 0, 3, 1, 1) _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: 144= .6, 220= .70, 440= .72", 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=.6, maximum=.75, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) self._tune_minus_20_chooser = forms.button( parent=self.GetWin(), value=self.tune_minus_20, callback=self.set_tune_minus_20, label="-20 Tune", choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3, 0], labels=[0, -20, -40, -60, -80, -100, -120, -140, 0], ) self.GridAdd(self._tune_minus_20_chooser, 0, 1, 1, 1) self._tune_minus_10_chooser = forms.button( parent=self.GetWin(), value=self.tune_minus_10, callback=self.set_tune_minus_10, label="-10 Tune", choices=[0,-10e3, -20e3, -30e3, -40e3,-50e3,0], labels=[0, -10, -20, -30, -40,-50,0], ) self.GridAdd(self._tune_minus_10_chooser, 1, 1, 1, 1) self._tune_20_chooser = forms.button( parent=self.GetWin(), value=self.tune_20, callback=self.set_tune_20, label="+20 Tune", choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3,0], labels=[0, '+20', '+40', '+60', '+80', '+100', '+120', '+140','0'], ) self.GridAdd(self._tune_20_chooser, 0, 0, 1, 1) self._tune_10_chooser = forms.button( parent=self.GetWin(), value=self.tune_10, callback=self.set_tune_10, label="+10 Tune", choices=[0,10e3, 20e3, 30e3, 40e3,50e3,0], labels=[0,'+10', '+20', '+30', '+40','+50','0'], ) self.GridAdd(self._tune_10_chooser, 1, 0, 1, 1) self._tone_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.tone, callback=self.set_tone, label="CTCSS", choices=[100,103.5, 110.9, 118.8, 123.0,127.3,179.5], labels=['100', '103.5', '110.9','118.8', '123.0', '127.3','179.5'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._tone_chooser, 0, 5, 1, 1) _squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._squelch_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, minimum=-95, maximum=-55, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_sizer, 0, 6, 1, 1) self._rx_offset_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.rx_offset, callback=self.set_rx_offset, label="RX offset", choices=[0, 600000, -600000,5e6], labels=['0', '+', '-','+5M'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._rx_offset_chooser, 1, 6, 1, 1) _rit_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._rit_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_rit_tune_sizer, value=self.rit_tune, callback=self.set_rit_tune, label="RIT", converter=forms.float_converter(), proportion=0, ) self._rit_tune_slider = forms.slider( parent=self.GetWin(), sizer=_rit_tune_sizer, value=self.rit_tune, callback=self.set_rit_tune, minimum=-30e3, maximum=+30e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rit_tune_sizer, 1, 2, 1, 3) self._offset_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset, callback=self.set_offset, label="TX offset", choices=[600000, -600000, 0,5e6], labels=['+', '-', '0','5MHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._offset_chooser, 0, 4, 1, 1) self._chooser_fm_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chooser_fm, callback=self.set_chooser_fm, label="Preset", choices=[145.13e6,145.33e6, 145.88e6, 146.46e6, 146.49e6, 146.52e6,146.58e6, 146.64e6,146.74e6, 146.82e6, 146.86e6, 146.92e6, 146.96e6, 147.0e6,147.06e6, 147.08e6, 147.20e6, 147.22e6, 147.34e6, 223.5e6,441.825e6, 432.25e6], labels=[145.13,145.33, 145.88, 146.46, 146.49, 146.52, 146.58, 146.64, 146.74, 146.82, 146.860, 146.92, 146.96, 147.00, 147.06, 147.08,147.200, 147.220, 147.34, 223.5,441.825, 432.25], style=wx.RA_HORIZONTAL, ) self.Add(self._chooser_fm_chooser) _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, label="Audio gain", converter=forms.float_converter(), proportion=0, ) self._audio_gain_slider = forms.slider( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, minimum=.1, maximum=4, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_audio_gain_sizer, 0, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=(((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset), y_per_div=5, y_divs=16, ref_level=-55, ref_scale=2.0, sample_rate=samp_rate/2, fft_size=1024*0+2048*0+4096, fft_rate=12, average=True, avg_alpha=.4, title="RF Bandpass", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 5, 14) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate((samp_rate)) self.uhd_usrp_source_0.set_center_freq((((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset)-10e3, 0) self.uhd_usrp_source_0.set_normalized_gain(.520*.8, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_bandwidth(1.99e6, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(320000) self.uhd_usrp_sink_1.set_center_freq((((((chooser_fm+offset)+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rit_tune, 0) self.uhd_usrp_sink_1.set_normalized_gain((.83*0+.72)*0+tx_gain, 0) self.uhd_usrp_sink_1.set_antenna("TX/RX", 0) self.uhd_usrp_sink_1.set_bandwidth(200000, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=32000, decimation=40000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate/2, decimation=samp_rate, taps=None, fractional_bw=None, ) self.pfb_decimator_ccf_0 = pfb.decimator_ccf( 2, (firdes.low_pass(.1, (samp_rate), (samp_rate)/4.05,10e3)), 0, 100, True, True) self.pfb_decimator_ccf_0.declare_sample_delay(0) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, 32000, 4400, 300, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, 32000, 4500, 600, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0 = filter.fir_filter_fff(1, firdes.high_pass( 1, 32000, 300, 100, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1,samp_rate/2,18e3,600)), 0+rit_tune+10e3, samp_rate/2) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((.8, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((125, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain*tx_rx_choice, )) self.blocks_add_xx_1 = blocks.add_vff(1) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=1+(tx_rx_choice), output_index=0, ) self.audio_source_1 = audio.source(32000, "", True) self.audio_sink_0 = audio.sink(32000, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, .0001) self.analog_sig_source_x_0 = analog.sig_source_f(32000, analog.GR_COS_WAVE, tone, .091, 0) self.analog_nbfm_tx_1 = analog.nbfm_tx( audio_rate=32000, quad_rate=320000, tau=(75e-6)*0+90e-6, max_dev=5e3, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=32000, quad_rate=32000, tau=75e-6, max_dev=5e3, ) self.analog_fm_preemph_0 = analog.fm_preemph(fs=32e3, tau=75e-6) self.analog_fm_deemph_0 = analog.fm_deemph(fs=32000, tau=75e-6) ################################################## # Connections ################################################## self.connect((self.analog_fm_deemph_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.analog_nbfm_tx_1, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blks2_selector_0_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.analog_nbfm_tx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.high_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blks2_selector_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.high_pass_filter_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_fm_preemph_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_decimator_ccf_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.pfb_decimator_ccf_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.lo_offset = lo_offset = 0 self.gain = gain = 80 self.freq = freq = 5.18e9 self.chan_est = chan_est = ieee802_11.LMS ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.Add(self.nb) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], labels=[ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ], ) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ], labels=["LS", "LMS", "STA", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_scopesink1 = scopesink2.scope_sink_c( self.nb.GetPage(0).GetWin(), title="Scope Plot", sample_rate=12500, v_scale=0.5, v_offset=0, t_scale=0.5, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(0).Add(self.wxgui_scopesink1.win) self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "") self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, "packet_len") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "/tmp/wifi.pcap", True) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.rftap_rftap_encap_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.wxgui_scopesink1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Communication System Graphical Analyzer (LAPS/UFCG)") ################################################## # Default Variables ################################################## self.sps = 2 self.snr = 20 self.symbol_rate = 140000 self.mod_type = "DBPSK" self.view = 1 self.band= 200 self.excess_bw=0.35 self.fading_flag = False self.fdts = -8 self.fading_state_rx = False ################################################## # Blocks Definition ################################################## #A bit stream of 1's is generated at the source, scrambled, #modulated and sent to the input of an AWGN channel. #random.seed(42) #self.source = gr.vector_source_b([random.randint(0, 2) for i in range(0,10^8)], True) self.source = gr.vector_source_b((1,), True, 1) self.thottle = gr.throttle(gr.sizeof_char,10e5) self.scrambler = gr.scrambler_bb(0x40801, 0x92F72, 20) #Taxa de simbolos constante self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.modulator = utils.mods[self.mod_type](self.sps,excess_bw=self.excess_bw) self.channel = utils.channel(1/10.0**(self.snr/10.0),self.band,self.symbol_rate,self.sps) #The noisy signal is demodulated, descrambled and the BER #is estimated by the ber_estim block using the receiver #density of 0 bits. self.demodulator = utils.demods[self.mod_type](self.sps,excess_bw=self.excess_bw) self.descrambler = gr.descrambler_bb(0x40801, 0x92F72, 20) self.char2float = gr.char_to_float() self.mov_average = gr.moving_average_ff(524288, 1/524288., 10000) self.ber = utils.ber_estim() #self.ber = utils.ber_estim_simple(3) ################################################## # GUI Elements Definition ################################################## #Defines an adds FFT Window to GUI self.fft = fftsink.fft_sink_c(self.GetWin(), sample_rate=self.symbol_rate*self.sps, baseband_freq=5e6) self.GridAdd(self.fft.win, 0,3,4,3) self.ctr= gr.complex_to_real(1) #Defines and adds SNR slider to GUI _snr_sizer = wx.BoxSizer(wx.HORIZONTAL) self._snr_text_box = forms.text_box(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, label=" SNR (dB)", converter=forms.float_converter(), proportion=0) self._snr_slider = forms.slider(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, minimum=0, maximum=20, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(_snr_sizer, 4, 3, 1, 3) #Defines and adds bandwidth slider to GUI band_sizer = wx.BoxSizer(wx.HORIZONTAL) self.band_text_box = forms.text_box(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, label="Bandwidth (kHz)", converter=forms.float_converter(), proportion=0) self.band_slider = forms.slider(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, minimum=30, maximum=200, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(band_sizer, 5, 3, 1, 3) #Defines and adds Rayleigh GUI elements fading_sizer = wx.BoxSizer(wx.HORIZONTAL) self.fading_text_box = forms.text_box(parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, label='Fading/log(FdTs)', converter=forms.float_converter(), proportion=0) self.fading_slider = forms.slider(parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, minimum=-8, maximum=-2, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(fading_sizer, 6, 3, 1, 3) #Defines and adds modulation type chooser to GUI self._mod_type_chooser = forms.radio_buttons(parent=self.GetWin(), value=self.mod_type, callback=self.set_mod_type, label="Modulation", choices=["DBPSK", "DQPSK", "D8PSK"], labels=["DBPSK", "DQPSK", "D8PSK"], style=wx.RA_HORIZONTAL) self.GridAdd(self._mod_type_chooser, 7, 4, 1, 2) #Defines and adds signal source chooser self.sig_src_chooser = forms.radio_buttons(parent=self.GetWin(), value=self.view, callback=self.callback_view, label="Signal Source", choices=[0,1], labels=["Transmitter","Receiver"], style=wx.RA_VERTICAL) self.GridAdd(self.sig_src_chooser, 7,3,1,1) #Definition of the of constellation window and attachment to the GUI self.constel = constsink.const_sink_c(self.GetWin(), title="RX Constellation Plot", sample_rate=self.symbol_rate, const_size=256, mod=self.mod_type) self.GridAdd(self.constel.win,0,0,8,3) #Definition of the constellation sink window and attachment to the GUI self.number_sink = bersink.number_sink_f(self.GetWin(), sample_rate=self.symbol_rate) self.GridAdd(self.number_sink.win,8,0,1,6) ################################################## # Blocks Connections ################################################## #The necessary block connections to the system work as described above. self.connect(self.source, self.scrambler , self.thottle, self.pack) #self.connect(self.source , self.thottle, self.pack) self.connect(self.pack, self.modulator, self.channel, self.demodulator) self.connect(self.channel, self.fft) self.connect(self.demodulator.diffdec, self.constel) self.connect(self.demodulator, self.descrambler, self.char2float, self.mov_average) self.connect(self.mov_average, self.ber, self.number_sink)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dectrx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.channel = channel = 1 self.samp_rate = samp_rate = 2.4e6 self.rf_gain = rf_gain = 10 self.ppm = ppm = 0 self.if_gain = if_gain = 20 self.freq = freq = 1897.344e6 - (channel * 1.728e6) self.dect_rate = dect_rate = 1.152e6 self.bb_gain = bb_gain = 20 ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label='rf_gain', converter=forms.float_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rf_gain_sizer) _ppm_sizer = wx.BoxSizer(wx.VERTICAL) self._ppm_text_box = forms.text_box( parent=self.GetWin(), sizer=_ppm_sizer, value=self.ppm, callback=self.set_ppm, label="ppm", converter=forms.int_converter(), proportion=0, ) self._ppm_slider = forms.slider( parent=self.GetWin(), sizer=_ppm_sizer, value=self.ppm, callback=self.set_ppm, minimum=-70, maximum=+70, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_ppm_sizer) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label='if_gain', converter=forms.float_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_if_gain_sizer) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label='bb_gain', converter=forms.float_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bb_gain_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=freq, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rf_gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(dect_rate, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, dect_rate, 10e3, firdes.WIN_HAMMING, 6.76)) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0, verbose=False, log=False, ) self._channel_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.channel, callback=self.set_channel, label="channel", major_dimension=10, choices=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._channel_chooser) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1, "127.0.0.1", 2323, 1472, True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) ################################################## # Connections ################################################## self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Complex Multiplier RX SDRstick HF1 with PBT & Variable BW") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.kHz = kHz = 0 self.MHz = MHz = 10 self.Hz = Hz = 0 self.samp_rate = samp_rate = 384000 self.pbt = pbt = 0 self.freq = freq = MHz * 1000000 + kHz * 1000 + Hz self.bw = bw = 1500 self.AF_gain = AF_gain = 2 ################################################## # Blocks ################################################## _pbt_sizer = wx.BoxSizer(wx.VERTICAL) self._pbt_text_box = forms.text_box( parent=self.GetWin(), sizer=_pbt_sizer, value=self.pbt, callback=self.set_pbt, label=" Passband Tuning", converter=forms.float_converter(), proportion=0, ) self._pbt_slider = forms.slider( parent=self.GetWin(), sizer=_pbt_sizer, value=self.pbt, callback=self.set_pbt, minimum=-.000190, maximum=.000190, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pbt_sizer) self._bw_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.bw, callback=self.set_bw, label=" Bandwidth", choices=[500, 1500, 3000, 10000], labels=['500', '1.5K', '3K', '10K'], style=wx.RA_HORIZONTAL, ) self.Add(self._bw_chooser) _AF_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._AF_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_AF_gain_sizer, value=self.AF_gain, callback=self.set_AF_gain, label=" Audio Gain", converter=forms.float_converter(), proportion=0, ) self._AF_gain_slider = forms.slider( parent=self.GetWin(), sizer=_AF_gain_sizer, value=self.AF_gain, callback=self.set_AF_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_AF_gain_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=(samp_rate), fft_size=4096, fft_rate=15, average=True, avg_alpha=.5, title=" LSB Baseband Frequency kHz USB", peak_hold=False, size=(850, 400), ) self.Add(self.wxgui_fftsink2_1.win) self.low_pass_filter_0 = filter.fir_filter_ccf( samp_rate / 48000, firdes.low_pass(1, samp_rate, bw / 2, 100, firdes.WIN_HAMMING, 6.76)) _kHz_sizer = wx.BoxSizer(wx.VERTICAL) self._kHz_text_box = forms.text_box( parent=self.GetWin(), sizer=_kHz_sizer, value=self.kHz, callback=self.set_kHz, label="kHz", converter=forms.float_converter(), proportion=0, ) self._kHz_slider = forms.slider( parent=self.GetWin(), sizer=_kHz_sizer, value=self.kHz, callback=self.set_kHz, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_kHz_sizer) self.hpsdr_hermesNB_0 = hpsdr.hermesNB(freq, freq, freq, 0, 0, 1, 1, 0, 384000, "eth0", "0xF0", 0xa0, 0, 0x00, 0x00, 0, 1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (AF_gain, )) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate / 48000, analog.GR_COS_WAVE, ((bw / 2) * pbt), .99, 0) self.analog_agc3_xx_0 = analog.agc3_cc(1, 1e-5, 0.5, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) _MHz_sizer = wx.BoxSizer(wx.VERTICAL) self._MHz_text_box = forms.text_box( parent=self.GetWin(), sizer=_MHz_sizer, value=self.MHz, callback=self.set_MHz, label="MHz", converter=forms.float_converter(), proportion=0, ) self._MHz_slider = forms.slider( parent=self.GetWin(), sizer=_MHz_sizer, value=self.MHz, callback=self.set_MHz, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_MHz_sizer) _Hz_sizer = wx.BoxSizer(wx.VERTICAL) self._Hz_text_box = forms.text_box( parent=self.GetWin(), sizer=_Hz_sizer, value=self.Hz, callback=self.set_Hz, label="Fine", converter=forms.float_converter(), proportion=0, ) self._Hz_slider = forms.slider( parent=self.GetWin(), sizer=_Hz_sizer, value=self.Hz, callback=self.set_Hz, minimum=-1000, maximum=1000, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Hz_sizer) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.hpsdr_hermesNB_0, 0)) self.connect((self.hpsdr_hermesNB_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="TX Test") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sampno = sampno = 32 self.samp_rate_1 = samp_rate_1 = sampno * 1e3 self.sigsource = sigsource = 100 self.samp_rate = samp_rate = int(samp_rate_1) self.carfreqno = carfreqno = 1 self.carfreq_1 = carfreq_1 = 1 self.bbfreqno = bbfreqno = 1 self.bbfreq_1 = bbfreq_1 = 1 self.bb_amp = bb_amp = 0 ################################################## # Blocks ################################################## self._bbfreqno_text_box = forms.text_box( parent=self.GetWin(), value=self.bbfreqno, callback=self.set_bbfreqno, label='Baseband Frequency', converter=forms.float_converter(), ) self.GridAdd(self._bbfreqno_text_box, 0, 0, 1, 1) self._sigsource_chooser = forms.drop_down( parent=self.GetWin(), value=self.sigsource, callback=self.set_sigsource, label='Signal Source', choices=[100, 101, 102, 103, 104, 105], labels=[ 'Constant', 'Sine Wave', 'Cosine Wave', 'Square', 'Triange', 'Saw Tooth' ], ) self.GridAdd(self._sigsource_chooser, 7, 0, 1, 1) self._sampno_text_box = forms.text_box( parent=self.GetWin(), value=self.sampno, callback=self.set_sampno, label='Sample Rate', converter=forms.float_converter(), ) self.GridAdd(self._sampno_text_box, 4, 0, 1, 1) self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Scope Sink") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT Sink") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Histo Sink") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Waterfall Sink") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Constellation Sink") self.GridAdd(self.notebook, 8, 0, 1, 1) self._carfreqno_text_box = forms.text_box( parent=self.GetWin(), value=self.carfreqno, callback=self.set_carfreqno, label='Carrier Frequency', converter=forms.float_converter(), ) self.GridAdd(self._carfreqno_text_box, 2, 0, 1, 1) self._bbfreq_1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.bbfreq_1, callback=self.set_bbfreq_1, label=' ', choices=[bbfreqno, bbfreqno * 1e3, bbfreqno * 1e6, bbfreqno * 1e9], labels=['Hz', 'kHz', 'MHz', 'GHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._bbfreq_1_chooser, 1, 0, 1, 1) _bb_amp_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_amp_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_amp_sizer, value=self.bb_amp, callback=self.set_bb_amp, label='Baseband Amplitude', converter=forms.float_converter(), proportion=0, ) self._bb_amp_slider = forms.slider( parent=self.GetWin(), sizer=_bb_amp_sizer, value=self.bb_amp, callback=self.set_bb_amp, minimum=-1, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_bb_amp_sizer, 6, 0, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.notebook.GetPage(3).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Waterfall Plot', win=window.hanning, ) self.notebook.GetPage(3).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook.GetPage(0).GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.notebook.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_histosink2_0 = histosink_gl.histo_sink_f( self.notebook.GetPage(2).GetWin(), title='Histogram Plot', num_bins=27, frame_size=1000, ) self.notebook.GetPage(2).Add(self.wxgui_histosink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.notebook.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, win=window.flattop, ) self.notebook.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.notebook.GetPage(4).GetWin(), title='Constellation Plot', sample_rate=samp_rate, frame_rate=5, const_size=2048, M=4, theta=0, loop_bw=6.28 / 100.0, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate / 4., omega_limit=0.005, ) self.notebook.GetPage(4).Add(self.wxgui_constellationsink2_0.win) self._samp_rate_1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate_1, callback=self.set_samp_rate_1, label=' ', choices=[sampno, sampno * 1e3, sampno * 1e6, sampno * 1e9], labels=['sp/s', 'ksp/s', 'msp/s', 'gsp/s'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._samp_rate_1_chooser, 5, 0, 1, 1) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=int(samp_rate / 32000), decimation=1, taps=None, fractional_bw=None, ) self._carfreq_1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.carfreq_1, callback=self.set_carfreq_1, label=' ', choices=[ carfreqno, carfreqno * 1e3, carfreqno * 1e6, carfreqno * 1e9 ], labels=['Hz', 'kHz', 'MHz', 'GHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._carfreq_1_chooser, 3, 0, 1, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_sig_source_x_0 = analog.sig_source_f( 32e3, sigsource, bbfreq_1, bb_amp, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_histosink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.freq = freq = 88.5e6 self.enable = enable = 0 self.audio_rate = audio_rate = 44100 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label='freq', converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=88.0e6, maximum=107.9e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self._enable_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.enable, callback=self.set_enable, label='enable', choices=[0,1], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._enable_chooser) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_normalized_gain(0.5, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate * 1.0), decimation=audio_rate * audio_interp, taps=None, fractional_bw=None, ) self.blocks_wavfile_source_1 = blocks.wavfile_source("/home/john/IRG/Music/John Prine - The Sins of Memphisto.wav", True) self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/john/IRG/Music/Inspired But Too Tired Acoustic.wav", True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((25, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((25, )) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=enable, output_index=0, ) self.analog_wfm_tx_0_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * audio_interp, tau=75e-6, max_dev=5e3, ) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * audio_interp, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_tx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.analog_wfm_tx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_selector_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_wfm_tx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_1, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver Juan") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 15 self.samp_rate_0 = samp_rate_0 = 20e6 self.samp_rate = samp_rate = 10e6 self.rx_gain = rx_gain = 5 self.oversampling = oversampling = 4 self.mult = mult = 0.38 self.lo_offset = lo_offset = 0 self.freq = freq = 5.89e9 self.encoding = encoding = 0 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0, 1, 2, 3, 4, 5, 6, 7], labels=[ "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=5000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wifi_phy_hier_0 = wifi_phy_hier( chan_est=0, encoding=0, ) _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=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) _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='rx_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.Add(_rx_gain_sizer) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac( ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42])) self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], labels=[ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ], ) self.Add(self._freq_chooser) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0).set_min_output_buffer(100000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=.5**.5, frequency_offset=0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1, "192.168.200.2", 1234, 100, True) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False) self.blocks_throttle_0 = blocks.throttle( gr.sizeof_char * 1, 2 * 4e3 + 0 * samp_rate / 40 / (oversampling * 8 * 2), True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/media/juan/d6aba572-c85c-40cc-9258-ae1538dfb8c5/home/juan/Music/de_mi.mp3", True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in')) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.spreading_offon = spreading_offon = 0 self.samp_rate = samp_rate = 5000 self.pn_len = pn_len = 32 self.interpolation = interpolation = 4 ################################################## # Blocks ################################################## self._spreading_offon_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.spreading_offon, callback=self.set_spreading_offon, label='Spreading Off/On', choices=[0, 1], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._spreading_offon_chooser) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate * pn_len * interpolation, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_base_xxx_0 = filter.rational_resampler_base_fff( pn_len, 1, ([ 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 0 ])) self.digital_glfsr_source_x_0 = digital.glfsr_source_f(15, True, 0, 1) self.blocks_throttle_0 = blocks.throttle( gr.sizeof_gr_complex * 1, samp_rate * pn_len * interpolation, True) self.blocks_repeat_1 = blocks.repeat(gr.sizeof_gr_complex * 1, 4) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 31) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=2, num_outputs=1, input_index=spreading_offon, output_index=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_selector_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_repeat_1, 0)) self.connect((self.blocks_repeat_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_repeat_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.rational_resampler_base_xxx_0, 0)) self.connect((self.rational_resampler_base_xxx_0, 0), (self.blks2_selector_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.variable_control = variable_control = 1 self.samp_rate = samp_rate = 0.5e6 self.freq_change = freq_change = -52e3 self.amp_const = amp_const = 0.1 self.RC_FREQUENCY = RC_FREQUENCY = 45.6498e6 self.RC_DIRECTION = RC_DIRECTION = 1 ################################################## # Blocks ################################################## _amp_const_sizer = wx.BoxSizer(wx.VERTICAL) self._amp_const_text_box = forms.text_box( parent=self.GetWin(), sizer=_amp_const_sizer, value=self.amp_const, callback=self.set_amp_const, label="amp const", converter=forms.float_converter(), proportion=0, ) self._amp_const_slider = forms.slider( parent=self.GetWin(), sizer=_amp_const_sizer, value=self.amp_const, callback=self.set_amp_const, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_amp_const_sizer) self._RC_FREQUENCY_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.RC_FREQUENCY, callback=self.set_RC_FREQUENCY, label="Transmission Frequency", choices=[27.253e6, 45.6498e6, 49e6], labels=["27 MHz", "45.6498 Mhz", "49 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._RC_FREQUENCY_chooser) self._RC_DIRECTION_chooser = forms.button( parent=self.GetWin(), value=self.RC_DIRECTION, callback=self.set_RC_DIRECTION, label="Select Direction", choices=[11,1, 2,6,12], labels=["ENDCODE","FORWARD","FORWARD TURBO","BACKWARDS","NOTHING"], ) self.Add(self._RC_DIRECTION_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) _variable_control_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_control_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_control_sizer, value=self.variable_control, callback=self.set_variable_control, label="direction", converter=forms.int_converter(), proportion=0, ) self._variable_control_slider = forms.slider( parent=self.GetWin(), sizer=_variable_control_sizer, value=self.variable_control, callback=self.set_variable_control, minimum=1, maximum=6, num_steps=6, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_variable_control_sizer) self.rccar_rc_interpolator_0 = rccar2.functioninterpolator(samp_rate) self.rccar_functioncoder_0 = rccar2.functioncoder(samplerate=samp_rate,functioncode=1) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "hackrf" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(RC_FREQUENCY, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(30, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) _freq_change_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_change_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_change_sizer, value=self.freq_change, callback=self.set_freq_change, label="freq_change", converter=forms.float_converter(), proportion=0, ) self._freq_change_slider = forms.slider( parent=self.GetWin(), sizer=_freq_change_sizer, value=self.freq_change, callback=self.set_freq_change, minimum=-2e6, maximum=2e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_change_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp_const, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_const_source_x_0 = analog.sig_source_i(0, analog.GR_CONST_WAVE, 0, 0, RC_DIRECTION) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.rccar_rc_interpolator_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.rccar_functioncoder_0, 0)) self.connect((self.rccar_functioncoder_0, 0), (self.rccar_rc_interpolator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.freq = freq = 2.437e9 self.chan_est = chan_est = ieee802_11.LMS ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[1e6, 3e6, 5e6, 10e6, 15e6, 20e6], labels=["1 MHz", "3 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2.412e9, 2.417e9, 2.422e9, 2.427e9, 2.432e9, 2.437e9, 2.442e9, 2.447e9, 2.452e9, 2.457e9, 2.462e9, 5.035e9, 5.040e9, 5.045e9, 5.055e9, 5.060e9, 5.080e9, 5.170e9, 5.180e9, 5.190e9, 5.200e9, 5.210e9, 5.220e9, 5.230e9, 5.240e9, 5.250e9, 5.260e9, 5.270e9, 5.280e9, 5.290e9, 5.300e9, 5.310e9, 5.320e9, 5.500e9, 5.510e9, 5.520e9, 5.530e9, 5.540e9, 5.550e9, 5.560e9, 5.570e9, 5.580e9, 5.590e9, 5.600e9, 5.610e9, 5.620e9, 5.630e9, 5.640e9, 5.660e9, 5.670e9, 5.680e9, 5.690e9, 5.700e9, 5.710e9, 5.720e9, 5.745e9, 5.755e9, 5.765e9, 5.775e9, 5.785e9, 5.795e9, 5.805e9, 5.825e9 ], labels=[ "Ch 1 | 2412", "Ch 2 | 2417", "Ch 3 | 2422", "Ch 4 | 2427", "Ch 5 | 2432", "Ch 6 | 2437", "Ch 7 | 2442", "Ch 8 | 2447", "Ch 9 | 2452", "Ch 10 | 2457", "Ch 11 | 2462", "Ch 36 | 5180", "Ch 7 | 5035", "Ch 8 | 5040", "Ch 9 | 5045", "Ch 11 | 5055", "Ch 12 | 5060", "Ch 16 | 5080", "Ch 34 | 5170", "Ch 36 | 5180", "Ch 38 | 5190", "Ch 40 | 5200", "Ch 42 | 5210", "Ch 44 | 5220", "Ch 46 | 5230", "Ch 48 | 5240", "Ch 50 | 5250", "Ch 52 | 5260", "Ch 54 | 5270", "Ch 56 | 5280", "Ch 58 | 5290", "Ch 60 | 5300", "Ch 62 | 5310", "Ch 64 | 5320", "Ch 100 | 5500", "Ch 102 | 5510", "Ch 104 | 5520", "Ch 106 | 5530", "Ch 108 | 5540", "Ch 110 | 5550", "Ch 112 | 5560", "Ch 114 | 5570", "Ch 116 | 5580", "Ch 118 | 5590", "Ch 120 | 5600", "Ch 122 | 5610", "Ch 124 | 5620", "Ch 126 | 5630", "Ch 128 | 5640", "Ch 132 | 5660", "Ch 134 | 5670", "Ch 136 | 5680", "Ch 138 | 5690", "Ch 140 | 5700", "Ch 142 | 5710", "Ch 144 | 5720", "Ch 149 | 5745", "Ch 151 | 5755", "Ch 153 | 5765", "Ch 155 | 5775", "Ch 157 | 5785", "Ch 159 | 5795", "Ch 161 | 5805", "Ch 165 | 5825" ]) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ], labels=["LS", "LMS", "STA", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "") self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, False, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(freq, True, False) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.rftap_rftap_encap_0, 'in')) self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="IEEE 802.15.4 Transceiver using OQPSK PHY") ################################################## # Variables ################################################## self.gain = gain = 50 self.freq = freq = 2450000000 ################################################## # Blocks ################################################## _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=1, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)], labels=[i for i in range(11, 27)], style=wx.RA_HORIZONTAL, ) self.Add(self._freq_chooser) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=4e6, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, "") self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(4e6) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy() self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True) self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False) self.epy_block_0 = blk() self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "/tmp/zigbee.pcap", False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.epy_block_0, 'out'), (self.rftap_rftap_encap_0, 'in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.epy_block_0, 'in')) self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Loopback Ah") ################################################## # Variables ################################################## self.snr = snr = 20 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.interval = interval = 100 self.encoding = encoding = 0 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## _snr_sizer = wx.BoxSizer(wx.VERTICAL) self._snr_text_box = forms.text_box( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, label='snr', converter=forms.float_converter(), proportion=0, ) self._snr_slider = forms.slider( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, minimum=-15, maximum=30, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_snr_sizer) _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL) self._pdu_length_text_box = forms.text_box( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, label='pdu_length', converter=forms.int_converter(), proportion=0, ) self._pdu_length_slider = forms.slider( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, minimum=0, maximum=1500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_pdu_length_sizer) _interval_sizer = wx.BoxSizer(wx.VERTICAL) self._interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, label="PDU Interval (ms)", converter=forms.int_converter(), proportion=0, ) self._interval_slider = forms.slider( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, minimum=10, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_interval_sizer) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0, 1, 2, 3, 4, 5, 6, 7, 8], labels=[ "BPSK 1/2", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4", "64QAM 5/6", "256QAM 3/4" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=12500, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wifi_phy_hier_ah_0 = wifi_phy_hier_ah( chan_est=chan_est, encoding=encoding, sensitivity=0.56, ) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac( False, True) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac( ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=1, frequency_offset=0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.float_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( ((10**(snr / 10.0))**.5, )) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("".join("x" for i in range(pdu_length))), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_ah_0, 'mac_in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_ah_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_ah_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 1), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Tx") ################################################## # Variables ################################################## self.tx_gain = tx_gain = 50 self.samp_rate = samp_rate = 10e6 self.period = period = 100 self.pdu_length = pdu_length = 100 self.out_buf_size = out_buf_size = 96000 self.mult = mult = .4 self.lo_offset = lo_offset = 11e6 self.freq = freq = 2.422e9 self.encoding = encoding = 0 ################################################## # Blocks ################################################## _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=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[10e6, 20e6], labels=["10 Mhz", "20 Mhz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) _period_sizer = wx.BoxSizer(wx.VERTICAL) self._period_text_box = forms.text_box( parent=self.GetWin(), sizer=_period_sizer, value=self.period, callback=self.set_period, label='period', converter=forms.int_converter(), proportion=0, ) self._period_slider = forms.slider( parent=self.GetWin(), sizer=_period_sizer, value=self.period, callback=self.set_period, minimum=1, maximum=10000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_period_sizer) _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL) self._pdu_length_text_box = forms.text_box( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, label='pdu_length', converter=forms.int_converter(), proportion=0, ) self._pdu_length_slider = forms.slider( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, minimum=0, maximum=1500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_pdu_length_sizer) _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0,1,2,3,4,5,6,7], labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.wifi_phy_hier_0 = wifi_phy_hier( chan_est=0, encoding=encoding, sensitivity=0.56, ) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), period) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver") ################################################## # Variables ################################################## self.tx_gain = tx_gain = 40 self.samp_rate = samp_rate = 20e6 self.rx_gain = rx_gain = 40 self.mult = mult = 0.38 self.lo_offset = lo_offset = 0 self.freq = freq = 2.412e9 self.encoding = encoding = 0 ################################################## # Blocks ################################################## _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=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6,10e6, 20e6], labels=["5MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) _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='rx_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.Add(_rx_gain_sizer) _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0,1,2,3,4,5,6,7], labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=5000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wifi_phy_hier_0 = wifi_phy_hier( chan_est=0, encoding=0, sensitivity=0.56, ) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B])) self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0).set_min_output_buffer(100000) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx") ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 10e6 self.lo_offset = lo_offset = 11e6 self.gain = gain = 20 self.freq = freq = 5.89e9 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.Add(self.nb) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short( 0.56, 2, False, False) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long( sync_length, False, False) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], labels=[ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ], ) self.Add(self._freq_chooser) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.data_equalizing_HYR_ofdm_0 = data_equalizing.HYR_ofdm() self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 64) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/esl/naver/TRANSCEIVERdump", False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_file_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.data_equalizing_HYR_ofdm_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.fft_vxx_0, 0), (self.data_equalizing_HYR_ofdm_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))
def __init__(self, options, hostname, msgq): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx") #_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" #self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.lo_offset = lo_offset = 0e6 self.gain = gain = 20 self.freq = freq = 5.87e9 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6, 10e6, 20e6], labels=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.Add(self.nb) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], labels=[ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ], ) self.Add(self._freq_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_scopesink1 = scopesink2.scope_sink_c( self.nb.GetPage(0).GetWin(), title="Scope Plot", sample_rate=12500, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(0).Add(self.wxgui_scopesink1.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short( 0.56, 2, False, False) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long( sync_length, True, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac( False, True) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols( chan_est, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal( False, False, True) #######Added 3rd argument self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac( True, False) ### _reg self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 48) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) ##self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) ##self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") ##The following block is newly added self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", hostname, str(options.PHYRXport), 10000) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.msg_sink = blocks.message_sink(4, msgq, True) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) ##self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) ##The following connection is newly added ###self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "fer", self.blocks_socket_pdu_0, "pdus") self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.blocks_socket_pdu_0, "pdus")) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) #self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink1, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) ##new added connection self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.msg_sink)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Example Tx Ii") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8000000 self.running = running = False self.command = command = 10 ################################################## # Blocks ################################################## self._running_check_box = forms.check_box( parent=self.GetWin(), value=self.running, callback=self.set_running, label='running', true=True, false=False, ) self.Add(self._running_check_box) self._command_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.command, callback=self.set_command, label='command', choices=[58,64,28,34,10,22,40,46,52], labels=['<-','->','<^','^>','^','^^','v','v>','<v'], style=wx.RA_HORIZONTAL, ) self.Add(self._command_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=2e-3, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_FREE, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.remotecar_RemoteCarIIBaseBand_0 = remotecar.RemoteCarIIBaseBand(samp_rate,running, command) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(27.15e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(40, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, devid="type=b100", rdsfile="rds_fifo", gain=35.0, freq=101.1e6, xmlport=13777, arate=int(48e3), mute=-15.0, ftune=0, ant="J1", subdev="A:0", ahw="pulse", deemph=75.0e-6, prenames='["UWRF","89.3","950","WEVR"]', prefreqs="[88.715e6,89.3e6,950.735e6,106.317e6]", volume=1.0): grc_wxgui.top_block_gui.__init__(self, title="Simple FM (Stereo) Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.devid = devid self.rdsfile = rdsfile self.gain = gain self.freq = freq self.xmlport = xmlport self.arate = arate self.mute = mute self.ftune = ftune self.ant = ant self.subdev = subdev self.ahw = ahw self.deemph = deemph self.prenames = prenames self.prefreqs = prefreqs self.volume = volume ################################################## # Variables ################################################## self.pthresh = pthresh = 350 self.preselect = preselect = eval(prefreqs)[0] self.pilot_level = pilot_level = 0 self.ifreq = ifreq = freq self.stpilotdet = stpilotdet = True if (pilot_level > pthresh) else False self.stereo = stereo = True self.rf_pwr_lvl = rf_pwr_lvl = 0 self.cur_freq = cur_freq = simple_fm_helper.freq_select(ifreq,preselect) self.vol = vol = volume self.variable_static_text_0 = variable_static_text_0 = 10.0*math.log(rf_pwr_lvl+1.0e-11)/math.log(10) self.tone_med = tone_med = 5 self.tone_low = tone_low = 5 self.tone_high = tone_high = 5 self.stereo_0 = stereo_0 = stpilotdet self.st_enabled = st_enabled = 1 if (stereo == True and pilot_level > pthresh) else 0 self.squelch_probe = squelch_probe = 0 self.sq_thresh = sq_thresh = mute self.samp_rate = samp_rate = 250e3 self.rtext_0 = rtext_0 = cur_freq self.record = record = False self.rdsrate = rdsrate = 25e3 self.osmo_taps = osmo_taps = firdes.low_pass(1.0,1.00e6,95e3,20e3,firdes.WIN_HAMMING,6.76) self.mod_reset = mod_reset = 0 self.igain = igain = gain self.fine = fine = ftune self.farate = farate = arate self.dm = dm = deemph self.discrim_dc = discrim_dc = 0 self.capture_file = capture_file = "capture.wav" self.asrate = asrate = 125e3 ################################################## # Blocks ################################################## _sq_thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._sq_thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, label="Mute Level", converter=forms.float_converter(), proportion=0, ) self._sq_thresh_slider = forms.slider( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, minimum=-30.0, maximum=-5.0, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_sq_thresh_sizer, 1, 5, 1, 1) self.input_power = gr.probe_avg_mag_sqrd_c(sq_thresh, 1.0/(samp_rate/10)) self.dc_level = gr.probe_signal_f() _vol_sizer = wx.BoxSizer(wx.VERTICAL) self._vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, label="Volume", converter=forms.float_converter(), proportion=0, ) self._vol_slider = forms.slider( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, minimum=0, maximum=11, num_steps=110, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vol_sizer, 0, 3, 1, 1) _tone_med_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_med_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, label="1Khz-4Khz", converter=forms.float_converter(), proportion=0, ) self._tone_med_slider = forms.slider( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_med_sizer, 1, 3, 1, 1) _tone_low_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_low_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, label="0-1Khz", converter=forms.float_converter(), proportion=0, ) self._tone_low_slider = forms.slider( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_low_sizer, 1, 2, 1, 1) _tone_high_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_high_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, label="4Khz-15Khz", converter=forms.float_converter(), proportion=0, ) self._tone_high_slider = forms.slider( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_high_sizer, 1, 4, 1, 1) def _squelch_probe_probe(): while True: val = self.input_power.unmuted() try: self.set_squelch_probe(val) except AttributeError, e: pass time.sleep(1.0/(10)) _squelch_probe_thread = threading.Thread(target=_squelch_probe_probe) _squelch_probe_thread.daemon = True _squelch_probe_thread.start() self._record_check_box = forms.check_box( parent=self.GetWin(), value=self.record, callback=self.set_record, label="Record Audio", true=True, false=False, ) self.GridAdd(self._record_check_box, 2, 2, 1, 1) self.pilot_probe = gr.probe_signal_f() _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-50.0e3, maximum=50.e03, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_sizer, 1, 0, 1, 1) def _discrim_dc_probe(): while True: val = self.dc_level.level() try: self.set_discrim_dc(val) except AttributeError, e: pass time.sleep(1.0/(2.5)) _discrim_dc_thread = threading.Thread(target=_discrim_dc_probe) _discrim_dc_thread.daemon = True _discrim_dc_thread.start() self._capture_file_text_box = forms.text_box( parent=self.GetWin(), value=self.capture_file, callback=self.set_capture_file, label="Record Filename", converter=forms.str_converter(), ) self.GridAdd(self._capture_file_text_box, 2, 0, 1, 2) self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "L/R") self.Main.AddPage(grc_wxgui.Panel(self.Main), "FM Demod Spectrum") self.Add(self.Main) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.Main.GetPage(0).GetWin(), title="Audio Channels (L and R)", sample_rate=farate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Rel. Audio Level", ) self.Main.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.Main.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=asrate, fft_size=1024, fft_rate=6, average=True, avg_alpha=0.1, title="FM Demod Spectrum", peak_hold=False, ) self.Main.GetPage(1).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="RF Power ", converter=forms.float_converter(formatter=lambda x: "%4.1f" % x), ) self.GridAdd(self._variable_static_text_0_static_text, 0, 2, 1, 1) self._stereo_0_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo_0, callback=self.set_stereo_0, label="Stereo Detect", true=True, false=False, ) self.GridAdd(self._stereo_0_check_box, 2, 5, 1, 1) self._stereo_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo, callback=self.set_stereo, label="Stereo", true=True, false=False, ) self.GridAdd(self._stereo_check_box, 2, 4, 1, 1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(1.0e6) self.rtl2832_source_0.set_frequency(cur_freq+200e3) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(gain) self._rtext_0_static_text = forms.static_text( parent=self.GetWin(), value=self.rtext_0, callback=self.set_rtext_0, label="CURRENT FREQUENCY>>", converter=forms.float_converter(), ) self.GridAdd(self._rtext_0_static_text, 0, 1, 1, 1) def _rf_pwr_lvl_probe(): while True: val = self.input_power.level() try: self.set_rf_pwr_lvl(val) except AttributeError, e: pass time.sleep(1.0/(2)) _rf_pwr_lvl_thread = threading.Thread(target=_rf_pwr_lvl_probe) _rf_pwr_lvl_thread.daemon = True _rf_pwr_lvl_thread.start() self._preselect_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.preselect, callback=self.set_preselect, label='preselect', choices=eval(prefreqs), labels=eval(prenames), style=wx.RA_HORIZONTAL, ) self.GridAdd(self._preselect_chooser, 0, 4, 1, 1) def _pilot_level_probe(): while True: val = self.pilot_probe.level() try: self.set_pilot_level(val) except AttributeError, e: pass time.sleep(1.0/(5)) _pilot_level_thread = threading.Thread(target=_pilot_level_probe) _pilot_level_thread.daemon = True _pilot_level_thread.start() self.low_pass_filter_3 = gr.fir_filter_fff(1, firdes.low_pass( 3, asrate/500, 10, 3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/50, 100, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/5, 1e3, 200, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = gr.fir_filter_fff(5, firdes.low_pass( 3, asrate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76)) _igain_sizer = wx.BoxSizer(wx.VERTICAL) self._igain_text_box = forms.text_box( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._igain_slider = forms.slider( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_igain_sizer, 1, 1, 1, 1) _ifreq_sizer = wx.BoxSizer(wx.VERTICAL) self._ifreq_text_box = forms.text_box( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._ifreq_slider = forms.slider( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, minimum=88.1e6, maximum=108.1e6, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ifreq_sizer, 0, 0, 1, 1) self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else capture_file, 2, int(farate), 16) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_single_pole_iir_filter_xx_1 = gr.single_pole_iir_filter_ff(2.5/(asrate/500), 1) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(1.0/(asrate/3), 1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0 = gr.multiply_vff(1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_3 = gr.multiply_const_vff((3.16e3 if st_enabled else 0, )) self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if st_enabled else 1.414, )) self.gr_multiply_const_vxx_1_0 = gr.multiply_const_vff((0 if st_enabled else 1, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0 if squelch_probe == 0 else 1.0, )) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((vol*1.5*10.0, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((vol*1.5*10.0 if st_enabled else 0, )) self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_float*1, int(asrate/3)) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(4, (osmo_taps), 200e3+fine+(-12e3*discrim_dc), 1.0e6) self.gr_fractional_interpolator_xx_0_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fft_filter_xxx_1_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,15.0e3,5.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,13.5e3,3.5e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_divide_xx_0 = gr.divide_ff(1) self.gr_agc_xx_1 = gr.agc_cc(1e-2, 0.35, 1.0, 5000) self.gr_add_xx_2_0 = gr.add_vff(1) self.gr_add_xx_2 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_const_vxx_0 = gr.add_const_vff((1.0e-7, )) self._dm_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.dm, callback=self.set_dm, label="FM Deemphasis", choices=[75.0e-6, 50.0e-6], labels=["NA", "EU"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._dm_chooser, 0, 5, 1, 1) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=samp_rate, audio_decimation=2, ) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.band_pass_filter_2_0 = gr.fir_filter_fff(1, firdes.band_pass( 20, asrate, 17.5e3, 17.9e3, 250, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_2 = gr.fir_filter_fff(1, firdes.band_pass( 10, asrate, 18.8e3, 19.2e3, 350, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = gr.fir_filter_fff(1, firdes.band_pass( 1, asrate, 38e3-(15e3), 38e3+(15e3), 4.0e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(farate), "" if ahw == "Default" else ahw, True) ################################################## # Connections ################################################## self.connect((self.gr_add_xx_1, 0), (self.gr_fractional_interpolator_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_fractional_interpolator_xx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_1_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0_0, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_divide_xx_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_add_const_vxx_0, 0)) self.connect((self.gr_add_const_vxx_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_keep_one_in_n_0, 0)) self.connect((self.gr_keep_one_in_n_0, 0), (self.pilot_probe, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_fractional_interpolator_xx_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0, 0)) self.connect((self.gr_fft_filter_xxx_1, 0), (self.gr_add_xx_2, 0)) self.connect((self.gr_fft_filter_xxx_1_0, 0), (self.gr_add_xx_2, 1)) self.connect((self.gr_fft_filter_xxx_1_0_0, 0), (self.gr_add_xx_2, 2)) self.connect((self.gr_add_xx_2, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_add_xx_2_0, 0), (self.gr_multiply_const_vxx_3, 0)) self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_add_xx_2_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0, 0), (self.gr_add_xx_2_0, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0_0, 0), (self.gr_add_xx_2_0, 2)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_1_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_fm_deemph_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 1)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 1)) self.connect((self.blks2_fm_deemph_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blks2_wfm_rcv_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_agc_xx_1, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.input_power, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.low_pass_filter_2, 0), (self.low_pass_filter_3, 0)) self.connect((self.gr_single_pole_iir_filter_xx_1, 0), (self.dc_level, 0)) self.connect((self.low_pass_filter_3, 0), (self.gr_single_pole_iir_filter_xx_1, 0)) self.connect((self.rtl2832_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 15 self.samp_rate = samp_rate = 10e6 self.rx_gain = rx_gain = 5 self.mult = mult = 0.38 self.lo_offset = lo_offset = 0 self.freq = freq = 5.89e9 self.encoding = encoding = 0 ################################################## # Blocks ################################################## self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[5e6,10e6, 20e6], labels=["5MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0,1,2,3,4,5,6,7], labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=5000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=5000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wifi_phy_hier_0_0 = wifi_phy_hier( chan_est=0, encoding=0, ) self.wifi_phy_hier_0 = wifi_phy_hier( chan_est=0, encoding=0, ) _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=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_sizer) _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='rx_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.Add(_rx_gain_sizer) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e6, 11e6], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) self.ieee802_11_ofdm_parse_mac_0_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_mac_0_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab])) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab])) self.ieee802_11_ether_encap_0_0 = ieee802_11.ether_encap(False) self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0], labels=[' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'], ) self.Add(self._freq_chooser) self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0_0).set_min_output_buffer(100000) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0).set_min_output_buffer(100000) self.blocks_tuntap_pdu_0_0 = blocks.tuntap_pdu("tap1", 1500, False) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 1500, False) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((mult, )) (self.blocks_multiply_const_vxx_0_0).set_min_output_buffer(100000) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap')) self.msg_connect((self.blocks_tuntap_pdu_0_0, 'pdus'), (self.ieee802_11_ether_encap_0_0, 'from tap')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to tap'), (self.blocks_tuntap_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.ieee802_11_ofdm_mac_0_0, 'phy out'), (self.wifi_phy_hier_0_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ether_encap_0_0, 'from wifi')) self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0_0, 'phy in')) self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.foo_packet_pad2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wifi_phy_hier_0_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.foo_packet_pad2_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0)) self.connect((self.wifi_phy_hier_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.wifi_phy_hier_0_0, 1), (self.wxgui_scopesink2_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.username = username = os.environ.get('USER') self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 100 self.frequency = frequency = 2440000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.trellis_encoder_xx_0 = trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0, 0) if False else trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0) self._symbol_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.symbol_rate, callback=self.set_symbol_rate, label='symbol_rate', choices=[250000, 333000, 500000, 1000000, 1200000, 1500000], labels=[ "250kS/s", "333kS/s", "500 kS/s", "1000kS/s", "1200kS/s", "1500kS/s" ], style=wx.RA_HORIZONTAL, ) self.Add(self._symbol_rate_chooser) self.pluto_sink_0 = iio.pluto_sink('', frequency, samp_rate, 20000000, 0x8000, False, 10.0, '', True) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.fec_puncture_xx_0 = fec.puncture_bb(14, 0b11010101100110, 0) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, 255, 239, 8, 51, 8) self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1) self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver( 136, 12, 17) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/media/" + username + "/PlutoSDR/rpidatv.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_puncture_xx_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0)) self.connect((self.fec_puncture_xx_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.username = username = os.environ.get('USER') self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 20 self.frequency = frequency = 970e6 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.trellis_encoder_xx_0 = trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0, 0) if False else trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0) self._symbol_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.symbol_rate, callback=self.set_symbol_rate, label='symbol_rate', choices=[333000, 500000, 1000000, 1200000, 1500000], labels=["333kS/s", "500 kS/s", "1000kS/s", "1200kS/s", "1500kS/s"], style=wx.RA_HORIZONTAL, ) self.Add(self._symbol_rate_chooser) self.pluto_sink_0 = iio.pluto_sink('', int(frequency), int(samp_rate), int(9000000), 0x8000, False, 0.0, '', True) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate / 2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs_reed_solomon_enc_bb_0 = dvbs.reed_solomon_enc_bb() self.dvbs_randomizer_bb_0 = dvbs.randomizer_bb() self.dvbs_puncture_bb_0 = dvbs.puncture_bb(dvbs.C1_2) self.dvbs_modulator_bc_0 = dvbs.modulator_bc() self.dvbs_interleaver_bb_0 = dvbs.interleaver_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_1 = blocks.file_source( gr.sizeof_char * 1, "/media/" + username + "/PlutoSDR/MPEG2-lalinea.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_1, 0), (self.dvbs_randomizer_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dvbs_modulator_bc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.dvbs_puncture_bb_0, 0)) self.connect((self.dvbs_interleaver_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.dvbs_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dvbs_puncture_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.dvbs_randomizer_bb_0, 0), (self.dvbs_reed_solomon_enc_bb_0, 0)) self.connect((self.dvbs_reed_solomon_enc_bb_0, 0), (self.dvbs_interleaver_bb_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wideband FM Receiver 1.0") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.gain = gain = 50 self.fft_size = fft_size = 512 self.f = f = 106.1e6 ################################################## # Blocks ################################################## self.notebook0 = self.notebook0 = wx.Notebook(self.GetWin(), style=wx.NB_BOTTOM) self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "RF FFT") self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "Waterfall") self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "Audio FFT") self.Add(self.notebook0) self._fft_size_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.fft_size, callback=self.set_fft_size, label='FFT Size', choices=[512, 1024, 2048, 4096, 8192], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._fft_size_chooser) _f_sizer = wx.BoxSizer(wx.VERTICAL) self._f_text_box = forms.text_box( parent=self.GetWin(), sizer=_f_sizer, value=self.f, callback=self.set_f, label='f', converter=forms.int_converter(), proportion=0, ) self._f_slider = forms.slider( parent=self.GetWin(), sizer=_f_sizer, value=self.f, callback=self.set_f, minimum=88e6, maximum=110e6, num_steps=220, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_f_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook0.GetPage(1).GetWin(), baseband_freq=f, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=fft_size, fft_rate=15, average=False, avg_alpha=None, title='Waterfall Plot', ) self.notebook0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=200e3, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot - Audio', peak_hold=False, win=window.rectangular, ) self.notebook0.GetPage(2).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook0.GetPage(0).GetWin(), baseband_freq=f, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=fft_size, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, win=window.blackmanharris, ) self.notebook0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_clock_source('internal', 0) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(f, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(1, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(5, 0) self.rtlsdr_source_0.set_if_gain(5, 0) self.rtlsdr_source_0.set_bb_gain(5, 0) self.rtlsdr_source_0.set_antenna('ant0', 0) self.rtlsdr_source_0.set_bandwidth(250000, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=100, decimation=441, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 20, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_BLACKMAN, 6.76)) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='Gain Control', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=100e3, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="TX/RX Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=1, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)], labels=[i for i in range(11, 27)], style=wx.RA_HORIZONTAL, ) self.Add(self._freq_chooser) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.uhd_usrp_sink_1.set_antenna("TX/RX", 0) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42])) self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "8048", 10000, False) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), msg_interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.connect((self.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self, filename="tx-test.32fc"): grc_wxgui.top_block_gui.__init__(self, title="SWiFi TX") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.filename = filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 self.mult = mult = 1 self.lo_offset = lo_offset = 0 self.gain = gain = 25 self.freq = freq = 2.462e9 self.encoding = encoding = 3 ################################################## # Blocks ################################################## _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self.swifi_wifi_conv_encoder_0 = swifi.wifi_conv_encoder("phy") self.swifi_scrambler_0_0 = swifi.scrambler(True, "phy") self.swifi_sample_adder_0 = swifi.sample_adder(100, 11, 320) self.swifi_phy_frame_generator_0 = swifi.phy_frame_generator( "phy", "packet_len") self.swifi_mac_frame_generator_0 = swifi.mac_frame_generator( "phy", 11, 100) self.swifi_interleaver_0_0 = swifi.interleaver(True, "phy") self.swifi_chunks_to_symbols_0_0 = swifi.chunks_to_symbols("phy") self.swifi_bit_stealer_0_0 = swifi.bit_stealer("phy") self.swifi_bit_packer_0_0 = swifi.bit_packer("phy", 1) self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[10e6, 20e6], labels=["10 Mhz", "20 Mhz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e9, 11e9], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], labels=[ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ], ) self.Add(self._freq_chooser) self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1.0 / 64] * 64)), True, 1) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0, 1, 2, 3, 4, 5, 6, 7], labels=[ "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer( 64, 64 + 16, 2, "") (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(100000) self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc( 64, (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ), ((-21, -7, 7, 21), ), ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)), ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0 - 1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0 - 1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0 - 1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 0, 0, 0, 0)), "packet_len") (self.digital_ofdm_carrier_allocator_cvc_0_0_0 ).set_min_output_buffer(10000) self.blocks_vector_source_x_1 = blocks.vector_source_b([ ord(x) for x in tuple( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ) ], False, 1, []) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, filename, False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.swifi_sample_adder_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.swifi_scrambler_0_0, 0)) self.connect((self.blocks_vector_source_x_1, 0), (self.swifi_mac_frame_generator_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0)) self.connect((self.swifi_bit_packer_0_0, 0), (self.swifi_chunks_to_symbols_0_0, 0)) self.connect((self.swifi_bit_stealer_0_0, 0), (self.swifi_interleaver_0_0, 0)) self.connect((self.swifi_chunks_to_symbols_0_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0)) self.connect((self.swifi_interleaver_0_0, 0), (self.swifi_bit_packer_0_0, 0)) self.connect((self.swifi_mac_frame_generator_0, 0), (self.swifi_phy_frame_generator_0, 0)) self.connect((self.swifi_phy_frame_generator_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.swifi_sample_adder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.swifi_scrambler_0_0, 0), (self.swifi_wifi_conv_encoder_0, 0)) self.connect((self.swifi_wifi_conv_encoder_0, 0), (self.swifi_bit_stealer_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg) + 15) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="TX/RX Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=1, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)], labels=[i for i in range(11, 27)], style=wx.RA_HORIZONTAL, ) self.Add(self._freq_chooser) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.4", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("J1", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("addr=192.168.10.6", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.trafficGenerator_Distribution_0 = trafficGenerator.Distribution( 0, 100, 4, 5, int) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern(text_msg), msg_interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.connect((self.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.trafficGenerator_Distribution_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Chu") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1200000 self.upconverter_lo_freq = upconverter_lo_freq = 125000000 self.space_tone = space_tone = 2025 self.offset = offset = 100000 self.mark_tone = mark_tone = 2225 self.gain = gain = 10 self.decimation = decimation = samp_rate / 48000 self.chu_freq = chu_freq = 3330000 self.channel_rate = channel_rate = 4800 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope") self.GridAdd(self.nb, 2, 0, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="USB tuner gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._chu_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chu_freq, callback=self.set_chu_freq, label="CHU frequency", choices=[3330000, 7850000, 14670000], labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=(mark_tone + space_tone) / 2, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=chu_freq, dynamic_range=50, ref_level=-60, ref_scale=2.0, sample_rate=samp_rate / decimation, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", win=window.hamming, ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1, v_offset=0, t_scale=0.050, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_fff(1, firdes.root_raised_cosine( 1, channel_rate, 300, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(chu_freq - offset + upconverter_lo_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(0, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_ccf(10, firdes.low_pass( 1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass( 1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.ham_chu_decode_0 = ham.chu_decode() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(channel_rate / (3.1416*(mark_tone - space_tone))) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(3.1416 / 500, 1.8, -1.8) self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self, options, queue): grc_wxgui.top_block_gui.__init__(self, title="Pager Rx") ################################################## # Variables ################################################## self.band = band = 929.5e6 self.click_freq = click_freq = band - 500000 + 12500 self.channel = channel = round( (click_freq - (band - 500000 - 12500)) / 25000) self.samp_rate = samp_rate = 1200000 self.freq = freq = band - 512500 + (channel * 25000) self.corr = corr = 0 self.gain = gain = 40.0 self.channel_rate = channel_rate = 25000 ################################################## # Blocks ################################################## self._freq_static_text = forms.static_text( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_static_text, 1, 2, 1, 1) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label="Frequency correction", converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_corr_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 2) self._band_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.band, callback=self.set_band, label='band', choices=[929.5e6, 931.5e6], labels=["929-930", "931-932"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._band_chooser, 1, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Channel Waterfall", ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=band, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Band Waterfall", ) self.GridAdd(self.wxgui_waterfallsink2_0.win, 2, 0, 1, 3) def wxgui_waterfallsink2_0_callback(x, y): self.set_click_freq(x) self.wxgui_waterfallsink2_0.set_callback( wxgui_waterfallsink2_0_callback) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(band, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( samp_rate / channel_rate, (filter.optfir.low_pass(1.0, samp_rate, 11000, 12500, 0.1, 60)), freq - band, samp_rate) _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=40, num_steps=39, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_channel_sizer, 1, 1, 1, 1) # FLEX protocol demodulator self.flex = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.flex, 0))
def __init__(self, options, queue): grc_wxgui.top_block_gui.__init__(self, title="Pager Rx") ################################################## # Variables ################################################## self.band = band = 929.5e6 self.click_freq = click_freq = band - 500000 + 12500 self.channel = channel = round((click_freq - (band - 500000 - 12500)) / 25000) self.samp_rate = samp_rate = 1200000 self.freq = freq = band - 512500 + (channel * 25000) self.corr = corr = 0 self.gain = gain = 40.0 self.channel_rate = channel_rate = 25000 ################################################## # Blocks ################################################## self._freq_static_text = forms.static_text( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_static_text, 1, 2, 1, 1) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label="Frequency correction", converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_corr_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 2) self._band_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.band, callback=self.set_band, label='band', choices=[929.5e6,931.5e6], labels=["929-930","931-932"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._band_chooser, 1, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Channel Waterfall", ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=band, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Band Waterfall", ) self.GridAdd(self.wxgui_waterfallsink2_0.win, 2, 0, 1, 3) def wxgui_waterfallsink2_0_callback(x, y): self.set_click_freq(x) self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(band, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(samp_rate / channel_rate, (filter.optfir.low_pass(1.0, samp_rate, 11000, 12500, 0.1, 60)), freq - band, samp_rate) _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=40, num_steps=39, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_channel_sizer, 1, 1, 1, 1) # FLEX protocol demodulator self.flex = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.flex, 0))
def build_gui(self): self.vbox.AddSpacer(5) self.vbox.AddStretchSpacer() ################################################## # Baseband controls ################################################## bb_vbox = forms.static_box_sizer(parent=self.panel, label="Baseband Modulation", orient=wx.VERTICAL, bold=True) self.vbox.Add(bb_vbox, 0, wx.EXPAND) sine_bb_hbox = wx.BoxSizer(wx.HORIZONTAL) sweep_bb_hbox = wx.BoxSizer(wx.HORIZONTAL) tone_bb_hbox = wx.BoxSizer(wx.HORIZONTAL) self.vbox.AddSpacer(10) self.vbox.AddStretchSpacer() #callback to show/hide forms def set_type(type): sine_bb_hbox.ShowItems(type == gr.GR_SIN_WAVE) sweep_bb_hbox.ShowItems(type == 'sweep') tone_bb_hbox.ShowItems(type == '2tone') self.vbox.Layout() self.tb.subscribe(usrp_siggen.TYPE_KEY, set_type) #create sine forms sine_bb_hbox.AddSpacer(10) forms.text_box( parent=self.panel, sizer=sine_bb_hbox, label='Frequency (Hz)', ps=self.tb, key=usrp_siggen.WAVEFORM_FREQ_KEY, converter=forms.float_converter(), ) sine_bb_hbox.AddStretchSpacer() #create sweep forms sweep_bb_hbox.AddSpacer(10) forms.text_box( parent=self.panel, sizer=sweep_bb_hbox, label='Sweep Width (Hz)', ps=self.tb, key=usrp_siggen.WAVEFORM_FREQ_KEY, converter=forms.float_converter(), ) sweep_bb_hbox.AddStretchSpacer() forms.text_box( parent=self.panel, sizer=sweep_bb_hbox, label='Sweep Rate (Hz)', ps=self.tb, key=usrp_siggen.WAVEFORM2_FREQ_KEY, converter=forms.float_converter(), ) sweep_bb_hbox.AddStretchSpacer() #create 2tone forms tone_bb_hbox.AddSpacer(10) forms.text_box( parent=self.panel, sizer=tone_bb_hbox, label='Tone 1 (Hz)', ps=self.tb, key=usrp_siggen.WAVEFORM_FREQ_KEY, converter=forms.float_converter(), ) tone_bb_hbox.AddStretchSpacer() forms.text_box( parent=self.panel, sizer=tone_bb_hbox, label='Tone 2 (Hz)', ps=self.tb, key=usrp_siggen.WAVEFORM2_FREQ_KEY, converter=forms.float_converter(), ) tone_bb_hbox.AddStretchSpacer() forms.radio_buttons( parent=self.panel, sizer=bb_vbox, choices=usrp_siggen.waveforms.keys(), labels=usrp_siggen.waveforms.values(), ps=self.tb, key=usrp_siggen.TYPE_KEY, style=wx.NO_BORDER | wx.RA_HORIZONTAL, ) bb_vbox.AddSpacer(10) bb_vbox.Add(sine_bb_hbox, 0, wx.EXPAND) bb_vbox.Add(sweep_bb_hbox, 0, wx.EXPAND) bb_vbox.Add(tone_bb_hbox, 0, wx.EXPAND) set_type(self.tb[usrp_siggen.TYPE_KEY]) ################################################## # Frequency controls ################################################## fc_vbox = forms.static_box_sizer(parent=self.panel, label="Center Frequency", orient=wx.VERTICAL, bold=True) fc_vbox.AddSpacer(5) # First row of frequency controls (center frequency) freq_hbox = wx.BoxSizer(wx.HORIZONTAL) fc_vbox.Add(freq_hbox, 0, wx.EXPAND) fc_vbox.AddSpacer(10) # Second row of frequency controls (results) tr_hbox = wx.BoxSizer(wx.HORIZONTAL) fc_vbox.Add(tr_hbox, 0, wx.EXPAND) fc_vbox.AddSpacer(5) # Add frequency controls to top window sizer self.vbox.Add(fc_vbox, 0, wx.EXPAND) self.vbox.AddSpacer(10) self.vbox.AddStretchSpacer() freq_hbox.AddSpacer(5) forms.text_box( parent=self.panel, sizer=freq_hbox, proportion=1, converter=forms.float_converter(), ps=self.tb, key=usrp_siggen.TX_FREQ_KEY, ) freq_hbox.AddSpacer(10) forms.slider( parent=self.panel, sizer=freq_hbox, proportion=2, ps=self.tb, key=usrp_siggen.TX_FREQ_KEY, minimum=self.tb[usrp_siggen.FREQ_RANGE_KEY][0], maximum=self.tb[usrp_siggen.FREQ_RANGE_KEY][1], num_steps=100, ) freq_hbox.AddSpacer(5) tr_hbox.AddSpacer(5) forms.static_text( parent=self.panel, sizer=tr_hbox, label='Daughterboard (Hz)', ps=self.tb, key=usrp_siggen.BB_FREQ_KEY, converter=forms.float_converter(), proportion=1, ) tr_hbox.AddSpacer(10) forms.static_text( parent=self.panel, sizer=tr_hbox, label='USRP DDC (Hz)', ps=self.tb, key=usrp_siggen.DDC_FREQ_KEY, converter=forms.float_converter(), proportion=1, ) tr_hbox.AddSpacer(5) ################################################## # Amplitude controls ################################################## amp_hbox = forms.static_box_sizer(parent=self.panel, label="Amplitude", orient=wx.VERTICAL, bold=True) amp_hbox.AddSpacer(5) # First row of amp controls (ampl) lvl_hbox = wx.BoxSizer(wx.HORIZONTAL) amp_hbox.Add(lvl_hbox, 0, wx.EXPAND) amp_hbox.AddSpacer(10) # Second row of amp controls (tx gain) gain_hbox = wx.BoxSizer(wx.HORIZONTAL) amp_hbox.Add(gain_hbox, 0, wx.EXPAND) amp_hbox.AddSpacer(5) self.vbox.Add(amp_hbox, 0, wx.EXPAND) self.vbox.AddSpacer(10) self.vbox.AddStretchSpacer() lvl_hbox.AddSpacer(5) forms.text_box( parent=self.panel, sizer=lvl_hbox, proportion=1, converter=forms.float_converter(), ps=self.tb, key=usrp_siggen.AMPLITUDE_KEY, label="Level (0.0-1.0)", ) lvl_hbox.AddSpacer(10) forms.log_slider( parent=self.panel, sizer=lvl_hbox, proportion=2, ps=self.tb, key=usrp_siggen.AMPLITUDE_KEY, min_exp=-6, max_exp=0, base=10, num_steps=100, ) lvl_hbox.AddSpacer(5) if self.tb[usrp_siggen.GAIN_RANGE_KEY][0] < self.tb[usrp_siggen.GAIN_RANGE_KEY][1]: gain_hbox.AddSpacer(5) forms.text_box( parent=self.panel, sizer=gain_hbox, proportion=1, converter=forms.float_converter(), ps=self.tb, key=usrp_siggen.GAIN_KEY, label="TX Gain (dB)", ) gain_hbox.AddSpacer(10) forms.slider( parent=self.panel, sizer=gain_hbox, proportion=2, ps=self.tb, key=usrp_siggen.GAIN_KEY, minimum=self.tb[usrp_siggen.GAIN_RANGE_KEY][0], maximum=self.tb[usrp_siggen.GAIN_RANGE_KEY][1], step_size=self.tb[usrp_siggen.GAIN_RANGE_KEY][2], ) gain_hbox.AddSpacer(5) ################################################## # Sample Rate controls ################################################## sam_hbox = forms.static_box_sizer(parent=self.panel, label="Sample Rate", orient=wx.HORIZONTAL, bold=True) self.vbox.Add(sam_hbox, 0, wx.EXPAND) self.vbox.AddSpacer(10) self.vbox.AddStretchSpacer() sam_hbox.AddSpacer(5) forms.text_box( parent=self.panel, sizer=sam_hbox, converter=forms.int_converter(), ps=self.tb, key=usrp_siggen.INTERP_KEY, label="Interpolation", ) sam_hbox.AddStretchSpacer(20) forms.static_text( parent=self.panel, sizer=sam_hbox, label='Sample Rate (sps)', ps=self.tb, key=usrp_siggen.SAMP_RATE_KEY, converter=forms.float_converter(), ) sam_hbox.AddStretchSpacer(20) forms.static_text( parent=self.panel, sizer=sam_hbox, label='Link Rate (bits/sec)', ps=self.tb, key=usrp_siggen.LINK_RATE_KEY, converter=forms.float_converter(), ) sam_hbox.AddSpacer(5) ################################################## # USRP status ################################################## u2_hbox = forms.static_box_sizer(parent=self.panel, label="USRP Status", orient=wx.HORIZONTAL, bold=True) self.vbox.Add(u2_hbox, 0, wx.EXPAND) self.vbox.AddSpacer(10) self.vbox.AddStretchSpacer() u2_hbox.AddSpacer(10) forms.static_text( parent=self.panel, sizer=u2_hbox, ps=self.tb, key=usrp_siggen.DESC_KEY, converter=forms.str_converter(), ) self.vbox.AddSpacer(5) self.vbox.AddStretchSpacer()
def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200") ################################################## # Parameters ################################################## self.subdev = subdev self.devid = devid self.frequency = frequency self.fftsize = fftsize ################################################## # Variables ################################################## self.GUI_samp_rate = GUI_samp_rate = 10e6 self.samp_rate = samp_rate = int(GUI_samp_rate) self.prefix = prefix = "tpr_" self.text_samp_rate = text_samp_rate = GUI_samp_rate self.text_deviceID = text_deviceID = subdev self.text_Device_addr = text_Device_addr = devid self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = 1 self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.noise_amplitude = noise_amplitude = .5 self.integ = integ = 2 self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = 1 self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_noise = add_noise = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._GUI_samp_rate_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.GUI_samp_rate, callback=self.set_GUI_samp_rate, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=.1, v_offset=0, t_scale=100, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_2 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=GUI_samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=True, avg_alpha=.01, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=20, ref_scale=2.0, sample_rate=GUI_samp_rate, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((devid, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(GUI_samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) (self.uhd_usrp_source_0).set_processor_affinity([0]) self._text_samp_rate_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_samp_rate, callback=self.set_text_samp_rate, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1) self._text_deviceID_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_deviceID, callback=self.set_text_deviceID, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1) self._text_Device_addr_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_Device_addr, callback=self.set_text_Device_addr, label="Device Address", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1) (self.single_pole_iir_filter_xx_0).set_processor_affinity([1]) _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_amplitude_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, label='noise_amplitude', converter=forms.float_converter(), proportion=0, ) self._noise_amplitude_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, minimum=.01, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self._add_noise_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_noise, callback=self.set_add_noise, label="Noise Source", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1) ################################################## # Connections ################################################## self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="V/HF mult-imode transmitter") ################################################## # Variables ################################################## self.var_1 = var_1 = 145100000 self.var_text = var_text = var_1 self.tx_mode = tx_mode = 0, 0, 1 self.tx_freq = tx_freq = 1500, -1500, -1500 self.tune = tune = 0 self.side_band = side_band = 2 self.samp_rate = samp_rate = 1.515152e6 self.pwr = pwr = 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.0, 0, 0.11 self.lo_freq_Hz = lo_freq_Hz = (145.1e6, 145.11e6, 14.070e6, 14.236e6, 28.720e6, 10.0e6, 15.0e6, var_1) self.hi_lo = hi_lo = 1 self.freq_chooser = freq_chooser = 0 self.fine_tune = fine_tune = 0 self.chooser = chooser = 1 ################################################## # Blocks ################################################## _tune_sizer = wx.BoxSizer(wx.VERTICAL) self._tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, label="Coarse Tune", converter=forms.int_converter(), proportion=0, ) self._tune_slider = forms.slider( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, minimum=-61000, maximum=61000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_tune_sizer, 3, 1, 1, 1) self._side_band_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.side_band, callback=self.set_side_band, label=" Sideband", choices=[0, 1, 2], labels=["LSB", "USB", "CW"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._side_band_chooser, 3, 2, 1, 1) self._hi_lo_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.hi_lo, callback=self.set_hi_lo, label="Power Level", choices=[1, 2], labels=["Low", "High"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._hi_lo_chooser, 4, 2, 1, 1) self._freq_chooser_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq_chooser, callback=self.set_freq_chooser, label="FREQUENCY SELECT", choices=[0, 1, 2, 3, 4, 5, 6, 7], labels=["145.100", "145.110", "14.070", "14.236", "28.720", "10", "15", "PRESET"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._freq_chooser_chooser, 1, 1, 1, 1) _fine_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, label="Fine Tune", converter=forms.float_converter(), proportion=0, ) self._fine_tune_slider = forms.slider( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, minimum=-5000 / 2, maximum=5000 / 2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_tune_sizer, 4, 1, 1, 1) self._chooser_chooser = forms.button( parent=self.GetWin(), value=self.chooser, callback=self.set_chooser, label="TX-RX Selector", choices=[1, 0], labels=["Receive", "Transmit"], ) self.GridAdd(self._chooser_chooser, 6, 1, 2, 1) self._var_text_static_text = forms.static_text( parent=self.GetWin(), value=self.var_text, callback=self.set_var_text, label="PRESET FREQUENCY", converter=forms.float_converter(), ) self.GridAdd(self._var_text_static_text, 1, 2, 1, 1) self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(8, (), 100) self.pfb_interpolator_ccf_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate / 4) self.osmosdr_sink_0.set_center_freq(lo_freq_Hz[freq_chooser] + tune + fine_tune - (tx_freq[side_band]), 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.fft_filter_xxx_0_0_0_0_0 = filter.fft_filter_fff( 1, (firdes.band_pass(1, samp_rate / 32, 250, 3500, 400)), 1 ) self.fft_filter_xxx_0_0_0_0_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 32, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0_0_0 = blocks.multiply_const_vcc(((pwr[freq_chooser] * hi_lo),)) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((40 * 10,)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(chooser)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=tx_mode[side_band], output_index=0, ) self.band_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.band_pass(1, 47348, 150, 1500, 300, firdes.WIN_HAMMING, 6.76) ) self.audio_source_0_0 = audio.source(47348, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate / 32, analog.GR_COS_WAVE, tx_freq[side_band], 1, 0) self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, (0.070) * 9) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.audio_source_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_multiply_const_vxx_1_0_0_0, 0)) self.connect((self.blks2_valve_1, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.fft_filter_xxx_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0_0, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1)) self.connect((self.fft_filter_xxx_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.pfb_interpolator_ccf_0, 0), (self.osmosdr_sink_0, 0))