def __init__(self, options): ''' See below for what options should hold ''' gr.hier_block2.__init__( self, "transmit_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature options = copy.copy( options) # make a copy so we can destructively modify self._verbose = options.verbose # turn verbose mode on/off self._tx_amplitude = options.tx_amplitude # digital amplitude sent to USRP self.ofdm_tx = \ blks2.ofdm_mod(options, msgq_limit=4, pad_for_usrp=False) self.amp = gr.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) # Display some information about the setup if self._verbose: self._print_verbage() # Create and setup transmit path flow graph self.connect(self.ofdm_tx, self.amp, self)
def __init__(self, options, rx_callback): phy_base.__init__(self, options, rx_callback) # Transmit chain self._tx_mod = blks2.ofdm_mod(options, msgq_limit=4, pad_for_usrp=False) self.connect(self._tx_mod, gr.kludge_copy(gr.sizeof_gr_complex), self) # Receive chain self._rx_demod = blks2.ofdm_demod(options, callback=self._rx_callback) self.connect(self, gr.kludge_copy(gr.sizeof_gr_complex), self._rx_demod)
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 = 1000 ################################################## # Blocks ################################################## self.blks2_ofdm_mod_0 = grc_blks2.packet_mod_b(blks2.ofdm_mod( options=grc_blks2.options( modulation="bpsk", fft_length=1024, occupied_tones=256, cp_length=512, pad_for_usrp=True, log=None, verbose=None, ), ), payload_length=0, ) self.gr_float_to_char_0 = gr.float_to_char() self.gr_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, 100, 127, 0) self.gr_throttle_0 = gr.throttle(gr.sizeof_char*1, samp_rate) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=samp_rate*1000, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.blks2_ofdm_mod_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_float_to_char_0, 0)) self.connect((self.gr_float_to_char_0, 0), (self.gr_throttle_0, 0)) self.connect((self.blks2_ofdm_mod_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Simulated Sender GUI") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 0.01 self.mult_const = mult_const = 1 ################################################## # Controls ################################################## _noise_voltage_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_voltage_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, label="Noise Voltage", converter=forms.float_converter(), proportion=0, ) self._noise_voltage_slider = forms.slider( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_voltage_sizer) self._mult_const_text_box = forms.text_box( parent=self.GetWin(), value=self.mult_const, callback=self.set_mult_const, label="Multiplication Const", converter=forms.float_converter(), ) self.Add(self._mult_const_text_box) ################################################## # Blocks ################################################## self.blks2_ofdm_mod_0 = grc_blks2.packet_mod_b( blks2.ofdm_mod(options=grc_blks2.options( modulation="bpsk", fft_length=512, occupied_tones=200, cp_length=128, pad_for_usrp=True, log=None, verbose=None, ), ), payload_length=512, ) self.gr_channel_model_0 = gr.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, ) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((mult_const, )) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.random_source_x_0 = gr.vector_source_b( map(int, numpy.random.randint(0, 256, 512)), True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, sample_rate=samp_rate, fft_size=256, fft_rate=30, average=True, avg_alpha=0.1, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.random_source_x_0, 0), (self.blks2_ofdm_mod_0, 0)) self.connect((self.blks2_ofdm_mod_0, 0), (self.gr_multiply_const_vxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Simulated Sender GUI") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 0.01 self.mult_const = mult_const = 1 ################################################## # Controls ################################################## _noise_voltage_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_voltage_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, label="Noise Voltage", converter=forms.float_converter(), proportion=0, ) self._noise_voltage_slider = forms.slider( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_voltage_sizer) self._mult_const_text_box = forms.text_box( parent=self.GetWin(), value=self.mult_const, callback=self.set_mult_const, label="Multiplication Const", converter=forms.float_converter(), ) self.Add(self._mult_const_text_box) ################################################## # Blocks ################################################## self.blks2_ofdm_mod_0 = grc_blks2.packet_mod_b(blks2.ofdm_mod( options=grc_blks2.options( modulation="bpsk", fft_length=512, occupied_tones=200, cp_length=128, pad_for_usrp=True, log=None, verbose=None, ), ), payload_length=512, ) self.gr_channel_model_0 = gr.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, ) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((mult_const, )) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 256, 512)), True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, sample_rate=samp_rate, fft_size=256, fft_rate=30, average=True, avg_alpha=0.1, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.random_source_x_0, 0), (self.blks2_ofdm_mod_0, 0)) self.connect((self.blks2_ofdm_mod_0, 0), (self.gr_multiply_const_vxx_0, 0))