def gen_object(M = 4, ctype = 'qam'): ''' Generate Constellation decoder object it is responsable for demapping received symbols into bits M - Constellation Number os points Type - Constellation Type ''' const = gen(M, ctype) pre_diff = [] if ctype == 'qam': obj = digital.constellation_rect( const, pre_diff, 1, # simetry int(sqrt(M)), # real constellation size int(sqrt(M)), # imag constellation size 2, # real constellation segment size 2) # imag constellation segment size elif ctype == 'pam': obj = digital.constellation_rect( const, pre_diff, 0, len(const), 1, 2, 0) elif ctype == 'psk': obj = None # TODO: implement psk exit(0) # TODO find a way to show error on GNU Radio Companion else: exit(0) # TODO find a way to show error on GNU Radio Companion return obj
def gen_object(M=4, ctype='qam'): ''' Generate Constellation decoder object it is responsable for demapping received symbols into bits M - Constellation Number os points Type - Constellation Type ''' const = gen(M, ctype) pre_diff = [] if ctype == 'qam': obj = digital.constellation_rect( const, pre_diff, 1, # simetry int(sqrt(M)), # real constellation size int(sqrt(M)), # imag constellation size 2, # real constellation segment size 2) # imag constellation segment size elif ctype == 'pam': obj = digital.constellation_rect(const, pre_diff, 0, len(const), 1, 2, 0) elif ctype == 'psk': obj = None # TODO: implement psk exit(0) # TODO find a way to show error on GNU Radio Companion else: exit(0) # TODO find a way to show error on GNU Radio Companion return obj
def test_qam16(i, sample, prec): sample = sample/1 qam_const_list = [qam_16_0, ] qam_lut_gen_list = [sd_qam_16_0, ] constel, code = qam_const_list[i]() qam_lut_gen = qam_lut_gen_list[i] rot_sym = 4 side = 2 width = 2 c = digital.constellation_rect(constel, code, rot_sym, side, side, width, width) # Get max energy/symbol in constellation constel = c.points() Es = max([abs(constel_i) for constel_i in constel]) #table = soft_dec_table_generator(qam_lut_gen, prec, Es) table = soft_dec_table(constel, code, prec, 1) #c.gen_soft_dec_lut(prec) c.set_soft_dec_lut(table, prec) y_python_gen_calc = qam_lut_gen(sample, Es) y_python_table = calc_soft_dec_from_table(sample, table, prec, Es) y_python_raw_calc = calc_soft_dec(sample, constel, code, 1) y_cpp_table = c.soft_decision_maker(sample) y_cpp_raw_calc = c.calc_soft_dec(sample) return (y_python_gen_calc, y_python_table, y_python_raw_calc, y_cpp_table, y_cpp_raw_calc, constel, code, c)
def test_qpsk(i, sample, prec): qpsk_const_list = [psk_4_0, psk_4_1, psk_4_2, psk_4_3, psk_4_4, psk_4_5, psk_4_6, psk_4_7] qpsk_lut_gen_list = [sd_psk_4_0, sd_psk_4_1, sd_psk_4_2, sd_psk_4_3, sd_psk_4_4, sd_psk_4_5, sd_psk_4_6, sd_psk_4_7] constel, code = qpsk_const_list[i]() qpsk_lut_gen = qpsk_lut_gen_list[i] rot_sym = 1 side = 2 width = 2 c = digital.constellation_rect(constel, code, rot_sym, side, side, width, width) # Get max energy/symbol in constellation constel = c.points() Es = max([numpy.sqrt(constel_i.real**2 + constel_i.imag**2) for constel_i in constel]) #table = soft_dec_table_generator(qpsk_lut_gen, prec, Es) table = soft_dec_table(constel, code, prec) c.gen_soft_dec_lut(prec) #c.set_soft_dec_lut(table, prec) y_python_gen_calc = qpsk_lut_gen(sample, Es) y_python_table = calc_soft_dec_from_table(sample, table, prec, Es) y_python_raw_calc = calc_soft_dec(sample, constel, code) y_cpp_table = c.soft_decision_maker(sample) y_cpp_raw_calc = c.calc_soft_dec(sample) return (y_python_gen_calc, y_python_table, y_python_raw_calc, y_cpp_table, y_cpp_raw_calc, constel, code, c)
def test_qam16(i, sample, prec): sample = sample / 1 qam_const_list = [qam_16_0, ] qam_lut_gen_list = [sd_qam_16_0, ] constel, code = qam_const_list[i]() qam_lut_gen = qam_lut_gen_list[i] rot_sym = 4 side = 2 width = 2 c = digital.constellation_rect(constel, code, rot_sym, side, side, width, width) # Get max energy/symbol in constellation constel = c.points() Es = max([abs(constel_i) for constel_i in constel]) #table = soft_dec_table_generator(qam_lut_gen, prec, Es) table = soft_dec_table(constel, code, prec, 1) #c.gen_soft_dec_lut(prec) c.set_soft_dec_lut(table, prec) y_python_gen_calc = qam_lut_gen(sample, Es) y_python_table = calc_soft_dec_from_table(sample, table, prec, Es) y_python_raw_calc = calc_soft_dec(sample, constel, code, 1) y_cpp_table = c.soft_decision_maker(sample) y_cpp_raw_calc = c.calc_soft_dec(sample) return (y_python_gen_calc, y_python_table, y_python_raw_calc, y_cpp_table, y_cpp_raw_calc, constel, code, c)
def constellation_32qam_cross(): ''' 0 1 29 28 4 8 12 16 20 24 5 9 13 17 21 25 6 10 14 18 22 26 7 11 15 19 23 27 3 2 30 31 ''' constellation_points = [ -3 + 5j, -1 + 5j, 1 + 5j, 3 + 5j, -5 + 3j, -3 + 3j, -1 + 3j, 1 + 3j, 3 + 3j, 5 + 3j, -5 + 1j, -3 + 1j, -1 + 1j, 1 + 1j, 3 + 1j, 5 + 1j, -5 - 1j, -3 - 1j, -1 - 1j, 1 - 1j, 3 - 1j, 5 - 1j, -5 - 3j, -3 - 3j, -1 - 3j, 1 - 3j, 3 - 3j, 5 - 3j, -3 - 5j, -1 - 5j, 1 - 5j, 3 - 5j ] # This is not quite a gray-code, but an optimal mapping. # This was taken from the MATLAB generated 32-QAM mapping gray_code = [ 0, 1, 29, 28, 4, 8, 12, 16, 20, 24, 5, 9, 13, 17, 21, 25, 6, 10, 14, 18, 22, 26, 7, 11, 15, 19, 23, 27, 3, 2, 30, 31 ] return digital.constellation_rect( constellation_points, gray_code, 4, # rotational symmetry 6, # real sectors 6, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def constellation_32qam_cross(): ''' 0 1 29 28 4 8 12 16 20 24 5 9 13 17 21 25 6 10 14 18 22 26 7 11 15 19 23 27 3 2 30 31 ''' constellation_points = [ -3 + 5j, -1 + 5j, 1 + 5j, 3 + 5j, -5 + 3j, -3 + 3j, -1 + 3j, 1 + 3j, 3 + 3j, 5 + 3j, -5 + 1j, -3 + 1j, -1 + 1j, 1 + 1j, 3 + 1j, 5 + 1j, -5 - 1j, -3 - 1j, -1 - 1j, 1 - 1j, 3 - 1j, 5 - 1j, -5 - 3j, -3 - 3j, -1 - 3j, 1 - 3j, 3 - 3j, 5 - 3j, -3 - 5j, -1 - 5j, 1 - 5j, 3 - 5j ] gray_code = [ 0, 1, 29, 28, 4, 8, 12, 16, 20, 24, 5, 9, 13, 17, 21, 25, 6, 10, 14, 18, 22, 26, 7, 11, 15, 19, 23, 27, 3, 2, 30, 31 ] return digital.constellation_rect( constellation_points, gray_code, 4, # rotational symmetry 6, # real sectors 6, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def qam_constellation(constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code): """ Creates a QAM constellation object. """ if mod_code == mod_codes.GRAY_CODE: gray_coded = True elif mod_code == mod_codes.NO_CODE: gray_coded = False else: raise ValueError("Mod code is not implemented for QAM") if differential: points = make_differential_constellation(constellation_points, gray_coded) else: points = make_non_differential_constellation(constellation_points, gray_coded) side = int(sqrt(constellation_points)) width = 2.0 / (side - 1) # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, side, side, width, width) return constellation
def test_normalization(self): rot_sym = 1 side = 2 width = 2 # Test a couple of basic constellations for constel_points, code in (digital.psk_4_0(), digital.qam_16_0()): constel = digital.constellation_rect( constel_points, code, rot_sym, side, side, width, width, constellation.POWER_NORMALIZATION) points = np.array(constel.points()) avg_power = np.sum(abs(points)**2) / len(points) self.assertAlmostEqual(avg_power, 1.0, 6) constel = digital.constellation_rect( constel_points, code, rot_sym, side, side, width, width, constellation.AMPLITUDE_NORMALIZATION) points = np.array(constel.points()) avg_amp = np.sum(abs(points)) / len(points) self.assertAlmostEqual(avg_amp, 1.0, 6)
def test_soft_qpsk_gen(self): prec = 8 constel, code = digital.psk_4_0() rot_sym = 1 side = 2 width = 2 c = digital.constellation_rect(constel, code, rot_sym, side, side, width, width) # Get max energy/symbol in constellation constel = c.points() Es = max([abs(constel_i) for constel_i in constel]) table = digital.soft_dec_table_generator(digital.sd_psk_4_0, prec, Es) c.set_soft_dec_lut(table, prec) x = sqrt(2.0) / 2.0 step = (x.real + x.real) / (2**prec - 1) samples = [-x - x * 1j, -x + x * 1j, x + x * 1j, x - x * 1j, (-x + 128 * step) + (-x + 128 * step) * 1j, (-x + 64 * step) + (-x + 64 * step) * 1j, (-x + 64 * step) + (-x + 192 * step) * 1j, (-x + 192 * step) + (-x + 192 * step) * 1j, (-x + 192 * step) + (-x + 64 * step) * 1j, ] y_python_raw_calc = [] y_python_gen_calc = [] y_python_table = [] y_cpp_raw_calc = [] y_cpp_table = [] for sample in samples: y_python_raw_calc += slicer( digital.calc_soft_dec( sample, constel, code)) y_python_gen_calc += slicer(digital.sd_psk_4_0(sample, Es)) y_python_table += slicer( digital.calc_soft_dec_from_table( sample, table, prec, Es)) y_cpp_raw_calc += c.calc_soft_dec(sample) y_cpp_table += c.soft_decision_maker(sample) self.assertFloatTuplesAlmostEqual( y_python_raw_calc, y_python_gen_calc, 0) self.assertFloatTuplesAlmostEqual(y_python_gen_calc, y_python_table, 0) self.assertFloatTuplesAlmostEqual(y_cpp_raw_calc, y_cpp_table, 0)
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.sps = sps = 4 self.samp_rate = samp_rate = 44100 self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.blocks_wavfile_sink = blocks.wavfile_sink('/tmp/challenge.wav', 2, samp_rate, 16) self.blocks_file_source = blocks.file_source(gr.sizeof_char * 1, '/tmp/input.txt', False) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) 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, ) ################################################## # Connections ################################################## self.connect((self.blocks_file_source, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_wavfile_sink, 1))
def constellation_16qam(self): # points are separated as such real, imaginary = np.meshgrid(np.linspace(-3, 3, 4), np.linspace(-3, 3, 4)) constellation_points = real + np.multiply(imaginary, 1j) gray_code = [2, 6, 14, 10, 3, 7, 15, 11, 1, 5, 13, 9, 0, 4, 12, 8] return digital.constellation_rect( constellation_points.flatten(), gray_code, 4, # rotational symmetry 4, # real sectors 4, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def constellation_4_ask(): ''' 0 1 3 2 ''' constellation_points = [-3, -1, 1, 3] gray_code = [0, 1, 3, 2] return digital.constellation_rect( constellation_points, gray_code, 2, # rotational symmetry 4, # real sectors 1, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def constellation_8_ask(): ''' 6 2 3 1 0 4 5 7 ''' constellation_points = [-7, -5, -3, -1, 1, 3, 5, 7] gray_code = [6, 2, 3, 1, 0, 4, 5, 7] return digital.constellation_rect( constellation_points, gray_code, 2, # rotational symmetry 8, # real sectors 1, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def __init__(self): gr.top_block.__init__(self, "Tx Simple") ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 2e6 self.qpsk_const = qpsk_const = digital.constellation_rect( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.f0 = f0 = 374e6 self.Gain_dB = Gain_dB = 45 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:A', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(f0, 0) self.uhd_usrp_sink_0.set_gain(Gain_dB, 0) self.uhd_usrp_sink_0.set_antenna('TX0', 0) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.10, verbose=False, log=False, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ber Test") ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 62.8e-3 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(([1+1j, -1+1j, -1-1j, 1-1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=True, log=False, ) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(qpsk) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 2, "", False, gr.GR_LSB_FIRST) self.blocks_random_pdu_0 = blocks.random_pdu(5, 6, chr(0xFF), 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_message_strobe_0 = blocks.message_strobe(pmt.PMT_T, 2000) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0))
def constellation_64qam(): # points are separated as such real, imaginary = np.meshgrid(np.linspace(-7, 7, 8), np.linspace(-7, 7, 8)) constellation_points = real + np.multiply(imaginary, 1j) gray_code = [ 4, 12, 28, 20, 52, 60, 44, 36, 5, 13, 29, 21, 53, 61, 45, 37, 7, 15, 31, 23, 55, 63, 47, 39, 6, 14, 30, 22, 54, 62, 46, 39, 2, 10, 26, 18, 50, 58, 42, 34, 3, 11, 27, 19, 51, 59, 43, 35, 1, 9, 25, 17, 49, 57, 41, 33, 0, 8, 24, 16, 48, 56, 40, 32 ] return digital.constellation_rect( constellation_points.flatten(), gray_code, 4, # rotational symmetry 8, # real sectors 8, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def constellation_8qam_cross(): ''' 0 4 6 2 5 7 3 1 ''' constellation_points = [ 0 + 3j, -2 + 1j, 0 + 1j, 2 + 1j, -2 - 1j, 0 - 1j, 2 - 1j, 0 - 3j ] gray_code = [0, 4, 6, 2, 5, 7, 3, 1] return digital.constellation_rect( constellation_points, gray_code, 2, # rotational symmetry 3, # real sectors 4, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def test_soft_qpsk_gen(self): prec = 8 constel, code = digital.psk_4_0() rot_sym = 1 side = 2 width = 2 c = digital.constellation_rect(constel, code, rot_sym, side, side, width, width) # Get max energy/symbol in constellation constel = c.points() Es = max([abs(constel_i) for constel_i in constel]) table = digital.soft_dec_table_generator(digital.sd_psk_4_0, prec, Es) c.set_soft_dec_lut(table, prec) x = sqrt(2.0)/2.0 step = (x.real+x.real) / (2**prec - 1) samples = [ -x-x*1j, -x+x*1j, x+x*1j, x-x*1j, (-x+128*step)+(-x+128*step)*1j, (-x+64*step) +(-x+64*step)*1j, (-x+64*step) +(-x+192*step)*1j, (-x+192*step)+(-x+192*step)*1j, (-x+192*step)+(-x+64*step)*1j,] y_python_raw_calc = [] y_python_gen_calc = [] y_python_table = [] y_cpp_raw_calc = [] y_cpp_table = [] for sample in samples: y_python_raw_calc += digital.calc_soft_dec(sample, constel, code) y_python_gen_calc += digital.sd_psk_4_0(sample, Es) y_python_table += digital.calc_soft_dec_from_table(sample, table, prec, Es) y_cpp_raw_calc += c.calc_soft_dec(sample) y_cpp_table += c.soft_decision_maker(sample) self.assertFloatTuplesAlmostEqual(y_python_raw_calc, y_python_gen_calc, 4) self.assertFloatTuplesAlmostEqual(y_python_raw_calc, y_python_table, 2) self.assertFloatTuplesAlmostEqual(y_cpp_raw_calc, y_cpp_table, 4)
def constellation_8qam_cross(): ''' 0 4 6 2 5 7 3 1 ''' constellation_points = [ 0 + 3j, -2 + 1j, 0 + 1j, 2 + 1j, -2 - 1j, 0 - 1j, 2 - 1j, 0 - 3j ] # This is not quite a gray-code, but an optimal mapping. # This was taken from a ppt I found online from Broadcom gray_code = [0, 4, 6, 2, 5, 7, 3, 1] return digital.constellation_rect( constellation_points, gray_code, 2, # rotational symmetry 3, # real sectors 4, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def constellation_32qam_rect(): ''' 2 6 14 19 26 29 22 18 3 7 15 11 27 30 23 19 1 5 13 9 25 28 21 17 0 4 12 8 24 27 20 16 ''' real, imaginary = np.meshgrid(np.linspace(-7, 7, 8), np.linspace(-3, 3, 4)) constellation_points = real + np.multiply(imaginary, 1j) gray_code = [ 2, 6, 14, 10, 26, 29, 22, 18, 3, 7, 15, 11, 27, 30, 23, 19, 1, 5, 13, 9, 25, 28, 21, 17, 0, 4, 12, 8, 24, 27, 20, 16 ] return digital.constellation_rect( constellation_points.flatten(), gray_code, 2, # rotational symmetry 4, # real sectors 8, # imaginary sectors 2, # real sector width 2 # imaginary sector width ).base()
def qam_constellation(constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code): """ Creates a QAM constellation object. """ if mod_code == mod_codes.GRAY_CODE: gray_coded = True elif mod_code == mod_codes.NO_CODE: gray_coded = False else: raise ValueError("Mod code is not implemented for QAM") if differential: points = make_differential_constellation(constellation_points, gray_coded) else: points = make_non_differential_constellation(constellation_points, gray_coded) side = int(sqrt(constellation_points)) width = 2.0/(side-1) # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] constellation = digital.constellation_rect(points, pre_diff_code, 4, side, side, width, width) return constellation
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 __init__(self): gr.top_block.__init__(self, "Message Test") Qt.QWidget.__init__(self) self.setWindowTitle("Message Test") 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", "message_test") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 16 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 62.8e-3 self.taps_0 = taps_0 = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.taps = taps = [ 1.0 + 0.0j, ] self.samp_rate_0 = samp_rate_0 = 10e3 self.samp_rate = samp_rate = 32e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.phase_bw = phase_bw = 62.8e-3 self.lpf_transition_width = lpf_transition_width = 500 self.lpf_cutoff_freq = lpf_cutoff_freq = 3e3 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 10e-3 self.center_freq = center_freq = 5e3 self.bpsk = bpsk = digital.constellation_rect( ([1 + 1j, -1 + 1j, -1 - 1j, 1 - 1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.arity = arity = 4 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Test: Downconersion", #name 2 #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) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = [ 'Down_Baseband', 'Bandpass', 'Passband(Real)', 'Passband(Img)', '', '', '', '', '', '' ] 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_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.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Test: Upconersion", #name 2 #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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = [ 'Baseband', 'Bandpass', 'Passband(Real)', 'Passband(Img)', '', '', '', '', '', '' ] 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_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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_freq_sink_x_1_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Down Conversion and LPF", #name 3 #number of inputs ) self.qtgui_freq_sink_x_1_1.set_update_time(0.10) self.qtgui_freq_sink_x_1_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_1.enable_autoscale(True) self.qtgui_freq_sink_x_1_1.enable_grid(False) self.qtgui_freq_sink_x_1_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1_1.set_plot_pos_half(not True) labels = ['Bandpass', 'IF', 'LPF', '', '', '', '', '', '', ''] 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(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_1_win) self.low_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, lpf_cutoff_freq, lpf_transition_width, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, lpf_cutoff_freq, lpf_transition_width, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=bpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=True, log=False, ) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( bpsk) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, 10e3, True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_MSB_FIRST) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/bin_test.txt', True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/bin_test_qpsk_NOpacketEncode_output.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_float_2 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, center_freq, -1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, center_freq, 1, 0) self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_complex_to_float_2, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_pfb_clock_sync_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_1_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_1_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.qtgui_freq_sink_x_1_1, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_2, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_1, 2)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_float_to_complex_0, 1))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage1") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage1") 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", "mpsk_stage1") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.excess_bw = excess_bw = 0.35 self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1, sps, 1, excess_bw, 45) 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.arity = arity = 4 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 200, #size samp_rate, #samp_rate '', #name 2 #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.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Re{TX}', 'Im{TX}', 'Re{RX}', 'Im{RX}', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "cyan", "magenta", "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 = [0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): 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.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-150, 0) 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 = ['TX', 'RX', '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [0.6, 0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024*4, #size '', #name 2 #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 = ['TX', 'RX', '', '', '', '', '', '', '', ''] 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 = [0.75, 0.5, 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_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.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)] self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (rrc_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) 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_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 1))
def __init__(self): gr.top_block.__init__(self, "QPSK Test") Qt.QWidget.__init__(self) self.setWindowTitle("QPSK Test") 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", "QPSK_Test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sym_rate = sym_rate = 500000 self.samp_rate = samp_rate = 2000000 self.sps = sps = int(samp_rate/sym_rate) self.nfilts = nfilts = 32 self.trans_width = trans_width = 10000 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0 + 0.0j, ] self.sps_out = sps_out = 2 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.phase_bw = phase_bw = 6.28/100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.filter_gain = filter_gain = 1 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.co_freq = co_freq = samp_rate/2 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, "LPF") self.controls_widget_2 = Qt.QWidget() self.controls_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_2) self.controls_grid_layout_2 = Qt.QGridLayout() self.controls_layout_2.addLayout(self.controls_grid_layout_2) self.controls.addTab(self.controls_widget_2, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,1) self._trans_width_layout = Qt.QHBoxLayout() self._trans_width_layout.addWidget(Qt.QLabel("Transition Width"+": ")) 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._trans_width_counter = qwt_counter_pyslot() self._trans_width_counter.setRange(1000, 100000, 1000) self._trans_width_counter.setNumButtons(2) self._trans_width_counter.setMinimumWidth(200) self._trans_width_counter.setValue(self.trans_width) self._trans_width_layout.addWidget(self._trans_width_counter) self._trans_width_counter.valueChanged.connect(self.set_trans_width) self.controls_grid_layout_1.addLayout(self._trans_width_layout, 1,0,1,1) self._timing_loop_bw_layout = Qt.QHBoxLayout() self._timing_loop_bw_layout.addWidget(Qt.QLabel("Timing Loop BW "+": ")) 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._timing_loop_bw_counter = qwt_counter_pyslot() self._timing_loop_bw_counter.setRange(0.0, 0.2, 0.01) self._timing_loop_bw_counter.setNumButtons(2) self._timing_loop_bw_counter.setMinimumWidth(200) self._timing_loop_bw_counter.setValue(self.timing_loop_bw) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_counter) self._timing_loop_bw_counter.valueChanged.connect(self.set_timing_loop_bw) self.controls_grid_layout_2.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QHBoxLayout() self._time_offset_layout.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.995, 1.005, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setMinimumWidth(200) self._time_offset_counter.setValue(self.time_offset) self._time_offset_layout.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 1,0,1,1) self._phase_bw_layout = Qt.QHBoxLayout() self._phase_bw_layout.addWidget(Qt.QLabel("Phase Loop BW "+": ")) 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._phase_bw_counter = qwt_counter_pyslot() self._phase_bw_counter.setRange(0.0, 1.0, 0.01) self._phase_bw_counter.setNumButtons(2) self._phase_bw_counter.setMinimumWidth(200) self._phase_bw_counter.setValue(self.phase_bw) self._phase_bw_layout.addWidget(self._phase_bw_counter) self._phase_bw_counter.valueChanged.connect(self.set_phase_bw) self.controls_grid_layout_2.addLayout(self._phase_bw_layout, 2,0,1,1) self._noise_volt_layout = Qt.QHBoxLayout() self._noise_volt_layout.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.setMinimumWidth(200) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QHBoxLayout() self._freq_offset_layout.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.setMinimumWidth(200) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 2,0,1,1) self._filter_gain_layout = Qt.QHBoxLayout() self._filter_gain_layout.addWidget(Qt.QLabel("Filter 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._filter_gain_counter = qwt_counter_pyslot() self._filter_gain_counter.setRange(1, 10, 1) self._filter_gain_counter.setNumButtons(2) self._filter_gain_counter.setMinimumWidth(200) self._filter_gain_counter.setValue(self.filter_gain) self._filter_gain_layout.addWidget(self._filter_gain_counter) self._filter_gain_counter.valueChanged.connect(self.set_filter_gain) self.controls_grid_layout_1.addLayout(self._filter_gain_layout, 2,0,1,1) self.fig_tabs = Qt.QTabWidget() self.fig_tabs_widget_0 = Qt.QWidget() self.fig_tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_0) self.fig_tabs_grid_layout_0 = Qt.QGridLayout() self.fig_tabs_layout_0.addLayout(self.fig_tabs_grid_layout_0) self.fig_tabs.addTab(self.fig_tabs_widget_0, "LPF output") self.fig_tabs_widget_1 = Qt.QWidget() self.fig_tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_1) self.fig_tabs_grid_layout_1 = Qt.QGridLayout() self.fig_tabs_layout_1.addLayout(self.fig_tabs_grid_layout_1) self.fig_tabs.addTab(self.fig_tabs_widget_1, "PFB output") self.fig_tabs_widget_2 = Qt.QWidget() self.fig_tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_2) self.fig_tabs_grid_layout_2 = Qt.QGridLayout() self.fig_tabs_layout_2.addLayout(self.fig_tabs_grid_layout_2) self.fig_tabs.addTab(self.fig_tabs_widget_2, "CMA output") self.fig_tabs_widget_3 = Qt.QWidget() self.fig_tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_3) self.fig_tabs_grid_layout_3 = Qt.QGridLayout() self.fig_tabs_layout_3.addLayout(self.fig_tabs_grid_layout_3) self.fig_tabs.addTab(self.fig_tabs_widget_3, "Costas output") self.top_grid_layout.addWidget(self.fig_tabs, 1,0,1,2) self._eq_gain_layout = Qt.QHBoxLayout() self._eq_gain_layout.addWidget(Qt.QLabel("Equalizer 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._eq_gain_counter = qwt_counter_pyslot() self._eq_gain_counter.setRange(0.0, 0.1, 0.001) self._eq_gain_counter.setNumButtons(2) self._eq_gain_counter.setMinimumWidth(200) self._eq_gain_counter.setValue(self.eq_gain) self._eq_gain_layout.addWidget(self._eq_gain_counter) self._eq_gain_counter.valueChanged.connect(self.set_eq_gain) self.controls_grid_layout_2.addLayout(self._eq_gain_layout, 1,0,1,1) self._co_freq_layout = Qt.QHBoxLayout() self._co_freq_layout.addWidget(Qt.QLabel("Cutoff Frequency"+": ")) 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._co_freq_counter = qwt_counter_pyslot() self._co_freq_counter.setRange(0, samp_rate/2, 100000) self._co_freq_counter.setNumButtons(2) self._co_freq_counter.setMinimumWidth(200) self._co_freq_counter.setValue(self.co_freq) self._co_freq_layout.addWidget(self._co_freq_counter) self._co_freq_counter.valueChanged.connect(self.set_co_freq) self.controls_grid_layout_1.addLayout(self._co_freq_layout, 0,0,1,1) self.qtgui_sink_x_0_2 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*sps_out/sps, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_2.set_update_time(1.0/10) self._qtgui_sink_x_0_2_win = sip.wrapinstance(self.qtgui_sink_x_0_2.pyqwidget(), Qt.QWidget) self.fig_tabs_layout_3.addWidget(self._qtgui_sink_x_0_2_win) self.qtgui_sink_x_0_2.enable_rf_freq(False) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*sps_out/sps, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_1.set_update_time(1.0/10) self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.fig_tabs_layout_1.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_1.enable_rf_freq(False) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0/10) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.fig_tabs_layout_0.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*sps_out/sps, #bw "", #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.fig_tabs_layout_2.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( filter_gain, samp_rate, co_freq, trans_width, firdes.WIN_RECTANGULAR, 6.76)) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=arity, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=0.35, verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, sps_out) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(11, 1, eq_gain, sps_out) 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_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_sink_x_0_2, 0)) self.connect((self.low_pass_filter_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_cma_equalizer_cc_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bob") Qt.QWidget.__init__(self) self.setWindowTitle("Bob") 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", "bob") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = rpower self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = jpower self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_const = pld_const = 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.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 24e8 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, rpower, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, jpower, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #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(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) 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) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #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) self.qtgui_time_sink_x_1_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_0_1_0.enable_grid(True) self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_0.enable_control_panel(False) self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_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_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = 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_1.set_update_time(0.10) 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(False) 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 True: 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, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_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_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.9995, sps) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/ELI/' + num + '/BOB_55_8000_BRUTO.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/it/ELI/' + num + '/BOB_EVM.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_1_0_1_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 64, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_1_0_1_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_1_0_1_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_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, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Eve") Qt.QWidget.__init__(self) self.setWindowTitle("Eve") 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", "eve") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 56 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_dec = pld_dec = map( (lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 7) ), range(0, 8)) self.pld_const = pld_const = 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.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 24e8 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 56, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EB09", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "After CAC", #name 1 #number of inputs ) self.qtgui_time_sink_x_2_0.set_update_time(0.10) self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5) self.qtgui_time_sink_x_2_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2_0.enable_tags(-1, True) self.qtgui_time_sink_x_2_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2_0.enable_autoscale(False) self.qtgui_time_sink_x_2_0.enable_grid(True) self.qtgui_time_sink_x_2_0.enable_axis_labels(True) self.qtgui_time_sink_x_2_0.enable_control_panel(False) self.qtgui_time_sink_x_2_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2_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_2_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_0_win = sip.wrapinstance( self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #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) self.qtgui_time_sink_x_1_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_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_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb( digital.packet_utils.default_access_code, 1) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/ELI/1/EVE_55_8000_BRUTO.txt', False) self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/andre/ELI/1/EVE_EVM.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_2_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.cac_cpp_cac_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_0, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0_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, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "QPSK Tx") Qt.QWidget.__init__(self) self.setWindowTitle("QPSK Tx") 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", "QPSK_Tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sym_rate = sym_rate = 500000 self.samp_rate = samp_rate = 2000000 self.sps = sps = int(samp_rate/sym_rate) self.sig_amp = sig_amp = 0.5 self.qpsk = qpsk = digital.constellation_rect(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.car_freq = car_freq = 1000000 self.arity = arity = 4 ################################################## # Blocks ################################################## self._sig_amp_layout = Qt.QHBoxLayout() self._sig_amp_layout.addWidget(Qt.QLabel("Signal Amplitude"+": ")) 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._sig_amp_counter = qwt_counter_pyslot() self._sig_amp_counter.setRange(0, 1, 0.05) self._sig_amp_counter.setNumButtons(2) self._sig_amp_counter.setMinimumWidth(200) self._sig_amp_counter.setValue(self.sig_amp) self._sig_amp_layout.addWidget(self._sig_amp_counter) self._sig_amp_counter.valueChanged.connect(self.set_sig_amp) self.top_layout.addLayout(self._sig_amp_layout) self._car_freq_layout = Qt.QHBoxLayout() self._car_freq_layout.addWidget(Qt.QLabel("Carrier Frequency"+": ")) 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._car_freq_counter = qwt_counter_pyslot() self._car_freq_counter.setRange(0, 5000000, 100000) self._car_freq_counter.setNumButtons(2) self._car_freq_counter.setMinimumWidth(200) self._car_freq_counter.setValue(self.car_freq) self._car_freq_layout.addWidget(self._car_freq_counter) self._car_freq_counter.valueChanged.connect(self.set_car_freq) self.top_layout.addLayout(self._car_freq_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(car_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #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.qtgui_sink_x_0.enable_rf_freq(False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((sig_amp, )) self.analog_random_source_x_0_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Trcbpsk") Qt.QWidget.__init__(self) self.setWindowTitle("Trcbpsk") 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", "trcbpsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 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(([1,1j, -1, -1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024/2, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10/2) 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(True) 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,0,1,1) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=sps, excess_bw=0.35, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 0.2, (rrc_taps), nfilts, 16, 1.5, sps/4) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(21, 0.000001, 4, qpsk) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(4, excess_bw, 45, 0.034) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.34, 4, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/arun/Desktop/Untitled Folder/abc.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_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): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr 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", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.usrp_rf_freq = usrp_rf_freq = 2405000000 self.usrp_int_freq = usrp_int_freq = 2400000000 self.timing_loop_bw = timing_loop_bw = 6.28/100 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 390625 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.phase_bw = phase_bw = 6.28/100 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector('test_may14_r1', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError, e: pass time.sleep(1.0/(0.2)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self._usrp_int_freq_layout = Qt.QVBoxLayout() self._usrp_int_freq_tool_bar = Qt.QToolBar(self) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_tool_bar) self._usrp_int_freq_tool_bar.addWidget(Qt.QLabel("usrp_int_freq"+": ")) self._usrp_int_freq_counter = Qwt.QwtCounter() self._usrp_int_freq_counter.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_counter.setNumButtons(2) self._usrp_int_freq_counter.setValue(self.usrp_int_freq) self._usrp_int_freq_tool_bar.addWidget(self._usrp_int_freq_counter) self._usrp_int_freq_counter.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_int_freq_slider.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_slider.setValue(self.usrp_int_freq) self._usrp_int_freq_slider.setMinimumWidth(100) self._usrp_int_freq_slider.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_slider) self.top_layout.addLayout(self._usrp_int_freq_layout) self.uhd_usrp_source_0_0 = uhd.usrp_source( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(10, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", args="addr=192.168.40.2", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(usrp_int_freq, 0) self.uhd_usrp_sink_1.set_gain(40, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.20.2", 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(usrp_rf_freq, 0) self.uhd_usrp_sink_0.set_gain(10, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/2, #samp_rate "BER", #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, "BER") 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_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,2,3])) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(20, 0.02, 2, qpsk) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) 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_constellation_receiver_cb_0 = digital.constellation_receiver_cb(qpsk, timing_loop_bw, 0.0001, 0.0002) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b((170,170), 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.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_random_source_x_1 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_map_bb_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.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.crew_db_channel_selector_0, 0))
def __init__(self): gr.top_block.__init__(self, "Byte Construction") Qt.QWidget.__init__(self) self.setWindowTitle("Byte Construction") 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", "byte_construction") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 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.phase_bw = phase_bw = 6.28 / 100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 58 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.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1) ] self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3) ] 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.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(2, 3) ] self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(1, 2) ] self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(1, 2) ] self._delay_range = Range(0, 200, 1, 58, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Input mins Output stream", #name 1 #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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.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.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_layout.addWidget(self._qtgui_time_sink_x_1_win) 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.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Rx Bits', 'Tx Bits', '', '', '', '', '', '', '', ''] 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.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] 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.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Symbols', '', '', '', '', '', '', '', '', ''] 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.received_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 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.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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) [self.received_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self.myblocks_qpsk_demod_v2_0 = myblocks.qpsk_demod_v2(0) 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, 3, 2, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) 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_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_LSB_FIRST) 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) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_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.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_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.myblocks_qpsk_demod_v2_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.digital_map_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage2", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage2") 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", "mpsk_stage2") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.time_offset = time_offset = 1.00 self.taps = taps = [ 1.0 + 0.0j, ] self.sps = sps = 4 self.samp_rate = samp_rate = 32000 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.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.arity = arity = 4 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Channel: Timing Offset', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._time_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Channel: Noise Voltage', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._noise_volt_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Channel: Frequency Offset', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._freq_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 200, #size samp_rate, #samp_rate '', #name 1, #number of inputs None # parent ) 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.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size window.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1, None # parent ) 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) self.qtgui_freq_sink_x_0.set_fft_window_normalized(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 4) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size '', #name 1, #number of inputs None # parent ) 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) 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 range(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, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) 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, truncate=False) 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_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 10000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_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))
def __init__(self): gr.top_block.__init__(self, "mpsk_rrc_rolloff") Qt.QWidget.__init__(self) self.setWindowTitle("mpsk_rrc_rolloff") 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", "opt") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate = samp_rate = 32000 self.qpsk_const = qpsk_const = digital.constellation_rect( [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], [0, 1, 3, 2], 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.350 self.arity = arity = 4 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'QT GUI plot', #name 5) 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) 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 range(5): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_constellation_modulator_4 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=1, verbose=False, log=False) self.digital_constellation_modulator_3 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.220, verbose=False, log=False) self.digital_constellation_modulator_2 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False) self.digital_constellation_modulator_1 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.5, verbose=False, log=False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.1, verbose=False, log=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 255, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_2, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_3, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_4, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_1, 0), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.digital_constellation_modulator_2, 0), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.digital_constellation_modulator_3, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_constellation_modulator_4, 0), (self.qtgui_freq_sink_x_0, 4))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Hop on Demand") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_samp_rate = tx_samp_rate = 50e3 self.tx_freq = tx_freq = 100e6 self.sps = sps = 4 self.rx_samp_rate = rx_samp_rate = 2e6 self.rx_freq = rx_freq = 100e6 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.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, "tcp://127.0.0.1:5557", 1000, False, -1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=rx_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=rx_samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=True, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(rx_samp_rate) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(tx_samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(30, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, rx_samp_rate, 1e6, 30e3, firdes.WIN_HAMMING, 6.76)) 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_probe_signal_x_0 = blocks.probe_signal_c() self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_probe_signal_x_0, 0)) ### Added by Bill Urrego ### t = Thread(target=sub, args=(self.change_freq,)) t.start()
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): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") 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_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## 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, 100, 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, 100, 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_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) 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, 3,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #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) 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.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF 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._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) 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.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage6") 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_stage6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate = samp_rate = 2e6 self.bps = bps = 500e3 self.decimation = decimation = int(samp_rate / (bps * sps)) self.transition_bw = transition_bw = samp_rate / (2 * decimation * 5) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 self.time_offset = time_offset = 1.00 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( ([-1, 0 + 1j, 0 - 1j, 1 + 0.0j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28 / 100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.fir_taps = fir_taps = firdes.low_pass( 1, samp_rate, samp_rate / (2 * decimation), transition_bw) self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.channel_freq = channel_freq = 2.4e9 self.center_freq = center_freq = 2.3995e9 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_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 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_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) self._channel_freq_range = Range(2.4e9 - samp_rate / 2, 2.4e9 + samp_rate / 2, 100, 2.4e9, 200) self._channel_freq_win = RangeWidget(self._channel_freq_range, self.set_channel_freq, "channel_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._channel_freq_win, 2, 2, 1, 1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Timing Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) self.rms_agc_0 = rms_agc( alpha=1e-2, reference=0.5, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #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_control_panel(False) if not True: self.qtgui_time_sink_x_1.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_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_const_sink_x_1_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_1.set_update_time(0.10) self.qtgui_const_sink_x_1_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_1.enable_autoscale(False) self.qtgui_const_sink_x_1_1.enable_grid(False) if not True: self.qtgui_const_sink_x_1_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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_1_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) if not True: self.qtgui_const_sink_x_1_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_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance( self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_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) 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.top_layout.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) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "Noise Voltage", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decimation, (fir_taps), channel_freq - center_freq, samp_rate) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Frequency Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 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_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self._delay_range = Range(0, 200, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "Delay", "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/ascl/sbandtest/text/fc_2_3995/500kbps/sps2M", True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1, "output", False) self.blocks_file_sink_1.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.rms_agc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.rms_agc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Audio Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Audio Tx") 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", "audio_tx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 1 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 32E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * 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.phase_bw = phase_bw = 6.28 / 100.0 self.excess_bw = excess_bw = 0.35 self.BPSK = BPSK = digital.constellation_qpsk().base() ################################################## # Blocks ################################################## self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.top_layout.addWidget(self._phase_bw_win) self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_1.set_update_time(0.10) self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_1.enable_autoscale(False) self.qtgui_time_sink_x_1_1.enable_grid(False) self.qtgui_time_sink_x_1_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_1.enable_control_panel(False) self.qtgui_time_sink_x_1_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_1_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) self.qtgui_time_sink_x_1_0.enable_stem_plot(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.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.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.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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "demod", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Rx", #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(True) 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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, 4, False) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( BPSK, phase_bw, 0, 2 * 3.14) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=2, verbose=False, log=False, ) self.blocks_multiply_xx_3_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_3 = blocks.multiply_vff(1) self.blocks_multiply_xx_2_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_2_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/test_input.txt', True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_3 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=sps, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_sig_source_x_0_1_0_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_1_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc( 1024, 1.55) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, -1) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, -1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_sig_source_x_0_1_0, 0), (self.blocks_multiply_xx_2_0, 1)) self.connect((self.analog_sig_source_x_0_1_0_0, 0), (self.blocks_multiply_xx_2_0_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_3, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_complex_to_imag_1, 0), (self.blocks_add_xx_3, 1)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_2_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_multiply_xx_2_0_0, 0), (self.blocks_complex_to_imag_1, 0)) self.connect((self.blocks_multiply_xx_2_1, 0), (self.blocks_add_xx_3, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_multiply_xx_2_1, 1)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.qtgui_time_sink_x_1_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage1") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage1") 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_stage1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.excess_bw = excess_bw = 0.10 self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1, sps, 1, excess_bw, 45) self.bpsk = bpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j]), ([0, 1,]), 2, 2, 0, 1, 0).base() self.arity = arity = 4 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.4175e9, 0) self.uhd_usrp_sink_0.set_gain(28, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(100e3, 0) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len") self.digital_constellation_modulator_0 = digital.generic_mod( constellation=bpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 8, "packet_len") self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=8, preamble="", access_code="", pad_for_usrp=True, ), payload_length=0, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_constellation_modulator_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Receiverpoly") ################################################## # Variables ################################################## self.sps = sps = 8 self.probe_var = probe_var = 0 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.SNR = SNR = 500 self.transistion = transistion = 100 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts/16, nfilts/16, 1.0/float(sps), 0.35, 11*sps*nfilts/16) 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.probe_var_n = probe_var_n = 0 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.noise_amp = noise_amp = probe_var/(10**(SNR/20)) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.interpolation = interpolation = 2000 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.probe_rms = blocks.probe_signal_f() self.probe_avg_n = blocks.probe_signal_f() self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=decimation, decimation=interpolation, taps=(rrc_taps), fractional_bw=None, ) def _probe_var_n_probe(): while True: val = self.probe_avg_n.level() try: self.set_probe_var_n(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe) _probe_var_n_thread.daemon = True _probe_var_n_thread.start() def _probe_var_probe(): while True: val = self.probe_rms.level() try: self.set_probe_var(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_thread = threading.Thread(target=_probe_var_probe) _probe_var_thread.daemon = True _probe_var_thread.start() self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate*10, sideband_rx,1000)), carrier, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constel) script, SNRinput, inputwav, outputBinary, delay= argv self.blocks_wavfile_source_0 = blocks.wavfile_source(inputwav, False) self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_1 = blocks.rms_cf(0.01) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, outputBinary, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_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_delay_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_throttle_1_0_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Rx") 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", "rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30 self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52 self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make( H_dec.get_base_sptr(), 100)), range(0, 8)) self.pld_const = pld_const = 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.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM') self._variable_qtgui_check_box_0_choices = {True: True, False: False} self._variable_qtgui_check_box_0_choices_inv = dict( (v, k) for k, v in self._variable_qtgui_check_box_0_choices.iteritems()) self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod( _variable_qtgui_check_box_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i])) self._variable_qtgui_check_box_0_callback( self.variable_qtgui_check_box_0) _variable_qtgui_check_box_0_check_box.stateChanged.connect( lambda i: self.set_variable_qtgui_check_box_0( self._variable_qtgui_check_box_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #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(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) 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) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #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) self.qtgui_time_sink_x_1_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = 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_1.set_update_time(0.10) 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(False) 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 True: 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, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_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_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder( decoder_obj_list=pld_dec, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 4, 'packet_len') self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.99, sps) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n( gr.sizeof_char, 440, 442, 0) self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n( gr.sizeof_char, 1100, 1104, 0) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, 'rx_ber.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 32, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_0_2_0_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0), (self.digital_map_bb_0_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.scrambler_cpp_additive_descrambler_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_copy_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_keep_m_in_n_0_0_2_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.scrambler_cpp_additive_descrambler_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Sender1") ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 32 self.transistion = transistion = 100 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 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.payload_size = payload_size = 10 self.interpolation = interpolation = 2000 self.gap = gap = 0 self.eb = eb = 0.35 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.const_type = const_type = 1 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interpolation, decimation=decimation, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.5,samp_rate,10000-sideband,10000+sideband,transistion)), -carrier, samp_rate) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_wavfile_sink_1 = blocks.wavfile_sink("BPSK_output.wav", 1, 48000, 16) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "TestData2", False) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary", False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary2", False) self.blocks_file_sink_0_0.set_unbuffered(False) script, sdelay= argv self.blocks_delay_0_0 = blocks.delay(gr.sizeof_char*1, int(sdelay)) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tx No Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Tx No Gui") 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", "tx_no_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.pld_enc = pld_enc = map( (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4)) self.pld_const = pld_const = 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.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 43, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), 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_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_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_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb( pld_const.arity()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/video_lion.mpeg', False) self.blocks_file_source_0_0_1_0_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000) self.acode_1104_0 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104_0, 0), (self.blocks_stream_mux_0_1_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_delay_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.blocks_stream_mux_0_1_0_0, 1)) self.connect((self.blocks_stream_mux_0_1_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.blocks_stream_mux_0_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))