def __init__(self, options): self.rx = raw.ofdm_demod(options, (options.nsr is not None) and 4 or 2) self.params = self.rx.params symbol_size = self.params.data_tones * gr.sizeof_gr_complex gr.hier_block2.__init__(self, "RX", gr.io_signature(1,1, gr.sizeof_gr_complex), gr.io_signature(1,1, symbol_size)) ff = raw.fix_frame(symbol_size, options.size) self.connect(self, self.rx, (ff,0), self) self.connect((self.rx,1), (ff,1)) # noise-to-signal ratio estimate # TODO: make it a proper output from the block if options.nsr is not None: nsr = gr.divide_ff() self.connect((self.rx,2), gr.integrate_ff(options.size), (nsr,0)) self.connect((self.rx,3), gr.integrate_ff(options.size), (nsr,1)) self.connect(nsr, gr.file_sink(gr.sizeof_float, options.nsr)) # what to do with the output? acq = self.rx.ofdm_recv.frame_acq acq.set_min_symbols(options.size) if options.numpkts is not None: acq.set_num_frames(options.numpkts) self.size = options.size if options.log: self.connect((self.rx,0), gr.file_sink(symbol_size, 'rx-ofdmdemod.dat')) self.connect((self.rx,1), gr.file_sink(gr.sizeof_char, 'rx-ofdmdemod.datb')) self.connect((ff,0), gr.file_sink(symbol_size, 'rx-fixframe.dat'))
def test_002_ff(self): src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] dst_data = [6.0, 15.0] src = gr.vector_source_f(src_data) itg = gr.integrate_ff(3) dst = gr.vector_sink_f() self.tb.connect(src, itg, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)
def __init__(self, data_tones, num_symbols, mode=0): symbol_size = data_tones * gr.sizeof_gr_complex gr.hier_block2.__init__(self, "SNR", gr.io_signature2(2,2, symbol_size, symbol_size), gr.io_signature(1,1, gr.sizeof_float)) sub = gr.sub_cc(data_tones) self.connect((self,0), (sub,0)) self.connect((self,1), (sub,1)) err = gr.complex_to_mag_squared(data_tones); self.connect(sub, err); pow = gr.complex_to_mag_squared(data_tones); self.connect((self,1), pow); if mode == 0: # one snr per symbol (num_symbols is ignored) snr = gr.divide_ff() self.connect(pow, gr.vector_to_stream(gr.sizeof_float, data_tones), gr.integrate_ff(data_tones), (snr,0)) self.connect(err, gr.vector_to_stream(gr.sizeof_float, data_tones), gr.integrate_ff(data_tones), (snr,1)) out = snr elif mode == 1: # one snr per packet snr = gr.divide_ff() self.connect(pow, gr.vector_to_stream(gr.sizeof_float, data_tones), gr.integrate_ff(data_tones*num_symbols), (snr,0)) self.connect(err, gr.vector_to_stream(gr.sizeof_float, data_tones), gr.integrate_ff(data_tones*num_symbols), (snr,1)) out = snr elif mode == 2: # one snr per frequency bin snr = gr.divide_ff(data_tones) self.connect(pow, raw.symbol_avg(data_tones, num_symbols), (snr,0)) self.connect(err, raw.symbol_avg(data_tones, num_symbols), (snr,1)) out = gr.vector_to_stream(gr.sizeof_float, data_tones) self.connect(snr, out) self.connect(out, gr.nlog10_ff(10), self)
def __init__(self, bits_per_byte): gr.hier_block2.__init__(self, "BitErrors", gr.io_signature(2, 2, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_int)) # Bit comparison comp = gr.xor_bb() intdump_decim = 100000 if N_BITS < intdump_decim: intdump_decim = int(N_BITS) self.connect(self, comp, gr.unpack_k_bits_bb(bits_per_byte), gr.uchar_to_float(), gr.integrate_ff(intdump_decim), gr.multiply_const_ff(1.0 / N_BITS), self) self.connect((self, 1), (comp, 1))
def __init__(self, bits_per_byte): gr.hier_block2.__init__(self, "BitErrors", gr.io_signature(2, 2, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_int)) # Bit comparison comp = gr.xor_bb() intdump_decim = 100000 if N_BITS < intdump_decim: intdump_decim = int(N_BITS) self.connect(self, comp, gr.unpack_k_bits_bb(bits_per_byte), gr.uchar_to_float(), gr.integrate_ff(intdump_decim), gr.multiply_const_ff(1.0/N_BITS), self) self.connect((self, 1), (comp, 1))
def __init__(self, options, noutputs=2): """ @param options: parsed raw.ofdm_params """ self.params = ofdm_params(options) params = self.params if noutputs == 2: output_signature = gr.io_signature2( 2, 2, gr.sizeof_gr_complex * params.data_tones, gr.sizeof_char) elif noutputs == 3: output_signature = gr.io_signature3( 3, 3, gr.sizeof_gr_complex * params.data_tones, gr.sizeof_char, gr.sizeof_float) elif noutputs == 4: output_signature = gr.io_signature4( 4, 4, gr.sizeof_gr_complex * params.data_tones, gr.sizeof_char, gr.sizeof_float, gr.sizeof_float) else: # error raise Exception("unsupported number of outputs") gr.hier_block2.__init__(self, "ofdm_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), output_signature) self.ofdm_recv = ofdm_receiver(params, options.log) # FIXME: magic parameters phgain = 0.4 frgain = phgain * phgain / 4.0 eqgain = 0.05 self.ofdm_demod = raw.ofdm_demapper(params.carriers, phgain, frgain, eqgain) # the studios can't handle the whole ofdm in one thread #ofdm_recv = raw.wrap_sts(self.ofdm_recv) ofdm_recv = self.ofdm_recv self.connect(self, ofdm_recv) self.connect((ofdm_recv, 0), (self.ofdm_demod, 0)) self.connect((ofdm_recv, 1), (self.ofdm_demod, 1)) self.connect(self.ofdm_demod, (self, 0)) self.connect((ofdm_recv, 1), (self, 1)) if noutputs > 2: # average noise power per (pilot) subcarrier self.connect((self.ofdm_demod, 1), (self, 2)) if noutputs > 3: # average signal power per subcarrier self.connect( (ofdm_recv, 0), gr.vector_to_stream(gr.sizeof_float, params.occupied_tones), gr.integrate_ff(params.occupied_tones), gr.multiply_ff(1.0 / params.occupied_tones), (self, 3)) if options.log: self.connect( (self.ofdm_demod, 2), gr.file_sink(gr.sizeof_gr_complex * params.occupied_tones, 'rx-eq.dat')) self.connect((self.ofdm_demod, 1), gr.file_sink(gr.sizeof_float, 'rx-noise.dat')) self.connect((self.ofdm_demod, 0), gr.file_sink(gr.sizeof_gr_complex * params.data_tones, 'rx-demap.dat'))
def __init__(self, freq_corr=0, N_id_1=134, avg_frames=1, N_id_2=0, decim=16): grc_wxgui.top_block_gui.__init__(self, title="Sss Corr2 Gui") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.freq_corr = freq_corr self.N_id_1 = N_id_1 self.avg_frames = avg_frames self.N_id_2 = N_id_2 self.decim = decim ################################################## # Variables ################################################## self.vec_half_frame = vec_half_frame = 30720*5/decim self.samp_rate = samp_rate = 30720e3/decim self.rot = rot = 0 self.noise_level = noise_level = 0 self.fft_size = fft_size = 2048/decim ################################################## # Blocks ################################################## _rot_sizer = wx.BoxSizer(wx.VERTICAL) self._rot_text_box = forms.text_box( parent=self.GetWin(), sizer=_rot_sizer, value=self.rot, callback=self.set_rot, label='rot', converter=forms.float_converter(), proportion=0, ) self._rot_slider = forms.slider( parent=self.GetWin(), sizer=_rot_sizer, value=self.rot, callback=self.set_rot, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rot_sizer) _noise_level_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_level_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_level_sizer, value=self.noise_level, callback=self.set_noise_level, label='noise_level', converter=forms.float_converter(), proportion=0, ) self._noise_level_slider = forms.slider( parent=self.GetWin(), sizer=_noise_level_sizer, value=self.noise_level, callback=self.set_noise_level, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_level_sizer) 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=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.gr_vector_to_stream_1 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size) self.gr_vector_to_stream_0_2 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size) self.gr_vector_to_stream_0_1 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size) self.gr_vector_to_stream_0_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size) self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_float*1, fft_size) self.gr_vector_source_x_0_0_0 = gr.vector_source_c((gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size) self.gr_vector_source_x_0_0 = gr.vector_source_c((gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size) self.gr_vector_source_x_0 = gr.vector_source_c((gen_sss_fd( N_id_1, N_id_2, fft_size).get_sss(True)), True, fft_size) self.gr_stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, fft_size) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, fft_size) self.gr_repeat_0 = gr.repeat(gr.sizeof_float*1, fft_size) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level, 0) self.gr_multiply_xx_1 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(fft_size) self.gr_multiply_const_vxx_1 = gr.multiply_const_vcc((1/1500., )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((exp(rot*2*numpy.pi*1j), )) self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex*fft_size) self.gr_integrate_xx_0 = gr.integrate_ff(fft_size) self.gr_float_to_complex_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/foo_pss0_sss_in.cfile", True) self.gr_fft_vxx_1 = gr.fft_vcc(fft_size, False, (window.blackmanharris(1024)), True, 1) self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1) self.gr_divide_xx_0_1 = gr.divide_cc(1) self.gr_divide_xx_0_0 = gr.divide_ff(1) self.gr_divide_xx_0 = gr.divide_cc(1) self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex*fft_size) self.gr_conjugate_cc_1 = gr.conjugate_cc() self.gr_conjugate_cc_0 = gr.conjugate_cc() self.gr_complex_to_mag_squared_0_0 = gr.complex_to_mag_squared(1) self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(fft_size) self.gr_add_xx_0 = gr.add_vcc(1) self.gr_add_const_vxx_0 = gr.add_const_vff((1, )) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.gr_conjugate_cc_0, 0), (self.gr_stream_to_vector_0_0, 0)) self.connect((self.gr_stream_to_vector_0_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_deinterleave_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_complex_to_mag_squared_0, 0)) self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_vector_to_stream_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.gr_integrate_xx_0, 0)) self.connect((self.gr_integrate_xx_0, 0), (self.gr_repeat_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_vector_to_stream_0_0, 0)) self.connect((self.gr_vector_to_stream_0_1, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_divide_xx_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_conjugate_cc_1, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_deinterleave_0, 1), (self.gr_vector_to_stream_0_1, 0)) self.connect((self.gr_repeat_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.const_source_x_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_vector_to_stream_0_0, 0), (self.gr_conjugate_cc_1, 0)) self.connect((self.gr_vector_to_stream_0_0, 0), (self.gr_complex_to_mag_squared_0_0, 0)) self.connect((self.gr_complex_to_mag_squared_0_0, 0), (self.gr_divide_xx_0_0, 0)) self.connect((self.gr_repeat_0, 0), (self.gr_divide_xx_0_0, 1)) self.connect((self.gr_divide_xx_0_0, 0), (self.gr_add_const_vxx_0, 0)) self.connect((self.gr_add_const_vxx_0, 0), (self.gr_float_to_complex_0_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.gr_float_to_complex_0_0, 1)) self.connect((self.gr_float_to_complex_0_0, 0), (self.gr_divide_xx_0_1, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_divide_xx_0_1, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0)) self.connect((self.gr_fft_vxx_0, 0), (self.gr_deinterleave_0, 0)) self.connect((self.gr_vector_to_stream_0_2, 0), (self.gr_conjugate_cc_0, 0)) self.connect((self.gr_divide_xx_0_1, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_interleave_0, 1)) self.connect((self.gr_interleave_0, 0), (self.gr_fft_vxx_1, 0)) self.connect((self.gr_fft_vxx_1, 0), (self.gr_vector_to_stream_1, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.gr_interleave_0, 0)) self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_vector_to_stream_0_2, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_vector_to_stream_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_vector_to_stream_0_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.gr_divide_xx_0_1, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, freq_corr=0, N_id_1=134, avg_frames=1, N_id_2=0, decim=16): grc_wxgui.top_block_gui.__init__(self, title="Sss Corr2 Gui") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.freq_corr = freq_corr self.N_id_1 = N_id_1 self.avg_frames = avg_frames self.N_id_2 = N_id_2 self.decim = decim ################################################## # Variables ################################################## self.vec_half_frame = vec_half_frame = 30720 * 5 / decim self.samp_rate = samp_rate = 30720e3 / decim self.rot = rot = 0 self.noise_level = noise_level = 0 self.fft_size = fft_size = 2048 / decim ################################################## # Blocks ################################################## _rot_sizer = wx.BoxSizer(wx.VERTICAL) self._rot_text_box = forms.text_box( parent=self.GetWin(), sizer=_rot_sizer, value=self.rot, callback=self.set_rot, label='rot', converter=forms.float_converter(), proportion=0, ) self._rot_slider = forms.slider( parent=self.GetWin(), sizer=_rot_sizer, value=self.rot, callback=self.set_rot, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rot_sizer) _noise_level_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_level_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_level_sizer, value=self.noise_level, callback=self.set_noise_level, label='noise_level', converter=forms.float_converter(), proportion=0, ) self._noise_level_slider = forms.slider( parent=self.GetWin(), sizer=_noise_level_sizer, value=self.noise_level, callback=self.set_noise_level, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_level_sizer) 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=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.gr_vector_to_stream_1 = gr.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.gr_vector_to_stream_0_2 = gr.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.gr_vector_to_stream_0_1 = gr.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.gr_vector_to_stream_0_0 = gr.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.gr_vector_to_stream_0 = gr.vector_to_stream( gr.sizeof_float * 1, fft_size) self.gr_vector_source_x_0_0_0 = gr.vector_source_c( (gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size) self.gr_vector_source_x_0_0 = gr.vector_source_c( (gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size) self.gr_vector_source_x_0 = gr.vector_source_c( (gen_sss_fd(N_id_1, N_id_2, fft_size).get_sss(True)), True, fft_size) self.gr_stream_to_vector_0_0 = gr.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.gr_stream_to_vector_0 = gr.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.gr_repeat_0 = gr.repeat(gr.sizeof_float * 1, fft_size) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex * 1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex * 1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level, 0) self.gr_multiply_xx_1 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(fft_size) self.gr_multiply_const_vxx_1 = gr.multiply_const_vcc((1 / 1500., )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc( (exp(rot * 2 * numpy.pi * 1j), )) self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex * fft_size) self.gr_integrate_xx_0 = gr.integrate_ff(fft_size) self.gr_float_to_complex_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_file_source_0 = gr.file_source( gr.sizeof_gr_complex * 1, "/home/user/git/gr-lte/gr-lte/test/foo_pss0_sss_in.cfile", True) self.gr_fft_vxx_1 = gr.fft_vcc(fft_size, False, (window.blackmanharris(1024)), True, 1) self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1) self.gr_divide_xx_0_1 = gr.divide_cc(1) self.gr_divide_xx_0_0 = gr.divide_ff(1) self.gr_divide_xx_0 = gr.divide_cc(1) self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex * fft_size) self.gr_conjugate_cc_1 = gr.conjugate_cc() self.gr_conjugate_cc_0 = gr.conjugate_cc() self.gr_complex_to_mag_squared_0_0 = gr.complex_to_mag_squared(1) self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(fft_size) self.gr_add_xx_0 = gr.add_vcc(1) self.gr_add_const_vxx_0 = gr.add_const_vff((1, )) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.gr_conjugate_cc_0, 0), (self.gr_stream_to_vector_0_0, 0)) self.connect((self.gr_stream_to_vector_0_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_deinterleave_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_complex_to_mag_squared_0, 0)) self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_vector_to_stream_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.gr_integrate_xx_0, 0)) self.connect((self.gr_integrate_xx_0, 0), (self.gr_repeat_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_vector_to_stream_0_0, 0)) self.connect((self.gr_vector_to_stream_0_1, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_divide_xx_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_conjugate_cc_1, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_deinterleave_0, 1), (self.gr_vector_to_stream_0_1, 0)) self.connect((self.gr_repeat_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.const_source_x_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_vector_to_stream_0_0, 0), (self.gr_conjugate_cc_1, 0)) self.connect((self.gr_vector_to_stream_0_0, 0), (self.gr_complex_to_mag_squared_0_0, 0)) self.connect((self.gr_complex_to_mag_squared_0_0, 0), (self.gr_divide_xx_0_0, 0)) self.connect((self.gr_repeat_0, 0), (self.gr_divide_xx_0_0, 1)) self.connect((self.gr_divide_xx_0_0, 0), (self.gr_add_const_vxx_0, 0)) self.connect((self.gr_add_const_vxx_0, 0), (self.gr_float_to_complex_0_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.gr_float_to_complex_0_0, 1)) self.connect((self.gr_float_to_complex_0_0, 0), (self.gr_divide_xx_0_1, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_divide_xx_0_1, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0)) self.connect((self.gr_fft_vxx_0, 0), (self.gr_deinterleave_0, 0)) self.connect((self.gr_vector_to_stream_0_2, 0), (self.gr_conjugate_cc_0, 0)) self.connect((self.gr_divide_xx_0_1, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_interleave_0, 1)) self.connect((self.gr_interleave_0, 0), (self.gr_fft_vxx_1, 0)) self.connect((self.gr_fft_vxx_1, 0), (self.gr_vector_to_stream_1, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.gr_interleave_0, 0)) self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_vector_to_stream_0_2, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_vector_to_stream_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_vector_to_stream_0_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.gr_divide_xx_0_1, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, options, noutputs = 2): """ @param options: parsed raw.ofdm_params """ self.params = ofdm_params(options) params = self.params if noutputs == 2: output_signature = gr.io_signature2(2, 2, gr.sizeof_gr_complex*params.data_tones, gr.sizeof_char ) elif noutputs == 3: output_signature = gr.io_signature3(3, 3, gr.sizeof_gr_complex*params.data_tones, gr.sizeof_char, gr.sizeof_float ) elif noutputs == 4: output_signature = gr.io_signature4(4, 4, gr.sizeof_gr_complex*params.data_tones, gr.sizeof_char, gr.sizeof_float, gr.sizeof_float ) else: # error raise Exception("unsupported number of outputs") gr.hier_block2.__init__(self, "ofdm_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), output_signature ) self.ofdm_recv = ofdm_receiver(params, options.log) # FIXME: magic parameters phgain = 0.4 frgain = phgain*phgain / 4.0 eqgain = 0.05 self.ofdm_demod = raw.ofdm_demapper(params.carriers, phgain, frgain, eqgain) # the studios can't handle the whole ofdm in one thread #ofdm_recv = raw.wrap_sts(self.ofdm_recv) ofdm_recv = self.ofdm_recv self.connect(self, ofdm_recv) self.connect((ofdm_recv,0), (self.ofdm_demod,0)) self.connect((ofdm_recv,1), (self.ofdm_demod,1)) self.connect(self.ofdm_demod, (self,0)) self.connect((ofdm_recv,1), (self,1)) if noutputs > 2: # average noise power per (pilot) subcarrier self.connect((self.ofdm_demod,1), (self,2)) if noutputs > 3: # average signal power per subcarrier self.connect((ofdm_recv,0), gr.vector_to_stream(gr.sizeof_float, params.occupied_tones), gr.integrate_ff(params.occupied_tones), gr.multiply_ff(1.0/params.occupied_tones), (self,3)) if options.log: self.connect((self.ofdm_demod, 2), gr.file_sink(gr.sizeof_gr_complex*params.occupied_tones, 'rx-eq.dat')) self.connect((self.ofdm_demod, 1), gr.file_sink(gr.sizeof_float, 'rx-noise.dat')) self.connect((self.ofdm_demod, 0), gr.file_sink(gr.sizeof_gr_complex*params.data_tones, 'rx-demap.dat'))