def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.osmosdr_sink_0.set_sample_rate(self.samp_rate) self.interp_fir_filter_xxx_0.set_taps((firdes.root_raised_cosine(0.07, self.samp_rate, self.samp_rate/3, 0.18, self.rrc_taps))) self.analog_sig_source_x_0_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) self.interp_fir_filter_xxx_0_0.set_taps((firdes.root_raised_cosine(0.07, self.samp_rate, self.samp_rate/3, 0.18, self.rrc_taps)))
def set_eb(self, eb): self.eb = eb self.set_matched_filter( firdes.root_raised_cosine(self.nfilts, self.nfilts, 1, self.eb, int(11 * self.sps * self.nfilts)) ) self.set_rrc_taps( firdes.root_raised_cosine( self.nfilts, self.nfilts, 1.0 / float(self.sps), self.eb, 5 * self.sps * self.nfilts ) )
def set_audio_rate(self, audio_rate): self.audio_rate = audio_rate self.set_samp_rate(self.audio_rate * 40) self.band_pass_filter_0_0.set_taps(firdes.complex_band_pass(1, self.audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1.set_taps(firdes.low_pass(0.5, self.audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.root_raised_cosine_filter_1.set_taps(firdes.root_raised_cosine(1, self.audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.audio_rate, 5, 0.35, 200)) self.analog_sig_source_x_6.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_5.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_3.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_3_0.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_2.set_sampling_freq(self.audio_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.osmosdr_sink_0.set_sample_rate(self.samp_rate) self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate) self.fft_filter_xxx_0.set_taps( (firdes.root_raised_cosine(1, self.samp_rate, self.samp_rate / 2, self.rolloff, self.taps)) )
def __init__(self, sps=2.0, rolloff=0.35, preamble=[0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,1,1,1,0,0,0,0], modtype=mapper.QPSK, greymap=[0,1,3,2] ): gr.hier_block2.__init__(self, "preamble_correlator", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_float)) #gr.io_signature(0,0,0)) # vet preamble bits for b in preamble: assert(b >= 0 and b<=1); tb = gr.top_block(); vs = blocks.vector_source_b( preamble ); mp = mapper.mapper(modtype, greymap); it = filter.interp_fir_filter_ccf(2, firdes.root_raised_cosine(1, 1.0, 1.0/sps, rolloff, 21)) vk = blocks.vector_sink_c(); tb.connect(vs,mp,it,vk); tb.run(); self.taps = list(vk.data()); self.taps.reverse(); self.taps = map(lambda x: x.conjugate(), self.taps); self.flt = filter.fft_filter_ccc(1, self.taps); self.mag = blocks.complex_to_mag_squared(); self.connect(self, self.flt, self.mag); # connect output self.connect(self.mag, self);
def set_len_sym_srrc(self, len_sym_srrc): self.len_sym_srrc = len_sym_srrc self.set_pulso( firdes.root_raised_cosine( self.samp_per_sym, self.samp_per_sym, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc ) )
def set_alfa(self, alfa): self.alfa = alfa self.set_pulso( firdes.root_raised_cosine( self.samp_per_sym, self.samp_per_sym, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc ) )
def set_samp_per_sym(self, samp_per_sym): self.samp_per_sym = samp_per_sym self.set_pulso( firdes.root_raised_cosine( self.samp_per_sym, self.samp_per_sym, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc ) )
def __init__(self, alfa=0.35, samp_per_sym=5, bits_per_sym=2, constellation=[-1-1j,1-1j, 1+1j, -1+1j], len_sym_srrc=7, out_const_mul=0.4): gr.hier_block2.__init__( self, "Hier Tx", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.alfa = alfa self.samp_per_sym = samp_per_sym self.bits_per_sym = bits_per_sym self.constellation = constellation self.len_sym_srrc = len_sym_srrc self.out_const_mul = out_const_mul ################################################## # Variables ################################################## self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc) ################################################## # Blocks ################################################## self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf( samp_per_sym, (pulso), 100) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((constellation), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((out_const_mul, )) if DEBUG: self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_ini", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_2bits", False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_out", False) self.blocks_file_sink_2.set_unbuffered(True) self.blocks_file_sink_3 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_sym", False) self.blocks_file_sink_3.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self, 0)) self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) if DEBUG: self.connect((self, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_file_sink_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_file_sink_3, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_baseband_rate(self.samp_rate/self.bb_decim) self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate) self.freq_xlating_fir_filter_xxx_0.set_taps((firdes.low_pass(1, self.samp_rate, self.xlate_bandwidth, 100000))) self.rtl_sdr_source0.set_sample_rate(self.samp_rate) self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate/self.bb_decim/self.audio_decim, 2375, 1, 100)) self.digital_mpsk_receiver_cc_0.set_omega(self.samp_rate/self.bb_decim/self.audio_decim/ 2375.0)
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-blade.py port [output_file]\n"); sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 tx_gain = 83 # max 89.5 tb = gr.top_block() out = uhd.usrp_sink( device_addr="recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(symbol_rate*4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) out.set_samp_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_gain(tx_gain, 0) #src = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", port, 18800, True) src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc(1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate/2, 0.1152, 100)) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def __init__(self): gr.top_block.__init__(self, "Qam64 B200") ################################################## # Variables ################################################## self.interpolation = interpolation = 2 self.samp_rate = samp_rate = 5056941 * interpolation self.rrc_taps = rrc_taps = 50 self.gain = gain = 83 self.center_freq = center_freq = 441000000 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(samp_rate*4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) 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(gain, 0) self.qam_trellis_enc_bb_0 = qam.trellis_enc_bb() self.qam_transport_framing_enc_bb_0 = qam.transport_framing_enc_bb() self.qam_reed_solomon_enc_bb_0 = qam.reed_solomon_enc_bb() self.qam_randomizer_bb_0 = qam.randomizer_bb() self.qam_interleaver_bb_0 = qam.interleaver_bb(128,4) self.qam_frame_sync_enc_bb_0 = qam.frame_sync_enc_bb(6) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(interpolation, (firdes.root_raised_cosine(0.14, samp_rate, samp_rate/interpolation, 0.18, rrc_taps))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([complex(1,1), complex(1,-1), complex(1,-3), complex(-3,-1), complex(-3,1), complex(1,3), complex(-3,-3), complex(-3,3), complex(-1,1), complex(-1,-1), complex(3,1), complex(-1,3), complex(-1,-3), complex(3,-1), complex(3,-3), complex(3,3), complex(5,1), complex(1,-5), complex(1,-7), complex(-7,-1), complex(-3,5), complex(5,3), complex(-7,-3), complex(-3,7), complex(-1,5), complex(-5,-1), complex(7,1), complex(-1,7), complex(-5,-3), complex(3,-5), complex(3,-7), complex(7,3), complex(1,5), complex(5,-1), complex(5,-3), complex(-3,-5), complex(-7,1), complex(1,7), complex(-3,-7), complex(-7,3), complex(-5,1), complex(-1,-5), complex(3,5), complex(-5,3), complex(-1,-7), complex(7,-1), complex(7,-3), complex(3,7), complex(5,5), complex(5,-5), complex(5,-7), complex(-7,-5), complex(-7,5), complex(5,7), complex(-7,-7), complex(-7,7), complex(-5,5), complex(-5,-5), complex(7,5), complex(-5,7), complex(-5,-7), complex(7,-5), complex(7,-7), complex(7,7)]), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(7, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=5555, server=True, ) ################################################## # Connections ################################################## self.connect((self.interp_fir_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.qam_interleaver_bb_0, 0), (self.qam_randomizer_bb_0, 0)) self.connect((self.qam_randomizer_bb_0, 0), (self.qam_frame_sync_enc_bb_0, 0)) self.connect((self.qam_frame_sync_enc_bb_0, 0), (self.qam_trellis_enc_bb_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qam_transport_framing_enc_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.qam_reed_solomon_enc_bb_0, 0)) self.connect((self.qam_transport_framing_enc_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.qam_trellis_enc_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.qam_reed_solomon_enc_bb_0, 0), (self.qam_interleaver_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Qam64 HackRF") ################################################## # Variables ################################################## self.interpolation = interpolation = 2 self.samp_rate = samp_rate = 5056941 * interpolation self.rrc_taps = rrc_taps = 50 self.gain = gain = 40 self.center_freq = center_freq = 441000000 ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink( args="hackrf=0" ) 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(14, 0) self.osmosdr_sink_0.set_if_gain(gain, 0) self.osmosdr_sink_0.set_bb_gain(-4, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.qam_trellis_enc_bb_0 = qam.trellis_enc_bb() self.qam_transport_framing_enc_bb_0 = qam.transport_framing_enc_bb() self.qam_reed_solomon_enc_bb_0 = qam.reed_solomon_enc_bb() self.qam_randomizer_bb_0 = qam.randomizer_bb() self.qam_interleaver_bb_0 = qam.interleaver_bb(128,4) self.qam_frame_sync_enc_bb_0 = qam.frame_sync_enc_bb(6) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(interpolation, (firdes.root_raised_cosine(0.14, samp_rate, samp_rate/interpolation, 0.18, rrc_taps))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([complex(1,1), complex(1,-1), complex(1,-3), complex(-3,-1), complex(-3,1), complex(1,3), complex(-3,-3), complex(-3,3), complex(-1,1), complex(-1,-1), complex(3,1), complex(-1,3), complex(-1,-3), complex(3,-1), complex(3,-3), complex(3,3), complex(5,1), complex(1,-5), complex(1,-7), complex(-7,-1), complex(-3,5), complex(5,3), complex(-7,-3), complex(-3,7), complex(-1,5), complex(-5,-1), complex(7,1), complex(-1,7), complex(-5,-3), complex(3,-5), complex(3,-7), complex(7,3), complex(1,5), complex(5,-1), complex(5,-3), complex(-3,-5), complex(-7,1), complex(1,7), complex(-3,-7), complex(-7,3), complex(-5,1), complex(-1,-5), complex(3,5), complex(-5,3), complex(-1,-7), complex(7,-1), complex(7,-3), complex(3,7), complex(5,5), complex(5,-5), complex(5,-7), complex(-7,-5), complex(-7,5), complex(5,7), complex(-7,-7), complex(-7,7), complex(-5,5), complex(-5,-5), complex(7,5), complex(-5,7), complex(-5,-7), complex(7,-5), complex(7,-7), complex(7,7)]), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(7, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=5555, server=True, ) ################################################## # Connections ################################################## self.connect((self.interp_fir_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.qam_interleaver_bb_0, 0), (self.qam_randomizer_bb_0, 0)) self.connect((self.qam_randomizer_bb_0, 0), (self.qam_frame_sync_enc_bb_0, 0)) self.connect((self.qam_frame_sync_enc_bb_0, 0), (self.qam_trellis_enc_bb_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qam_transport_framing_enc_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.qam_reed_solomon_enc_bb_0, 0)) self.connect((self.qam_transport_framing_enc_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.qam_trellis_enc_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.qam_reed_solomon_enc_bb_0, 0), (self.qam_interleaver_bb_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: atsc-blade.py input_file [output_file]\n"); sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 txvga1_gain = -4 txvga2_gain = 25 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc_taps = firdes.root_raised_cosine(0.1, symbol_rate*2, symbol_rate/2, 0.1152, 200) rrc = filter.rational_resampler_ccc(interpolation=2, decimation=3, taps=rrc_taps, fractional_bw=None, ) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(symbol_rate * 2 / 3) 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(6000000, 0) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
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: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-hackrf.py port [output_file]\n"); sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 rf_gain = 14 if_gain = 40 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc(1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate/2, 0.1152, 100)) out = osmosdr.sink(args="hackrf=0") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(6000000, 0) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def set_n_filts(self, n_filts): self.n_filts = n_filts self.set_filtro_srrc( firdes.root_raised_cosine( self.n_filts, self.samp_per_sym * self.n_filts, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc * self.n_filts, ) )
def set_len_sym_srrc(self, len_sym_srrc): self.len_sym_srrc = len_sym_srrc self.set_filtro_srrc( firdes.root_raised_cosine( self.n_filts, self.samp_per_sym * self.n_filts, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc * self.n_filts, ) )
def set_alfa(self, alfa): self.alfa = alfa self.set_filtro_srrc( firdes.root_raised_cosine( self.n_filts, self.samp_per_sym * self.n_filts, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc * self.n_filts, ) )
def __init__(self, bw_clock_sync=2*math.pi/100, bw_fll=math.pi/1600, bw_costas=2*math.pi/100, n_filts=32, len_sym_srrc=7, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=3, alfa=0.35, bits_per_sym=2, alpha_probe=0.1, th_probe=0): gr.hier_block2.__init__( self, "Hier Rx", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Parameters ################################################## self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.bw_costas = bw_costas self.n_filts = n_filts self.len_sym_srrc = len_sym_srrc self.constellation = constellation self.samp_per_sym = samp_per_sym self.alfa = alfa self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(th_probe, alpha_probe) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self, 0)) self.connect((self, 0), (self.analog_probe_avg_mag_sqrd_x_0, 0))
def __init__(self, wpm, tx_freq, if_gain, rf_amp, morse_vector): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.wpm = wpm self.tx_freq = tx_freq - cw_tone_ofs self.rf_sample_rate = rf_sample_rate = 500000 self.morse_vector = morse_vector self.audio_rate = audio_rate = 8000 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=rf_sample_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(rf_sample_rate) self.osmosdr_sink_0.set_center_freq(self.tx_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) # OK, osmocom is incredibly stupid. It interprets "0" for these fields as "not set", #and defaults to an IF gain of +16 and turning the RF amp *ON*. # A value of "1" for the RF gain turns it off, and a value >=7 turns it on. # For IF gain, 0->16, 1..47 behave as you'd expect. This means IF gain=0 is impossible. self.osmosdr_sink_0.set_gain( 14 if rf_amp > 0 else 1, 0) self.osmosdr_sink_0.set_if_gain(if_gain if if_gain > 0 else 1, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, cw_tone_ofs, 1, 0) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, decay=0.001, samp_rate=48000, attack=0.1, Frequency=1200): gr.hier_block2.__init__( self, "Detectmarkspace", gr.io_signature(1, 1, gr.sizeof_float*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.decay = decay self.samp_rate = samp_rate self.attack = attack self.Frequency = Frequency ################################################## # Variables ################################################## self.Baud = Baud = 1200 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate, Baud, 0.35, samp_rate/Baud)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -Frequency, 1, 0) self.analog_agc2_xx_0 = analog.agc2_ff(attack, decay, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(1.0) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_mag_0, 0))
def set_samp_per_sym(self, samp_per_sym): self.samp_per_sym = samp_per_sym self.set_filtro_srrc( firdes.root_raised_cosine( self.n_filts, self.samp_per_sym * self.n_filts, 1.0, self.alfa, self.samp_per_sym * self.len_sym_srrc * self.n_filts, ) ) self.wxgui_scopesink2_0.set_sample_rate(250000 / self.samp_per_sym) self.uhd_usrp_source_0.set_samp_rate(50000 * self.samp_per_sym)
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.wpm = wpm = 15 self.tx_freq = tx_freq = 433.000e6 self.rf_sample_rate = rf_sample_rate = 250000 self.morse_vector = morse_vector = (1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0) self.audio_rate = audio_rate = 8000 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=rf_sample_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(rf_sample_rate) self.osmosdr_sink_0.set_center_freq(tx_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
def getfir(samplerate, filtertype, bw, transition, maxtaps): """ Design a FIR lowpass. The filter will have samplerate/bw passband. filtertype -- string "window" or "rcos" window -- design a Hamming window lowpass rcos -- design a Root Raised Cosine lowpass https://en.wikipedia.org/wiki/Root-raised-cosine_filter For some digital protocols, like Tetra, rcos filter minimizes intersymbol interference. For analog modulations it is probably insignificant. transition -- adjusts order of the filter For "window" type filter, it is the transition band, and GnuRadio documentation does not tell you much more about it http://gnuradio.org/doc/doxygen/classgr_1_1filter_1_1firdes.html#a772eb5c542093d65518a6d721483aace For "rcos" filter, it is the order of the filter (number of taps) maxtaps -- do not exceed this number of taps """ coefs = None if filtertype not in ["hamming", "rcos"]: print("Unknown filter type %s, defaulting to hamming"%xl.filtertype) filtertype = "hamming" if filtertype == "hamming": while True: coefs = firdes.low_pass(1, samplerate, bw, transition, firdes.WIN_HAMMING) if len(coefs) < maxtaps: break print("transition %f yields too long filter (%i)"%(transition, len(coefs))) transition += 1 transition *= 1.2 print("trying transition %f"%transition) elif filtertype == "rcos": if transition > maxtaps: print("The requested raised cosine filter of len %i is too long. Limiting to %i."%(transition, maxtaps)) transition = maxtaps coefs = firdes.root_raised_cosine(1, samplerate, bw, 0.35, transition) return coefs
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sps = sps = 6 self.samp_rate = samp_rate = 600e3 self.rx_taps = rx_taps = firdes.root_raised_cosine(32,32*sps,1.0,0.35,1024) ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(6, 1, (rx_taps), 32, 16, 1.5, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/rs/sem_v/EE340/14D070033/File1.dat", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, N): self.N = N self.sps = 4 self.eb = 0.25 self.freq_bw = 2*numpy.pi/100.0 self.timing_bw = 2*numpy.pi/100.0 self.timing_max_dev = 0.5 self.phase_bw = 2*numpy.pi/100.0 self.fll_ntaps = 55 self.fmin = -0.25 self.fmax = 0.25 self.nfilts = 32 self.ntaps = 11 * int(self.sps*self.nfilts) self.taps = firdes.root_raised_cosine(self.nfilts, self.nfilts*self.sps, 1.0, self.eb, self.ntaps) # Generate some random bits rndm = random.Random() rndm.seed(0) self.src_data_bpsk = tuple([rndm.randint(0,1) for i in range(0, self.N)]) self.src_data_qpsk = tuple([rndm.randint(0,1) for i in range(0, 2*self.N)]) self.src_data_8psk = tuple([rndm.randint(0,1) for i in range(0, 3*self.N)])
def set_sps(self, sps): self.sps = sps self.set_rrc_taps( firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 45))
def set_sps(self, sps): self.sps = sps self.set_rrc_tx(firdes.root_raised_cosine(self.sps, self.sps, 1, self.eb, self.sps*self.ntaps)) self.set_rrc_rx(firdes.root_raised_cosine(1.0, self.sps, 1, self.eb, self.ntaps)) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.8, 0.00005*self.sps, 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.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts 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.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.pld_enc = pld_enc = map((lambda a: fec.cc_encoder_make( 440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), 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.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.copy = copy = True self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 50, 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, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) _copy_check_box = Qt.QCheckBox("copy") self._copy_choices = {True: True, False: False} self._copy_choices_inv = dict( (v, k) for k, v in self._copy_choices.iteritems()) self._copy_callback = lambda i: Qt.QMetaObject.invokeMethod( _copy_check_box, "setChecked", Qt.Q_ARG("bool", self._copy_choices_inv[i])) self._copy_callback(self.copy) _copy_check_box.stateChanged.connect( lambda i: self.set_copy(self._copy_choices[bool(i)])) self.top_grid_layout.addWidget(_copy_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_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_unknown_pps(uhd.time_spec()) 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_packets_same_seed_scramble_packetize_0 = scrambler_packets_same_seed.scramble_packetize( 0x8A, 0x7F, 7, 440) 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_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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_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(filt_delay) 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_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (892, 4)) 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 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(copy) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.acode_1104 = 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, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_copy_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_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_packets_same_seed_scramble_packetize_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_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)) 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_copy_0, 0)) self.connect( (self.scrambler_packets_same_seed_scramble_packetize_0, 0), (self.fec_extended_encoder_0, 0))
def __init__(self): gr.top_block.__init__(self, "Handshake Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("Handshake 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", "handshake_transmitter") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_rx_gain = range_rx_gain = 15 self.range_mu = range_mu = 0.6 self.usrp_device_address = usrp_device_address = "addr=192.168.10.4" self.tx_center_frequency = tx_center_frequency = 400000000 self.timeout_duration_ms = timeout_duration_ms = 1000 self.system_time_granularity_us = system_time_granularity_us = 1000 self.source_address = source_address = 1 self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = range_rx_gain self.rx_center_frequency = rx_center_frequency = 400000000 self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.result_record_directory = result_record_directory = "/home/pwa/Source/gr-dmdl/results" self.reserved_field_II = reserved_field_II = 6 self.reserved_field_I = reserved_field_I = 5 self.preamble_detector_threshold = preamble_detector_threshold = 30 self.mu = mu = range_mu self.min_backoff_ms = min_backoff_ms = 50 self.max_num_retransmission = max_num_retransmission = 5 self.max_buffer_size = max_buffer_size = 10 self.len_source_address = len_source_address = 1 self.len_reserved_field_II = len_reserved_field_II = 2 self.len_reserved_field_I = len_reserved_field_I = 2 self.len_payload_length = len_payload_length = 1 self.len_num_transmission = len_num_transmission = 1 self.len_frame_type = len_frame_type = 1 self.len_frame_index = len_frame_index = 1 self.len_destination_address = len_destination_address = 1 self.increase_index = increase_index = 1 self.frame_type = frame_type = 1 self.frame_index = frame_index = 0 self.experiment_duration_s = experiment_duration_s = 1000 self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.develop_mode_list = develop_mode_list = [0] self.destination_address = destination_address = 2 self.cs_threshold = cs_threshold = 0.005 self.cs_duration = cs_duration = 50 self.counter_id = counter_id = 20 self.backoff_time_unit_ms = backoff_time_unit_ms = 50 self.apply_address_check = apply_address_check = 1 ################################################## # Blocks ################################################## self._range_rx_gain_range = Range(0, 60, 1, 15, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._range_mu_range = Range(0, 1, 0.01, 0.6, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.dmdl_type_check_0 = dmdl.type_check(0, 25, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) self.dmdl_timeout_0 = dmdl.timeout(0, 10, 100, 10, 0) self.dmdl_start_0 = dmdl.start(5, 10) self.dmdl_sending_0 = dmdl.sending( 0, 11, gnuradio.digital.constellation_qpsk().base(), diff_preamble_128, samp_rate, sps, system_time_granularity_us, usrp_device_address, tx_center_frequency, 0.005, 0.05, "t1TXs", "Tfr", 0, 1, 0) self.dmdl_receiving_0 = dmdl.receiving( 1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency) self.dmdl_probe_0_2_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, result_record_directory, "t1TXe", 1) self.dmdl_probe_0_2 = dmdl.probe(0, 100, 0, 0, 0.01, 1, result_record_directory, "t1TXr", 1) self.dmdl_probe_0_1 = dmdl.probe(0, 100, 0, 0, 0.01, 1, result_record_directory, "t1RXe", 1) self.dmdl_probe_0_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, result_record_directory, "t1CS", 1) self.dmdl_probe_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, result_record_directory, "t1DQ", 1) self.dmdl_path_0 = dmdl.path(0, 44, 1, "") self.dmdl_framing_0 = dmdl.framing(0, 17, 1, 1, 0, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_frame_analysis_0 = dmdl.frame_analysis( 0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address) self.dmdl_error_detection_0 = dmdl.error_detection(0, 9) self.dmdl_dummy_source_0 = dmdl.dummy_source(0, 23, 100, 2, 1) self.dmdl_cmd_buffer_0 = dmdl.cmd_buffer(0, 16, 10, 1, 1, 1) self.dmdl_address_check_0 = dmdl.address_check(0, 17, source_address, 0) ################################################## # Connections ################################################## self.msg_connect((self.dmdl_address_check_0, 'P'), (self.dmdl_type_check_0, 'B')) self.msg_connect((self.dmdl_cmd_buffer_0, 'U'), (self.dmdl_probe_0, 'B')) self.msg_connect((self.dmdl_cmd_buffer_0, 'U'), (self.dmdl_receiving_0, 'RXI')) self.msg_connect((self.dmdl_dummy_source_0, 'E'), (self.dmdl_framing_0, 'B')) self.msg_connect((self.dmdl_error_detection_0, 'P'), (self.dmdl_address_check_0, 'B')) self.msg_connect((self.dmdl_frame_analysis_0, 'P'), (self.dmdl_error_detection_0, 'B')) self.msg_connect((self.dmdl_framing_0, 'E'), (self.dmdl_cmd_buffer_0, 'Q')) self.msg_connect((self.dmdl_path_0, 'E'), (self.dmdl_receiving_0, 'RXI')) self.msg_connect((self.dmdl_receiving_0, 'E'), (self.dmdl_frame_analysis_0, 'B')) self.msg_connect((self.dmdl_receiving_0, 'RXO'), (self.dmdl_probe_0_2, 'B')) self.msg_connect((self.dmdl_receiving_0, 'RXO'), (self.dmdl_sending_0, 'B')) self.msg_connect((self.dmdl_sending_0, 'RXO'), (self.dmdl_path_0, 'B')) self.msg_connect((self.dmdl_sending_0, 'E'), (self.dmdl_probe_0_2_0, 'B')) self.msg_connect((self.dmdl_sending_0, 'E'), (self.dmdl_timeout_0, 'B')) self.msg_connect((self.dmdl_start_0, 'B'), (self.dmdl_dummy_source_0, 'B')) self.msg_connect((self.dmdl_timeout_0, 'E'), (self.dmdl_cmd_buffer_0, 'D')) self.msg_connect((self.dmdl_type_check_0, 'ACK'), (self.dmdl_probe_0_1, 'B')) self.msg_connect((self.dmdl_type_check_0, 'ACK'), (self.dmdl_timeout_0, 'I'))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Top Block") ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts 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.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[2] self.pld_enc = pld_enc = map( (lambda a: fec.cc_encoder_make(440, k, rate, (polys), 0, fec.CC_TERMINATED, True) ), 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.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## 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) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) 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(filt_delay) 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_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4) 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 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 992, "packet_len") self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (892, 4)) self.blocks_stream_mux_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, 2, "packet_len", 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.acode_1104 = 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, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_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.uhd_usrp_sink_0_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.blocks_stream_mux_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_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.digital_map_bb_1_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11 * nfilts * sps self.excess_bw = excess_bw = 0.35 self.time_off = time_off = 1 self.taps = taps = 1 self.samp_rate = samp_rate = 32e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, excess_bw, ntaps) 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 = 100e-6 self.freq_off = freq_off = 0 self.const_points_0 = const_points_0 = 256 self.const_points = const_points = 256 self.cma_gain = cma_gain = 10e-3 self.BW = BW = 62.8e-3 ################################################## # Blocks ################################################## self._time_off_range = Range(0.999, 1.001, 100e-6, 1, 200) self._time_off_win = RangeWidget(self._time_off_range, self.set_time_off, "time_off", "counter_slider", float) self.top_grid_layout.addWidget(self._time_off_win, 0, 1) self._noise_volt_range = Range(0, 1, 0.01, 100e-6, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "noise_volt", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_volt_win, 0, 0) self._freq_off_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_off_win = RangeWidget(self._freq_off_range, self.set_freq_off, "freq_off", "counter_slider", float) self.top_grid_layout.addWidget(self._freq_off_win, 0, 2) self._cma_gain_range = Range(0, 100e-3, 1e-3, 10e-3, 200) self._cma_gain_win = RangeWidget(self._cma_gain_range, self.set_cma_gain, "cma_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._cma_gain_win, 2, 1) self._BW_range = Range(-0, 200e-3, 10e-3, 62.8e-3, 200) self._BW_win = RangeWidget(self._BW_range, self.set_BW, "BW", "counter_slider", float) self.top_grid_layout.addWidget(self._BW_win, 0, 3) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "", #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) if not False: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "green", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [1, 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, 0) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "", #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) if not False: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "green", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [1, 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, 1, 3) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #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) if not False: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "green", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [1, 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, 1, 2) 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 False: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "green", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [1, 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, 1, 1) (self.qtgui_const_sink_x_0).set_block_alias("square") self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 4.004, BW, (rrc_taps), 32, 16, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(BW, 4, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 11, 1, cma_gain, 2) self.const = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=4, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_off, epsilon=time_off, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_throttle_0_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, const_points, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.const, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.const, 0), (self.blocks_throttle_0_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_0_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0_0_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_0_0, 0))
def __init__(self, antenna="", baudrate=800.0, bb_freq=0.0, bw=0.0, dc_removal="False", decoded_data_file_path="/tmp/.satnogs/data/data", dev_args="", doppler_correction_per_sec=20, enable_iq_dump=0, excess_bw=0.5, file_path="test.wav", gain=0.0, gain_mode="Overall", iq_file_path="/tmp/iq.dat", lo_offset=100e3, max_cfo=1000.0, other_settings="", ppm=0, rigctl_port=4532, rx_freq=100e6, samp_rate_rx=0.0, soapy_rx_device="driver=invalid", stream_args="", tune_args="", udp_IP="127.0.0.1", udp_dump_dest='127.0.0.1', udp_dump_port=7355, udp_port=16887, waterfall_file_path="/tmp/waterfall.dat"): gr.top_block.__init__(self, "satnogs_argos_bpsk_ldr") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_freq = bb_freq self.bw = bw self.dc_removal = dc_removal self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.excess_bw = excess_bw self.file_path = file_path self.gain = gain self.gain_mode = gain_mode self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.max_cfo = max_cfo self.other_settings = other_settings self.ppm = ppm self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.samp_rate_rx = samp_rate_rx self.soapy_rx_device = soapy_rx_device self.stream_args = stream_args self.tune_args = tune_args self.udp_IP = udp_IP self.udp_dump_dest = udp_dump_dest self.udp_dump_port = udp_dump_port self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.audio_samp_rate = audio_samp_rate = 48000 self.variable_argos_ldr_decoder_0_0 = variable_argos_ldr_decoder_0_0 = satnogs.argos_ldr_decoder_make(True, 64) self.variable_argos_ldr_decoder_0 = variable_argos_ldr_decoder_0 = satnogs.argos_ldr_decoder_make(True, 64) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 11*sps*nfilts) self.if_freq = if_freq = 12000 self.decimation = decimation = satnogs.find_decimation(baudrate, 2, audio_samp_rate,sps) self.bpsk_constellation = bpsk_constellation = digital.constellation_calcdist([-1+1j, 1+1j], [0, 1], 2, 1).base() self.avg_len = avg_len = 2048 ################################################## # Blocks ################################################## self.soapy_source_0 = None # Make sure that the gain mode is valid if(gain_mode not in ['Overall', 'Specific', 'Settings Field']): raise ValueError("Wrong gain mode on channel 0. Allowed gain modes: " "['Overall', 'Specific', 'Settings Field']") dev = soapy_rx_device # Stream arguments for every activated stream tune_args = [tune_args] settings = [other_settings] # Setup the device arguments dev_args = dev_args self.soapy_source_0 = soapy.source(1, dev, dev_args, stream_args, tune_args, settings, samp_rate_rx, "fc32") self.soapy_source_0.set_dc_removal(0,bool(distutils.util.strtobool(dc_removal))) # Set up DC offset. If set to (0, 0) internally the source block # will handle the case if no DC offset correction is supported self.soapy_source_0.set_dc_offset(0,0) # Setup IQ Balance. If set to (0, 0) internally the source block # will handle the case if no IQ balance correction is supported self.soapy_source_0.set_iq_balance(0,0) self.soapy_source_0.set_agc(0,False) # generic frequency setting should be specified first self.soapy_source_0.set_frequency(0, rx_freq - lo_offset) self.soapy_source_0.set_frequency(0,"BB",bb_freq) # Setup Frequency correction. If set to 0 internally the source block # will handle the case if no frequency correction is supported self.soapy_source_0.set_frequency_correction(0,ppm) self.soapy_source_0.set_antenna(0,antenna) self.soapy_source_0.set_bandwidth(0,bw) if(gain_mode != 'Settings Field'): # pass is needed, in case the template does not evaluare anything pass self.soapy_source_0.set_gain(0,gain) self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink(baudrate*decimation, rx_freq, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, int(1000.0/doppler_correction_per_sec) + 1, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0) self.satnogs_json_converter_0 = satnogs.json_converter() self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(decoded_data_file_path, 0) self.satnogs_frame_decoder_0_0_0 = satnogs.frame_decoder(variable_argos_ldr_decoder_0_0, 1 * 1) self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder(variable_argos_ldr_decoder_0, 1 * 1) self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(samp_rate_rx, rx_freq, lo_offset, baudrate*decimation, 1, 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate/(baudrate*decimation), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass( 1, audio_samp_rate, ((1.0 + excess_bw) * baudrate/2.0) + min(baudrate, abs(max_cfo)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( decimation // sps, firdes.low_pass( 1, baudrate*decimation, baudrate/2 + excess_bw *baudrate/2 + 200, baudrate / 4.0, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2.0 * math.pi/100.0, rrc_taps, nfilts, nfilts/2, 1.5, 1) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(bpsk_constellation, 2.0 * math.pi/50.0, -0.125, 0.125) self.blocks_vco_c_0 = blocks.vco_c((baudrate*decimation), -(baudrate*decimation), 1.0) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dump_dest, udp_dump_port+1, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dump_dest, udp_dump_port, 1472, True) self.blocks_rotator_cc_0_0 = blocks.rotator_cc(2.0 * math.pi * (if_freq / audio_samp_rate)) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(avg_len, 1/avg_len, 4000, 1) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0) self.blocks_delay_1 = blocks.delay(gr.sizeof_gr_complex*1, avg_len // 2) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(2*math.pi/100, 2*math.pi*max_cfo/(baudrate*decimation), -2*math.pi*max_cfo/(baudrate*decimation)) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'), (self.satnogs_json_converter_0, 'in')) self.msg_connect((self.satnogs_frame_decoder_0_0_0, 'out'), (self.satnogs_json_converter_0, 'in')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_compensation_0, 'doppler')) self.connect((self.analog_agc2_xx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_1, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.satnogs_frame_decoder_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.satnogs_frame_decoder_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_vco_c_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_iq_sink_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_waterfall_sink_0_0, 0)) self.connect((self.soapy_source_0, 0), (self.satnogs_doppler_compensation_0, 0))
def __init__(self): gr.top_block.__init__(self, "Symbol Sampling") Qt.QWidget.__init__(self) self.setWindowTitle("Symbol Sampling") 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", "symbol_sampling") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.ntaps = ntaps = 45 self.eb = eb = 0.25 self.samp_rate = samp_rate = 32000 self.rrc_tx = rrc_tx = firdes.root_raised_cosine( sps, sps, 1, eb, sps * ntaps) self.rrc_rx = rrc_rx = firdes.root_raised_cosine(1, sps, 1, eb, ntaps) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 27, #size samp_rate, #samp_rate "QT GUI Plot", #name 4 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.01) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.25) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.9, 0.0002, 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_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ "Rx Symbol 1", "Rx Symbol 2", "Rx Symbol 3", "Rx Symbol 4", "", "", "", "", "", "" ] widths = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, 0, 0, -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(4): 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, 0, 1, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 27, #size samp_rate, #samp_rate "QT GUI Plot", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.01) self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.25) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.99, 0.0002, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Symbol 1", "Symbol 2", "Symbol 3", "Symbol 4", "", "", "", "", "", "" ] widths = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, 0, 0, -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(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_fff( sps, (rrc_tx)) self.interp_fir_filter_xxx_0_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0 = filter.interp_fir_filter_fff( sps, (rrc_tx)) self.interp_fir_filter_xxx_0_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff( sps, (rrc_tx)) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( sps, (rrc_tx)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0_1 = filter.fir_filter_fff(1, (rrc_rx)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0_0 = filter.fir_filter_fff(1, (rrc_rx)) self.fir_filter_xxx_0_0_0.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_fff(1, (rrc_rx)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (rrc_rx)) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_vector_source_x_0_1 = blocks.vector_source_f( 51 * [ 0, ] + [ 1, ] + 48 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f( 52 * [ 0, ] + [ 1, ] + 47 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_f( 50 * [ 0, ] + [ 1, ] + 49 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_f( 49 * [ 0, ] + [ 1, ] + 50 * [ 0, ], True, 1, []) self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_throttle_0_0_0, 0), (self.interp_fir_filter_xxx_0_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.interp_fir_filter_xxx_0_1, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_throttle_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_1, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 3)) self.connect((self.fir_filter_xxx_0_1, 0), (self.qtgui_time_sink_x_0_0, 2)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.fir_filter_xxx_0_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.qtgui_time_sink_x_0, 2))
def set_rrc_taps(self, rrc_taps): self.rrc_taps = rrc_taps self.fft_filter_xxx_0.set_taps((firdes.root_raised_cosine(1.79, self.samp_rate, self.samp_rate/2, 0.35, self.rrc_taps)))
def set_excess_bw(self, excess_bw): self.excess_bw = excess_bw self.set_rrc_taps( firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 45))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage5") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage5") 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_stage5") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 self.samp_rate = samp_rate = 56250 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 = 6.28 / 100.0 self.min_freq_deviation = min_freq_deviation = -500 self.max_freq_deviation = max_freq_deviation = 500 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 self.NOAA_DSB_Constellation = NOAA_DSB_Constellation = digital.constellation_calcdist( ([0.3907 - 0.9205j, 0.3907 + 0.9205j]), ([0, 1]), 0, 1).base() ################################################## # Blocks ################################################## 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.top_grid_layout.addWidget(self._timing_loop_bw_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Output Bytes", #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(-0.1, 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 = ['Direct', 'through decoder', '', '', '', '', '', '', '', ''] 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_grid_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 "Constellation outputs", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_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 = ['Error', 'Phase', 'Frequency', '', '', '', '', '', '', ''] 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, 4, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("Byte Output") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_2 = qtgui.const_sink_c( 1024, #size "After AutoGain Control", #name 1 #number of inputs ) self.qtgui_const_sink_x_2.set_update_time(0.10) self.qtgui_const_sink_x_2.set_y_axis(-2, 2) self.qtgui_const_sink_x_2.set_x_axis(-2, 2) self.qtgui_const_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_2.enable_autoscale(False) self.qtgui_const_sink_x_2.enable_grid(False) self.qtgui_const_sink_x_2.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_2.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_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_2.set_line_label(i, labels[i]) self.qtgui_const_sink_x_2.set_line_width(i, widths[i]) self.qtgui_const_sink_x_2.set_line_color(i, colors[i]) self.qtgui_const_sink_x_2.set_line_style(i, styles[i]) self.qtgui_const_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_2_win = sip.wrapinstance( self.qtgui_const_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_2_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Input Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Output Constellation", #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.top_grid_layout.addWidget(self._qtgui_const_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_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( NOAA_DSB_Constellation, phase_bw, min_freq_deviation, max_freq_deviation) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'C:\\Users\\Sevy\\Desktop\\School\\ETH\\SDR\\POES_56k250.raw', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_char * 1, 'C:\\Users\\Sevy\\Desktop\\School\\ETH\\SDR\\Packed Byte Out.txt', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, 'C:\\Users\\Sevy\\Desktop\\School\\ETH\\SDR\\Byte Out.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_agc3_xx_0 = analog.agc3_cc(500e-3, 1, 1.0, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_agc3_xx_0, 0), (self.qtgui_const_sink_x_2, 0)) self.connect((self.blocks_char_to_float_0, 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_pack_k_bits_bb_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_char_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)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.qtgui_time_sink_x_0, 2)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
def set_sps(self, sps): self.sps = sps self.set_decimation(satnogs.find_decimation(self.baudrate, 2, self.audio_samp_rate,self.sps)) self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 11*self.sps*self.nfilts))
def set_samp_per_sym(self, samp_per_sym): self.samp_per_sym = samp_per_sym self.root_raised_cosine_filter_0_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.samp_rate/self.samp_per_sym, 0.35, 11)) self.digital_clock_recovery_mm_xx_0.set_omega(self.samp_per_sym*(1+0.0))
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-blade.py port [output_file]\n") sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 tx_gain = 83 # max 89.5 tb = gr.top_block() out = uhd.usrp_sink( device_addr= "recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(symbol_rate * 4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) out.set_samp_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_gain(tx_gain, 0) #src = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", port, 18800, True) src = grc_blks2.tcp_source(gr.sizeof_char * 1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc( ([symbol + 1.25 for symbol in [-7, -5, -3, -1, 1, 3, 5, 7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc( 1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate / 2, 0.1152, 100)) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def set_nfilts(self, nfilts): self.nfilts = nfilts self.set_ntaps(11 * self.nfilts * self.sps) self.set_rrc_taps( firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0, self.excess_bw, self.ntaps))
def set_excess_bw(self, excess_bw): self.excess_bw = excess_bw self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 11*self.sps*self.nfilts)) self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.baudrate*self.decimation, self.baudrate/2 + self.excess_bw *self.baudrate/2 + 200, self.baudrate / 4.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.audio_samp_rate, ((1.0 + self.excess_bw) * self.baudrate/2.0) + min(self.baudrate, abs(self.max_cfo)), self.baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) self.root_raised_cosine_filter_0_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.samp_rate/self.samp_per_sym, 0.35, 11)) self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) self.qtgui_sink_x_0.set_frequency_range(self.cfreq, self.samp_rate)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.length_tag_key = length_tag_key = "packet_len" self.hsize = hsize = 10 self.variable_tag_object_3_0 = variable_tag_object_3_0 = gr.tag_utils.python_to_tag((0, pmt.intern("key"), pmt.intern("value"), pmt.intern("src"))) self.variable_tag_object_3 = variable_tag_object_3 = gr.tag_utils.python_to_tag((0, pmt.intern("key"), pmt.intern("value"), pmt.intern("src"))) self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sym = sym = -1,1 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_qpsk().base() self.phase_bw = phase_bw = 6.28/100.0 self.original = original = gr.tag_utils.python_to_tag((96, "original", 96, pmt.intern("src"))) self.header_formatter = header_formatter = digital.packet_header_default(hsize,length_tag_key) self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## 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.top_grid_layout.addWidget(self._timing_loop_bw_win, 6, 3, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 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', "dial", float) self.top_grid_layout.addWidget(self._phase_bw_win, 6, 1, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 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 (Gain)', "slider", float) self.top_grid_layout.addWidget(self._eq_gain_win, 6, 2, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_formatter.formatter(), "original") self.digital_crc32_bb_0 = digital.crc32_bb(False, "original", True) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((qpsk.points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, "original", 0) self.blocks_tag_debug_1_1_0_0_1_0 = blocks.tag_debug(gr.sizeof_char*1, 'Tx Bytes_Mux', ""); self.blocks_tag_debug_1_1_0_0_1_0.set_display(True) self.blocks_tag_debug_1_1_0_0 = blocks.tag_debug(gr.sizeof_gr_complex*1, 'Tx Bytes_Symbols', ""); self.blocks_tag_debug_1_1_0_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 96, "original") self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 2, "original", False, gr.GR_LSB_FIRST) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/transmit_maior.txt', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tag_debug_1_1_0_0_1_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tag_debug_1_1_0_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage6") 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_stage6") 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 self.a_code = a_code = "0111000110101100011001011000011101011010010" ################################################## # 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_2 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Out Stream", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) 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 "Demod Raw", #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_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/test.jpg', False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/test_out.jpg', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, int(delay)) self.blocks_char_to_float_0_0_1 = blocks.char_to_float(1, 1) 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.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=sps, bits_per_symbol=2, preamble='', access_code=a_code, pad_for_usrp=False, ), payload_length=2, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code=a_code, threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blks2_packet_encoder_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_char_to_float_0_0_1, 0), (self.qtgui_time_sink_x_2, 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_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0_1, 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.channels_channel_model_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_unpack_k_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 set_ntaps(self, ntaps): self.ntaps = ntaps self.set_tx_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0, self.excess_bw, self.ntaps)) self.set_rx_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0, self.excess_bw, self.ntaps))
def __init__(self): gr.top_block.__init__(self, "Qpsk Demod") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Demod") 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", "QPSK_demod") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sro = sro = 0 self.samp_rate = samp_rate = 400000 self.samp_per_sym = samp_per_sym = 2 self.frame_width = frame_width = 1024*2 self.cfreq = cfreq = 278000000 self.cfo = cfo = 0 self.SNR = SNR = 12 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "serial=3134BA2")), 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(cfreq, 0) self.uhd_usrp_source_0.set_gain(60, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self._sro_range = Range(-1e-1, 1e-1, 1e-3, 0, 200) self._sro_win = RangeWidget(self._sro_range, self.set_sro, 'Sample Rate Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._sro_win) self.root_raised_cosine_filter_0_0 = filter.interp_fir_filter_ccf(samp_per_sym*0+1, firdes.root_raised_cosine( 1, samp_rate, samp_rate/samp_per_sym, 0.35, 11)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_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(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype cfreq, #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_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 840-84, #size 'QT GUI Plot', #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) 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_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 840-84, #size 'QT GUI Plot', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) 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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1e-2, 4, True) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self._cfo_range = Range(-1e-1, 1e-1, 1e-3, 0, 200) self._cfo_win = RangeWidget(self._cfo_range, self.set_cfo, 'Freq Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._cfo_win) self._SNR_tool_bar = Qt.QToolBar(self) self._SNR_tool_bar.addWidget(Qt.QLabel('SNR'+": ")) self._SNR_line_edit = Qt.QLineEdit(str(self.SNR)) self._SNR_tool_bar.addWidget(self._SNR_line_edit) self._SNR_line_edit.returnPressed.connect( lambda: self.set_SNR(eng_notation.str_to_num(str(self._SNR_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._SNR_tool_bar) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 3), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.root_raised_cosine_filter_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Symbol Sampling") Qt.QWidget.__init__(self) self.setWindowTitle("Symbol Sampling") 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", "symbol_sampling") 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.ntaps = ntaps = 45 self.eb = eb = 0.25 self.samp_rate = samp_rate = 32000 self.rrc_tx = rrc_tx = firdes.root_raised_cosine( sps, sps, 1, eb, sps * ntaps) self.rrc_rx = rrc_rx = firdes.root_raised_cosine(1, sps, 1, eb, ntaps) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 27, #size samp_rate, #samp_rate 'QT GUI Plot', #name 4 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.01) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.25) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.9, 0.0002, 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) labels = [ 'Rx Symbol 1', 'Rx Symbol 2', 'Rx Symbol 3', 'Rx Symbol 4', '', '', '', '', '', 'Signal 10' ] widths = [2, 2, 2, 2, 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 = [0, 0, 0, 0, -1, -1, -1, -1, -1, -1] for i in range(4): 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, 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.qtgui_time_sink_x_0 = qtgui.time_sink_f( 27, #size samp_rate, #samp_rate 'QT GUI Plot', #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.01) self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.25) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.99, 0.0002, 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 = [ 'Symbol 1', 'Symbol 2', 'Symbol 3', 'Symbol 4', '', '', '', '', '', 'Signal 10' ] widths = [2, 2, 2, 2, 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 = [0, 0, 0, 0, -1, -1, -1, -1, -1, -1] for i in range(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 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.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_fff( sps, rrc_tx) self.interp_fir_filter_xxx_0_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0 = filter.interp_fir_filter_fff( sps, rrc_tx) self.interp_fir_filter_xxx_0_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff( sps, rrc_tx) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( sps, rrc_tx) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0_1 = filter.fir_filter_fff(1, rrc_rx) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0_0 = filter.fir_filter_fff(1, rrc_rx) self.fir_filter_xxx_0_0_0.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_fff(1, rrc_rx) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, rrc_rx) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_vector_source_x_0_1 = blocks.vector_source_f( 51 * [ 0, ] + [ 1, ] + 48 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f( 52 * [ 0, ] + [ 1, ] + 47 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_f( 50 * [ 0, ] + [ 1, ] + 49 * [ 0, ], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_f( 49 * [ 0, ] + [ 1, ] + 50 * [ 0, ], True, 1, []) self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_throttle_0_0_0, 0), (self.interp_fir_filter_xxx_0_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.interp_fir_filter_xxx_0_1, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_throttle_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_1, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 3)) self.connect((self.fir_filter_xxx_0_1, 0), (self.qtgui_time_sink_x_0_0, 2)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.fir_filter_xxx_0_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.qtgui_time_sink_x_0, 2))
def set_excess_bw(self, excess_bw): self.excess_bw = excess_bw self.set_tx_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0, self.excess_bw, self.ntaps)) self.set_rx_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0, self.excess_bw, self.ntaps))
def __init__(self, callsign='', gpredict_port=4532, latitude=0, longitude=0): gr.top_block.__init__(self, "LilacSat-2 decoder for FUNcube Dongle Pro+") ################################################## # Parameters ################################################## self.callsign = callsign self.gpredict_port = gpredict_port self.latitude = latitude self.longitude = longitude ################################################## # Variables ################################################## self.sub_sps = sub_sps = 32 self.sub_nfilts = sub_nfilts = 16 self.sub_alpha = sub_alpha = 0.35 self.sps = sps = 5 self.nfilts = nfilts = 16 self.freq = freq = 437.2e6 self.alpha = alpha = 0.35 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.threshold = threshold = 4 self.sub_rrc_taps = sub_rrc_taps = firdes.root_raised_cosine(sub_nfilts, sub_nfilts, 1.0/float(sub_sps), sub_alpha, 11*sub_sps*sub_nfilts) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), alpha, 11*sps*nfilts) self.rf_samp_rate = rf_samp_rate = 192000 self.offset = offset = 30e3 self.if_samp_rate = if_samp_rate = 48000 self.doppler_freq = doppler_freq = freq self.af_samp_rate = af_samp_rate = 9600 ################################################## # Blocks ################################################## self.sync_to_pdu_0_1_0 = sync_to_pdu( packlen=(114+32)*8, sync="00011010110011111111110000011101", threshold=threshold, ) self.sync_to_pdu_0_1 = sync_to_pdu( packlen=(114+32)*8, sync="00011010110011111111110000011101", threshold=threshold, ) self.sync_to_pdu_0_0_0 = sync_to_pdu( packlen=(114+32)*8, sync="00011010110011111111110000011101", threshold=threshold, ) self.sync_to_pdu_0_0 = sync_to_pdu( packlen=(114+32)*8, sync="00011010110011111111110000011101", threshold=threshold, ) self.sync_to_pdu_0 = sync_to_pdu( packlen=(114+32)*8, sync="00011010110011111111110000011101", threshold=threshold, ) self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', 40908, callsign, longitude, latitude, '') self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S') self.low_pass_filter_3_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, if_samp_rate, 8e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, af_samp_rate, 200, 50, firdes.WIN_HAMMING, 6.76)) self.libfec_decode_rs_0_0_0 = libfec.decode_rs(True, 0) self.libfec_decode_rs_0_0 = libfec.decode_rs(True, 0) self.libfec_decode_rs_0 = libfec.decode_rs(True, 0) self.kiss_kiss_to_pdu_0_1 = kiss.kiss_to_pdu(False) self.kiss_kiss_to_pdu_0_0 = kiss.kiss_to_pdu(False) self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(False) self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, False) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(rf_samp_rate/if_samp_rate, (filter.firdes.low_pass(1,rf_samp_rate,10000,2000)), doppler_freq - freq + offset, rf_samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(rf_samp_rate/if_samp_rate, (filter.firdes.low_pass(1,rf_samp_rate,5000,2000)), doppler_freq - freq + offset + 25e3, rf_samp_rate) self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus('',1) self.fcdproplus_fcdproplus_0.set_lna(0) self.fcdproplus_fcdproplus_0.set_mixer_gain(0) self.fcdproplus_fcdproplus_0.set_if_gain(0) self.fcdproplus_fcdproplus_0.set_freq_corr(0) self.fcdproplus_fcdproplus_0.set_freq(freq-offset) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_fff(sub_sps, 0.0628, (sub_rrc_taps), sub_nfilts, sub_nfilts/2, 0.01, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 0.100, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc(2, 0.3, 2, variable_constellation_0) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.350, 100, 0.1) self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(0.4, 2, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.ccsds_viterbi_0_1 = ccsds_viterbi() self.ccsds_viterbi_0_0_0 = ccsds_viterbi() self.ccsds_viterbi_0_0 = ccsds_viterbi() self.ccsds_viterbi_0 = ccsds_viterbi() self.ccsds_descrambler_0_0_0 = ccsds_descrambler() self.ccsds_descrambler_0_0 = ccsds_descrambler() self.ccsds_descrambler_0 = ccsds_descrambler() self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_message_debug_0 = blocks.message_debug() self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float*1, 1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.5) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=af_samp_rate, quad_rate=if_samp_rate, tau=75e-6, max_dev=3.5e3, ) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_descrambler_0, 'out'), (self.libfec_decode_rs_0, 'in')) self.msg_connect((self.ccsds_descrambler_0_0, 'out'), (self.libfec_decode_rs_0_0, 'in')) self.msg_connect((self.ccsds_descrambler_0_0_0, 'out'), (self.libfec_decode_rs_0_0_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0_0, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0_1, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0_1, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.libfec_decode_rs_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.libfec_decode_rs_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.libfec_decode_rs_0_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.sync_to_pdu_0, 'out'), (self.ccsds_descrambler_0, 'in')) self.msg_connect((self.sync_to_pdu_0_0, 'out'), (self.ccsds_descrambler_0_0, 'in')) self.msg_connect((self.sync_to_pdu_0_0_0, 'out'), (self.ccsds_descrambler_0_0_0, 'in')) self.msg_connect((self.sync_to_pdu_0_1, 'out'), (self.ccsds_descrambler_0_0, 'in')) self.msg_connect((self.sync_to_pdu_0_1_0, 'out'), (self.ccsds_descrambler_0_0_0, 'in')) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.ccsds_viterbi_0_1, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ccsds_viterbi_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.ccsds_viterbi_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.kiss_kiss_to_pdu_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_kiss_to_pdu_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.kiss_kiss_to_pdu_0_1, 0)) self.connect((self.ccsds_viterbi_0, 0), (self.sync_to_pdu_0_1_0, 0)) self.connect((self.ccsds_viterbi_0_0, 0), (self.sync_to_pdu_0_0_0, 0)) self.connect((self.ccsds_viterbi_0_0_0, 0), (self.digital_diff_decoder_bb_0_0, 0)) self.connect((self.ccsds_viterbi_0_1, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_1, 0), (self.sync_to_pdu_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.ccsds_viterbi_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_lms_dd_equalizer_cc_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.sync_to_pdu_0_1, 0)) self.connect((self.digital_diff_decoder_bb_0_0, 0), (self.sync_to_pdu_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_binary_slicer_fb_1, 0)) self.connect((self.fcdproplus_fcdproplus_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.fcdproplus_fcdproplus_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.low_pass_filter_3_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.low_pass_filter_3_0_0, 0), (self.analog_nbfm_rx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11*nfilts*sps self.excess_bw = excess_bw = 0.4 self.tx_taps = tx_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps) self.timing_bw = timing_bw = 2*pi/100 self.samp_rate_2 = samp_rate_2 = 20000 self.samp_rate = samp_rate = 320000 self.rx_taps = rx_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps) self.const_points = const_points = 4 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/4, #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(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_taps), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.iir_filter_xxx_0 = filter.iir_filter_ffd(([0.01]), ([-1,0.99]), True) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([1+1j,-1+1j,-1-1j,1-1j]), 1) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float*1, samp_rate/4,True) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_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, 200000 ] self.rate = rate = 2 self.polys = polys = [109, 79] self.nfilts = nfilts = 32 self.k = k = 7 self.eb = eb = 0.22 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.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.cc_decoder.make( 440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)), 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_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, 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, 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, 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.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 = 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, 2) self.digital_map_bb_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_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.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_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_0_2_0 = blocks.keep_m_in_n( gr.sizeof_char, 892, 896, 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_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_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), (self.fec_extended_decoder_0_0_1_0_1_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_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_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.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_2, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_keep_m_in_n_0_0_2_0, 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.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_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0, 0), (self.scrambler_cpp_additive_descrambler_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, freq): gr.top_block.__init__(self, "Burst Transmitter") ################################################## # Variables ################################################## self.tsh = tsh = 0 self.sps = sps = 4 self.nfilts = nfilts = 64 self.eb = eb = .700 self.usrp_rate = usrp_rate = 500e3 self.psf_taps = psf_taps = firdes.root_raised_cosine( nfilts / 1.5, nfilts, 1.0, eb, 5 * sps * nfilts) self.pld_cons = pld_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.hdr_cons = hdr_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.freq = freq self.format_0 = format_0 = digital.header_format_default( digital.packet_utils.default_access_code, tsh) self.b_ntaps = b_ntaps = 50 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(usrp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps, taps=(psf_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, usrp_rate, usrp_rate / sps * 1.4, 10e3, firdes.WIN_KAISER, 6.76)) self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async( format_0) self.digital_map_bb_0_0 = digital.map_bb((pld_cons.pre_diff_code())) self.digital_map_bb_0 = digital.map_bb((hdr_cons.pre_diff_code())) self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb( pld_cons.arity()) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_cons.points()), pld_cons.dimensionality()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (hdr_cons.points()), hdr_cons.dimensionality()) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc( (firdes.window(firdes.WIN_HANN, b_ntaps, 0)), 10, 20, True, "packet_len") self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, "packet_len", 0) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", sps) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10000, False) self.blocks_repack_bits_bb_2 = blocks.repack_bits_bb( 8, 1, "packet_len", False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 8, 1, "packet_len", False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.digital_protocol_formatter_async_0, 'in')) self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.blocks_pdu_to_tagged_stream_1_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_repack_bits_bb_2, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_2, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_diff_encoder_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.digital_diff_encoder_bb_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def set_nfilts(self, nfilts): self.nfilts = nfilts self.set_rrc_taps( firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0 / float(self.sps), 0.35, 11 * self.sps * self.nfilts))
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 = 4 self.excess_bw = excess_bw = 0.35 self.samp_rate = samp_rate = 5000000 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.freq = freq = 880000000 self.arity = arity = 4 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(0, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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_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" == "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.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.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, samp_rate)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 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_multiply_xx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self, n_filts=32, bits_per_sym=2, alpha_probe=0.1, th_probe=0, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=5, bw_costas=2*math.pi/100, bw_clock_sync=2*math.pi/100, bw_fll=2*math.pi/100, len_sym_srrc=11, alfa=0.45): grc_wxgui.top_block_gui.__init__(self, title="Test Hier Rx Usrp") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.n_filts = n_filts self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe self.constellation = constellation self.samp_per_sym = samp_per_sym self.bw_costas = bw_costas self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.len_sym_srrc = len_sym_srrc self.alfa = alfa ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=250000/samp_per_sym, v_scale=0.3, v_offset=0, t_scale=0.3, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) 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(50000*samp_per_sym) self.uhd_usrp_source_0.set_center_freq(850000000, 0) self.uhd_usrp_source_0.set_gain(18, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(2, 1000, 0.1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/belza/pruebasUSRP/file_rx_sym", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 2, 15) self.analog_agc2_xx_0.set_max_gain(15) ################################################## # Connections ################################################## self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.H = H = 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 = 50 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 34 self.time_offset = time_offset = 1.0 self.samp_rate = samp_rate = 500000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.pld_enc = pld_enc = fec.ldpc_par_mtrx_encoder_make_H(H) self.pld_dec = pld_dec = fec.ldpc_bit_flip_decoder.make( H_dec.get_base_sptr(), 100) 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, 3, 2]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.noise = noise = 0.0 self.frequencia_usrp = frequencia_usrp = 435000000 self.freq_offset = freq_offset = 0 self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.amp = amp = 1.0 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_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._noise_range = Range(0, 5, 0.01, 0.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_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.5, 0.5, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_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._amp_range = Range(0, 2, 0.01, 1.0, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win) self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 50, 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, 4, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_range = Range(0, 90, 1, 34, 200) self._variable_qtgui_range_0_win = RangeWidget( self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_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_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #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, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.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(filt_delay) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading=None, puncpat=puncpat) self.fec_extended_decoder_0_0_1_0_1_0 = fec.extended_decoder( decoder_obj_list=pld_dec, threading=None, ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 44, 0.05) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 200.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, 3, 'packet_len') self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf( pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 1200 / 2, "packet_len") self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_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, 2, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) 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 = blocks.keep_m_in_n( gr.sizeof_char, 1100, 1104, 0) self.blocks_file_source_0_0_1 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/book.txt', False) self.blocks_file_source_0_0_1.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1) self.acode_1104 = 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), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.digital_binary_slicer_fb_0_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)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_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), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_throttle_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 4500000 self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 20 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=435000000, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, 2, (0171, 0133)), 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(435e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(2, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-4, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate/2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs_reed_solomon_enc_bb_0 = dvbs.reed_solomon_enc_bb() self.dvbs_randomizer_bb_0 = dvbs.randomizer_bb() self.dvbs_puncture_bb_0 = dvbs.puncture_bb(dvbs.C1_2) self.dvbs_modulator_bc_0 = dvbs.modulator_bc() self.dvbs_interleaver_bb_0 = dvbs.interleaver_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/adv.ts", False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs_randomizer_bb_0, 0)) self.connect((self.dvbs_randomizer_bb_0, 0), (self.dvbs_reed_solomon_enc_bb_0, 0)) self.connect((self.dvbs_reed_solomon_enc_bb_0, 0), (self.dvbs_interleaver_bb_0, 0)) self.connect((self.dvbs_interleaver_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.dvbs_puncture_bb_0, 0)) self.connect((self.dvbs_puncture_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.dvbs_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dvbs_modulator_bc_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __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, 100000, 50000 ] 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(198400) ] 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[18] 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.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_vector_source_x_0 = blocks.vector_source_b([ 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 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, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (155, 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_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Dropbox/Investiga\xc3\xa7\xc3\xa3o_Metricas_Sync/Testes/After_Coding_header/original10000.txt', False) self.blocks_file_source_0_0_1_0_0_0_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0_0_1_0_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_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.blocks_stream_mux_0_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), (self.blocks_stream_mux_0_1_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))