def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.frequency = frequency = 1280e6 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc(dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb(dtv.FECFRAME_NORMAL, dtv.C_OTHER, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/Volumes/work/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dvbt2 Master") ################################################## # Variables ################################################## self.samp_rate = samp_rate = (8000000.0 * 8) / 7 self._rf_gain_config = ConfigParser.ConfigParser() self._rf_gain_config.read('./dvbt2.conf') try: rf_gain = self._rf_gain_config.getint('hackrf', 'rf-gain') except: rf_gain = 0 self.rf_gain = rf_gain self._if_gain_config = ConfigParser.ConfigParser() self._if_gain_config.read('./dvbt2.conf') try: if_gain = self._if_gain_config.getint('hackrf', 'if-gain') except: if_gain = 0 self.if_gain = if_gain self._center_freq_config = ConfigParser.ConfigParser() self._center_freq_config.read('./dvbt2.conf') try: center_freq = self._center_freq_config.getint( 'hackrf', 'frequency') except: center_freq = 0 self.center_freq = center_freq self._band_width_config = ConfigParser.ConfigParser() self._band_width_config.read('./dvbt2.conf') try: band_width = self._band_width_config.getint('hackrf', 'bandwidth') except: band_width = 0 self.band_width = band_width self._VERSION_config = ConfigParser.ConfigParser() self._VERSION_config.read('./dvbt2.conf') try: VERSION = self._VERSION_config.getint('dvbt2', 'version') except: VERSION = 0 self.VERSION = VERSION self._PREAMBLE_config = ConfigParser.ConfigParser() self._PREAMBLE_config.read('./dvbt2.conf') try: PREAMBLE = self._PREAMBLE_config.get('dvbt2', 'preamble') except: PREAMBLE = '0' self.PREAMBLE = PREAMBLE self._PILOT_config = ConfigParser.ConfigParser() self._PILOT_config.read('./dvbt2.conf') try: PILOT = self._PILOT_config.getint('dvbt2', 'pilot-pattern') except: PILOT = 0 self.PILOT = PILOT self._PAPR_config = ConfigParser.ConfigParser() self._PAPR_config.read('./dvbt2.conf') try: PAPR = self._PAPR_config.get('dvbt2', 'papr') except: PAPR = '0' self.PAPR = PAPR self._L1MOD_config = ConfigParser.ConfigParser() self._L1MOD_config.read('./dvbt2.conf') try: L1MOD = self._L1MOD_config.get('dvbt2', 'L1-mod') except: L1MOD = '0' self.L1MOD = L1MOD self._GI_config = ConfigParser.ConfigParser() self._GI_config.read('./dvbt2.conf') try: GI = self._GI_config.get('dvbt2', 'guard-interval') except: GI = '0' self.GI = GI self._FFTSIZE_config = ConfigParser.ConfigParser() self._FFTSIZE_config.read('./dvbt2.conf') try: FFTSIZE = self._FFTSIZE_config.get('dvbt2', 'fft-size') except: FFTSIZE = '0' self.FFTSIZE = FFTSIZE self._FECBLKS_config = ConfigParser.ConfigParser() self._FECBLKS_config.read('./dvbt2.conf') try: FECBLKS = self._FECBLKS_config.getint('dvbt2', 'fec-blocks') except: FECBLKS = 0 self.FECBLKS = FECBLKS self._DATASYM_config = ConfigParser.ConfigParser() self._DATASYM_config.read('./dvbt2.conf') try: DATASYM = self._DATASYM_config.getint('dvbt2', 'datasymbols') except: DATASYM = 0 self.DATASYM = DATASYM self._CONSTELLATION_config = ConfigParser.ConfigParser() self._CONSTELLATION_config.read('./dvbt2.conf') try: CONSTELLATION = self._CONSTELLATION_config.get( 'dvbt2', 'constellation') except: CONSTELLATION = '0' self.CONSTELLATION = CONSTELLATION self._CODERATE_config = ConfigParser.ConfigParser() self._CODERATE_config.read('./dvbt2.conf') try: CODERATE = self._CODERATE_config.get('dvbt2', 'coderate') except: CODERATE = '0' self.CODERATE = CODERATE self._CARREXT_config = ConfigParser.ConfigParser() self._CARREXT_config.read('./dvbt2.conf') try: CARREXT = self._CARREXT_config.get('dvbt2', 'ext-carriers') except: CARREXT = '0' self.CARREXT = CARREXT infile = str(sys.argv[1]) if VERSION == 111: ver = dtv.VERSION_111 elif VERSION == 131: ver = dtv.VERSION_131 else: sys.stderr.write("VERSION IN CONFIG WRONG! Values: 111 or 131 \n") sys.exit(1) if PREAMBLE == "SISO": preamb = dtv.PREAMBLE_T2_SISO elif PREAMBLE == "MISO": preamb = dtv.PREAMBLE_T2_MISO else: sys.stderr.write( "PREAMBLE IN CONFIG WRONG! Values: SISO or MISO \n") sys.exit(1) if PILOT == 1: pil = dtv.PILOT_PP1 elif PILOT == 2: pil = dtv.PILOT_PP2 elif PILOT == 3: pil = dtv.PILOT_PP3 elif PILOT == 4: pil = dtv.PILOT_PP4 elif PILOT == 5: pil = dtv.PILOT_PP5 elif PILOT == 6: pil = dtv.PILOT_PP6 elif PILOT == 7: pil = dtv.PILOT_PP7 elif PILOT == 8: pil = dtv.PILOT_PP8 else: sys.stderr.write( "PILOT-PATTERN IN CONFIG WRONG! Values: 1, 2, 3, 4, 5, 6, 7 or 8 \n" ) sys.exit(1) if PAPR == "on": pap = dtv.PAPR_ON elif PAPR == "off": pap = dtv.PAPR_OFF else: sys.stderr.write("PAPR IN CONFIG WRONG! Values: on or off \n") sys.exit(1) if L1MOD == "QPSK": l1m = dtv.L1_MOD_QPSK elif L1MOD == "BPSK": l1m = dtv.L1_MOD_BPSK elif L1MOD == "16QAM": l1m = dtv.L1_MOD_16QAM elif L1MOD == "64QAM": l1m = dtv.L1_MOD_64QAM else: sys.stderr.write( "L1-MOD IN CONFIG WRONG! Values: QPSK, BPSK, 16QAM or 64QAM \n" ) sys.exit(1) if GI == "1/32": gint = dtv.GI_1_32 mul = 1 div = 32 elif GI == "1/16": gint = dtv.GI_1_16 mul = 1 div = 16 elif GI == "1/8": gint = dtv.GI_1_8 mul = 1 div = 8 elif GI == "1/4": gint = dtv.GI_1_4 mul = 1 div = 4 elif GI == "1/128": gint = dtv.GI_1_128 mul = 1 div = 128 elif GI == "19/128": gint = dtv.GI_19_128 mul = 19 div = 128 elif GI == "19/256": gint = dtv.GI_19_256 mul = 19 div = 256 else: sys.stderr.write( "GUARD-INTERVAL IN CONFIG WRONG! Values: 1/32, 1/16, 1/8, 1/4, 1/128, 19/128, 19/256 \n" ) sys.exit(1) if FFTSIZE == "16k": ffts = dtv.FFTSIZE_16K fft_length = 16384 elif FFTSIZE == "32k": ffts = dtv.FFTSIZE_32K fft_length = 32768 else: sys.stderr.write("FFTSIZE IN CONFIG WRONG! Values: 16k or 32k \n") sys.exit(1) if CONSTELLATION == "QPSK": const = dtv.MOD_QPSK elif CONSTELLATION == "16QAM": const = dtv.MOD_16QAM elif CONSTELLATION == "64QAM": const = dtv.MOD_64QAM elif CONSTELLATION == "256QAM": const = dtv.MOD_256QAM else: sys.stderr.write( "CONSTELLATION IN CONFIG WRONG! Values: QPSK 16QAM 64QAM 256QAM \n" ) sys.exit(1) if CODERATE == "1/2": codr = dtv.C1_2 elif CODERATE == "2/5": codr = dtv.C2_5 elif CODERATE == "3/5": codr = dtv.C3_5 elif CODERATE == "2/3": codr = dtv.C2_3 elif CODERATE == "3/4": codr = dtv.C3_4 elif CODERATE == "4/5": codr = dtv.C4_5 elif CODERATE == "5/6": codr = dtv.C5_6 else: sys.stderr.write( "CODERATE IN CONFIG WRONG! Values: 1/2 2/5 3/5 2/3 3/4 4/5 5/6 \n" ) sys.exit(1) if CARREXT == "on": extcarr = dtv.CARRIERS_EXTENDED elif CARREXT == "off": extcarr = dtv.CARRIERS_NORMAL else: sys.stderr.write( "EXT-CARRIERS IN CONFIG WRONG! Values: on or off \n") sys.exit(1) cp_length = fft_length + (fft_length * mul) / div ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + 'hackrf,buffers=128,buflen=32768') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(band_width, 0) self.dtv_dvbt2_pilotgenerator_cc_0 = dtv.dvbt2_pilotgenerator_cc( extcarr, ffts, pil, gint, DATASYM, pap, ver, preamb, dtv.MISO_TX1, dtv.EQUALIZATION_OFF, dtv.BANDWIDTH_8_0_MHZ, fft_length) self.dtv_dvbt2_p1insertion_cc_0 = dtv.dvbt2_p1insertion_cc( extcarr, ffts, gint, DATASYM, preamb, dtv.SHOWLEVELS_OFF, 3.3) self.dtv_dvbt2_modulator_bc_0 = dtv.dvbt2_modulator_bc( dtv.FECFRAME_NORMAL, const, dtv.ROTATION_OFF) self.dtv_dvbt2_interleaver_bb_0 = dtv.dvbt2_interleaver_bb( dtv.FECFRAME_NORMAL, codr, const) self.dtv_dvbt2_freqinterleaver_cc_0 = dtv.dvbt2_freqinterleaver_cc( extcarr, ffts, pil, gint, DATASYM, pap, ver, preamb) self.dtv_dvbt2_framemapper_cc_0 = dtv.dvbt2_framemapper_cc( dtv.FECFRAME_NORMAL, codr, const, dtv.ROTATION_OFF, FECBLKS, 3, extcarr, ffts, gint, l1m, pil, 2, DATASYM, pap, ver, preamb, dtv.INPUTMODE_NORMAL, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) self.dtv_dvbt2_cellinterleaver_cc_0 = dtv.dvbt2_cellinterleaver_cc( dtv.FECFRAME_NORMAL, const, FECBLKS, 3) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr, dtv.RO_0_35, dtv.INPUTMODE_HIEFF, dtv.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_length, cp_length, 0, '') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, )) if infile == "-": self.blocks_file_descriptor_source_0 = blocks.file_descriptor_source( gr.sizeof_char * 1, 0, True) else: self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, infile, True) ################################################## # Connections ################################################## if infile == "-": self.connect((self.blocks_file_descriptor_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) else: self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.dtv_dvbt2_p1insertion_cc_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbt2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbt2_cellinterleaver_cc_0, 0), (self.dtv_dvbt2_framemapper_cc_0, 0)) self.connect((self.dtv_dvbt2_framemapper_cc_0, 0), (self.dtv_dvbt2_freqinterleaver_cc_0, 0)) self.connect((self.dtv_dvbt2_freqinterleaver_cc_0, 0), (self.dtv_dvbt2_pilotgenerator_cc_0, 0)) self.connect((self.dtv_dvbt2_interleaver_bb_0, 0), (self.dtv_dvbt2_modulator_bc_0, 0)) self.connect((self.dtv_dvbt2_modulator_bc_0, 0), (self.dtv_dvbt2_cellinterleaver_cc_0, 0)) self.connect((self.dtv_dvbt2_p1insertion_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dtv_dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, constellation, frame_type, code_rate): gr.top_block.__init__(self, "Dvbs2 Tx") ################################################## # Parameters ################################################## # Header is 10 bytes try: frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80 except KeyError: raise UnknownFrameLength(frame_type, code_rate) # print("Base frame length: %s" % frame_length) frame_length /= 8 # print("Base frame length: %s" % frame_length) assert int( frame_length ) == 1.0 * frame_length, "Frame length {0} won't work because {0}/8 = {1}!".format( frame_length, frame_length / 8.0) frame_length = int(frame_length) self.frame_length = frame_length bits_per_input, bits_per_output = get_ratio(constellation) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.noise = noise = 0 self.gain = gain = 1 self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self.ldpc_encoder_input = blocks.file_sink(gr.sizeof_char * 1, 'ldpc_encoder_input.bin', False) self.ldpc_encoder_input.set_unbuffered(False) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc( 1, (numpy.conj([ 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j ] + [ 0, ] * (89 - 32)))) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (numpy.conj([ 0, ] * (89 - 25) + [ 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 0.00000j ]))) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( frame_type, code_rate, dtv.MOD_BPSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( frame_type, code_rate, dtv.MOD_BPSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( frame_type, code_rate, constellation) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, frame_type, code_rate) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, frame_type, code_rate) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 2, math.pi / 100.0, (firdes.root_raised_cosine( 2 * 32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32)), 32, 16, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi / 100.0, 4, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate / 10, True) self.blocks_sub_xx_0 = blocks.sub_cc(1) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((gain, )) self.blocks_max_xx_0 = blocks.max_ff(1, 1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, 'output.bin', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.bit_interleaver_output_packed = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_output_packed.bin', False) self.bit_interleaver_output_packed.set_unbuffered(False) self.bit_interleaver_output = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_output.bin', False) self.bit_interleaver_output.set_unbuffered(False) self.bit_interleaver_input = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_input.bin', False) self.bit_interleaver_input.set_unbuffered(False) self.bch_encoder_input = blocks.file_sink(gr.sizeof_char * 1, 'bch_encoder_input.bin', False) self.bch_encoder_input.set_unbuffered(False) self.bb_scrambler_input_0 = blocks.file_sink(gr.sizeof_char * 1, 'bb_scrambler_input.bin', False) self.bb_scrambler_input_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, frame_length)), False) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, noise, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(8192) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.analog_random_source_x_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.bit_interleaver_output_packed, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.bb_scrambler_input_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.bch_encoder_input, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.bit_interleaver_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.bit_interleaver_output, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_sub_xx_0, 1))
def test_000(self): infile = ts_in_file outfile = "vv.cfile" testfile = complex_out_file file_source = blocks.file_source(gr.sizeof_char*1, infile, False, 0, 0) file_source.set_begin_tag(pmt.PMT_NIL) bbheader = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.RO_0_35, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) bbscrambler = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3) bch = dtv.dvb_bch_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3) ldpc = dtv.dvb_ldpc_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_OTHER) interleaver = dtv.dvbt2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_64QAM) modulator = dtv.dvbt2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.MOD_64QAM, dtv.ROTATION_ON) cellinterleaver = dtv.dvbt2_cellinterleaver_cc( dtv.FECFRAME_NORMAL, dtv.MOD_64QAM, 2, 3) framemapper = dtv.dvbt2_framemapper_cc( dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_64QAM, dtv.ROTATION_ON, 2, 3, dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.GI_1_32, dtv.L1_MOD_16QAM, dtv.PILOT_PP7, 2, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.INPUTMODE_NORMAL, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) freqinterleaver = dtv.dvbt2_freqinterleaver_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO ) pilotgenerator = dtv.dvbt2_pilotgenerator_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.MISO_TX1, dtv.EQUALIZATION_OFF, dtv.BANDWIDTH_8_0_MHZ, 4096 ) paprtr = dtv.dvbt2_paprtr_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, 3.0, 10, 4096 ) ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( 4096, 4096 + 4096 // 32, 0, '') p1insertion = dtv.dvbt2_p1insertion_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.GI_1_32, 7, dtv.PREAMBLE_T2_SISO, dtv.SHOWLEVELS_OFF, 3.01 ) file_sink = blocks.file_sink(gr.sizeof_gr_complex*1, outfile, False) file_sink.set_unbuffered(True) self.tb.connect( file_source, bbheader, bbscrambler, bch, ldpc, interleaver, modulator, cellinterleaver, framemapper, freqinterleaver, pilotgenerator, paprtr, ofdm_cyclic_prefixer, p1insertion, file_sink) self.tb.run() file_sink.close() self.assertEqual(getsize(outfile), getsize(testfile)) out_data = np.fromfile(outfile, dtype=np.float32) expected_data = np.fromfile(testfile, dtype=np.float32) os.remove(outfile) self.assertFloatTuplesAlmostEqual(out_data, expected_data, 5) pass
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.frequency = frequency = 1280e6 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C_OTHER, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/Volumes/work/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbt2-blade.py input_file [output_file]\n") sys.exit(1) version = dtv.VERSION_111 fft_size = dtv.FFTSIZE_4K input_mode = dtv.INPUTMODE_NORMAL frame_size = dtv.FECFRAME_NORMAL code_rate = dtv.C2_3 data_symbols = 100 fec_blocks = 31 ti_blocks = 3 constellation = dtv.MOD_64QAM rotation = dtv.ROTATION_ON guard_interval = dtv.GI_1_32 mode = dtv.PREAMBLE_T2_SISO carrier_mode = dtv.CARRIERS_NORMAL pilot_pattern = dtv.PILOT_PP7 l1_constellation = dtv.L1_MOD_16QAM papr_mode = dtv.PAPR_OFF papr_vclip = 3.3 papr_iterations = 3 channel_mhz = 8 samp_rate = channel_mhz * 8000000.0 / 7 center_freq = 429000000 txvga1_gain = -8 txvga2_gain = 12 if channel_mhz == 10: bandwidth = 10000000 equalization_bandwidth = dtv.BANDWIDTH_10_0_MHZ elif channel_mhz == 8: bandwidth = 8750000 equalization_bandwidth = dtv.BANDWIDTH_8_0_MHZ elif channel_mhz == 7: bandwidth = 7000000 equalization_bandwidth = dtv.BANDWIDTH_7_0_MHZ elif channel_mhz == 6: bandwidth = 5500000 equalization_bandwidth = dtv.BANDWIDTH_6_0_MHZ elif channel_mhz == 5: bandwidth = 5000000 equalization_bandwidth = dtv.BANDWIDTH_5_0_MHZ else: bandwidth = 1750000 equalization_bandwidth = dtv.BANDWIDTH_1_7_MHZ if fft_size == dtv.FFTSIZE_1K: fftsize = 1024 elif fft_size == dtv.FFTSIZE_2K: fftsize = 2048 elif fft_size == dtv.FFTSIZE_4K: fftsize = 4096 elif fft_size == dtv.FFTSIZE_8K: fftsize = 8192 elif fft_size == dtv.FFTSIZE_8K_T2GI: fftsize = 8192 elif fft_size == dtv.FFTSIZE_16K: fftsize = 16384 elif fft_size == dtv.FFTSIZE_16K_T2GI: fftsize = 16384 elif fft_size == dtv.FFTSIZE_32K: fftsize = 32768 elif fft_size == dtv.FFTSIZE_32K_T2GI: fftsize = 32768 if guard_interval == dtv.GI_1_32: gi = fftsize // 32 elif guard_interval == dtv.GI_1_16: gi = fftsize // 16 elif guard_interval == dtv.GI_1_8: gi = fftsize // 8 elif guard_interval == dtv.GI_1_4: gi = fftsize // 4 elif guard_interval == dtv.GI_1_128: gi = fftsize // 128 elif guard_interval == dtv.GI_19_128: gi = (fftsize * 19) // 128 elif guard_interval == dtv.GI_19_256: gi = (fftsize * 19) // 256 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbt2_bbheader = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBT2, frame_size, code_rate, dtv.RO_0_35, input_mode, dtv.INBAND_OFF, fec_blocks, 4000000) dvbt2_bbscrambler = dtv.dvb_bbscrambler_bb(dtv.STANDARD_DVBT2, frame_size, code_rate) dvbt2_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBT2, frame_size, code_rate) dvbt2_ldpc = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBT2, frame_size, code_rate, dtv.MOD_OTHER) dvbt2_interleaver = dtv.dvbt2_interleaver_bb(frame_size, code_rate, constellation) dvbt2_modulator = dtv.dvbt2_modulator_bc(frame_size, constellation, rotation) dvbt2_cellinterleaver = dtv.dvbt2_cellinterleaver_cc( frame_size, constellation, fec_blocks, ti_blocks) dvbt2_framemapper = dtv.dvbt2_framemapper_cc( frame_size, code_rate, constellation, rotation, fec_blocks, ti_blocks, carrier_mode, fft_size, guard_interval, l1_constellation, pilot_pattern, 2, data_symbols, papr_mode, version, mode, input_mode, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) dvbt2_freqinterleaver = dtv.dvbt2_freqinterleaver_cc( carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode) dvbt2_pilotgenerator = dtv.dvbt2_pilotgenerator_cc( carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode, dtv.MISO_TX1, dtv.EQUALIZATION_ON, equalization_bandwidth, fftsize) dvbt2_paprtr = dtv.dvbt2_paprtr_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, papr_vclip, papr_iterations, fftsize) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( fftsize, fftsize + gi, 0, "") dvbt2_p1insertion = dtv.dvbt2_p1insertion_cc(carrier_mode, fft_size, guard_interval, data_symbols, mode, dtv.SHOWLEVELS_OFF, papr_vclip + 0.01) blocks_multiply_const = blocks.multiply_const_vcc((0.2, )) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt2_bbheader) tb.connect(dvbt2_bbheader, dvbt2_bbscrambler) tb.connect(dvbt2_bbscrambler, dvbt2_bch) tb.connect(dvbt2_bch, dvbt2_ldpc) tb.connect(dvbt2_ldpc, dvbt2_interleaver) tb.connect(dvbt2_interleaver, dvbt2_modulator) tb.connect(dvbt2_modulator, dvbt2_cellinterleaver) tb.connect(dvbt2_cellinterleaver, dvbt2_framemapper) tb.connect(dvbt2_framemapper, dvbt2_freqinterleaver) tb.connect(dvbt2_freqinterleaver, dvbt2_pilotgenerator) tb.connect(dvbt2_pilotgenerator, dvbt2_paprtr) tb.connect(dvbt2_paprtr, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, dvbt2_p1insertion) tb.connect(dvbt2_p1insertion, blocks_multiply_const) tb.connect(blocks_multiply_const, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const, dst) tb.run()
def __init__(self): gr.top_block.__init__(self, "DVB-S2 B200 Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("DVB-S2 B200 Transmitter") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "dvbs2_8psk_tx_var_v1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## #self.symbol_rate = symbol_rate 1000000 self.symbol_rate = symbol_rate self.variable_qtgui_push_button_0 = variable_qtgui_push_button_0 = 1 self.tx_gain = tx_gain = 65 self.taps = taps = 100 self.symbol_rate_display = symbol_rate_display = symbol_rate / 1000 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 #self.fec_display = fec_display = "7/8" self.fec_display = fec_display self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 65, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'Tx Gain [dB]', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 9, 0, 1, 5) self._center_freq_options = ( 50e6, 437e6, 1280e6, 10400e6, ) self._center_freq_labels = ( '50 MHz', '437 MHz', "1'280 MHz", "10'400 MHz", ) self._center_freq_group_box = Qt.QGroupBox('TX Frequency') self._center_freq_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._center_freq_button_group = variable_chooser_button_group() self._center_freq_group_box.setLayout(self._center_freq_box) for i, label in enumerate(self._center_freq_labels): radio_button = Qt.QRadioButton(label) self._center_freq_box.addWidget(radio_button) self._center_freq_button_group.addButton(radio_button, i) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._center_freq_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_button_group.buttonClicked[int].connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_grid_layout.addWidget(self._center_freq_group_box, 0, 0, 1, 5) _variable_qtgui_push_button_0_push_button = Qt.QPushButton('TRANSMIT') self._variable_qtgui_push_button_0_choices = { 'Pressed': 0, 'Released': 1 } _variable_qtgui_push_button_0_push_button.pressed.connect( lambda: self.set_variable_qtgui_push_button_0( self._variable_qtgui_push_button_0_choices['Pressed'])) _variable_qtgui_push_button_0_push_button.released.connect( lambda: self.set_variable_qtgui_push_button_0( self._variable_qtgui_push_button_0_choices['Released'])) self.top_grid_layout.addWidget( _variable_qtgui_push_button_0_push_button, 10, 0, 1, 5) self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0_0_0.set_antenna('TX/RX', 0) self._symbol_rate_display_tool_bar = Qt.QToolBar(self) if "{0:,}".format: self._symbol_rate_display_formatter = "{0:,}".format else: self._symbol_rate_display_formatter = lambda x: x self._symbol_rate_display_tool_bar.addWidget( Qt.QLabel(' Symbol Rate [ks/s] ' + ": ")) self._symbol_rate_display_label = Qt.QLabel( str(self._symbol_rate_display_formatter(self.symbol_rate_display))) self._symbol_rate_display_tool_bar.addWidget( self._symbol_rate_display_label) self.top_grid_layout.addWidget(self._symbol_rate_display_tool_bar, 1, 1, 1, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, -20) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0, 6, 5) self.fft_filter_xxx_0_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, rolloff, taps)), 1) self.fft_filter_xxx_0_0.declare_sample_delay(0) self._fec_display_tool_bar = Qt.QToolBar(self) if "": self._fec_display_formatter = "" else: self._fec_display_formatter = lambda x: x self._fec_display_tool_bar.addWidget(Qt.QLabel('FEC ' + ": ")) self._fec_display_label = Qt.QLabel( str(self._fec_display_formatter(self.fec_display))) self._fec_display_tool_bar.addWidget(self._fec_display_label) self.top_grid_layout.addWidget(self._fec_display_tool_bar, 1, 3, 1, 2) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_8PSK, dtv.PILOTS_OFF, 0) self.dtv_dvbs2_modulator_bc_0_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_8PSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_8PSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_35, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) fifo_path = os.path.dirname(os.path.realpath(__file__)) + '/fifo.ts' self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, fifo_path, True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0_0, 0)) self.connect((self.fft_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fft_filter_xxx_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbt2-blade.py input_file [output_file]\n"); sys.exit(1) version = dtv.VERSION_111 fft_size = dtv.FFTSIZE_4K input_mode = dtv.INPUTMODE_NORMAL frame_size = dtv.FECFRAME_NORMAL code_rate = dtv.C2_3 data_symbols = 100 fec_blocks = 31 ti_blocks = 3 constellation = dtv.MOD_64QAM rotation = dtv.ROTATION_ON guard_interval = dtv.GI_1_32 mode = dtv.PREAMBLE_T2_SISO carrier_mode = dtv.CARRIERS_NORMAL pilot_pattern = dtv.PILOT_PP7 l1_constellation = dtv.L1_MOD_16QAM papr_mode = dtv.PAPR_OFF papr_vclip = 3.3 papr_iterations = 3 channel_mhz = 8 samp_rate = channel_mhz * 8000000.0 / 7 center_freq = 429000000 txvga1_gain = -8 txvga2_gain = 12 if channel_mhz == 10: bandwidth = 10000000 equalization_bandwidth = dtv.BANDWIDTH_10_0_MHZ elif channel_mhz == 8: bandwidth = 8750000 equalization_bandwidth = dtv.BANDWIDTH_8_0_MHZ elif channel_mhz == 7: bandwidth = 7000000 equalization_bandwidth = dtv.BANDWIDTH_7_0_MHZ elif channel_mhz == 6: bandwidth = 5500000 equalization_bandwidth = dtv.BANDWIDTH_6_0_MHZ elif channel_mhz == 5: bandwidth = 5000000 equalization_bandwidth = dtv.BANDWIDTH_5_0_MHZ else: bandwidth = 1750000 equalization_bandwidth = dtv.BANDWIDTH_1_7_MHZ if fft_size == dtv.FFTSIZE_1K: fftsize = 1024 elif fft_size == dtv.FFTSIZE_2K: fftsize = 2048 elif fft_size == dtv.FFTSIZE_4K: fftsize = 4096 elif fft_size == dtv.FFTSIZE_8K: fftsize = 8192 elif fft_size == dtv.FFTSIZE_8K_T2GI: fftsize = 8192 elif fft_size == dtv.FFTSIZE_16K: fftsize = 16384 elif fft_size == dtv.FFTSIZE_16K_T2GI: fftsize = 16384 elif fft_size == dtv.FFTSIZE_32K: fftsize = 32768 elif fft_size == dtv.FFTSIZE_32K_T2GI: fftsize = 32768 if guard_interval == dtv.GI_1_32: gi = fftsize // 32 elif guard_interval == dtv.GI_1_16: gi = fftsize // 16 elif guard_interval == dtv.GI_1_8: gi = fftsize // 8 elif guard_interval == dtv.GI_1_4: gi = fftsize // 4 elif guard_interval == dtv.GI_1_128: gi = fftsize // 128 elif guard_interval == dtv.GI_19_128: gi = (fftsize * 19) // 128 elif guard_interval == dtv.GI_19_256: gi = (fftsize * 19) // 256 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbt2_bbheader = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBT2, frame_size, code_rate, dtv.RO_0_35, input_mode, dtv.INBAND_OFF, fec_blocks, 4000000) dvbt2_bbscrambler = dtv.dvb_bbscrambler_bb(dtv.STANDARD_DVBT2, frame_size, code_rate) dvbt2_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBT2, frame_size, code_rate) dvbt2_ldpc = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBT2, frame_size, code_rate, dtv.MOD_OTHER) dvbt2_interleaver = dtv.dvbt2_interleaver_bb(frame_size, code_rate, constellation) dvbt2_modulator = dtv.dvbt2_modulator_bc(frame_size, constellation, rotation) dvbt2_cellinterleaver = dtv.dvbt2_cellinterleaver_cc(frame_size, constellation, fec_blocks, ti_blocks) dvbt2_framemapper = dtv.dvbt2_framemapper_cc(frame_size, code_rate, constellation, rotation, fec_blocks, ti_blocks, carrier_mode, fft_size, guard_interval, l1_constellation, pilot_pattern, 2, data_symbols, papr_mode, version, mode, input_mode, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) dvbt2_freqinterleaver = dtv.dvbt2_freqinterleaver_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode) dvbt2_pilotgenerator = dtv.dvbt2_pilotgenerator_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode, dtv.MISO_TX1, dtv.EQUALIZATION_ON, equalization_bandwidth, fftsize) dvbt2_paprtr = dtv.dvbt2_paprtr_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, papr_vclip, papr_iterations, fftsize) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(fftsize, fftsize + gi, 0, "") dvbt2_p1insertion = dtv.dvbt2_p1insertion_cc(carrier_mode, fft_size, guard_interval, data_symbols, mode, dtv.SHOWLEVELS_OFF, papr_vclip + 0.01) blocks_multiply_const = blocks.multiply_const_vcc((0.2, )) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt2_bbheader) tb.connect(dvbt2_bbheader, dvbt2_bbscrambler) tb.connect(dvbt2_bbscrambler, dvbt2_bch) tb.connect(dvbt2_bch, dvbt2_ldpc) tb.connect(dvbt2_ldpc, dvbt2_interleaver) tb.connect(dvbt2_interleaver, dvbt2_modulator) tb.connect(dvbt2_modulator, dvbt2_cellinterleaver) tb.connect(dvbt2_cellinterleaver, dvbt2_framemapper) tb.connect(dvbt2_framemapper, dvbt2_freqinterleaver) tb.connect(dvbt2_freqinterleaver, dvbt2_pilotgenerator) tb.connect(dvbt2_pilotgenerator, dvbt2_paprtr) tb.connect(dvbt2_paprtr, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, dvbt2_p1insertion) tb.connect(dvbt2_p1insertion, blocks_multiply_const) tb.connect(blocks_multiply_const, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const, dst) tb.run()
def __init__(self, constellation, frame_type, code_rate): gr.top_block.__init__(self, "Dvbs2 Tx") ################################################## # Parameters ################################################## # Header is 10 bytes try: frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80 except KeyError: raise UnknownFrameLength(frame_type, code_rate) # print("Base frame length: %s" % frame_length) frame_length /= 8 # print("Base frame length: %s" % frame_length) assert ( int(frame_length) == 1.0 * frame_length ), "Frame length {0} won't work because {0}/8 = {1}!".format( frame_length, frame_length / 8.0 ) frame_length = int(frame_length) self.frame_length = frame_length bits_per_input, bits_per_output = get_ratio(constellation) ################################################## # Variables ################################################## self.frame_type = frame_type self.constellation = constellation self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.noise = noise = 0 self.gain = gain = 1 self.center_freq = center_freq = 1280e6 self.physical_layer_gold_code = physical_layer_gold_code = 0 self.physical_layer_header_length = physical_layer_header_length = 90 ################################################## # Blocks ################################################## self.undo_bit_stuffing_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, 1, 2, 0 ) self.undo_bit_stuffing_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, 1, 2, 0 ) self.plframe_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_pilots_on_float.bin", False ) self.plframe_pilots_on_float.set_unbuffered(False) self.plframe_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_pilots_on_fixed_point.bin", False ) self.plframe_pilots_on_fixed_point.set_unbuffered(False) self.plframe_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_pilots_off_float.bin", False ) self.plframe_pilots_off_float.set_unbuffered(False) self.plframe_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_pilots_off_fixed_point.bin", False ) self.plframe_pilots_off_fixed_point.set_unbuffered(False) self.plframe_payload_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_payload_pilots_on_float.bin", False ) self.plframe_payload_pilots_on_float.set_unbuffered(False) self.plframe_payload_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_payload_pilots_on_fixed_point.bin", False ) self.plframe_payload_pilots_on_fixed_point.set_unbuffered(False) self.plframe_payload_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_payload_pilots_off_float.bin", False ) self.plframe_payload_pilots_off_float.set_unbuffered(False) self.plframe_payload_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_payload_pilots_off_fixed_point.bin", False ) self.plframe_payload_pilots_off_fixed_point.set_unbuffered(False) self.plframe_header_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_header_pilots_on_float.bin", False ) self.plframe_header_pilots_on_float.set_unbuffered(False) self.plframe_header_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_header_pilots_on_fixed_point.bin", False ) self.plframe_header_pilots_on_fixed_point.set_unbuffered(False) self.plframe_header_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_header_pilots_off_float.bin", False ) self.plframe_header_pilots_off_float.set_unbuffered(False) self.plframe_header_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_header_pilots_off_fixed_point.bin", False ) self.plframe_header_pilots_off_fixed_point.set_unbuffered(False) self.pl_complex_to_float_1 = blocks.complex_to_float(1) self.pl_complex_to_float_0_1 = blocks.complex_to_float(1) self.pl_complex_to_float_0_0_0 = blocks.complex_to_float(1) self.pl_complex_to_float_0_0 = blocks.complex_to_float(1) self.pl_complex_to_float_0 = blocks.complex_to_float(1) self.pl_complex_to_float = blocks.complex_to_float(1) self.organize = blocks.multiply_const_vcc((1,)) self.ldpc_encoder_input = blocks.file_sink( gr.sizeof_char * 1, "ldpc_encoder_input.bin", False ) self.ldpc_encoder_input.set_unbuffered(False) self.keep_plframe_payload_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, self.get_physical_layer_frame_size(dtv.PILOTS_OFF) - physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_OFF), 0, ) self.keep_plframe_payload_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, self.get_physical_layer_frame_size(dtv.PILOTS_ON) - physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_ON), 0, ) self.keep_plframe_header_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_OFF), 0, ) self.keep_plframe_header_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_ON), 0, ) self.dtv_dvbs2_physical_cc_with_pilots = dtv.dvbs2_physical_cc( frame_type, code_rate, constellation, dtv.PILOTS_ON, physical_layer_gold_code, ) self.dtv_dvbs2_physical_cc_pilots_off = dtv.dvbs2_physical_cc( frame_type, code_rate, constellation, dtv.PILOTS_OFF, physical_layer_gold_code, ) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( frame_type, code_rate, constellation, dtv.INTERPOLATION_OFF ) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( frame_type, code_rate, constellation ) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.MOD_OTHER ) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb( dtv.STANDARD_DVBS2, frame_type, code_rate ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, frame_type, code_rate ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000, ) self.blocks_stream_mux_0_2 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_1 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_1 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST ) self.blocks_float_to_short_0_3 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_2 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_2 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32768) self.bit_mapper_output_fixed = blocks.file_sink( gr.sizeof_short * 1, "bit_mapper_output_fixed.bin", False ) self.bit_mapper_output_fixed.set_unbuffered(False) self.bit_mapper_output_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "bit_mapper_output_float.bin", False ) self.bit_mapper_output_float.set_unbuffered(False) self.bit_mapper_complex_to_float = blocks.complex_to_float(1) self.bit_interleaver_output_packed = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_output_packed.bin", False ) self.bit_interleaver_output_packed.set_unbuffered(False) self.bit_interleaver_output = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_output.bin", False ) self.bit_interleaver_output.set_unbuffered(False) self.bit_interleaver_input = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_input.bin", False ) self.bit_interleaver_input.set_unbuffered(False) self.bch_encoder_input = blocks.file_sink( gr.sizeof_char * 1, "bch_encoder_input.bin", False ) self.bch_encoder_input.set_unbuffered(False) self.bb_scrambler_input_0 = blocks.file_sink( gr.sizeof_char * 1, "bb_scrambler_input.bin", False ) self.bb_scrambler_input_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, self.frame_length)), False ) ################################################## # Connections ################################################## self.connect( (self.analog_random_source_x_0, 0), (self.dtv_dvb_bbheader_bb_0, 0) ) self.connect( (self.bit_mapper_complex_to_float, 0), (self.blocks_float_to_short_0_0_2, 0) ) self.connect( (self.bit_mapper_complex_to_float, 1), (self.blocks_float_to_short_0_3, 0) ) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_stream_mux_0, 0)) self.connect( (self.blocks_float_to_short_0_0_0, 0), (self.blocks_stream_mux_0_0, 0) ) self.connect( (self.blocks_float_to_short_0_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 0) ) self.connect( (self.blocks_float_to_short_0_0_0_0_0, 0), (self.blocks_stream_mux_0_0_0_0, 0), ) self.connect( (self.blocks_float_to_short_0_0_0_1, 0), (self.blocks_stream_mux_0_0_1, 0) ) self.connect( (self.blocks_float_to_short_0_0_1, 0), (self.blocks_stream_mux_0_1, 0) ) self.connect( (self.blocks_float_to_short_0_0_2, 0), (self.blocks_stream_mux_0_2, 0) ) self.connect( (self.blocks_float_to_short_0_1, 0), (self.blocks_stream_mux_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_0, 0), (self.blocks_stream_mux_0_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_0_0, 0), (self.blocks_stream_mux_0_0_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_1, 0), (self.blocks_stream_mux_0_0_1, 1) ) self.connect( (self.blocks_float_to_short_0_2, 0), (self.blocks_stream_mux_0_1, 1) ) self.connect( (self.blocks_float_to_short_0_3, 0), (self.blocks_stream_mux_0_2, 1) ) self.connect( (self.blocks_repack_bits_bb_0, 0), (self.bit_interleaver_output_packed, 0) ) self.connect( (self.blocks_stream_mux_0, 0), (self.plframe_pilots_on_fixed_point, 0) ) self.connect( (self.blocks_stream_mux_0_0, 0), (self.plframe_payload_pilots_on_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_0, 0), (self.plframe_header_pilots_on_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_0_0, 0), (self.plframe_header_pilots_off_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_1, 0), (self.plframe_payload_pilots_off_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_1, 0), (self.plframe_pilots_off_fixed_point, 0) ) self.connect((self.blocks_stream_mux_0_2, 0), (self.bit_mapper_output_fixed, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.bb_scrambler_input_0, 0)) self.connect( (self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0) ) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.bch_encoder_input, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.bit_interleaver_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.bit_interleaver_output, 0) ) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.blocks_repack_bits_bb_0, 0) ) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0) ) self.connect( (self.dtv_dvbs2_modulator_bc_0, 0), (self.bit_mapper_complex_to_float, 0) ) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.bit_mapper_output_float, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.organize, 0)) self.connect( (self.dtv_dvbs2_physical_cc_pilots_off, 0), (self.undo_bit_stuffing_pilots_off, 0), ) self.connect( (self.dtv_dvbs2_physical_cc_with_pilots, 0), (self.undo_bit_stuffing_pilots_on, 0), ) self.connect( (self.keep_plframe_header_pilots_off, 0), (self.pl_complex_to_float_0_0_0, 0), ) self.connect( (self.keep_plframe_header_pilots_off, 0), (self.plframe_header_pilots_off_float, 0), ) self.connect( (self.keep_plframe_header_pilots_on, 0), (self.pl_complex_to_float_0_0, 0) ) self.connect( (self.keep_plframe_header_pilots_on, 0), (self.plframe_header_pilots_on_float, 0), ) self.connect( (self.keep_plframe_payload_pilots_off, 0), (self.pl_complex_to_float_0_1, 0) ) self.connect( (self.keep_plframe_payload_pilots_off, 0), (self.plframe_payload_pilots_off_float, 0), ) self.connect( (self.keep_plframe_payload_pilots_on, 0), (self.pl_complex_to_float_0, 0) ) self.connect( (self.keep_plframe_payload_pilots_on, 0), (self.plframe_payload_pilots_on_float, 0), ) self.connect((self.organize, 0), (self.dtv_dvbs2_physical_cc_pilots_off, 0)) self.connect((self.organize, 0), (self.dtv_dvbs2_physical_cc_with_pilots, 0)) self.connect((self.pl_complex_to_float, 1), (self.blocks_float_to_short_0, 0)) self.connect((self.pl_complex_to_float, 0), (self.blocks_float_to_short_0_0, 0)) self.connect( (self.pl_complex_to_float_0, 0), (self.blocks_float_to_short_0_0_0, 0) ) self.connect( (self.pl_complex_to_float_0, 1), (self.blocks_float_to_short_0_1, 0) ) self.connect( (self.pl_complex_to_float_0_0, 0), (self.blocks_float_to_short_0_0_0_0, 0) ) self.connect( (self.pl_complex_to_float_0_0, 1), (self.blocks_float_to_short_0_1_0, 0) ) self.connect( (self.pl_complex_to_float_0_0_0, 0), (self.blocks_float_to_short_0_0_0_0_0, 0), ) self.connect( (self.pl_complex_to_float_0_0_0, 1), (self.blocks_float_to_short_0_1_0_0, 0) ) self.connect( (self.pl_complex_to_float_0_1, 0), (self.blocks_float_to_short_0_0_0_1, 0) ) self.connect( (self.pl_complex_to_float_0_1, 1), (self.blocks_float_to_short_0_1_1, 0) ) self.connect( (self.pl_complex_to_float_1, 0), (self.blocks_float_to_short_0_0_1, 0) ) self.connect( (self.pl_complex_to_float_1, 1), (self.blocks_float_to_short_0_2, 0) ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.keep_plframe_header_pilots_off, 0), ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.keep_plframe_payload_pilots_off, 0), ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.pl_complex_to_float_1, 0) ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.plframe_pilots_off_float, 0) ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.keep_plframe_header_pilots_on, 0), ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.keep_plframe_payload_pilots_on, 0), ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.pl_complex_to_float, 0) ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.plframe_pilots_on_float, 0) )
def __init__(self): gr.top_block.__init__(self, "Dvb S2 Tx Example") Qt.QWidget.__init__(self) self.setWindowTitle("Dvb S2 Tx Example") 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", "dvb_s2_Tx_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vga2_gain_0 = vga2_gain_0 = 10 self.vga1_gain = vga1_gain = -8 self.tx_gain = tx_gain = 35 self.taps = taps = 100 self.symbol_rate = symbol_rate = 5000000 self.samp_rate = samp_rate = 10000000 self.rolloff = rolloff = 0.200 self.center_freq = center_freq = 1280000000 ################################################## # Blocks ################################################## self._vga1_gain_range = Range(-35, -4, 1, -8, 200) self._vga1_gain_win = RangeWidget(self._vga1_gain_range, self.set_vga1_gain, 'VGA#1 Gain', "counter_slider", float) self.top_layout.addWidget(self._vga1_gain_win) self._vga2_gain_0_range = Range(0, 25, 1, 10, 200) self._vga2_gain_0_win = RangeWidget(self._vga2_gain_0_range, self.set_vga2_gain_0, 'VGA#2 Gain', "counter_slider", float) self.top_layout.addWidget(self._vga2_gain_0_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(vga1_gain, 0) self.uhd_usrp_sink_0.set_antenna('tx_gain', 0) self._tx_gain_range = Range(0, 89, 1, 35, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TXGain', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (100, ), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_OFF, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab6/example1/adv16apsk910.ts', True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0))