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 = 32000 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), 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(2.415e9, 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(8.7e6, 0) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 1, 1, 1), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.500, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=True, ), payload_length=0, ) self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1), (1, 1, 1)) ################################################## # Connections ################################################## self.connect((self.Spread_ds_spreader_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## #Create Input Vector here barker13 = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0] msg = string_to_list.conv_string_to_1_0_list("Hello World\n") pad = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] pad = pad + pad + pad + pad + pad input_vector = barker13+msg+pad # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s) #print(input_vector) ################################################## # Blocks ################################################## #USRP #Variables self.samp_rate = samp_rate = 390625.0 self.sink_args = args = "type=b200" #self.address = address = "addr=192.168.10.2" # real men hard-code parameters! self.freq = freq= 1425000000 self.freq_offset = freq_offset= 0 self.gain = gain= 13 print "Sample Rate:", samp_rate print "Freq:", freq #Init self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((args, "")), 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_gain(gain+70.5, 0) ################################################## self.input_vector_source = blocks.vector_source_b(input_vector, True, 1, []) self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.mod = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) ################################################## # Connections ################################################## self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self.uhd_usrp_sink_0)
def __init__(self, b_freq, gain, dt): gr.top_block.__init__(self, "Transmit Busy Tone") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200000 self.b_freq = b_freq ################################################## # Blocks ################################################## 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(b_freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_bandwidth(10e6, 0) self.digital_dxpsk_mod_1 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((10, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 500, 10, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_dxpsk_mod_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_dxpsk_mod_1, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## #Create Input Vector here input_vector = 0 # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s) ################################################## # Blocks ################################################## self.input_vector_source = blocks.vector_source_b( input_vector, True, 1, []) self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.mod = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.demod = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.frame_sync = frame_sync() # Your custom block!!! self.output_file_sink = blocks.file_sink(gr.sizeof_char * 1, "output.txt", False) self.output_file_sink.set_unbuffered(True) ################################################## # Connections ################################################## self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self.demod, self.output_unpacked_to_packed, self.frame_sync, self.output_file_sink)
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## s = "Hello Ether!" #Create Input Vector here input_vector = string_to_list.conv_string_to_1_0_list(s) # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s) ################################################## # Blocks ################################################## self.input_vector_source = blocks.vector_source_b(input_vector, True, 1, []) self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.mod = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.demod = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.frame_sync = frame_sync() # Your custom block!!! self.output_file_sink = blocks.file_sink(gr.sizeof_char*1, "output.txt", False) self.output_file_sink.set_unbuffered(True) ################################################## # Connections ################################################## self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self.demod, self.output_unpacked_to_packed, self.frame_sync, self.output_file_sink)
def __init__(self, amplitude=0.01, excessBW=0.35, sps=4, arity=1): gr.hier_block2.__init__( self, "DPSKTransmitter", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.amplitude = amplitude self.excessBW = excessBW self.sps = sps self.arity = arity if (arity != 2 and arity != 4): raise ValueError, "Unsupported modulation order '%d'" % (arity, ) ################################################## # Blocks ################################################## if (self.arity == 2): # BPSK self.digital_dxpsk_mod = digital.dbpsk_mod(samples_per_symbol=sps, excess_bw=excessBW, mod_code="gray", verbose=False, log=False) else: self.digital_dxpsk_mod = digital.dqpsk_mod(samples_per_symbol=sps, excess_bw=excessBW, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx = blocks.multiply_const_vcc( (amplitude, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx, 0), (self, 0)) self.connect((self.digital_dxpsk_mod, 0), (self.blocks_multiply_const_vxx, 0)) self.connect((self, 0), (self.digital_dxpsk_mod, 0))
def __init__(self, frame_sz_bytes=30): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.frame_sz_bytes = frame_sz_bytes ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.ccsds_encoder_var = ccsds_encoder_var = fec.ccsds_encoder_make(frame_sz_bytes * 8, 0, fec.CC_TAILBITING) self.cc_decoder_var = cc_decoder_var = fec.cc_decoder.make(frame_sz_bytes * 8, 7, 2, ([109,79]), 0, -1, fec.CC_TAILBITING, False) ################################################## # Blocks ################################################## self.fec_extended_encoder_0 = fec.extended_encoder(encoder_obj_list=ccsds_encoder_var, threading='capillary', puncpat='11') self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=cc_decoder_var, threading='capillary', ann=None, puncpat='11', integration_period=10000) self.digital_map_bb_0 = digital.map_bb((-1,1)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.5, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(16) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(16) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/jeff/EE420/FinalProj/testdat.txt', True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/jeff/EE420/Repo/EE420SDR/FinalProj/fecout.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_1 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_1.recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.blks2_packet_encoder_1, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_1, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blks2_packet_encoder_1, 0))
def __init__(self, addr="127.0.0.1", alpha=0.5, bb_gain=0.65, port="4000", samps_per_symb=4, tx_correct=0, tx_freq=2402e6, tx_gain=20, samp_rate=100e3, tx_offset=50e3): gr.top_block.__init__(self, "Tx Scram Sock") ################################################## # Parameters ################################################## self.addr = addr self.alpha = alpha self.bb_gain = bb_gain self.port = port self.samps_per_symb = samps_per_symb self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.samp_rate = samp_rate self.tx_offset = tx_offset ################################################## # Blocks ################################################## self.vtgs_mult_scrambler_0 = vtgs.mult_scrambler(17, 0x3FFFF) self.vtgs_ao40_encoder_0 = vtgs.ao40_encoder(False, 449838109) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_time_source("gpsdo", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(tx_freq+tx_correct, tx_offset), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_map_bb_0 = digital.map_bb((1,0)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_symb, excess_bw=alpha, mod_code="gray", verbose=False, log=False) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, (384,5232,384)) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", addr, port, 10000, False) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((bb_gain, )) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 1, 1000)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.vtgs_ao40_encoder_0, 'in')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.vtgs_mult_scrambler_0, 0)) self.connect((self.vtgs_ao40_encoder_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.vtgs_mult_scrambler_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="MPSK Demod Demo") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samps_per_sym = samps_per_sym = 4 self.samp_rate = samp_rate = 32000 self.noise = noise = 0.1 self.freq_on = freq_on = 0 ################################################## # Blocks ################################################## _noise_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, label='Noise', converter=forms.float_converter(), proportion=0, ) self._noise_slider = forms.slider( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_sizer) 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), "FFT") self.Add(self.nb) _freq_on_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_on_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_on_sizer, value=self.freq_on, callback=self.set_freq_on, label='freq_on', converter=forms.float_converter(), proportion=0, ) self._freq_on_slider = forms.slider( parent=self.GetWin(), sizer=_freq_on_sizer, value=self.freq_on, callback=self.set_freq_on, minimum=-0.5, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_on_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, win=window.blackmanharris, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.nb.GetPage(0).GetWin(), title='Constellation Plot', sample_rate=samp_rate, frame_rate=5, const_size=1024, M=4, theta=0, loop_bw=0.030, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate/4., omega_limit=0.005, ) self.nb.GetPage(0).Add(self.wxgui_constellationsink2_0.win) self.digital_constellation_8psk_sptr = digital.dbpsk_mod( samples_per_symbol=4, excess_bw=0.35, mod_code="gray", verbose=False, log=True) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_on, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2**8, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_8psk_sptr, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_8psk_sptr, 0), (self.channels_channel_model_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 = 1000000 ################################################## # Blocks ################################################## 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(88.1e6, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) 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(88.1e6, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.blocks_vector_source_x_0 = blocks.vector_source_b([1,1], True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "dbpsk_out.txt", False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0))
def __init__(self, addr='127.0.0.1', alpha=0.5, bb_gain=1, port='4000', samp_rate=250e3, samps_per_symb=2, tx_correct=0, tx_freq=2402e6, tx_gain=20, tx_offset=50e3): gr.top_block.__init__(self, "Trx Scram Sock") Qt.QWidget.__init__(self) self.setWindowTitle("Trx Scram Sock") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "trx_scram_sock") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.addr = addr self.alpha = alpha self.bb_gain = bb_gain self.port = port self.samp_rate = samp_rate self.samps_per_symb = samps_per_symb self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_offset = tx_offset ################################################## # Blocks ################################################## self.vtgs_mult_scrambler_0 = vtgs.mult_scrambler(17, 0x3FFFF) self.vtgs_ao40_encoder_0 = vtgs.ao40_encoder(False, 449838109) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_map_bb_0 = digital.map_bb((1, 0)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_symb, excess_bw=alpha, mod_code="gray", verbose=False, log=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1, (768, 5232)) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", addr, port, 10000, False) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (bb_gain, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 100e3, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 1, 768)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.vtgs_ao40_encoder_0, 'in')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.vtgs_mult_scrambler_0, 0)) self.connect((self.vtgs_ao40_encoder_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.vtgs_mult_scrambler_0, 0), (self.blocks_pack_k_bits_bb_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 = 10000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) 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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.random_source_x_0 = gr.vector_source_b( map(int, numpy.random.randint(0, 2, 1000)), True) self.gr_vector_to_stream_0 = gr.vector_to_stream( gr.sizeof_gr_complex * 1, 512) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_sub_xx_0 = gr.sub_cc(512) self.gr_stream_to_vector_0 = gr.stream_to_vector( gr.sizeof_gr_complex * 1, 512) self.gr_file_source_1 = gr.file_source( gr.sizeof_gr_complex * 512, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/hilbert.txt", True) self.gr_file_source_0 = gr.file_source( gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/INPUT.txt", True) self.gr_file_sink_0 = gr.file_sink( gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/OUTPUT.txt" ) self.gr_file_sink_0.set_unbuffered(False) self.gr_add_xx_0 = gr.add_vcc(1) self.fft_vxx_1 = fft.fft_vcc(512, False, (window.blackmanharris(1024)), True, 1) self.fft_vxx_0 = fft.fft_vcc(512, True, (window.blackmanharris(1024)), True, 1) self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f( digital.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=0, ) self.digital_ofdm_demod_0 = grc_blks2.packet_demod_f( digital.ofdm_demod( options=grc_blks2.options( modulation="bpsk", fft_length=512, occupied_tones=200, cp_length=128, snr=10, log=None, verbose=None, ), callback=lambda ok, payload: self.digital_ofdm_demod_0. recv_pkt(ok, payload), ), ) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, gray_coded=True, verbose=False, log=False) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.digital_ofdm_mod_0, 0)) self.connect((self.digital_ofdm_demod_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.digital_ofdm_mod_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.fft_vxx_0, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_file_source_1, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_vector_to_stream_0, 0), (self.digital_ofdm_demod_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.fft_vxx_1, 0)) self.connect((self.fft_vxx_1, 0), (self.gr_vector_to_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain_ch2 = tx_gain_ch2 = 0 self.tx_gain_ch1 = tx_gain_ch1 = 50 self.tx_freq_ch2 = tx_freq_ch2 = 2.4e9 self.tx_freq_ch1 = tx_freq_ch1 = 2.4e9 self.samp_rate = samp_rate = 32000 self.rx_gain_ch2 = rx_gain_ch2 = 0 self.rx_gain_ch1 = rx_gain_ch1 = 50 self.rx_freq_ch2 = rx_freq_ch2 = 2.4e9 self.rx_freq_ch1 = rx_freq_ch1 = 2.4e9 ################################################## # Blocks ################################################## self._tx_gain_ch1_range = Range(0, 50, 1, 50, 200) self._tx_gain_ch1_win = RangeWidget(self._tx_gain_ch1_range, self.set_tx_gain_ch1, 'TX Gain CH1', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_ch1_win) self._tx_freq_ch1_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._tx_freq_ch1_win = RangeWidget(self._tx_freq_ch1_range, self.set_tx_freq_ch1, 'TX Freq CH1', "counter_slider", float) self.top_layout.addWidget(self._tx_freq_ch1_win) self._rx_gain_ch1_range = Range(0, 50, 1, 50, 200) self._rx_gain_ch1_win = RangeWidget(self._rx_gain_ch1_range, self.set_rx_gain_ch1, 'RX Gain CH1', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_ch1_win) self._rx_freq_ch1_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._rx_freq_ch1_win = RangeWidget(self._rx_freq_ch1_range, self.set_rx_freq_ch1, 'RX Freq CH1', "counter_slider", float) self.top_layout.addWidget(self._rx_freq_ch1_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.30.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(200e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_clock_source('internal', 0) 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_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(rx_freq_ch1, 0) self.uhd_usrp_source_0.set_gain(rx_gain_ch1, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:0 ', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq_ch1, 0) self.uhd_usrp_sink_0.set_gain(tx_gain_ch1, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self._tx_gain_ch2_range = Range(0, 30, 1, 0, 200) self._tx_gain_ch2_win = RangeWidget(self._tx_gain_ch2_range, self.set_tx_gain_ch2, 'TX Gain CH2', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_ch2_win) self._tx_freq_ch2_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._tx_freq_ch2_win = RangeWidget(self._tx_freq_ch2_range, self.set_tx_freq_ch2, 'TX Freq CH2', "counter_slider", float) self.top_layout.addWidget(self._tx_freq_ch2_win) self._rx_gain_ch2_range = Range(0, 30, 1, 0, 200) self._rx_gain_ch2_win = RangeWidget(self._rx_gain_ch2_range, self.set_rx_gain_ch2, 'RX Gain CH2', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_ch2_win) self._rx_freq_ch2_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._rx_freq_ch2_win = RangeWidget(self._rx_freq_ch2_range, self.set_rx_freq_ch2, 'RX Freq CH2', "counter_slider", float) self.top_layout.addWidget(self._rx_freq_ch2_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -255) self.qtgui_number_sink_0_0.set_max(i, 256) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -5) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b( (1, 0, 0, 0, 0, 1), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/hanqing/Wireless Research/Y_test', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/hanqing/Wireless Research/X_test', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/hanqing/Wireless Research/dbpsk_out', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "DPSK Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("DPSK Loopback") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "dpsk_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000 self.freq = freq = 500 ################################################## # Blocks ################################################## self._freq_range = Range(0, 5000, 1, 500, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_layout.addWidget(self._freq_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'QT GUI Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1.1, 1.1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_dxpsk_mod_1 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_1 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_f( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_dxpsk_mod_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_dxpsk_demod_1, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_dxpsk_mod_1, 0), (self.digital_dxpsk_demod_1, 0))
def __init__(self): gr.top_block.__init__(self, "Barker Burst1") Qt.QWidget.__init__(self) self.setWindowTitle("Barker Burst1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "barker_burst1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.samp_per_symb = samp_per_symb = 4 self.alpha = alpha = 0.5 self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samp_per_symb * 32), alpha, samp_per_symb * 32) self.noise_amp = noise_amp = 0.01 self.fft_size = fft_size = 256 self.delay = delay = 0 self.chan_delay = chan_delay = 0 self.baud = baud = samp_rate / samp_per_symb self.b7 = b7 = (1, 1, 1, -1, -1, 1, -1) self.b5 = b5 = (1, 1, 1, -1, 1) self.b4_2 = b4_2 = (1, 1, 1, -1) self.b4_1 = b4_1 = (1, 1, -1, 1) self.b3 = b3 = (1, 1, -1) self.b2_2 = b2_2 = (1, 1) self.b2_1 = b2_1 = (1, -1) self.b13 = b13 = [1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1] self.b11 = b11 = (1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1) ################################################## # Blocks ################################################## self._noise_amp_range = Range(0, 1, 0.001, 0.01, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win) self._delay_range = Range(0, 10000, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "delay", "counter_slider", int) self.top_grid_layout.addWidget(self._delay_win) self._chan_delay_tool_bar = Qt.QToolBar(self) self._chan_delay_tool_bar.addWidget(Qt.QLabel("chan_delay" + ": ")) self._chan_delay_line_edit = Qt.QLineEdit(str(self.chan_delay)) self._chan_delay_tool_bar.addWidget(self._chan_delay_line_edit) self._chan_delay_line_edit.returnPressed.connect( lambda: self.set_chan_delay( int(str(self._chan_delay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._chan_delay_tool_bar) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size baud, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_size / 2, #size baud, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_size, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_0_0_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), False, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 1) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samp_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samp_per_symb, excess_bw=0.5, mod_code="gray", verbose=False, log=False) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fft_size) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_s( b13, True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_short * 1, samp_rate, True) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc( fft_size) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, delay) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, chan_delay) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, noise_amp, 0, 8192) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_vector_to_stream_0_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_0_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.fft_vxx_0_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1))
def __init__(self, addr='127.0.0.1', alpha=0.5, bb_gain=.5, port='4000', post_bytes=7, pre_bytes=100, samp_rate=500e3, samps_per_symb=4, tx_correct=0, tx_freq=2395e6, tx_gain=40, tx_offset=250e3): gr.top_block.__init__(self, "Tx Hdlc Dbpsk") ################################################## # Parameters ################################################## self.addr = addr self.alpha = alpha self.bb_gain = bb_gain self.port = port self.post_bytes = post_bytes self.pre_bytes = pre_bytes self.samp_rate = samp_rate self.samps_per_symb = samps_per_symb self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_offset = tx_offset ################################################## # Blocks ################################################## 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( uhd.tune_request(tx_freq + tx_correct, tx_offset), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=pre_bytes, postamble_bytes=post_bytes) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_symb, excess_bw=alpha, mod_code="gray", verbose=False, log=False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", addr, port, 255, False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'pl2') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (bb_gain, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_unpacked_to_packed_xx_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 = 10000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) 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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex * 1, 512) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_sub_xx_0 = gr.sub_cc(512) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex * 1, 512) self.gr_file_source_1 = gr.file_source( gr.sizeof_gr_complex * 512, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/hilbert.txt", True ) self.gr_file_source_0 = gr.file_source( gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/INPUT.txt", True ) self.gr_file_sink_0 = gr.file_sink( gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/OUTPUT.txt" ) self.gr_file_sink_0.set_unbuffered(False) self.gr_add_xx_0 = gr.add_vcc(1) self.fft_vxx_1 = fft.fft_vcc(512, False, (window.blackmanharris(1024)), True, 1) self.fft_vxx_0 = fft.fft_vcc(512, True, (window.blackmanharris(1024)), True, 1) self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f( digital.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=0, ) self.digital_ofdm_demod_0 = grc_blks2.packet_demod_f( digital.ofdm_demod( options=grc_blks2.options( modulation="bpsk", fft_length=512, occupied_tones=200, cp_length=128, snr=10, log=None, verbose=None ), callback=lambda ok, payload: self.digital_ofdm_demod_0.recv_pkt(ok, payload), ) ) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, gray_coded=True, verbose=False, log=False ) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.digital_ofdm_mod_0, 0)) self.connect((self.digital_ofdm_demod_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.digital_ofdm_mod_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.fft_vxx_0, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_file_source_1, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_vector_to_stream_0, 0), (self.digital_ofdm_demod_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.fft_vxx_1, 0)) self.connect((self.fft_vxx_1, 0), (self.gr_vector_to_stream_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Direct-sequence spread spectrum") ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.GetWin(), title='Received binary', 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_2.win) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b( (0, 1, 0, 1, 0, 1), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1000) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader( samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.msg_connect((self.Spread_rx_sync_0, 'out'), (self.Spread_deframer_0, 'in')) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_char_to_float_1, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Direct-sequence spread spectrum") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_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=1024, fft_rate=15, average=False, avg_alpha=None, title='Despread Signal ', peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0_0.win, 2, 3, 1, 2) 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=1024, fft_rate=15, average=False, avg_alpha=None, title='Received DS Signal', peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 1, 1, 2) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1000) self.Spread_sync_0 = Spread.sync() self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_preamble_0 = Spread.preamble_bb(1389, (64 * (1, 1))) self.Spread_msg_source_0 = Spread.msg_source(100, 100) self.Spread_framer_0 = Spread.framer(0) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader( samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.msg_connect((self.Spread_framer_0, 'out'), (self.Spread_sync_0, 'in')) self.msg_connect((self.Spread_msg_source_0, 'out'), (self.Spread_framer_0, 'in')) self.msg_connect((self.Spread_rx_sync_0, 'out'), (self.Spread_deframer_0, 'in')) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.Spread_preamble_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.Spread_sync_0, 0), (self.Spread_preamble_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Direct-sequence spread spectrum") ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_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=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal ", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0_0.win, 2, 3, 1, 2) 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=1024, fft_rate=15, average=False, avg_alpha=None, title="Received DS Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 1, 1, 2) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1000) self.Spread_sync_0 = Spread.sync() self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_preamble_0 = Spread.preamble_bb(1389, (64*(1, 1))) self.Spread_msg_source_0 = Spread.msg_source(100, 100) self.Spread_framer_0 = Spread.framer(0) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader(samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.Spread_sync_0, 0), (self.Spread_preamble_0, 0)) self.connect((self.Spread_preamble_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.Spread_framer_0, "out", self.Spread_sync_0, "in") self.msg_connect(self.Spread_msg_source_0, "out", self.Spread_framer_0, "in") self.msg_connect(self.Spread_rx_sync_0, "out", self.Spread_deframer_0, "in")
def __init__(self, addr='127.0.0.1', alpha=0.5, bb_gain=1, port='4000', samp_rate=500e3, samps_per_symb=4, tx_correct=0, tx_freq=2395e6, tx_gain=20, tx_offset=0, tx_period=500, update_period=2000): gr.top_block.__init__(self, "Tx Scram Rand 2") ################################################## # Parameters ################################################## self.addr = addr self.alpha = alpha self.bb_gain = bb_gain self.port = port self.samp_rate = samp_rate self.samps_per_symb = samps_per_symb self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_offset = tx_offset self.tx_period = tx_period self.update_period = update_period ################################################## # Blocks ################################################## self.vtgs_ao40_encoder_0 = vtgs.ao40_encoder(False, 449838109) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_time_source('gpsdo', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(tx_freq+tx_correct, tx_offset), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.digital_map_bb_0 = digital.map_bb((1,0)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_symb, excess_bw=alpha, mod_code="gray", verbose=False, log=False) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, (768,5232)) self.blocks_random_pdu_0 = blocks.random_pdu(256, 256, chr(0xFF), 2) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((bb_gain, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("TEST"), tx_period) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), update_period) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 1, 768)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.vtgs_ao40_encoder_0, 'in')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_message_strobe_0_0, 'set_msg')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.vtgs_ao40_encoder_0, 0), (self.blocks_stream_mux_0, 1))
def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if (options.spec): self.u.set_subdev_spec(options.spec, 0) if (options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start() + g.stop()) / 2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 # self.amp.set_k(1) # self.set_freq(self._tx_freq) # self.u.set_gain(30,0) ################################################## # Blocks ################################################## # self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(1, samp_rate, 1, 0.35, 11*samp_rate)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 1, 0), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2.500, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="11111111", pad_for_usrp=True, ), payload_length=0, ) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_dxpsk_mod_0, self.blocks_multiply_const_vxx_0, hopper_block, self.u)
def __init__(self, addr='0.0.0.0', alpha=0.5, bb_gain=.5, port='52001', samp_rate=500e3, samps_per_symb=4, tx_correct=0, tx_freq=2395e6, tx_gain=20, tx_offset=50e3): gr.top_block.__init__(self, "Tx Scram Sock") ################################################## # Parameters ################################################## self.addr = addr self.alpha = alpha self.bb_gain = bb_gain self.port = port self.samp_rate = samp_rate self.samps_per_symb = samps_per_symb self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_offset = tx_offset ################################################## # Blocks ################################################## self.vtgs_mult_scrambler_0 = vtgs.mult_scrambler(17, 0x3FFFF) self.vtgs_ao40_encoder_0 = vtgs.ao40_encoder(False, 449838109) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_time_source('gpsdo', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(tx_freq + tx_correct, tx_offset), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.digital_map_bb_0 = digital.map_bb((1, 0)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_symb, excess_bw=alpha, mod_code="gray", verbose=False, log=False) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1, (768, 5232)) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", addr, port, 256, False) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (bb_gain, )) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 1, 768)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.vtgs_ao40_encoder_0, 'in')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.vtgs_mult_scrambler_0, 0)) self.connect((self.vtgs_ao40_encoder_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.vtgs_mult_scrambler_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if(options.spec): self.u.set_subdev_spec(options.spec, 0) if(options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 # self.amp.set_k(1) # self.set_freq(self._tx_freq) # self.u.set_gain(30,0) ################################################## # Blocks ################################################## # self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(1, samp_rate, 1, 0.35, 11*samp_rate)) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b((1,0,1,0), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2.500, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="11111111", pad_for_usrp=True, ), payload_length=0, ) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_dxpsk_mod_0, self.blocks_multiply_const_vxx_0, hopper_block, self.u)
def __init__(self, tx_gain, samps_per_sym, pay_len, freq, samp_rate, ampl, file_source): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature ################################################## # Variables ################################################## self.file_source = file_source self.tx_gain = tx_gain self.samps_per_sym = samps_per_sym self.samp_rate = samp_rate self.pay_len = pay_len self.freq = freq self.ampl = ampl ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=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_gain(tx_gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=125, decimation=4, taps=None, fractional_bw=None, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=samps_per_sym, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=True, ), payload_length=pay_len, ) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, file_source, False) ################################################## # Connections ################################################## self.connect((self.digital_dxpsk_mod_0, 0), (self.rational_resampler_xxx_0,0)) self.connect((self.rational_resampler_xxx_0,0),(self.blocks_multiply_const_vxx_0,0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Occam Generated") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.stdValG = stdValG = 0.40 self.seedValG = seedValG = 0L self.samplingRate2 = samplingRate2 = 640000 self.samplingRate = samplingRate = 320000 self.rfGain2 = rfGain2 = 25.0 self.rfGain = rfGain = 1.0 self.recvThresh = recvThresh = 0.3 self.rcFiltCoeff = rcFiltCoeff = 1.0 self.meanValG = meanValG = 0.0 self.gaussGain = gaussGain = 0.3 self.excessBw = excessBw = 0.35 self.dataName = dataName = 1.0 self.dataGain = dataGain = 10.0 self.carrierFreq = carrierFreq = 462562500.0 self.bbGain2 = bbGain2 = 1.0 self.bbGain = bbGain = 1.3 ################################################## # Blocks ################################################## self.throttle = gr.throttle(gr.sizeof_float*1, samplingRate) self.gaussScale = blocks.multiply_const_vcc((gaussGain, )) self.gauss = analog.noise_source_c(analog.GR_GAUSSIAN, 0.3, 0) self.dbpskMod = digital.dbpsk_mod( samples_per_symbol=samplingRate2/samplingRate, excess_bw=0.35, gray_coded=True, verbose=False, log=False) self.dbpskEnc = grc_blks2.packet_mod_f(grc_blks2.packet_encoder( samples_per_symbol=samplingRate2/samplingRate, bits_per_symbol=1, access_code="", pad_for_usrp=True, ), payload_length=0, ) self.dbpskDemod = digital.dbpsk_demod( samples_per_symbol=samplingRate2/samplingRate, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, gray_coded=True, verbose=False, log=False ) self.dbpskDec = grc_blks2.packet_demod_f(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.dbpskDec.recv_pkt(ok, payload), ), ) self.dataSrc = gr.file_source(gr.sizeof_float*1, "music-tx1.0.dat", False) self.dataOut = gr.file_sink(gr.sizeof_float*1, "music-rx1.0.dat") self.dataOut.set_unbuffered(False) self.channelFilter2 = blocks.multiply_const_vcc((1.0, )) self.channelFilter = blocks.multiply_const_vcc((1.0, )) self.basebandScale2 = blocks.multiply_const_vcc((bbGain2, )) self.basebandScale = blocks.multiply_const_vcc((bbGain, )) self.add = blocks.add_vcc(1) ################################################## # Connections ################################################## self.connect((self.dataSrc, 0), (self.throttle, 0)) self.connect((self.throttle, 0), (self.dbpskEnc, 0)) self.connect((self.dbpskMod, 0), (self.channelFilter, 0)) self.connect((self.dbpskDemod, 0), (self.dbpskDec, 0)) self.connect((self.basebandScale, 0), (self.add, 0)) self.connect((self.gauss, 0), (self.gaussScale, 0)) self.connect((self.basebandScale2, 0), (self.channelFilter2, 0)) self.connect((self.add, 0), (self.basebandScale2, 0)) self.connect((self.dbpskDec, 0), (self.dataOut, 0)) self.connect((self.dbpskEnc, 0), (self.dbpskMod, 0)) self.connect((self.gaussScale, 0), (self.add, 1)) self.connect((self.channelFilter, 0), (self.basebandScale, 0)) self.connect((self.channelFilter2, 0), (self.dbpskDemod, 0))