def __init__(self, ebno_db=0, min_errors=100, samp_per_sym=1): gr.top_block.__init__(self, "BER 4FSK ") ################################################## # Parameters ################################################## self.ebno_db = ebno_db self.min_errors = min_errors self.samp_per_sym = samp_per_sym ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.bits_per_sym = bits_per_sym = 1 self.bit_rate = bit_rate = float(symb_rate)*bits_per_sym self.average_power = average_power = 1.0 self.ebno = ebno = 10**(ebno_db/10.0) self.eb = eb = average_power/bit_rate self.samp_rate = samp_rate = symb_rate*samp_per_sym self.no = no = eb/ebno self.noise_variance = noise_variance = no*samp_rate/2.0 ################################################## # Blocks ################################################## self.sample_counter = sample_counter() self.probe_avg_power = analog.probe_avg_mag_sqrd_f(0, 1) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.glfsr = digital.glfsr_source_b(8, True, 0, 1) self.four_level_symbol_mapper_0 = four_level_symbol_mapper( symbol_map=[-1,1], ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_per_sym) self.blocks_add_xx_0 = blocks.add_vff(1) self.ber_sink = blocks.vector_sink_f(1) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, math.sqrt(noise_variance), 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.ber_measure, 0), (self.ber_sink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.four_level_symbol_mapper_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.probe_avg_power, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.four_level_symbol_mapper_0, 0), (self.sample_counter, 0)) self.connect((self.glfsr, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.glfsr, 0), (self.pack_msg_bits, 0)) self.connect((self.pack_msg_bits, 0), (self.ber_measure, 0)) self.connect((self.pack_rx_bits, 0), (self.ber_measure, 1)) self.connect((self.sample_counter, 0), (self.pack_rx_bits, 0))
def __init__(self, ebn0, nbits): gr.hier_block2.__init__(self, 'FSK', gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) samp_rate = 48e3 sps = 5 deviation = 5000 bt = 1.0 self.head = blocks.head(gr.sizeof_char, nbits) self.pack = blocks.pack_k_bits_bb(8) self.modulator = digital.gfsk_mod( samples_per_symbol = sps, sensitivity = 2*np.pi*deviation/samp_rate, bt = bt, verbose = False, log = False) spb = sps self.channel = channels.channel_model(np.sqrt(spb)/10**(ebn0/20), 0, 1.0, [1], RAND_SEED, False) self.demod = fsk_demodulator(samp_rate/sps, samp_rate, deviation = deviation, iq = True) self.slice = digital.binary_slicer_fb() self.connect(self, self.head, self.pack, self.modulator, self.channel, self.demod, self.slice, self)
def __init__(self, delay): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.delay = delay = delay ################################################## # Blocks ################################################## self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate * 20,True) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_head_1 = blocks.head(gr.sizeof_char*1, 393460) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/rcampello/Main/FixedPath/OOT Gnuradio/gr-ITpp/examples/Simula\xc3\xa7\xc3\xa3o BPSK/Transmiss\xc3\xa3o RedDot Usando ConstellationMod/output.data', True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/rcampello/Main/FixedPath/OOT Gnuradio/gr-ITpp/examples/Simula\xc3\xa7\xc3\xa3o BPSK/Transmiss\xc3\xa3o RedDot Usando ConstellationMod/output2.data', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.ITpp_BCH_Decoder_0 = ITpp.BCH_Decoder(15, 2) ################################################## # Connections ################################################## self.connect((self.ITpp_BCH_Decoder_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_delay_0, 0), (self.ITpp_BCH_Decoder_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_head_1, 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.blocks_delay_0, 0))
def __init__(self): gr.top_block.__init__(self, "Blight 1 Solution") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, 'dist/blight1a.bin', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, OUT_DIR + 'blight1a_soln.out', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wmbus Phy2") ################################################## # Variables ################################################## self.frame = frame = [1,1] ################################################## # Blocks ################################################## self.gr_vector_source_x_0 = blocks.vector_source_b((frame), False, 1) self.gr_vector_sink_x_1 = blocks.vector_sink_b(1) self.gr_vector_sink_x_0 = blocks.vector_sink_b(1) self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(4, gr.GR_MSB_FIRST) self.gr_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(6) self.digital_map_bb_1 = digital.map_bb(([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1])) self.digital_map_bb_0 = digital.map_bb(([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 16, 1, 2, 16, 16, 16, 16, 7, 16, 16, 0, 16, 16, 5, 6, 16, 4, 16, 16, 16, 16, 16, 16, 11, 16, 9, 10, 16, 16, 15, 16, 16, 8, 16, 16, 16, 16, 13, 14, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16])) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_vector_sink_x_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.digital_map_bb_1, 0), (self.gr_vector_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.delay = delay = 0 ################################################## # Blocks ################################################## self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate * 20,True) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_head_1 = blocks.head(gr.sizeof_char*1, int(7 * 200e3 * 15/15)) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/rcampello/Main/FixedPath/OOT Gnuradio/gr-ITpp/examples/BPSK Ladams/27-06-2019 (BER Sem Diff)/Com C\xc3\xb3digo/output2.data', True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/rcampello/Main/FixedPath/OOT Gnuradio/gr-ITpp/examples/BPSK Ladams/27-06-2019 (BER Sem Diff)/Com C\xc3\xb3digo/output3.data', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.ITpp_BCH_Decoder_0 = ITpp.BCH_Decoder(15, 2) ################################################## # Connections ################################################## self.connect((self.ITpp_BCH_Decoder_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_delay_0, 0), (self.ITpp_BCH_Decoder_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_head_1, 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.blocks_delay_0, 0))
def __init__(self, ebn0, nbits): gr.hier_block2.__init__(self, 'BPSK', gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) samp_rate = 48e3 sps = 5 self.head = blocks.head(gr.sizeof_char, nbits) self.pack = blocks.pack_k_bits_bb(8) self.bpsk_constellation = digital.constellation_bpsk().base() self.modulator = digital.generic_mod( constellation = self.bpsk_constellation, differential = False, samples_per_symbol = sps, pre_diff_code = True, excess_bw = 0.35, verbose = False, log = False) spb = sps self.channel = channels.channel_model(np.sqrt(spb)/10**(ebn0/20), 0, 1.0, [1], RAND_SEED, False) self.demod = bpsk_demodulator(samp_rate/sps, samp_rate, iq = True) self.slice = digital.binary_slicer_fb() self.connect(self, self.head, self.pack, self.modulator, self.channel, self.demod, self.slice, self)
def test_004(self): # Test tags propagation # Tags on the incoming bits src_data = [1, 0, 1, 1, 0, 0, 0, 1] #src_tag_offsets = [1, 2, 3, 5, 6] src_tag_offsets = [1, 2, 3, 5, 6, 7] # Ground Truth expected_data = [2, 3, 0, 1] expected_tag_offsets = [0, 1, 1, 2, 3, 3] test_tags = list() tag_indexs = range(len(src_tag_offsets)) for src_tag in tag_indexs: test_tags.append( gr.tag_utils.python_to_tag( (src_tag_offsets[src_tag], pmt.intern('tag_byte'), pmt.from_long(src_tag), None))) src = blocks.vector_source_b(src_data, False, 1, test_tags) op = blocks.pack_k_bits_bb(2) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() # Check the data self.assertEqual(expected_data, dst.data()) # Check the tag values self.assertEqual(list(tag_indexs), [pmt.to_python(x.value) for x in dst.tags()]) # Check the tag offsets self.assertEqual(expected_tag_offsets, [x.offset for x in dst.tags()])
def __init__(self, encoder_obj_list, puncpat=None, lentagname=None, mtu=1500): gr.hier_block2.__init__(self, "extended_tagged_encoder", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) self.blocks = [] self.puncpat = puncpat # If it's a list of encoders, take the first one, unless it's # a list of lists of encoders. if (type(encoder_obj_list) == list): # This block doesn't handle parallelism of > 1 # We could just grab encoder [0][0], but we don't want to encourage this. if (type(encoder_obj_list[0]) == list): gr.log.info( "fec.extended_tagged_encoder: Parallelism must be 0 or 1.") raise AttributeError encoder_obj = encoder_obj_list[0] # Otherwise, just take it as is else: encoder_obj = encoder_obj_list # If lentagname is None, fall back to using the non tagged # stream version if type(lentagname) == str: if (lentagname.lower() == 'none'): lentagname = None if fec.get_encoder_input_conversion(encoder_obj) == "pack": self.blocks.append(blocks.pack_k_bits_bb(8)) if (not lentagname): self.blocks.append( fec.encoder(encoder_obj, gr.sizeof_char, gr.sizeof_char)) else: self.blocks.append( fec.tagged_encoder(encoder_obj, gr.sizeof_char, gr.sizeof_char, lentagname, mtu)) if self.puncpat != '11': self.blocks.append( fec.puncture_bb(len(puncpat), read_bitlist(puncpat), 0)) # Connect the input to the encoder and the output to the # puncture if used or the encoder if not. self.connect((self, 0), (self.blocks[0], 0)) self.connect((self.blocks[-1], 0), (self, 0)) # If using the puncture block, add it into the flowgraph after # the encoder. for i in range(len(self.blocks) - 1): self.connect((self.blocks[i], 0), (self.blocks[i + 1], 0))
def test_003(self): src_data = expected_results = map(lambda x: random.randint(0,3), range(10)); src = blocks.vector_source_b( src_data ); pack = blocks.pack_k_bits_bb(2); unpack = blocks.unpack_k_bits_bb(2); snk = blocks.vector_sink_b(); self.tb.connect(src,unpack,pack,snk); self.tb.run() self.assertEqual(list(expected_results), list(snk.data()));
def test_003(self): src_data = expected_results = [random.randint(0, 3) for x in range(10)] src = blocks.vector_source_b(src_data) pack = blocks.pack_k_bits_bb(2) unpack = blocks.unpack_k_bits_bb(2) snk = blocks.vector_sink_b() self.tb.connect(src, unpack, pack, snk) self.tb.run() self.assertEqual(list(expected_results), list(snk.data()))
def test_001(self): src_data = (1,0,1,1,0,1,1,0) expected_results = (1,0,1,1,0,1,1,0) src = blocks.vector_source_b(src_data,False) op = blocks.pack_k_bits_bb(1) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data())
def test_001(self): src_data = [1, 0, 1, 1, 0, 1, 1, 0] expected_results = [1, 0, 1, 1, 0, 1, 1, 0] src = blocks.vector_source_b(src_data, False) op = blocks.pack_k_bits_bb(1) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data())
def __init__(self, generic_encoder=0, generic_decoder=0, esno=0, samp_rate=3200000, threading="capillary", puncpat='11', seed=0): gr.hier_block2.__init__(self, "fec_test", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(2, 2, gr.sizeof_char * 1)) self.generic_encoder = generic_encoder self.generic_decoder = generic_decoder self.esno = esno self.samp_rate = samp_rate self.threading = threading self.puncpat = puncpat self.map_bb = digital.map_bb(([-1, 1])) self.b2f = blocks.char_to_float(1, 1) self.unpack8 = blocks.unpack_k_bits_bb(8) self.pack8 = blocks.pack_k_bits_bb(8) self.encoder = extended_encoder(encoder_obj_list=generic_encoder, threading=threading, puncpat=puncpat) self.decoder = extended_decoder(decoder_obj_list=generic_decoder, threading=threading, ann=None, puncpat=puncpat, integration_period=10000, rotator=None) noise = math.sqrt((10.0**(-esno / 10.0)) / 2.0) #self.fastnoise = analog.fastnoise_source_f(analog.GR_GAUSSIAN, noise, seed, 8192) self.fastnoise = analog.noise_source_f(analog.GR_GAUSSIAN, noise, seed) self.addnoise = blocks.add_ff(1) # Send packed input directly to the second output self.copy_packed = blocks.copy(gr.sizeof_char) self.connect(self, self.copy_packed) self.connect(self.copy_packed, (self, 1)) # Unpack inputl encode, convert to +/-1, add noise, decode, repack self.connect(self, self.unpack8) self.connect(self.unpack8, self.encoder) self.connect(self.encoder, self.map_bb) self.connect(self.map_bb, self.b2f) self.connect(self.b2f, (self.addnoise, 0)) self.connect(self.fastnoise, (self.addnoise, 1)) self.connect(self.addnoise, self.decoder) self.connect(self.decoder, self.pack8) self.connect(self.pack8, (self, 0))
def test_002(self): src_data = (1,0,1,1,0,0,0,1) expected_results = ( 2, 3, 0, 1) src = blocks.vector_source_b(src_data,False) op = blocks.pack_k_bits_bb(2) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() #self.assertEqual(expected_results, dst.data()) self.assertEqual(expected_results, dst.data())
def __init__(self, encoder_obj_list, puncpat=None, lentagname=None): gr.hier_block2.__init__(self, "extended_tagged_encoder", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) self.blocks=[] self.puncpat=puncpat # If it's a list of encoders, take the first one, unless it's # a list of lists of encoders. if(type(encoder_obj_list) == list): # This block doesn't handle parallelism of > 1 # We could just grab encoder [0][0], but we don't want to encourage this. if(type(encoder_obj_list[0]) == list): gr.log.info("fec.extended_tagged_encoder: Parallelism must be 0 or 1.") raise AttributeError encoder_obj = encoder_obj_list[0] # Otherwise, just take it as is else: encoder_obj = encoder_obj_list # If lentagname is None, fall back to using the non tagged # stream version if type(lentagname) == str: if(lentagname.lower() == 'none'): lentagname = None if fec.get_encoder_input_conversion(encoder_obj) == "pack": self.blocks.append(blocks.pack_k_bits_bb(8)) if(not lentagname): self.blocks.append(fec.encoder(encoder_obj, gr.sizeof_char, gr.sizeof_char)) else: self.blocks.append(fec.tagged_encoder(encoder_obj, gr.sizeof_char, gr.sizeof_char, lentagname)) if self.puncpat != '11': self.blocks.append(fec.puncture_bb(len(puncpat), read_bitlist(puncpat), 0)) # Connect the input to the encoder and the output to the # puncture if used or the encoder if not. self.connect((self, 0), (self.blocks[0], 0)); self.connect((self.blocks[-1], 0), (self, 0)); # If using the puncture block, add it into the flowgraph after # the encoder. for i in range(len(self.blocks) - 1): self.connect((self.blocks[i], 0), (self.blocks[i+1], 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.lowpass2 = lowpass2 = 10e3 self.lowpass = lowpass = 10e3 self.base = base = "/home/ali/Documents/UTAT/GNURadio/2018-12-28/es_pipe_U@?U@?U@?" self.samp_rate = samp_rate = 4003200 self.filename_2_0 = filename_2_0 = base+"_mmclock" self.filename_2 = filename_2 = base+"_bits" self.filename_1 = filename_1 = base+"_quaddemod_lpf_"+str((lowpass/1000.0))+"lpf2_"+str((lowpass2/1000.0)) self.filename_0 = filename_0 = base+"_quaddemod_lpf_"+str((lowpass/1000.0)) self.filename = filename = base+"_lpf_"+str((lowpass/1000.0)) ################################################## # Blocks ################################################## self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, lowpass2, lowpass2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, lowpass, lowpass/3, firdes.WIN_HAMMING, 6.76)) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(417*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, base, False) self.blocks_file_sink_0_2 = blocks.file_sink(gr.sizeof_float*1, filename_2_0, False) self.blocks_file_sink_0_2.set_unbuffered(False) self.blocks_file_sink_0_1_0 = blocks.file_sink(gr.sizeof_char*1, filename_2, False) self.blocks_file_sink_0_1_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-15, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1e6, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(2123.8262) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0_1_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_file_sink_0_2, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))
def test_extended_pack_data(self): # test if extended encoder gets correct values for input and output # conversion. n_frames = 10 frame_size = 32 data = np.random.randint(0, 2, n_frames * frame_size) data.dtype = np.uint8 packed_data = np.packbits(data) tb = gr.top_block() src = blocks.vector_source_b(data) snk0 = blocks.vector_sink_b(1) snk1 = blocks.vector_sink_b(1) snk2 = blocks.vector_sink_b(1) snk3 = blocks.vector_sink_b(1) packer = blocks.pack_k_bits_bb(8) tb.connect(src, packer, snk0) enc_unpacked = fec.dummy_encoder_make(frame_size, False, False) ext_enc_unp = extended_encoder(enc_unpacked, threading='none', puncpat='11') tb.connect(src, ext_enc_unp, snk1) enc_pack = fec.dummy_encoder_make(frame_size // 8, True, False) ext_enc_pack = extended_encoder(enc_pack, threading='none', puncpat='11') tb.connect(src, ext_enc_pack, snk2) enc_packed_bits = fec.dummy_encoder_make(frame_size // 8, False, True) ext_enc_packed_bits = extended_encoder(enc_packed_bits, threading='none', puncpat='11') tb.connect(packer, ext_enc_packed_bits, snk3) tb.run() r0 = snk0.data() r1 = snk1.data() r2 = snk2.data() r3 = snk3.data() data = list(data) packed_data = list(packed_data) self.assertListEqual(packed_data, r0) self.assertListEqual(data, r1) self.assertListEqual(packed_data, r2) self.assertListEqual(data, r3)
def __init__(self, encoder_obj_list, threading, puncpat=None): gr.hier_block2.__init__(self, "extended_encoder", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) self.blocks = [] self.puncpat = puncpat if (type(encoder_obj_list) == list): if (type(encoder_obj_list[0]) == list): gr.log.info("fec.extended_encoder: Parallelism must be 1.") raise AttributeError else: # If it has parallelism of 0, force it into a list of 1 encoder_obj_list = [ encoder_obj_list, ] if fec.get_encoder_input_conversion(encoder_obj_list[0]) == "pack": self.blocks.append(blocks.pack_k_bits_bb(8)) if threading == 'capillary': self.blocks.append( capillary_threaded_encoder(encoder_obj_list, gr.sizeof_char, gr.sizeof_char)) elif threading == 'ordinary': self.blocks.append( threaded_encoder(encoder_obj_list, gr.sizeof_char, gr.sizeof_char)) else: self.blocks.append( fec.encoder(encoder_obj_list[0], gr.sizeof_char, gr.sizeof_char)) if fec.get_encoder_output_conversion( encoder_obj_list[0]) == "packed_bits": self.blocks.append(blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST)) if self.puncpat != '11': self.blocks.append( fec.puncture_bb(len(puncpat), read_bitlist(puncpat), 0)) # Connect the input to the encoder and the output to the # puncture if used or the encoder if not. self.connect((self, 0), (self.blocks[0], 0)) self.connect((self.blocks[-1], 0), (self, 0)) # If using the puncture block, add it into the flowgraph after # the encoder. for i in range(len(self.blocks) - 1): self.connect((self.blocks[i], 0), (self.blocks[i + 1], 0))
def __init__(self,mod,delay=0,n_0=0,min_errors=100): ModMeasurementGraph.__init__(self, mod, "BER Measurement") self.__probe_thread = None self._did_timeout = False # Blocks self.src = digital.glfsr_source_b(8, True, 0, 1) # self.src = blocks.vector_source_b(np.concatenate((np.ones(5,dtype='B'),np.zeros(10,dtype='B'))).tolist(),True) # self.src = blocks.vector_source_b(np.zeros(10,dtype='B').tolist(),True) self.noise = analog.noise_source_c(analog.GR_GAUSSIAN, math.sqrt(float(n_0)), 0) self.delay = blocks.delay(gr.sizeof_char,delay) self.add = blocks.add_vcc(1) self.skiphead_orig = blocks.skiphead(gr.sizeof_char,500) self.skiphead_rx = blocks.skiphead(gr.sizeof_char,500) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.ber_sink = blocks.vector_sink_f(1) # Connections self.connect(self.src,self.mod_in_bits) # Adding noise to tx output of mod self.connect(self.mod_out_signal,(self.add,0)) self.connect(self.noise,(self.add,1)) self.connect(self.add,self.mod_in_signal) # Rx bits from mod to ber measure self.connect(self.mod_out_bits,self.skiphead_rx) self.connect(self.skiphead_rx,self.pack_rx_bits) self.connect(self.pack_rx_bits,(self.ber_measure,1)) # delayed bits to ber measure self.connect(self.src,self.delay) self.connect(self.delay,self.skiphead_orig) self.connect(self.skiphead_orig,self.pack_msg_bits) self.connect(self.pack_msg_bits,(self.ber_measure,0)) self.connect(self.ber_measure,self.ber_sink)
def test_009_t (self): preamble = [2, 4, 8, 16] pre_len = len(preamble); src_data = (2, 4, 8, 16, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 17, 18, 19, 20, 21, 22, 23, 24) expected_result = (31, 172, 240, 0) src = blocks.vector_source_b(src_data) dst = blocks.vector_sink_b() pck = blocks.pack_k_bits_bb(8) dtct = frame_detection.preamble_detector_bb(preamble, pre_len, 16, 8) self.tb.connect(src, dtct) self.tb.connect(dtct, pck, dst) self.tb.run () result_data = dst.data() self.assertEqual(expected_result, result_data)
def __init__(self, generic_encoder=0, generic_decoder=0, esno=0, samp_rate=3200000, threading="capillary", puncpat='11', seed=0): gr.hier_block2.__init__(self, "fec_test", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(2, 2, gr.sizeof_char*1)) self.generic_encoder = generic_encoder self.generic_decoder = generic_decoder self.esno = esno self.samp_rate = samp_rate self.threading = threading self.puncpat = puncpat self.map_bb = digital.map_bb(([-1, 1])) self.b2f = blocks.char_to_float(1, 1) self.unpack8 = blocks.unpack_k_bits_bb(8) self.pack8 = blocks.pack_k_bits_bb(8) self.encoder = extended_encoder(encoder_obj_list=generic_encoder, threading=threading, puncpat=puncpat) self.decoder = extended_decoder(decoder_obj_list=generic_decoder, threading=threading, ann=None, puncpat=puncpat, integration_period=10000, rotator=None) noise = math.sqrt((10.0**(-esno/10.0))/2.0) #self.fastnoise = analog.fastnoise_source_f(analog.GR_GAUSSIAN, noise, seed, 8192) self.fastnoise = analog.noise_source_f(analog.GR_GAUSSIAN, noise, seed) self.addnoise = blocks.add_ff(1) # Send packed input directly to the second output self.copy_packed = blocks.copy(gr.sizeof_char) self.connect(self, self.copy_packed) self.connect(self.copy_packed, (self, 1)) # Unpack inputl encode, convert to +/-1, add noise, decode, repack self.connect(self, self.unpack8) self.connect(self.unpack8, self.encoder) self.connect(self.encoder, self.map_bb) self.connect(self.map_bb, self.b2f) self.connect(self.b2f, (self.addnoise, 0)) self.connect(self.fastnoise, (self.addnoise,1)) self.connect(self.addnoise, self.decoder) self.connect(self.decoder, self.pack8) self.connect(self.pack8, (self, 0))
def test_009_t(self): preamble = [2, 4, 8, 16] pre_len = len(preamble) src_data = (2, 4, 8, 16, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 17, 18, 19, 20, 21, 22, 23, 24) expected_result = (31, 172, 240, 0) src = blocks.vector_source_b(src_data) dst = blocks.vector_sink_b() pck = blocks.pack_k_bits_bb(8) dtct = frame_detection.preamble_detector_bb(preamble, pre_len, 16, 8) self.tb.connect(src, dtct) self.tb.connect(dtct, pck, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def test_010_t (self): preamble = [2, 4, 8, 16] pre_len = len(preamble); src_data = (2, 4, 8, 16, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 4, 8, 16, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0) #expected_result = (0, 0, 0, 255, 255, 255, 255, 255, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 255, 255, 255, 255, 255, 1, 0, 1, 0, 1, 0, 1, 0) expected_result = (31, 173, 15, 31, 170, 150) src = blocks.vector_source_b(src_data) dst = blocks.vector_sink_b() pck = blocks.pack_k_bits_bb(8) dtct = frame_detection.preamble_detector_bb(preamble, pre_len, 16, 8) self.maxDiff = None self.tb.connect(src, dtct) self.tb.connect(dtct, pck, dst) self.tb.run () result_data = dst.data() self.assertEqual(expected_result, result_data)
def __init__(self, encoder_obj_list, threading, puncpat=None): gr.hier_block2.__init__(self, "extended_encoder", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) self.blocks=[] self.puncpat=puncpat if(type(encoder_obj_list) == list): if(type(encoder_obj_list[0]) == list): gr.log.info("fec.extended_encoder: Parallelism must be 1.") raise AttributeError else: # If it has parallelism of 0, force it into a list of 1 encoder_obj_list = [encoder_obj_list,] if fec.get_encoder_input_conversion(encoder_obj_list[0]) == "pack": self.blocks.append(blocks.pack_k_bits_bb(8)) if threading == 'capillary': self.blocks.append(capillary_threaded_encoder(encoder_obj_list, gr.sizeof_char, gr.sizeof_char)) elif threading == 'ordinary': self.blocks.append(threaded_encoder(encoder_obj_list, gr.sizeof_char, gr.sizeof_char)) else: self.blocks.append(fec.encoder(encoder_obj_list[0], gr.sizeof_char, gr.sizeof_char)) if fec.get_encoder_output_conversion(encoder_obj_list[0]) == "packed_bits": self.blocks.append(blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)) if self.puncpat != '11': self.blocks.append(fec.puncture_bb(len(puncpat), read_bitlist(puncpat), 0)) # Connect the input to the encoder and the output to the # puncture if used or the encoder if not. self.connect((self, 0), (self.blocks[0], 0)); self.connect((self.blocks[-1], 0), (self, 0)); # If using the puncture block, add it into the flowgraph after # the encoder. for i in range(len(self.blocks) - 1): self.connect((self.blocks[i], 0), (self.blocks[i+1], 0));
def __init__(self): gr.hier_block2.__init__( self, 'SI4463 scrambler', gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_in('in') self.message_port_register_hier_out('out') ################################################## # Blocks ################################################## self.digital_additive_scrambler_bb_0_0 = ( digital.additive_scrambler_bb( 0x21, 0x1e1, 8, count=0, bits_per_byte=1, reset_tag_key="packet_len")) self.blocks_tagged_stream_to_pdu_0_0 = ( blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')) self.blocks_tagged_stream_multiply_length_0 = ( blocks.tagged_stream_multiply_length(gr.sizeof_char*1, 'packet_len', 1.0/8)) self.blocks_pdu_to_tagged_stream_0 = ( blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) ################################################## # Connections ################################################## self.msg_connect( (self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self, 'out')) self.msg_connect( (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect( (self.blocks_pack_k_bits_bb_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect( (self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_additive_scrambler_bb_0_0, 0)) self.connect( (self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect( (self.digital_additive_scrambler_bb_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
def test_extended_pack_data(self): # test if extended encoder gets correct values for input and output conversion. n_frames = 10 frame_size = 32 data = np.random.randint(0, 2, n_frames * frame_size) data.dtype = np.uint8 packed_data = np.packbits(data) tb = gr.top_block() src = blocks.vector_source_b(data) snk0 = blocks.vector_sink_b(1) snk1 = blocks.vector_sink_b(1) snk2 = blocks.vector_sink_b(1) snk3 = blocks.vector_sink_b(1) packer = blocks.pack_k_bits_bb(8) tb.connect(src, packer, snk0) enc_unpacked = fec.dummy_encoder_make(frame_size, False, False) ext_enc_unp = extended_encoder(enc_unpacked, threading='none', puncpat='11') tb.connect(src, ext_enc_unp, snk1) enc_pack = fec.dummy_encoder_make(frame_size // 8, True, False) ext_enc_pack = extended_encoder(enc_pack, threading='none', puncpat='11') tb.connect(src, ext_enc_pack, snk2) enc_packed_bits = fec.dummy_encoder_make(frame_size // 8, False, True) ext_enc_packed_bits = extended_encoder(enc_packed_bits, threading='none', puncpat='11') tb.connect(packer, ext_enc_packed_bits, snk3) tb.run() r0 = snk0.data() r1 = snk1.data() r2 = snk2.data() r3 = snk3.data() data = tuple(data) packed_data = tuple(packed_data) self.assertTupleEqual(packed_data, r0) self.assertTupleEqual(data, r1) self.assertTupleEqual(packed_data, r2) self.assertTupleEqual(data, r3)
def test_010_t(self): preamble = [2, 4, 8, 16] pre_len = len(preamble) src_data = (2, 4, 8, 16, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 4, 8, 16, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0) #expected_result = (0, 0, 0, 255, 255, 255, 255, 255, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 255, 255, 255, 255, 255, 1, 0, 1, 0, 1, 0, 1, 0) expected_result = (31, 173, 15, 31, 170, 150) src = blocks.vector_source_b(src_data) dst = blocks.vector_sink_b() pck = blocks.pack_k_bits_bb(8) dtct = frame_detection.preamble_detector_bb(preamble, pre_len, 16, 8) self.maxDiff = None self.tb.connect(src, dtct) self.tb.connect(dtct, pck, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def __init__(self): gr.top_block.__init__(self, "Wmbus Phy2") ################################################## # Variables ################################################## self.frame = frame = [1, 1] ################################################## # Blocks ################################################## self.gr_vector_source_x_0 = blocks.vector_source_b((frame), False, 1) self.gr_vector_sink_x_1 = blocks.vector_sink_b(1) self.gr_vector_sink_x_0 = blocks.vector_sink_b(1) self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 4, gr.GR_MSB_FIRST) self.gr_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(6) self.digital_map_bb_1 = digital.map_bb( ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) self.digital_map_bb_0 = digital.map_bb(([ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 16, 1, 2, 16, 16, 16, 16, 7, 16, 16, 0, 16, 16, 5, 6, 16, 4, 16, 16, 16, 16, 16, 16, 11, 16, 9, 10, 16, 16, 15, 16, 16, 8, 16, 16, 16, 16, 13, 14, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 ])) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_vector_sink_x_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.digital_map_bb_1, 0), (self.gr_vector_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "MPSK Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Receiver") 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", "mpsk_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.usrp_gain = usrp_gain = 40 self.timing_loop_bw = timing_loop_bw = 0.01 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 0.1 self.n = n = 4 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self._usrp_gain_layout = Qt.QVBoxLayout() self._usrp_gain_tool_bar = Qt.QToolBar(self) self._usrp_gain_layout.addWidget(self._usrp_gain_tool_bar) self._usrp_gain_tool_bar.addWidget(Qt.QLabel("USRP Gain"+": ")) self._usrp_gain_counter = Qwt.QwtCounter() self._usrp_gain_counter.setRange(0, 100, 1) self._usrp_gain_counter.setNumButtons(2) self._usrp_gain_counter.setValue(self.usrp_gain) self._usrp_gain_tool_bar.addWidget(self._usrp_gain_counter) self._usrp_gain_counter.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_gain_slider.setRange(0, 100, 1) self._usrp_gain_slider.setValue(self.usrp_gain) self._usrp_gain_slider.setMinimumWidth(200) self._usrp_gain_slider.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_layout.addWidget(self._usrp_gain_slider) self.top_layout.addLayout(self._usrp_gain_layout) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.top_grid_layout.addLayout(self._phase_bw_layout, 0,2,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.top_grid_layout.addLayout(self._eq_gain_layout, 0,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.4e9, 0) self.uhd_usrp_source_0.set_gain(usrp_gain, 0) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.frame_detection_deinterleaver_bb_0 = frame_detection.deinterleaver_bb(n, n) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/rx_message", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.frame_detection_deinterleaver_bb_0, 0)) self.connect((self.frame_detection_deinterleaver_bb_0, 0), (self.blocks_file_sink_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbs-blade.py input_file [output_file]\n") sys.exit(1) symbol_rate = 4500000 samp_rate = symbol_rate * 2 code_rate = dvbs.C1_2 rrc_taps = 20 center_freq = 435000000 txvga1_gain = -4 txvga2_gain = 1 bandwidth = 6000000 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbs_randomizer = dvbs.randomizer_bb() dvbs_reed_solomon_enc = dvbs.reed_solomon_enc_bb() dvbs_interleaver = dvbs.interleaver_bb() blocks_packed_to_unpacked = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) trellis_encoder = trellis.encoder_bb(trellis.fsm(1, 2, (0171, 0133)), 0) blocks_unpack_k_bits = blocks.unpack_k_bits_bb(2) dvbs_puncture = dvbs.puncture_bb(code_rate) blocks_pack_k_bits = blocks.pack_k_bits_bb(2) dvbs_modulator = dvbs.modulator_bc() fft_filter = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate / 2, 0.35, rrc_taps)), 1 ) fft_filter.declare_sample_delay(0) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbs_randomizer) tb.connect(dvbs_randomizer, dvbs_reed_solomon_enc) tb.connect(dvbs_reed_solomon_enc, dvbs_interleaver) tb.connect(dvbs_interleaver, blocks_packed_to_unpacked) tb.connect(blocks_packed_to_unpacked, trellis_encoder) tb.connect(trellis_encoder, blocks_unpack_k_bits) tb.connect(blocks_unpack_k_bits, dvbs_puncture) tb.connect(dvbs_puncture, blocks_pack_k_bits) tb.connect(blocks_pack_k_bits, dvbs_modulator) tb.connect(dvbs_modulator, fft_filter) tb.connect(fft_filter, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(fft_filter, dst) tb.run()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 4500000 self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 20 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=435000000, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, 2, (0171, 0133)), 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(435e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(2, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-4, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate/2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs_reed_solomon_enc_bb_0 = dvbs.reed_solomon_enc_bb() self.dvbs_randomizer_bb_0 = dvbs.randomizer_bb() self.dvbs_puncture_bb_0 = dvbs.puncture_bb(dvbs.C1_2) self.dvbs_modulator_bc_0 = dvbs.modulator_bc() self.dvbs_interleaver_bb_0 = dvbs.interleaver_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/adv.ts", False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs_randomizer_bb_0, 0)) self.connect((self.dvbs_randomizer_bb_0, 0), (self.dvbs_reed_solomon_enc_bb_0, 0)) self.connect((self.dvbs_reed_solomon_enc_bb_0, 0), (self.dvbs_interleaver_bb_0, 0)) self.connect((self.dvbs_interleaver_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.dvbs_puncture_bb_0, 0)) self.connect((self.dvbs_puncture_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.dvbs_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dvbs_modulator_bc_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbs-blade.py input_file [output_file]\n") sys.exit(1) symbol_rate = 4500000 samp_rate = symbol_rate * 2 code_rate = dvbs.C1_2 rrc_taps = 20 center_freq = 435000000 txvga1_gain = -4 txvga2_gain = 1 bandwidth = 6000000 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbs_randomizer = dvbs.randomizer_bb() dvbs_reed_solomon_enc = dvbs.reed_solomon_enc_bb() dvbs_interleaver = dvbs.interleaver_bb() blocks_packed_to_unpacked = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) trellis_encoder = trellis.encoder_bb(trellis.fsm(1, 2, (0171, 0133)), 0) blocks_unpack_k_bits = blocks.unpack_k_bits_bb(2) dvbs_puncture = dvbs.puncture_bb(code_rate) blocks_pack_k_bits = blocks.pack_k_bits_bb(2) digital_chunks_to_symbols = digital.chunks_to_symbols_bc(([ complex(0.70710678, 0.70710678), complex(0.70710678, -0.70710678), complex(-0.70710678, 0.70710678), complex(-0.70710678, -0.70710678) ]), 1) interp_fir_filter = filter.interp_fir_filter_ccc( 2, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate / 2, 0.35, rrc_taps))) interp_fir_filter.declare_sample_delay(0) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbs_randomizer) tb.connect(dvbs_randomizer, dvbs_reed_solomon_enc) tb.connect(dvbs_reed_solomon_enc, dvbs_interleaver) tb.connect(dvbs_interleaver, blocks_packed_to_unpacked) tb.connect(blocks_packed_to_unpacked, trellis_encoder) tb.connect(trellis_encoder, blocks_unpack_k_bits) tb.connect(blocks_unpack_k_bits, dvbs_puncture) tb.connect(dvbs_puncture, blocks_pack_k_bits) tb.connect(blocks_pack_k_bits, digital_chunks_to_symbols) tb.connect(digital_chunks_to_symbols, interp_fir_filter) tb.connect(interp_fir_filter, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(interp_fir_filter, dst) tb.run()
def __init__(self): gr.top_block.__init__(self, "Simulation for SDR TCC") Qt.QWidget.__init__(self) self.setWindowTitle("Simulation for SDR TCC") 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", "sdrSim2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.timing_loop_bw = timing_loop_bw = 0.005 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.payload_size = payload_size = 992 self.noise_volt = noise_volt = 0.0001 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.freq_offset = freq_offset = 0 self.freq_bw = freq_bw = 6.28/100.0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Channel") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_tool_bar = Qt.QToolBar(self) self._time_offset_layout.addWidget(self._time_offset_tool_bar) self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._time_offset_counter = qwt_counter_pyslot() self._time_offset_counter.setRange(0.999, 1.001, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setValue(self.time_offset) self._time_offset_tool_bar.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.999, 1.001, 0.0001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_layout.addWidget(self._time_offset_slider) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 0,2,1,1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, "Constellation") self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, "Symbols") self.top_grid_layout.addWidget(self.received, 2,0,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.controls_grid_layout_1.addLayout(self._phase_bw_layout, 0,2,1,1) self._noise_volt_layout = Qt.QVBoxLayout() self._noise_volt_tool_bar = Qt.QToolBar(self) self._noise_volt_layout.addWidget(self._noise_volt_tool_bar) self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_volt_counter = qwt_counter_pyslot() self._noise_volt_counter.setRange(0, 1, 0.01) self._noise_volt_counter.setNumButtons(2) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_tool_bar.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_volt_slider.setRange(0, 1, 0.01) self._noise_volt_slider.setValue(self.noise_volt) self._noise_volt_slider.setMinimumWidth(200) self._noise_volt_slider.valueChanged.connect(self.set_noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_slider) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_offset_counter = qwt_counter_pyslot() self._freq_offset_counter.setRange(-0.1, 0.1, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.1, 0.1, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.controls_grid_layout_1.addLayout(self._eq_gain_layout, 0,1,1,1) self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("Delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 200, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 200, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_grid_layout.addLayout(self._delay_layout, 1,0,1,1) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 2 #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, 2) 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) 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: 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, 2,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #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, 4) 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) 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.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) 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.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 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 = [0, 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1) self._freq_bw_layout = Qt.QVBoxLayout() self._freq_bw_label = Qt.QLabel("Frequency Bandwidth") self._freq_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_bw_slider.setRange(0.0, 1.0, 0.01) self._freq_bw_slider.setValue(self.freq_bw) self._freq_bw_slider.setMinimumWidth(200) self._freq_bw_slider.valueChanged.connect(self.set_freq_bw) self._freq_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_bw_layout.addWidget(self._freq_bw_label) self._freq_bw_layout.addWidget(self._freq_bw_slider) self.controls_grid_layout_1.addLayout(self._freq_bw_layout, 0,3,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,3,2])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/rx_teste.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self, tx_freq=401.5e6, tx_offset=250e3): gr.top_block.__init__(self, "Simple GMSK/AX.25 Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("Simple GMSK/AX.25 Transmitter") 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", "fsk_tx_file") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.tx_freq = tx_freq self.tx_offset = tx_offset ################################################## # Variables ################################################## self.samp_rate = samp_rate = 240000 self.baud = baud = 9600 self.tx_gain = tx_gain = 0 self.tx_correct = tx_correct = -300 self.samps_per_symb = samps_per_symb = samp_rate/baud self.interp = interp = 25 self.decim = decim = 24 self.bb_gain = bb_gain = .75 self.alpha = alpha = .5 ################################################## # Blocks ################################################## self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 6, 0, 1, 4) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0; self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 0, 0, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._tx_gain_range = Range(0, 86, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 7, 0, 1, 4) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._tx_correct_range = Range(-10000, 10000, 1, -300, 200) self._tx_correct_win = RangeWidget(self._tx_correct_range, self.set_tx_correct, "tx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._tx_correct_win, 8, 0, 1, 4) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim * interp/5, #bw "TX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.010) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2, 0, 4, 4) for r in range(2, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=64) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=int(samps_per_symb), bt=alpha, verbose=False, log=False, ) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("packet_len") self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_CLIENT", '0.0.0.0', '8000', 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Turbo Verification V0") Qt.QWidget.__init__(self) self.setWindowTitle("Turbo Verification V0") 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", "turbo_verification_v0") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 500e3 self.sps = sps = 4 self.vcdu_size = vcdu_size = 223 - 10 self.samp_rate = samp_rate = symbol_rate * sps self.ntaps = ntaps = 40 * sps self.nfilts = nfilts = 32 self.value = value = [0, 1] self.to = to = 0.0 self.taps = taps = firdes.root_raised_cosine(sps, samp_rate, symbol_rate, 0.35, ntaps) self.symbol = symbol = [-1, 1] self.scramble = scramble = 0 self.rs = rs = 1 self.reset = reset = vcdu_size self.polyphase_taps = polyphase_taps = firdes.root_raised_cosine( sps * nfilts, nfilts, 1.0 / float(sps), 0.35, 20 * sps * nfilts) self.parity = parity = 32 self.linecode = linecode = 1 self.intDepth = intDepth = 1 self.frame_size = frame_size = vcdu_size + 10 self.cfo = cfo = 0.25 self.SNR = SNR = 10 self.Rc = Rc = 0.5 ################################################## # Blocks ################################################## self.tdd_ferMsgGen_0 = tdd.ferMsgGen(vcdu_size, 'cadu_len', 'vcdu_len') self.tdd_ferMsgCount_0 = tdd.ferMsgCount(0) self.mapper_prbs_source_b_0 = mapper.prbs_source_b("PRBS31", reset * 8) self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS31", reset * 8) self.dslwp_frame_spliter_f_0 = dslwp.frame_spliter_f( 'payload_start', 3576) self.dslwp_ccsds_turbo_decode_0 = dslwp.ccsds_turbo_decode( 223, 1, 2, 2, 0.707, 1) self.digital_map_bb_0 = digital.map_bb((-1, 1)) self.ccsds_synchronizeCADU_0 = ccsds.synchronizeCADU( '1ACFFC1D', 0, "sync") self.ccsds_recoverCADU_1 = ccsds.recoverCADU( int(frame_size / Rc) + 1, scramble, 'sync') self.ccsds_encodeTurbo_0 = ccsds.encodeTurbo(frame_size, 2, 'cadu_len') self.ccsds_createCADU_0 = ccsds.createCADU( int(frame_size / Rc) + 1, '1ACFFC1D', scramble, 'xx_len') self.blocks_unpack_k_bits_bb_1 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_2 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 3576, "payload_start") self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, int(frame_size / Rc) + 1, "xx_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, vcdu_size, "vcdu_len") self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_recoverCADU_1, 'cadu'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.dslwp_ccsds_turbo_decode_0, 'out'), (self.blocks_message_debug_0, 'store')) self.msg_connect((self.dslwp_ccsds_turbo_decode_0, 'out'), (self.tdd_ferMsgCount_0, 'in')) self.msg_connect((self.dslwp_frame_spliter_f_0, 'out'), (self.dslwp_ccsds_turbo_decode_0, 'in')) self.msg_connect((self.tdd_ferMsgCount_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_stream_to_tagged_stream_2, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_unpack_k_bits_bb_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.tdd_ferMsgGen_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.ccsds_createCADU_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_2, 0), (self.dslwp_frame_spliter_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.ccsds_synchronizeCADU_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_1, 0), (self.mapper_prbs_sink_b_0, 0)) self.connect((self.ccsds_createCADU_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.ccsds_encodeTurbo_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.ccsds_synchronizeCADU_0, 0), (self.ccsds_recoverCADU_1, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.tdd_ferMsgGen_0, 0), (self.ccsds_encodeTurbo_0, 0))
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, 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): gr.top_block.__init__(self, "MPSK Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Transmitter") 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", "mpsk_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.usrp_gain = usrp_gain = 20 self.sps = sps = 4 self.samp_rate = samp_rate = 1e6 self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.payload_size = payload_size = 992 self.n = n = 4 self.excess_bw = excess_bw = 0.35 self.arity = arity = 4 ################################################## # Blocks ################################################## self._usrp_gain_layout = Qt.QVBoxLayout() self._usrp_gain_tool_bar = Qt.QToolBar(self) self._usrp_gain_layout.addWidget(self._usrp_gain_tool_bar) self._usrp_gain_tool_bar.addWidget(Qt.QLabel("USRP Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._usrp_gain_counter = qwt_counter_pyslot() self._usrp_gain_counter.setRange(0, 100, 1) self._usrp_gain_counter.setNumButtons(2) self._usrp_gain_counter.setValue(self.usrp_gain) self._usrp_gain_tool_bar.addWidget(self._usrp_gain_counter) self._usrp_gain_counter.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_gain_slider.setRange(0, 100, 1) self._usrp_gain_slider.setValue(self.usrp_gain) self._usrp_gain_slider.setMinimumWidth(200) self._usrp_gain_slider.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_layout.addWidget(self._usrp_gain_slider) self.top_layout.addLayout(self._usrp_gain_layout) 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(2.4e9, 0) self.uhd_usrp_sink_0.set_gain(usrp_gain, 0) self.tcc_sdr_interleaver_bb_0 = tcc_sdr.interleaver_bb(n, n) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 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) 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) 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*1): 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.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.tcc_sdr_interleaver_bb_0, 0)) self.connect((self.tcc_sdr_interleaver_bb_0, 0), (self.blocks_stream_mux_0_0_0, 1))
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.symbol_rate = symbol_rate = 200 self.samp_rate = samp_rate = 8000 self.samp_per_sym = samp_per_sym = samp_rate/symbol_rate self.fsk_deviation_hz = fsk_deviation_hz = symbol_rate * 0.5 ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_f( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0.02, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_1.win) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/msk-bin", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-79, )) self.band_pass_filter_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, samp_rate, 750, 1250, 10, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(samp_rate, "dsp0", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0)) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Sim") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Sim") 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", "mpsk_sim") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.n = n = 4 self.sps = sps = 4 self.nfilts = nfilts = 32 self.m = m = n self.eb = eb = 0.35 self.timing_loop_bw = timing_loop_bw = 0.01 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 0.1 self.payload_size = payload_size = 100*n*m self.packed_preamble = packed_preamble = [83, 34, 91, 29, 13, 115, 223, 3] self.noise_volt = noise_volt = 0 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Transmitter") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_tool_bar = Qt.QToolBar(self) self._time_offset_layout.addWidget(self._time_offset_tool_bar) self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) self._time_offset_counter = Qwt.QwtCounter() self._time_offset_counter.setRange(0.999, 1.001, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setValue(self.time_offset) self._time_offset_tool_bar.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.999, 1.001, 0.0001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_layout.addWidget(self._time_offset_slider) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 0,2,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.controls_grid_layout_1.addLayout(self._phase_bw_layout, 0,2,1,1) self._noise_volt_layout = Qt.QVBoxLayout() self._noise_volt_tool_bar = Qt.QToolBar(self) self._noise_volt_layout.addWidget(self._noise_volt_tool_bar) self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) self._noise_volt_counter = Qwt.QwtCounter() self._noise_volt_counter.setRange(0, 1, 0.01) self._noise_volt_counter.setNumButtons(2) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_tool_bar.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_volt_slider.setRange(0, 1, 0.01) self._noise_volt_slider.setValue(self.noise_volt) self._noise_volt_slider.setMinimumWidth(200) self._noise_volt_slider.valueChanged.connect(self.set_noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_slider) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) self._freq_offset_counter = Qwt.QwtCounter() self._freq_offset_counter.setRange(-0.1, 0.1, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.1, 0.1, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.controls_grid_layout_1.addLayout(self._eq_gain_layout, 0,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 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) 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_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.controls_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1,0,2,2) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.controls_grid_layout_1.addWidget(self._qtgui_sink_x_1_win, 1,0,2,2) self.qtgui_sink_x_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.controls_grid_layout_1.addWidget(self._qtgui_sink_x_0_win, 3,0,2,2) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=([1]), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(int(math.log(arity,2))) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/Documents/UTFPR/10o_periodo/TCC2/projeto/tcc/gnuradio/tx_teste.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/Documents/UTFPR/10o_periodo/TCC2/projeto/tcc/gnuradio/rx_teste.txt", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1))
def __init__(self, parameter_0=0): gr.top_block.__init__(self, "BER 4FSK ") Qt.QWidget.__init__(self) self.setWindowTitle("BER 4FSK ") 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", "rrc_heir") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.parameter_0 = parameter_0 ################################################## # Variables ################################################## self.samp_per_sym = samp_per_sym = 120 self.symb_rate = symb_rate = 1200 self.rrc_taps = rrc_taps = samp_per_sym * 6 + 1 self.tcola_r = tcola_r = 1 self.tcola_m = tcola_m = 32 self.symbol_delay = symbol_delay = rrc_taps / samp_per_sym self.samp_rate = samp_rate = symb_rate * samp_per_sym self.noise = noise = 0 self.fsk_deviation_hz = fsk_deviation_hz = 648 self.fc = fc = 900e6 self.bits_per_sym = bits_per_sym = 2 ################################################## # Blocks ################################################## self._noise_range = Range(0, 5, 0.01, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "Noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self.tcola_time_compression_0 = tcola.time_compression_c( tcola_m, tcola_r, ()) self.tcola_overlap_add_0 = tcola.overlap_add_c(tcola_m, tcola_r, ()) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100, #size samp_rate, #samp_rate "", #name 2 #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(0, 3) 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(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ "Symbols", "Received Symbols", "RRC RX", "", "", "", "", "", "", "" ] 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 = [0, 2, -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: 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_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 3 #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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["Post RRC Tx", "Post RRC Rx", "", "", "", "", "", "", "", ""] 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(3): 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.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 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, 0.0) self.qtgui_number_sink_0_0.set_max(i, 1) 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_float, 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, -7) self.qtgui_number_sink_0.set_max(i, 0) 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.four_level_rrc_transmitter_0 = four_level_rrc_transmitter( alpha=0.350, bits_per_symbol=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.four_level_rrc_receiver_0_0 = four_level_rrc_receiver( alpha=0.350, bits_per_sym=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.four_level_rrc_receiver_0 = four_level_rrc_receiver( alpha=0.350, bits_per_sym=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(8, True, 0, 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, fsk_deviation_hz * 2 * math.pi, 1) self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_delay_2 = blocks.delay( gr.sizeof_char * 1, (symbol_delay + symb_rate) * bits_per_sym - 2) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, samp_rate) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, samp_rate - tcola_m) self.blocks_delay_0 = blocks.delay( gr.sizeof_float * 1, symbol_delay * samp_per_sym / 2 + samp_rate) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz)) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz)) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.four_level_rrc_receiver_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.four_level_rrc_receiver_0_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.tcola_time_compression_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.tcola_overlap_add_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_delay_2, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.four_level_rrc_transmitter_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blks2_error_rate_0, 1)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blocks_char_to_float_0, 0)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.four_level_rrc_receiver_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.four_level_rrc_receiver_0_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.four_level_rrc_receiver_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.four_level_rrc_transmitter_0, 1), (self.blocks_delay_0, 0)) self.connect((self.four_level_rrc_transmitter_0, 1), (self.blocks_vco_c_0, 0)) self.connect((self.tcola_overlap_add_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.tcola_time_compression_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): 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()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 self.preamble = preamble = [ -0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j] self.audio_rate = audio_rate = 8000 self.audio_interp = audio_interp = 2 self.voice_gain = voice_gain = 0 self.tau = tau = 75e-6 self.rx_channel = rx_channel = 110 self.quadrature_rate = quadrature_rate = audio_rate*audio_interp self.qpsk_constellation = qpsk_constellation = digital.constellation_calcdist(([(sqrt(2)/2)+(sqrt(2)/2)*1j,-(sqrt(2)/2)+(sqrt(2)/2)*1j,(sqrt(2)/2)-(sqrt(2)/2)*1j,-(sqrt(2)/2)-(sqrt(2)/2)*1j]), (digital.psk_4()[1]), 4, 1).base() self.qpsk_constellation.gen_soft_dec_lut(8) self.preamble_size = preamble_size = len(preamble) self.poly_taps = poly_taps = firdes.low_pass(2.0, samp_rate, 20000, 1000, firdes.WIN_HAMMING, 6.76) self.payload_size = payload_size = 100 self.num_channels = num_channels = 4 self.max_deviation = max_deviation = 3500 self.guard_size = guard_size = 10 self.codec_rate = codec_rate = 64000 self.bpsk_rate = bpsk_rate = 400000 ################################################## # Blocks ################################################## self._voice_gain_range = Range(0, 2, 0.01, 0, 200) self._voice_gain_win = RangeWidget(self._voice_gain_range, self.set_voice_gain, "voice_gain", "counter_slider", float) self.top_layout.addWidget(self._voice_gain_win) self.tab2 = Qt.QTabWidget() self.tab2_widget_0 = Qt.QWidget() self.tab2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_0) self.tab2_grid_layout_0 = Qt.QGridLayout() self.tab2_layout_0.addLayout(self.tab2_grid_layout_0) self.tab2.addTab(self.tab2_widget_0, "Preamble Correlation") self.tab2_widget_1 = Qt.QWidget() self.tab2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_1) self.tab2_grid_layout_1 = Qt.QGridLayout() self.tab2_layout_1.addLayout(self.tab2_grid_layout_1) self.tab2.addTab(self.tab2_widget_1, "Received Analog Voice") self.top_grid_layout.addWidget(self.tab2, 1,1,1,1) self._rx_channel_options = (110, 110*2, 110*3, 0, ) self._rx_channel_labels = ("0", "1", "2", "3", ) self._rx_channel_group_box = Qt.QGroupBox("rx_channel") self._rx_channel_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._rx_channel_button_group = variable_chooser_button_group() self._rx_channel_group_box.setLayout(self._rx_channel_box) for i, label in enumerate(self._rx_channel_labels): radio_button = Qt.QRadioButton(label) self._rx_channel_box.addWidget(radio_button) self._rx_channel_button_group.addButton(radio_button, i) self._rx_channel_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_channel_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._rx_channel_options.index(i))) self._rx_channel_callback(self.rx_channel) self._rx_channel_button_group.buttonClicked[int].connect( lambda i: self.set_rx_channel(self._rx_channel_options[i])) self.top_layout.addWidget(self._rx_channel_group_box) self.vocoder_ulaw_decode_bs_0 = vocoder.ulaw_decode_bs() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=309AF9C", "")), 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(433e6, 0) self.uhd_usrp_source_0.set_gain(5, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(2, firdes.root_raised_cosine( 1, bpsk_rate, bpsk_rate/2, 0.35, 101)) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size bpsk_rate/2, #samp_rate "Preamble Correlation", #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, False) 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(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: 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*1): 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.tab2_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_b( codec_rate, 100, (guard_size+payload_size)*num_channels, ([]), ([]), "Received TDM Frame", 1, ) self.qtgui_time_raster_sink_x_0_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [2, 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_time_raster_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_0_win, 1,2,1,1) self.qtgui_freq_sink_x_3 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Received Analog Voice", #name 1 #number of inputs ) self.qtgui_freq_sink_x_3.set_update_time(0.10) self.qtgui_freq_sink_x_3.set_y_axis(-140, 10) self.qtgui_freq_sink_x_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_3.enable_autoscale(False) self.qtgui_freq_sink_x_3.enable_grid(False) self.qtgui_freq_sink_x_3.set_fft_average(1.0) self.qtgui_freq_sink_x_3.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_3.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_3.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_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_3.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_3.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_3.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_3.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_3_win = sip.wrapinstance(self.qtgui_freq_sink_x_3.pyqwidget(), Qt.QWidget) self.tab2_layout_1.addWidget(self._qtgui_freq_sink_x_3_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Received Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_1.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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,1,1) self.digital_map_bb_0_0 = digital.map_bb((digital.psk_4()[1])) self.digital_corr_est_cc_0 = digital.corr_est_cc((preamble), 1, 0, 0.15) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(qpsk_constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_align_0 = blocks.tagged_stream_align(gr.sizeof_gr_complex*1, "corr_start") self.blocks_short_to_float_0 = blocks.short_to_float(1, 2000) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((voice_gain, )) self.blocks_keep_m_in_n_1 = blocks.keep_m_in_n(gr.sizeof_char, payload_size, num_channels*(payload_size+guard_size), rx_channel) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, num_channels*(payload_size+guard_size)/2, num_channels*(payload_size+guard_size)/2 + preamble_size, preamble_size) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*(num_channels*(payload_size+guard_size)/2+preamble_size)-1) self.audio_sink_0 = audio.sink(8000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_delay_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.blocks_keep_m_in_n_1, 0), (self.vocoder_ulaw_decode_bs_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_keep_m_in_n_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.qtgui_time_raster_sink_x_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_freq_sink_x_3, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_tagged_stream_align_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.vocoder_ulaw_decode_bs_0, 0), (self.blocks_short_to_float_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, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002): gr.top_block.__init__(self, "Rx Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Gui") 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", "rx_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.loopbw_0 = loopbw_0 self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'PMF Out') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Abs PMF Out') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'FLL In') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'FLL Out') self.tabs_widget_4 = Qt.QWidget() self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4) self.tabs_grid_layout_4 = Qt.QGridLayout() self.tabs_layout_4.addLayout(self.tabs_grid_layout_4) self.tabs.addTab(self.tabs_widget_4, 'FLL State') self.tabs_widget_5 = Qt.QWidget() self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5) self.tabs_grid_layout_5 = Qt.QGridLayout() self.tabs_layout_5.addLayout(self.tabs_grid_layout_5) self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out') self.tabs_widget_6 = Qt.QWidget() self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6) self.tabs_grid_layout_6 = Qt.QGridLayout() self.tabs_layout_6.addLayout(self.tabs_grid_layout_6) self.tabs.addTab(self.tabs_widget_6, 'Costas State') self.tabs_widget_7 = Qt.QWidget() self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7) self.tabs_grid_layout_7 = Qt.QGridLayout() self.tabs_layout_7.addLayout(self.tabs_grid_layout_7) self.tabs.addTab(self.tabs_widget_7, 'Demod Bits') self.tabs_widget_8 = Qt.QWidget() self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8) self.tabs_grid_layout_8 = Qt.QGridLayout() self.tabs_layout_8.addLayout(self.tabs_grid_layout_8) self.tabs.addTab(self.tabs_widget_8, 'Costas Sym Out') self.tabs_widget_9 = Qt.QWidget() self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9) self.tabs_grid_layout_9 = Qt.QGridLayout() self.tabs_layout_9.addLayout(self.tabs_grid_layout_9) self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols') self.top_layout.addWidget(self.tabs) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.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*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_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_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '', '', '', '', '', ''] 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(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f( 1024*4, #size samp_rate, #samp_rate "Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_3.set_update_time(0.10) self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_3.enable_tags(-1, True) self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_3.enable_autoscale(False) self.qtgui_time_sink_x_0_3.enable_grid(False) self.qtgui_time_sink_x_0_3.enable_axis_labels(True) self.qtgui_time_sink_x_0_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_3.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_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget) self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( preamble_size + payload_size, #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(True) 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 = ['Mag Sq', 'Mag', '', '', '', '', '', '', '', ''] 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.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_sink_x_5 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_5.set_update_time(1.0/10) self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget) self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win) self.qtgui_sink_x_5.enable_rf_freq(False) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) 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.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 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 = [0, 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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_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 = [1, 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 = [0, 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.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_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, 1), (self.qtgui_time_sink_x_0_3, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0)) self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2)) self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
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): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.username = username = os.environ.get('USER') self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 100 self.frequency = frequency = 2440000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.trellis_encoder_xx_0 = trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0, 0) if False else trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0) self._symbol_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.symbol_rate, callback=self.set_symbol_rate, label='symbol_rate', choices=[250000, 333000, 500000, 1000000, 1200000, 1500000], labels=[ "250kS/s", "333kS/s", "500 kS/s", "1000kS/s", "1200kS/s", "1500kS/s" ], style=wx.RA_HORIZONTAL, ) self.Add(self._symbol_rate_chooser) self.pluto_sink_0 = iio.pluto_sink('', frequency, samp_rate, 20000000, 0x8000, False, 10.0, '', True) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.fec_puncture_xx_0 = fec.puncture_bb(14, 0b11010101100110, 0) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, 255, 239, 8, 51, 8) self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1) self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver( 136, 12, 17) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/media/" + username + "/PlutoSDR/rpidatv.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_puncture_xx_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0)) self.connect((self.fec_puncture_xx_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="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.symbol_rate = symbol_rate = 60000 self.symbol_period = symbol_period = pow(symbol_rate,-1) self.samp_rate = samp_rate = 300e3 self.samp_per_sym = samp_per_sym = 5 self.packet_len = packet_len = 256 self.decimation = decimation = 1 self.bits_per_sym = bits_per_sym = 1 self.Sq_Thresh = Sq_Thresh = -30 self.RF_Gain = RF_Gain = 20 self.Fc = Fc = 175e6 ################################################## # Blocks ################################################## _Sq_Thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._Sq_Thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_Sq_Thresh_sizer, value=self.Sq_Thresh, callback=self.set_Sq_Thresh, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._Sq_Thresh_slider = forms.slider( parent=self.GetWin(), sizer=_Sq_Thresh_sizer, value=self.Sq_Thresh, callback=self.set_Sq_Thresh, minimum=-50, maximum=20, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_Sq_Thresh_sizer, 0, 2, 1, 1) _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._RF_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._RF_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, minimum=0, maximum=50, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_RF_Gain_sizer, 0, 0, 1, 1) _Fc_sizer = wx.BoxSizer(wx.VERTICAL) self._Fc_text_box = forms.text_box( parent=self.GetWin(), sizer=_Fc_sizer, value=self.Fc, callback=self.set_Fc, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._Fc_slider = forms.slider( parent=self.GetWin(), sizer=_Fc_sizer, value=self.Fc, callback=self.set_Fc, minimum=50e6, maximum=1700e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_Fc_sizer, 0, 1, 1, 1) self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl_tcp=10.0.0.13:1234' ) self.osmosdr_source_0_0.set_sample_rate(samp_rate) self.osmosdr_source_0_0.set_center_freq(Fc+10e6, 0) self.osmosdr_source_0_0.set_freq_corr(0, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0_0.set_gain_mode(False, 0) self.osmosdr_source_0_0.set_gain(RF_Gain, 0) self.osmosdr_source_0_0.set_if_gain(0, 0) self.osmosdr_source_0_0.set_bb_gain(0, 0) self.osmosdr_source_0_0.set_antenna("", 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl_tcp=10.0.0.12:1234' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(Fc, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(samp_rate)*5) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(samp_rate)*5) self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blks2_tcp_sink_0_0_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=3493, server=True, ) self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=3491, server=True, ) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(Sq_Thresh, 0.01, 5, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-10, 0.01, 5, True) self.analog_fm_demod_cf_0_0 = analog.fm_demod_cf( channel_rate=samp_rate, audio_decim=decimation, deviation=75e3, audio_pass=120e3, audio_stop=140e3, gain=1.0, tau=75e-6, ) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=samp_rate, audio_decim=decimation, deviation=75e3, audio_pass=120e3, audio_stop=140e3, gain=1.0, tau=75e-6, ) self.RPi_Rx_RPi_Rx_0_0 = RPi_Rx.RPi_Rx(bits_per_sym, samp_per_sym, packet_len, 65) self.RPi_Rx_RPi_Rx_0 = RPi_Rx.RPi_Rx(bits_per_sym, samp_per_sym, packet_len, 65) ################################################## # Connections ################################################## self.connect((self.analog_fm_demod_cf_0, 0), (self.RPi_Rx_RPi_Rx_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blks2_tcp_sink_0_0, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.blks2_tcp_sink_0_0_0, 0)) self.connect((self.analog_fm_demod_cf_0_0, 0), (self.RPi_Rx_RPi_Rx_0_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.analog_fm_demod_cf_0_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.blocks_skiphead_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Corr And Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Test Corr And Sync") 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", "test_corr_and_sync") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 100000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), eb, 5*sps*nfilts) self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase = phase = 0 self.payload_size = payload_size = 992 self.noise = noise = 0 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.gap = gap = 20000 self.freq_offset = freq_offset = 0 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.bb_filter = bb_filter = firdes.root_raised_cosine(sps, sps, 1, eb, 101) ################################################## # Blocks ################################################## self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_label = Qt.QLabel("Timing Offset") self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.995, 1.005, 0.00001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._time_offset_layout.addWidget(self._time_offset_label) self._time_offset_layout.addWidget(self._time_offset_slider) self.top_grid_layout.addLayout(self._time_offset_layout, 4,1,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_label = Qt.QLabel("Noise") self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 1, 0.005) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._noise_layout.addWidget(self._noise_label) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 3,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_label = Qt.QLabel("Frequency Offset") self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.001, 0.001, 0.00002) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_offset_layout.addWidget(self._freq_offset_label) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.top_grid_layout.addLayout(self._freq_offset_layout, 4,0,1,1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 80000, #size samp_rate, #samp_rate "QT GUI Plot", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-200, 400) self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 200, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) labels = ["|corr|^2", "Re{corr}", "Im{corr}", "", "", "", "", "", "", ""] 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(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1,0,1,2) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 50000, #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(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 1, 0.1, 0, "time_est") self.qtgui_time_sink_x_0.enable_autoscale(False) 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*1): 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) (self.qtgui_time_sink_x_0).set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1000, #size "QT GUI Plot", #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_TAG, qtgui.TRIG_SLOPE_POS, 0, 0, "time_est") self.qtgui_const_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 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 = [0, 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,1,1,1) self._phase_layout = Qt.QVBoxLayout() self._phase_label = Qt.QLabel("Phase offset") self._phase_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_slider.setRange(-2*scipy.pi, 2*scipy.pi, 0.1) self._phase_slider.setValue(self.phase) self._phase_slider.setMinimumWidth(200) self._phase_slider.valueChanged.connect(self.set_phase) self._phase_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_layout.addWidget(self._phase_label) self._phase_layout.addWidget(self._phase_slider) self.top_grid_layout.addLayout(self._phase_layout, 3,1,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, 0, 0.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1*3.14/50.0, 2) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, ((len(preamble)+8*payload_size)*sps, gap)) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 100000)), True) ################################################## # Connections ################################################## self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_1, 2)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self, channel_noise, img_path): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.taps = taps = [1] self.size_packed_file = size_packed_file = os.path.getsize( "/home/rcampello/Main/FixedPath/OOT Gnuradio/Material/GnuRadio/Scripts/BPSK/{}" .format(str(img_path))) self.samp_rate = samp_rate = 32000 * 20 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32) self.noise = noise = channel_noise self.eq_gain = eq_gain = 0 self.delay2 = delay2 = int(8) self.delay = delay = int(2) self.BPSK = BPSK = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 4, 62.8e-3, (rrc_taps), 32, 16, 1.5, 2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 62.8e-3, 2, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=False, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( BPSK) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=(taps), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_char * 1, int(size_packed_file * 0.1)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, int(size_packed_file * 2)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/rcampello/Main/FixedPath/OOT Gnuradio/Material/GnuRadio/Scripts/BPSK/{}' .format(str(img_path)), True) self.sink = blocks.vector_sink_b() ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_head_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.sink, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Application") Qt.QWidget.__init__(self) self.setWindowTitle("Tx Application") 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", "tx_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.usrp_rf_freq = usrp_rf_freq = 2475e6 self.sps = sps = 4 self.samp_rate = samp_rate = 200000 self.qpsk = qpsk = digital.constellation_rect(([0.25*(0.707+0.707j),0.25*( -0.707+0.707j),0.25*( -0.707-0.707j), 0.25*(0.707-0.707j)]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble_qpsk = preamble_qpsk = map(lambda x: x*(1+1j)/pow(2,0.5), preamble) self.payload_size = payload_size = 100 self.length_tag_key = length_tag_key = "packet_len" self.header_len = header_len = 4 self.gain = gain = 26 self.eb = eb = 0.35 self.digital_gain = digital_gain = 1.0/4 self.crc_len = crc_len = 4 self.bps = bps = 2 self.addr = addr = "addr=192.168.60.2" ################################################## # Blocks ################################################## self._usrp_rf_freq_range = Range(2400e6, 2500e6, 100e3, 2475e6, 200) self._usrp_rf_freq_win = RangeWidget(self._usrp_rf_freq_range, self.set_usrp_rf_freq, "Rx Frequency", "counter_slider") self.top_layout.addWidget(self._usrp_rf_freq_win) self._gain_range = Range(0, 31.5, 0.5, 26, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "Tx Gain", "counter_slider") self.top_layout.addWidget(self._gain_win) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join((addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0_0.set_gain(gain, 0) self.uhd_usrp_sink_0_0.set_antenna("J1", 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype usrp_rf_freq, #fc samp_rate, #bw "QT GUI Plot", #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(-120, 20) 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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(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.qpsk_preamp_to_bits = blocks.vector_source_b(map(lambda x: int((x*(1j-1)/pow(2,0.5)).real+1), preamble_qpsk), True, 1, []) self.padded_bits = blocks.vector_source_b((0,0,0,0,0,0,0,0), True, 1, []) (self.padded_bits).set_block_alias("padded bits") self.digital_packet_headergenerator_bb_default_0 = digital.packet_headergenerator_bb(header_len*8, length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, payload_size, length_tag_key) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)*bps/8,header_len,payload_size+crc_len,6)) self.blocks_pack_k_bits_bb_0_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((digital_gain, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/users/lwei/GITfolder/wirelessacademy/BasicTxRx/wilabt/file_sent.txt", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_1, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_0_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_packet_headergenerator_bb_default_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.padded_bits, 0), (self.blocks_stream_mux_0_0_0, 3)) self.connect((self.qpsk_preamp_to_bits, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_stream_mux_0_0_0, 2)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_packet_headergenerator_bb_default_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.blocks_stream_mux_0_0_0, 1))