def __init__(self, carrier_freq_hi=1750, carrier_freq_lo=1080, input_path_hi='/tmp/remote.bin', input_path_lo='/tmp/local.bin', lo_delay=180): gr.top_block.__init__(self, "Dual Fsk Modulation") ################################################## # Parameters ################################################## self.carrier_freq_hi = carrier_freq_hi self.carrier_freq_lo = carrier_freq_lo self.input_path_hi = input_path_hi self.input_path_lo = input_path_lo self.lo_delay = lo_delay ################################################## # Variables ################################################## self.oversample = oversample = 1 self.samp_rate = samp_rate = 44100 self.baud = baud = 300/oversample self.fsk_deviation_hz = fsk_deviation_hz = 100 self.SPS = SPS = samp_rate/baud ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq_lo-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq_lo+2*3.14*fsk_deviation_hz)), 1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq_hi-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq_hi+2*3.14*fsk_deviation_hz)), 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/tmp/data.wav', 1, samp_rate, 16) self.blocks_vco_f_0_0 = blocks.vco_f(samp_rate*oversample, 1, 0.25) self.blocks_vco_f_0 = blocks.vco_f(samp_rate*oversample, 1, 0.25) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, SPS) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, SPS) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, input_path_lo, False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, input_path_hi, False) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, lo_delay * SPS) self.blocks_add_xx_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_vco_f_0_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vco_f_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.blocks_repeat_0_0, 0))
def asktx(self, carrier=32000, samp_rate=80000, bw=1000, amp=1, code=codes.mycode, balanced=False, **kwargs): code_len = len(code) chunk_len = int(log(code_len, 2)) topblock(self, carrier, samp_rate, bw, amp) ################################################## # Blocks ################################################## blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( chunk_len, gr.GR_LSB_FIRST) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (codes.codes2list(code, balanced)), len(code[0])) blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, samp_rate / bw) ################################################## # Connections ################################################## self.connect((self.source, 0), (blocks_packed_to_unpacked_xx_0, 0)) self.connect((blocks_packed_to_unpacked_xx_0, 0), (digital_chunks_to_symbols_xx_0, 0)) self.connect((digital_chunks_to_symbols_xx_0, 0), (blocks_repeat_0, 0)) self.connect((blocks_repeat_0, 0), (self.sink, 0))
def __init__(self, sample_rate, amplitude): gr.hier_block2.__init__(self, "gsm_source_c", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._symb_rate = 13e6 / 48; self._samples_per_symbol = 2 self._data = blocks.vector_source_b(self.gen_gsm_seq(), True, 2) self._split = blocks.vector_to_streams(gr.sizeof_char*1, 2) self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self._mod = digital.gmsk_mod(self._samples_per_symbol, bt=0.35) self._pwr_f = blocks.char_to_float(1, 1) self._pwr_c = blocks.float_to_complex(1) self._pwr_w = blocks.repeat(gr.sizeof_gr_complex*1, self._samples_per_symbol) self._mul = blocks.multiply_vcc(1) self._interpolate = filter.fractional_resampler_cc( 0, (self._symb_rate * self._samples_per_symbol) / sample_rate ) self._scale = blocks.multiply_const_cc(amplitude) self.connect(self._data, self._split) self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0)) self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w, (self._mul, 1)) self.connect(self._mul, self._interpolate, self._scale, self)
def __init__(self, samp_rate, src_filename, dest_filename): gr.top_block.__init__(self, "SAME Encoder") ################################################## # Variables ################################################## self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.msg_source = blocks.file_source(1, src_filename) self.packed_to_unpacked = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST) self.repeat = blocks.repeat(4, 96) self.chunks_to_symbols = digital.chunks_to_symbols_bf(([-1, 1]), 1) self.freq_mod = analog.frequency_modulator_fc(3.14159265 / 96) # TODO: Make amplitude adjustable self.center_freq_src = analog.sig_source_c(50000, analog.GR_COS_WAVE, 1822.916666, 0.1, 0) self.freq_mult = blocks.multiply_vcc(1) self.rational_resampler = filter.rational_resampler_ccc( interpolation=samp_rate / 100, decimation=500, taps=None, fractional_bw=None ) self.complex_to_float = blocks.complex_to_float() self.float_to_short = blocks.float_to_short(1, 32767) self.sink = blocks.file_sink(2, dest_filename) self.sink.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.msg_source, 0), (self.packed_to_unpacked, 0), (self.chunks_to_symbols, 0)) self.connect((self.chunks_to_symbols, 0), (self.repeat, 0), (self.freq_mod, 0), (self.freq_mult, 0)) self.connect((self.center_freq_src, 0), (self.freq_mult, 1)) self.connect((self.freq_mult, 0), (self.rational_resampler, 0), (self.complex_to_float, 0)) self.connect((self.complex_to_float, 0), (self.float_to_short, 0), (self.sink, 0))
def __init__(self, samplerate, bits_per_sec, fftlen): gr.hier_block2.__init__( self, "square_and_fft_sync_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature #this is just the old square-and-fft method #ais.freqest is simply looking for peaks spaced bits-per-sec apart self.square = blocks.multiply_cc(1) self.fftvect = blocks.stream_to_vector(gr.sizeof_gr_complex, fftlen) self.fft = fft.fft_vcc(fftlen, True, window.rectangular(fftlen), True) self.freqest = ais.freqest(int(samplerate), int(bits_per_sec), fftlen) self.repeat = blocks.repeat(gr.sizeof_float, fftlen) self.fm = analog.frequency_modulator_fc(-1.0 / (float(samplerate) / (2 * pi))) self.mix = blocks.multiply_cc(1) self.connect(self, (self.square, 0)) self.connect(self, (self.square, 1)) #this is the feedforward branch self.connect(self, (self.mix, 0)) #this is the feedback branch self.connect(self.square, self.fftvect, self.fft, self.freqest, self.repeat, self.fm, (self.mix, 1)) #and this is the output self.connect(self.mix, self)
def __init__(self, context, mode, rtty_baud=_DEFAULT_BAUD, rtty_shift=170.0, message='\0'): gr.hier_block2.__init__( self, self.__class__.__name__, gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1)) encoded_message = map(float, _encode_rtty_alloc(map( ord, message))) # TODO char encoding issues half_bit_rate = rtty_baud * 2 wanted_bandwidth = rtty_shift * 1.5 sample_rate_as_half_bits = int( math.ceil(wanted_bandwidth / half_bit_rate)) self.__sample_rate_out = sample_rate_as_half_bits * half_bit_rate self.__char_rate = half_bit_rate / _HALF_BITS_PER_CODE self.__baud = rtty_baud self.connect( blocks.vector_source_f(encoded_message, repeat=True), # RTTYEncoder(), blocks.repeat(gr.sizeof_float, sample_rate_as_half_bits), blocks.add_const_ff(-0.5), analog.frequency_modulator_fc( (2 * math.pi) * rtty_shift / self.__sample_rate_out), self)
def __init__(self, sample_rate, amplitude): gr.hier_block2.__init__( self, "gsm_source_c", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._symb_rate = 13e6 / 48 self._samples_per_symbol = 2 self._data = blocks.vector_source_b(self.gen_gsm_seq(), True, 2) self._split = blocks.vector_to_streams(gr.sizeof_char * 1, 2) self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self._mod = digital.gmsk_mod(self._samples_per_symbol, bt=0.35) self._pwr_f = blocks.char_to_float(1, 1) self._pwr_c = blocks.float_to_complex(1) self._pwr_w = blocks.repeat(gr.sizeof_gr_complex * 1, self._samples_per_symbol) self._mul = blocks.multiply_vcc(1) self._interpolate = filter.fractional_resampler_cc( 0, (self._symb_rate * self._samples_per_symbol) / sample_rate) self._scale = blocks.multiply_const_cc(amplitude) self.connect(self._data, self._split) self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0)) self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w, (self._mul, 1)) self.connect(self._mul, self._interpolate, self._scale, self)
def __init__(self, vecsize=1024): gr.hier_block2.__init__( self, "Vector Normalize", gr.io_signature(1, 1, gr.sizeof_float * 1024), gr.io_signature(1, 1, gr.sizeof_float * 1024), ) ################################################## # Parameters ################################################## self.vecsize = vecsize ################################################## # Blocks ################################################## self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, vecsize) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, vecsize) self.blocks_max_xx_0 = blocks.max_ff(vecsize) self.blocks_divide_xx_0 = blocks.divide_ff(vecsize) ################################################## # Connections ################################################## self.connect((self.blocks_divide_xx_0, 0), (self, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self, 0), (self.blocks_divide_xx_0, 0))
def oqpsktx(self, carrier=10000, samp_rate=80000, bw=4000, amp=1, code=codes.mycode, **kwargs): code_table, code_len = codes.codes2table(code), len(code) chunk_len = int(log(code_len, 2)) topblock(self, carrier, samp_rate, bw, amp) ################################################## # Blocks ################################################## self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( chunk_len, gr.GR_LSB_FIRST) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (code_table), code_len) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 4) self.blocks_vector_source_x_0 = blocks.vector_source_c( [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, []) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 2) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate / bw), decimation=1, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.sink, 0))
def __init__(self): gr.top_block.__init__(self, "Hd Tx Rtl File") ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None) self.nrsc5_sis_encoder_0 = nrsc5.sis_encoder('ABCD') self.nrsc5_psd_encoder_0 = nrsc5.psd_encoder(0, 'Title', 'Artist') self.nrsc5_l2_encoder_0 = nrsc5.l2_encoder(1, 0, 146176) self.nrsc5_l1_fm_encoder_mp1_0 = nrsc5.l1_fm_encoder(1) self.nrsc5_hdc_encoder_0 = nrsc5.hdc_encoder(2, 64000) self.fft_vxx_0 = fft.fft_vcc(2048, False, window.rectangular(2048), True, 1) self.blocks_wavfile_source_0 = blocks.wavfile_source('sample.wav', True) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048) self.blocks_vector_source_x_0 = blocks.vector_source_c([math.sin(math.pi / 2 * i / 112) for i in range(112)] + [1] * (2048-112) + [math.cos(math.pi / 2 * i / 112) for i in range(112)], True, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*2048, 2) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 2160, 4096, 0) self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float*1, 1) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, 'hd-generated.raw', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(127.5) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_interleave_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_interleave_0, 1)) self.connect((self.blocks_conjugate_cc_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_interleave_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.nrsc5_hdc_encoder_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.nrsc5_hdc_encoder_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.nrsc5_hdc_encoder_0, 0), (self.nrsc5_l2_encoder_0, 0)) self.connect((self.nrsc5_l1_fm_encoder_mp1_0, 0), (self.fft_vxx_0, 0)) self.connect((self.nrsc5_l2_encoder_0, 0), (self.nrsc5_l1_fm_encoder_mp1_0, 0)) self.connect((self.nrsc5_psd_encoder_0, 0), (self.nrsc5_l2_encoder_0, 1)) self.connect((self.nrsc5_sis_encoder_0, 0), (self.nrsc5_l1_fm_encoder_mp1_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, ebno_db=0, min_errors=100, samp_per_sym=1): gr.top_block.__init__(self, "BER 4FSK ") ################################################## # Parameters ################################################## self.ebno_db = ebno_db self.min_errors = min_errors self.samp_per_sym = samp_per_sym ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.bits_per_sym = bits_per_sym = 1 self.bit_rate = bit_rate = float(symb_rate)*bits_per_sym self.average_power = average_power = 1.0 self.ebno = ebno = 10**(ebno_db/10.0) self.eb = eb = average_power/bit_rate self.samp_rate = samp_rate = symb_rate*samp_per_sym self.no = no = eb/ebno self.noise_variance = noise_variance = no*samp_rate/2.0 ################################################## # Blocks ################################################## self.sample_counter = sample_counter() self.probe_avg_power = analog.probe_avg_mag_sqrd_f(0, 1) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.glfsr = digital.glfsr_source_b(8, True, 0, 1) self.four_level_symbol_mapper_0 = four_level_symbol_mapper( symbol_map=[-1,1], ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_per_sym) self.blocks_add_xx_0 = blocks.add_vff(1) self.ber_sink = blocks.vector_sink_f(1) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, math.sqrt(noise_variance), 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.ber_measure, 0), (self.ber_sink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.four_level_symbol_mapper_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.probe_avg_power, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.four_level_symbol_mapper_0, 0), (self.sample_counter, 0)) self.connect((self.glfsr, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.glfsr, 0), (self.pack_msg_bits, 0)) self.connect((self.pack_msg_bits, 0), (self.ber_measure, 0)) self.connect((self.pack_rx_bits, 0), (self.ber_measure, 1)) self.connect((self.sample_counter, 0), (self.pack_rx_bits, 0))
def __init__(self, snr_db=10, num_symbols=1024, taps=[]): gr.top_block.__init__(self, "LMS Nonlinear Experiment") ################################################## # Variables ################################################## self.snr_db = snr_db self.samp_rate = samp_rate = 1000000 self.num_symbols = num_symbols self.taps = taps self.const = const = digital.constellation_8psk().base() ################################################## # Blocks ################################################## #self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(2, (firdes.low_pass_2(1, 1, .25, .1, 80))) #self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.digital_lms_equalizer_cc_0 = digital.lms_dd_equalizer_cc(4, .01, 2, self.const) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc((const.points()), 1) self.blocks_vector_sink_x_0 = blocks.vector_sink_c(1) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, num_symbols) self.analog_random_source_x_1 = blocks.vector_source_b(map(int, numpy.random.randint(0, const.arity(), 1000)), True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 2) #self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(1, ( #self.taps[0]/ numpy.sqrt((numpy.abs(self.taps[0]) ** 2 + numpy.abs(self.taps[1]) ** 2)), #self.taps[1]/ numpy.sqrt((numpy.abs(self.taps[0]) ** 2 + numpy.abs(self.taps[1]) ** 2)))) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(1, self.taps) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, .1) self.analog_noise_source_x_1 = analog.noise_source_c(analog.GR_GAUSSIAN, 10 ** (-20 / 20) / numpy.sqrt(2), 50) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_1, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0)) #self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_lms_equalizer_cc_0, 0)) self.connect((self.digital_lms_equalizer_cc_0, 0), (self.blocks_head_0, 0)) #self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_multiply_xx_0, 2))
def __init__(self): gr.hier_block2.__init__( self, "IEEE802.15.4 OQPSK PHY", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("txin") self.message_port_register_hier_out("rxout") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1) self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10) self.ieee802_15_4_access_code_prefixer_0 = ieee802_15_4.access_code_prefixer() self.foo_burst_tagger_0 = foo.burst_tagger(pmt.intern("pdu_length"), 128) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.000225, 0.5, 0.03, 0.0002) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]), 16) self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4) self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pdu_length') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(4, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_15_4_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'), (self, 'rxout')) self.msg_connect((self, 'txin'), (self.ieee802_15_4_access_code_prefixer_0, 'in')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.foo_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.ieee802_15_4_packet_sink_0, 0)) self.connect((self.foo_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
def __init__(self, RIC=1006370, SubRIC=0, Text='pRIWET'): gr.top_block.__init__(self, "POCSAG Sender via HackRF") ################################################## # Parameters ################################################## self.RIC = RIC self.SubRIC = SubRIC self.Text = Text ################################################## # Variables ################################################## self.tx_gain = tx_gain = 47 self.symrate = symrate = 38400 self.samp_rate = samp_rate = 12000000 self.pocsagbitrate = pocsagbitrate = 1200 self.pagerfreq = pagerfreq = 473325000 self.max_deviation = max_deviation = 4500.0 self.af_gain = af_gain = 190 ################################################## # Blocks ################################################## self.pocsag_generator = pocsag_generator.pocsagsender(number=RIC, source=SubRIC, sleeptime=5, text=Text) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( float(samp_rate)/float(symrate), taps=None, flt_size=16) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf' ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(pagerfreq, 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(tx_gain, 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_repeat_0 = blocks.repeat(gr.sizeof_char*1, symrate/pocsagbitrate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((af_gain/100, )) self.blocks_char_to_float_0 = blocks.char_to_float(1, af_gain*0.7/1000) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate)) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.pocsag_generator, 0), (self.blocks_repeat_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 1 Task 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 1 Task 1") 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", "lab1_task1") 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.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/home/ipsit/Documents/EE 340/Lab 1/hbd.wav', 1, samp_rate, 8) self.blocks_vector_source_x_0 = blocks.vector_source_f((262,262,294,262,349,330,262,294,262,392,349,262,262,523,440,349,330,294,466,466,440,349,392,349), True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 6.28, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_rate//2) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
def __init__(self, txstr="Hello World", carrier=10000, samp_rate = 80000, bw=4000, amp=1): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.carrier = carrier self.bw = bw ################################################## # Blocks ################################################## self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, []) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate/bw), decimation=1, taps=None, fractional_bw=None, ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((CODE_TABLE), CODE_LEN) self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(CHUNK_LEN, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_sink_0 = audio.sink(samp_rate, "") #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0) ################################################## # Connections ################################################## self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 ################################################## # 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_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(1090000000, 0) self.uhd_usrp_sink_0.set_gain(33, 0) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 2) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1.25) self.AdsbEncoder_0 = adsbtx.AdsbEncoder(200) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repeat_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.AdsbEncoder_0, "pdus", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.AdsbEncoder_0, "pdus")
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.sen = sen = 25 self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## _sen_sizer = wx.BoxSizer(wx.VERTICAL) self._sen_text_box = forms.text_box( parent=self.GetWin(), sizer=_sen_sizer, value=self.sen, callback=self.set_sen, label='sen', converter=forms.float_converter(), proportion=0, ) self._sen_slider = forms.slider( parent=self.GetWin(), sizer=_sen_sizer, value=self.sen, callback=self.set_sen, minimum=10, maximum=100, num_steps=75, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sen_sizer) self.blocks_vector_source_x_0 = blocks.vector_source_f( (262, 262, 294, 262, 350, 330, 0, 262, 262, 294, 262, 392, 350, 0, 262, 262, 524, 440, 392, 350, 330, 0, 467, 467, 440, 350, 392, 350), True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 30, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 16000) self.audio_sink_0 = audio.sink(samp_rate, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
def __init__(self): gr.top_block.__init__(self, "Blade Tx") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 self.interpolation = interpolation = 80 self.wpm = wpm = 15 self.tune = tune = 100 self.rf_gain = rf_gain = 10 self.offset = offset = 200000 self.cw_vector = cw_vector = (1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0) self.correction = correction = 0 self.bb_gain = bb_gain = -25 self.band = band = 432 self.audio_rate = audio_rate = samp_rate / interpolation ################################################## # Blocks ################################################## self.resamp = filter.rational_resampler_ccc( interpolation=interpolation, decimation=1, taps=None, fractional_bw=None, ) self.out = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.out.set_sample_rate(samp_rate) self.out.set_center_freq(band * (1 + correction / 1e6) * 1e6 + 100000 - offset, 0) self.out.set_freq_corr(0, 0) self.out.set_gain(rf_gain, 0) self.out.set_if_gain(0, 0) self.out.set_bb_gain(bb_gain, 0) self.out.set_antenna("", 0) self.out.set_bandwidth(0, 0) self.offset_osc = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, tune * 1000 + 100000, 0.9, 0) self.mixer = blocks.multiply_vcc(1) self.cw_vector_source = blocks.vector_source_c(cw_vector, False, 1, []) self.cw_repeat = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.click_filter = filter.single_pole_iir_filter_cc(1e-2, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.000001, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.resamp, 0)) self.connect((self.click_filter, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.cw_repeat, 0), (self.click_filter, 0)) self.connect((self.cw_vector_source, 0), (self.cw_repeat, 0)) self.connect((self.mixer, 0), (self.out, 0)) self.connect((self.offset_osc, 0), (self.mixer, 0)) self.connect((self.resamp, 0), (self.mixer, 1))
def test_001_float(self): src_data = [n * 1.0 for n in range(100)] dst_data = [] for n in range(100): dst_data += [1.0 * n, 1.0 * n, 1.0 * n] src = blocks.vector_source_f(src_data) rpt = blocks.repeat(gr.sizeof_float, 3) dst = blocks.vector_sink_f() self.tb.connect(src, rpt, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)
def test_001_float(self): src_data = [n*1.0 for n in range(100)]; dst_data = [] for n in range(100): dst_data += [1.0*n, 1.0*n, 1.0*n] src = blocks.vector_source_f(src_data) rpt = blocks.repeat(gr.sizeof_float, 3) dst = blocks.vector_sink_f() self.tb.connect(src, rpt, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)
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, txstr="Hello world", carrier=32000, samp_rate=80000, bw=1000, amp=1): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.carrier = carrier self.bw = bw ################################################## # Blocks ################################################## self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, []) blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( ([0, 1, 1, 0]), 2) blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, samp_rate / bw) #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0) blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) blocks_complex_to_real_0 = blocks.complex_to_real(1) audio_sink_0 = audio.sink(samp_rate, "") self.samp_blocks = [ self.source, blocks_repeat_0, analog_sig_source_x_0, audio_sink_0 ] ################################################## # Connections ################################################## self.connect((self.source, 0), (blocks_packed_to_unpacked_xx_0, 0)) self.connect((blocks_packed_to_unpacked_xx_0, 0), (digital_chunks_to_symbols_xx_0, 0)) self.connect((digital_chunks_to_symbols_xx_0, 0), (blocks_repeat_0, 0)) self.connect((blocks_repeat_0, 0), (blocks_multiply_xx_0_0, 0)) self.connect((analog_sig_source_x_0, 0), (blocks_multiply_xx_0_0, 1)) self.connect((blocks_multiply_xx_0_0, 0), (blocks_complex_to_real_0, 0)) self.connect((blocks_complex_to_real_0, 0), (audio_sink_0, 0))
def setUp(self): self.tb = gr.top_block() print "begin setup" key = "descr_part" self.src = blocks.vector_source_f([0.0] * 480, False, 480) self.rpt = blocks.repeat(gr.sizeof_float * 480, 4) self.stv = blocks.stream_to_vector(gr.sizeof_float * 480, 4) self.descr = lte.pbch_descrambler_vfvf(key) self.snk = blocks.vector_sink_f(120) self.tb.connect(self.src, self.rpt, self.stv, self.descr, self.snk) print "end setup"
def __init__(self, fixed=1234567890, freq=315150000, rolling=1234567890): gr.top_block.__init__(self, "Secplus Tx") ################################################## # Parameters ################################################## self.fixed = fixed self.freq = freq self.rolling = rolling ################################################## # Variables ################################################## self.seq = seq = [0] * 100 + secplus.encode_ook( rolling, fixed, fast=False) * 4 + [0] * 100 self.samp_rate = samp_rate = 2e6 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_cc( 0.1, 1) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + '') self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(freq - 300e3, 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(47, 0) self.osmosdr_sink_0.set_bb_gain(0, 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( seq, False, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 1000) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 300e3, 0.9, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, snr_db=10, num_symbols=1024, taps=[]): gr.top_block.__init__(self, "CMA Watterson Experiment") ################################################## # Variables ################################################## self.snr_db = snr_db self.samp_rate = samp_rate = 1000000 self.num_symbols = num_symbols self.taps = taps self.const = const = digital.constellation_8psk().base() ################################################## # Blocks ################################################## #self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(2, (firdes.low_pass_2(1, 1, .25, .1, 80))) #self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 4, 1, .01, 2) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc( (const.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=10**(-self.snr_db / 20.0) / numpy.sqrt(2), frequency_offset=0.0, epsilon=1.0, taps=self.taps, noise_seed=0, block_tags=False) self.blocks_vector_sink_x_0 = blocks.vector_sink_c(1) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, num_symbols) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, const.arity(), 1000)), True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 2) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_1, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_cma_equalizer_cc_0, 0)) #self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.blocks_head_0, 0)) #self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.blocks_repeat_0, 0))
def __init__(self, rf_params, bb_params): gr.hier_block2.__init__( self, "TX Mod Block", gr.io_signature(1, 1, gr.sizeof_char * 1), # single in gr.io_signature(1, 1, gr.sizeof_gr_complex * 1) # single out ) ################################################## # Parameters ################################################## # ADD VALIDITY CHECKS TO EACH OF THESE self.symbol_time = bb_params.symbol_time ################################################## # Variables ################################################## self.sps = int(rf_params.samp_rate * bb_params.symbol_time) ################################################## # Blocks ################################################## # convert to unpacked self.blocks_packed_to_unpacked_xx_0 = \ blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) # convert to float self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) # stretch out waveform to match eventual samp_rate self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, self.sps) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_repeat_0, 0)) # modulate by conversion to complex stream with: # - real portion equal to baseband (1 or 0) # - imaginary portion equal to 0 self.analog_const_source_x_0 = \ analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_float_to_complex_0, 0)) # send to hier block output self.connect((self.blocks_float_to_complex_0, 0), (self, 0))
def setUp(self): self.tb = gr.top_block() print "begin setup" key = "descr_part" self.src = blocks.vector_source_f([0.0]*480, False, 480) self.rpt = blocks.repeat(gr.sizeof_float*480, 4) self.stv = blocks.stream_to_vector(gr.sizeof_float*480, 4) self.descr = lte.pbch_descrambler_vfvf(key) self.snk = blocks.vector_sink_f(120) self.tb.connect(self.src, self.rpt, self.stv, self.descr, self.snk) print "end setup"
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 __init__(self, parameter_0=0): gr.top_block.__init__(self, "gfsk_tx") ################################################## # Parameters ################################################## self.parameter_0 = parameter_0 ################################################## # Variables ################################################## self.transmission_rate = transmission_rate = 200e3 self.samp_rate = samp_rate = 4e6 ################################################## # Blocks ################################################## self.vlc_vlc_packet_source_b_0 = vlc.vlc_packet_source_b( 'vlc_gr_server') self.vlc_vlc_board_interface_b_0 = vlc.vlc_board_interface_b( '192.168.1.24', 7777, 6666, 256) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_repeat_0 = blocks.repeat( gr.sizeof_float * 1, int(samp_rate / transmission_rate * 32)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(255) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect( (self.vlc_vlc_board_interface_b_0, 'vlc_board_int_msg_out'), (self.vlc_vlc_packet_source_b_0, 'vlc_pkt_src_msg_in')) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.vlc_vlc_board_interface_b_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.vlc_vlc_packet_source_b_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self, fft_len): gr.hier_block2.__init__(self, "FFT Peak", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1])) ''' Constructor @param fft_len - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len ################################################## # Blocks ################################################## self.fft = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), False, 1) self.v2s = blocks.vector_to_stream(gr.sizeof_float*1, fft_len) self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len) self.s2f = blocks.short_to_float(1, 1) self.repeat = blocks.repeat(gr.sizeof_short*1, fft_len) self.null_0 = blocks.null_sink(gr.sizeof_float*1) self.null_1 = blocks.null_sink(gr.sizeof_short*1) self.c2mag = blocks.complex_to_mag(fft_len) self.argmax = blocks.argmax_fs(fft_len) ################################################## # Connections ################################################## self.connect((self.argmax, 1), (self.null_1, 0)) self.connect((self.argmax, 0), (self.repeat, 0)) self.connect((self.c2mag, 0), (self.argmax, 0)) self.connect((self.c2mag, 0), (self.v2s, 0)) self.connect((self.repeat, 0), (self.s2f, 0)) self.connect((self.s2f, 0), (self, 0)) self.connect((self.s2v, 0), (self.fft, 0)) self.connect((self.v2s, 0), (self.null_0, 0)) self.connect((self.v2s, 0), (self, 1)) self.connect((self.fft, 0), (self.c2mag, 0)) self.connect((self, 0), (self.s2v, 0))
def __init__(self, samp_rate, src_filename, dest_filename): gr.top_block.__init__(self, "SAME Encoder") ################################################## # Variables ################################################## self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.msg_source = blocks.file_source(1, src_filename) self.packed_to_unpacked = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.repeat = blocks.repeat(4, 96) self.chunks_to_symbols = digital.chunks_to_symbols_bf(([-1, 1]), 1) self.freq_mod = analog.frequency_modulator_fc(3.14159265 / 96) # TODO: Make amplitude adjustable self.center_freq_src = analog.sig_source_c(50000, analog.GR_COS_WAVE, 1822.916666, 0.1, 0) self.freq_mult = blocks.multiply_vcc(1) self.rational_resampler = filter.rational_resampler_ccc( interpolation=samp_rate / 100, decimation=500, taps=None, fractional_bw=None, ) self.complex_to_float = blocks.complex_to_float() self.float_to_short = blocks.float_to_short(1, 32767) self.sink = blocks.file_sink(2, dest_filename) self.sink.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.msg_source, 0), (self.packed_to_unpacked, 0), (self.chunks_to_symbols, 0)) self.connect((self.chunks_to_symbols, 0), (self.repeat, 0), (self.freq_mod, 0), (self.freq_mult, 0)) self.connect((self.center_freq_src, 0), (self.freq_mult, 1)) self.connect((self.freq_mult, 0), (self.rational_resampler, 0), (self.complex_to_float, 0)) self.connect((self.complex_to_float, 0), (self.float_to_short, 0), (self.sink, 0))
def __init__(self, vector): gr.top_block.__init__(self, "Stanley Tx") ################################################## # Variables ################################################## self.interp = interp = 1200 self.baud_rate = baud_rate = 1872 self.samp_rate = samp_rate = baud_rate*interp self.center_freq = center_freq = 433893000 ################################################## # Blocks ################################################## 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(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(40, 0) self.osmosdr_sink_0.set_bb_gain(40, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(2000000, 0) self.blocks_vector_source_x_0 = blocks.vector_source_c( (([int(v) for v in vector] + [0]*25) * 25), False, 1, [] ) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, interp) self.blocks_moving_average_xx_0 = blocks.moving_average_cc( 20, 0.9/20, 4000 ) ################################################## # Connections ################################################## self.connect( (self.blocks_moving_average_xx_0, 0), (self.osmosdr_sink_0, 0) ) self.connect( (self.blocks_repeat_0, 0), (self.blocks_moving_average_xx_0, 0) ) self.connect( (self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0) )
def oqpsktx(self, carrier=10000, samp_rate = 80000, bw=4000, amp=1, code=codes.mycode, **kwargs): code_table, code_len = codes.codes2table(code), len(code) chunk_len = int(log(code_len,2)) topblock(self, carrier, samp_rate, bw, amp) ################################################## # Blocks ################################################## self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(chunk_len, gr.GR_LSB_FIRST) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((code_table), code_len) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4) self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate/bw), decimation=1, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.sink, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=25, taps=None, fractional_bw=None, ) self.blocks_vector_source_x_0 = blocks.vector_source_c((1,1,1,0,1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,0,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0,0,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,0,1,0,0,0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,), True, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 15000) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2, )) self.blocks_file_source_1 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/pi/africube_software/iq_fifo', True) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blks2_tcp_sink_1 = grc_blks2.tcp_sink( itemsize=gr.sizeof_gr_complex*1, addr='127.0.0.1', port=8011, server=False, ) self.analog_sig_source_x_2 = analog.sig_source_c(125000, analog.GR_SIN_WAVE, 48000, 0.3, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blks2_tcp_sink_1, 0)) self.connect((self.blocks_file_source_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, carrier_freq=1080, input_path='/media/psf/Home/test.bin'): gr.top_block.__init__(self, "Fsk Modulation") ################################################## # Parameters ################################################## self.carrier_freq = carrier_freq self.input_path = input_path ################################################## # Variables ################################################## self.oversample = oversample = 1 self.samp_rate = samp_rate = 44100 self.baud = baud = 300 / oversample self.fsk_deviation_hz = fsk_deviation_hz = 100 self.SPS = SPS = samp_rate / baud ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf( ((2 * 3.14 * carrier_freq - 2 * 3.14 * fsk_deviation_hz, 2 * 3.14 * carrier_freq + 2 * 3.14 * fsk_deviation_hz)), 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/media/psf/Home/test.wav', 1, samp_rate, 16) self.blocks_vco_f_0 = blocks.vco_f(samp_rate * oversample, 1, 1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, SPS) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, input_path, False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0))
def asktx(self, carrier=32000, samp_rate = 80000, bw=1000, amp=1, code=codes.mycode, balanced=False, **kwargs): code_len = len(code) chunk_len = int(log(code_len,2)) topblock(self, carrier, samp_rate, bw, amp) ################################################## # Blocks ################################################## blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(chunk_len, gr.GR_LSB_FIRST) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((codes.codes2list(code, balanced)), len(code[0])) blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, samp_rate/bw) ################################################## # Connections ################################################## self.connect((self.source, 0), (blocks_packed_to_unpacked_xx_0, 0)) self.connect((blocks_packed_to_unpacked_xx_0, 0), (digital_chunks_to_symbols_xx_0, 0)) self.connect((digital_chunks_to_symbols_xx_0, 0), (blocks_repeat_0, 0)) self.connect((blocks_repeat_0, 0), (self.sink, 0))
def __init__( self, n_channels,burst_length, freq_delta, base_freq, seed,rate ): gr.hier_block2.__init__(self, "HoppingRx", gr.io_signature(1, 1, gr.sizeof_float), # Input Signature gr.io_signature(1, 1, gr.sizeof_gr_complex), # Output Signature ) ################################################## # Hopping Sequence ################################################## lowest_frequency = base_freq - numpy.floor(n_channels/2) * freq_delta self.hop_sequence = [lowest_frequency + n * freq_delta for n in xrange(n_channels)] random.seed(seed) lam = random.random() random.shuffle(self.hop_sequence, lambda: lam) senstivity = 2*math.pi ################################################## # Blocks ################################################## self.hop_vec = blocks.vector_source_f((self.hop_sequence), repeat=True) self.repeat_blk = blocks.repeat(gr.sizeof_float*1, burst_length) self.vco_blk = blocks.vco_c(rate,senstivity,1.0) self.null_snk = blocks.null_sink(gr.sizeof_float*1) ################################################## # Connections ################################################## self.connect((self.hop_vec,0),(self.repeat_blk,0)) self.connect((self.repeat_blk,0),(self.vco_blk,0)) self.connect((self.vco_blk,0),self) self.connect(self,(self.null_snk,0)) threshold = self
def __init__(self, n_channels, burst_length, freq_delta, base_freq, seed, rate): gr.hier_block2.__init__( self, "HoppingRx", gr.io_signature(1, 1, gr.sizeof_float), # Input Signature gr.io_signature(1, 1, gr.sizeof_gr_complex), # Output Signature ) ################################################## # Hopping Sequence ################################################## lowest_frequency = base_freq - numpy.floor(n_channels / 2) * freq_delta self.hop_sequence = [ lowest_frequency + n * freq_delta for n in xrange(n_channels) ] random.seed(seed) lam = random.random() random.shuffle(self.hop_sequence, lambda: lam) senstivity = 2 * math.pi ################################################## # Blocks ################################################## self.hop_vec = blocks.vector_source_f((self.hop_sequence), repeat=True) self.repeat_blk = blocks.repeat(gr.sizeof_float * 1, burst_length) self.vco_blk = blocks.vco_c(rate, senstivity, 1.0) self.null_snk = blocks.null_sink(gr.sizeof_float * 1) ################################################## # Connections ################################################## self.connect((self.hop_vec, 0), (self.repeat_blk, 0)) self.connect((self.repeat_blk, 0), (self.vco_blk, 0)) self.connect((self.vco_blk, 0), self) self.connect(self, (self.null_snk, 0)) threshold = self
def __init__(self, txstr="Hello world", carrier=32000, samp_rate = 80000, bw=1000, amp=1): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.carrier = carrier self.bw = bw ################################################## # Blocks ################################################## self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, []) blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([0,1,1,0]), 2) blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, samp_rate/bw) #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0) blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) blocks_complex_to_real_0 = blocks.complex_to_real(1) audio_sink_0 = audio.sink(samp_rate, "") self.samp_blocks = [self.source, blocks_repeat_0, analog_sig_source_x_0, audio_sink_0] ################################################## # Connections ################################################## self.connect((self.source, 0), (blocks_packed_to_unpacked_xx_0, 0)) self.connect((blocks_packed_to_unpacked_xx_0, 0), (digital_chunks_to_symbols_xx_0, 0)) self.connect((digital_chunks_to_symbols_xx_0, 0), (blocks_repeat_0, 0)) self.connect((blocks_repeat_0, 0), (blocks_multiply_xx_0_0, 0)) self.connect((analog_sig_source_x_0, 0), (blocks_multiply_xx_0_0, 1)) self.connect((blocks_multiply_xx_0_0, 0), (blocks_complex_to_real_0, 0)) self.connect((blocks_complex_to_real_0, 0), (audio_sink_0, 0))
def __init__(self, spread_seq=(-1, 1) ): gr.hier_block2.__init__( self, "Variable Symbol Rate Modulation Modulator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.spread_seq = spread_seq ################################################## # Variables ################################################## ################################################## # Blocks ################################################## self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, len(spread_seq)) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, len(spread_seq)) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, len(spread_seq)) self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(gr.sizeof_gr_complex*1, ([0] + [1]*len(spread_seq))) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((spread_seq)) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_deinterleave_0, 0), (self.blocks_patterned_interleaver_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_patterned_interleaver_0, 0), (self, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_patterned_interleaver_0, 1)) self.connect((self, 0), (self.blocks_deinterleave_0, 0))
def __init__(self, context, mode, rtty_baud=_DEFAULT_BAUD, rtty_shift=170.0, message='\0'): gr.hier_block2.__init__( self, type(self).__name__, gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1)) encoded_message = map(float, _encode_rtty_alloc(map(ord, message))) # TODO char encoding issues half_bit_rate = rtty_baud * 2 wanted_bandwidth = rtty_shift * 1.5 sample_rate_as_half_bits = int(math.ceil(wanted_bandwidth / half_bit_rate)) self.__sample_rate_out = sample_rate_as_half_bits * half_bit_rate self.__char_rate = half_bit_rate / _HALF_BITS_PER_CODE self.__baud = rtty_baud self.connect( blocks.vector_source_f(encoded_message, repeat=True), # RTTYEncoder(), blocks.repeat(gr.sizeof_float, sample_rate_as_half_bits), blocks.add_const_ff(-0.5), analog.frequency_modulator_fc((2 * math.pi) * rtty_shift / self.__sample_rate_out), self)
def __init__(self, samplerate, bits_per_sec, fftlen): gr.hier_block2.__init__(self, "square_and_fft_sync_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature #this is just the old square-and-fft method #ais.freqest is simply looking for peaks spaced bits-per-sec apart self.square = blocks.multiply_cc(1) self.fftvect = blocks.stream_to_vector(gr.sizeof_gr_complex, fftlen) self.fft = fft.fft_vcc(fftlen, True, window.rectangular(fftlen), True) self.freqest = ais.freqest(int(samplerate), int(bits_per_sec), fftlen) self.repeat = blocks.repeat(gr.sizeof_float, fftlen) self.fm = analog.frequency_modulator_fc(-1.0/(float(samplerate)/(2*pi))) self.mix = blocks.multiply_cc(1) self.connect(self, (self.square, 0)) self.connect(self, (self.square, 1)) #this is the feedforward branch self.connect(self, (self.mix, 0)) #this is the feedback branch self.connect(self.square, self.fftvect, self.fft, self.freqest, self.repeat, self.fm, (self.mix, 1)) #and this is the output self.connect(self.mix, self)
def __init__(self, samp_per_bit, samp_rate, spacing, taps=None): gr.hier_block2.__init__( self, "FM FSK Modulator", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.samp_per_bit = samp_per_bit self.samp_rate = samp_rate self.spacing = spacing self.taps = taps ################################################## # Blocks ################################################## self._repeat = blocks.repeat(gr.sizeof_char, samp_per_bit) self._char_to_float = blocks.char_to_float(1, 1) self._add = blocks.add_const_vff((-1.0, )) self._filter = interp_fir_filter_fff(1, self._taps()) self._fm_mod = frequency_modulator_fc(self._fm_mod_sensitivity()) ################################################## # Connections ################################################## self.connect( self, self._repeat, self._char_to_float, self._add, self._filter, self._fm_mod, self, )
def __init__(self, dev_type="UHD", dev_addr="", dip_conf="10101", socket="A", func="on", gain=33): gr.top_block.__init__(self) ################################################## # Parameters ################################################## self.dev_type = dev_type self.dev_addr = dev_addr self.dip_conf = dip_conf self.func = func self.socket = socket self.gain = gain ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e5 ################################################## # Blocks ################################################## #self.init_device() self.device = None self.build_signal() self.gr_vector_source_x_0 = blocks.vector_source_c(self.signal, False, 1) self.gr_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 125) self.gr_freq_xlating_fir_filter_xxx_0 = gr_filter.freq_xlating_fir_filter_ccf(1, (1, ), -180e3, samp_rate) ################################################## # Connections ################################################## #self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.device, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_repeat_0, 0)) self.connect((self.gr_repeat_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.down_sampling = down_sampling = 16 self.sample_rate = sample_rate = 250e3*down_sampling self.preamble_len_tag = preamble_len_tag = gr.tag_utils.python_to_tag((0, pmt.intern("packet_len"), pmt.from_long(8), pmt.intern("src"))) self.f1_bp_taps = f1_bp_taps = [-0.008489873260259628, 0.017516516149044037, -0.02309376560151577, 3.1378305752533504e-17, 0.06292477995157242, -0.12457011640071869, 0.1126808300614357, -3.387264241990756e-17, -0.14707811176776886, 0.21481703221797943, -0.14707811176776886, -3.387264241990756e-17, 0.1126808300614357, -0.12457011640071869, 0.06292477995157242, 3.1378305752533504e-17, -0.02309376560151577, 0.017516516149044037, -0.008489873260259628] self.f0_bp_taps = f0_bp_taps = [0.008489873260259628, 0.017516516149044037, 0.02309376560151577, -1.1766864243609758e-17, -0.06292477995157242, -0.12457011640071869, -0.1126808300614357, 3.387264241990756e-17, 0.14707811176776886, 0.21481703221797943, 0.14707811176776886, 3.387264241990756e-17, -0.1126808300614357, -0.12457011640071869, -0.06292477995157242, -1.1766864243609758e-17, 0.02309376560151577, 0.017516516149044037, 0.008489873260259628] ################################################## # Blocks ################################################## self.rad1o_id_compare_select_fb_0 = rad1o_id.compare_select_fb() self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size sample_rate/down_sampling, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] 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*2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -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_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate/down_sampling, #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_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fir_filter_xxx_1_0 = filter.fir_filter_fff(down_sampling/2, (1, )) self.fir_filter_xxx_1_0.declare_sample_delay(0) self.fir_filter_xxx_1 = filter.fir_filter_fff(down_sampling/2, (1, )) self.fir_filter_xxx_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(down_sampling/2, (f1_bp_taps)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(down_sampling/2, (f0_bp_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([0.5, 1.5]), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=100e-2, frequency_offset=1e-4, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True ) self.blocks_vector_source_x_1 = blocks.vector_source_b((0,0), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([0,0], True, 1, [preamble_len_tag]) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, "packet_len", 0) self.blocks_tagged_stream_align_1 = blocks.tagged_stream_align(gr.sizeof_char*1, "packet_len") self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "packet_length", ""); self.blocks_tag_debug_0.set_display(False) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 64, "packet_len") self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, 16) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*pi/4) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.fir_filter_xxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_tagged_stream_align_1, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_tagged_stream_align_1, 0)) self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_1, 0), (self.rad1o_id_compare_select_fb_0, 0)) self.connect((self.fir_filter_xxx_1_0, 0), (self.rad1o_id_compare_select_fb_0, 1)) self.connect((self.rad1o_id_compare_select_fb_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self, rxPort=52002, txPort=52001): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.rxPort = rxPort self.txPort = txPort ################################################## # Variables ################################################## self.localOscillator = localOscillator = 14070000 self.threshold = threshold = -200 self.samp_rate = samp_rate = 48000 self.rxPhase = rxPhase = .84 self.rxMagnitude = rxMagnitude = 0.854 self.freqFine = freqFine = 0 self.freq = freq = localOscillator self.bandwidth = bandwidth = 50 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope") self.Add(self.notebook_0) _freqFine_sizer = wx.BoxSizer(wx.VERTICAL) self._freqFine_text_box = forms.text_box( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._freqFine_slider = forms.slider( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freqFine_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=localOscillator-samp_rate, maximum=localOscillator+samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, label="Signal Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, minimum=30, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bandwidth_sizer) self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=localOscillator, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76)) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001) self.blocks_transcendental_1 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25) self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25)) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=txPort, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=rxPort, server=False, ) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self, options): gr.hier_block2.__init__( self, "fbmc_transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex) ) common_options.defaults(options) config = self.config = station_configuration() config.data_subcarriers = options.subcarriers config.cp_length = 0 config.frame_data_blocks = options.data_blocks config._verbose = options.verbose config.fft_length = options.fft_length config.dc_null = options.dc_null config.training_data = default_block_header(config.data_subcarriers, config.fft_length, config.dc_null, options) config.coding = options.coding config.fbmc = options.fbmc config.adaptive_fbmc = options.adaptive_fbmc config.frame_id_blocks = 1 # FIXME # digital rms amplitude sent to USRP rms_amp = options.rms_amplitude self._options = copy.copy(options) config.block_length = config.fft_length + config.cp_length config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks config.frame_length = config.training_data.fbmc_no_preambles + 2 * config.frame_data_part config.subcarriers = config.data_subcarriers + config.training_data.pilot_subcarriers config.virtual_subcarriers = config.fft_length - config.subcarriers - config.dc_null # default values if parameters not set if rms_amp is None: rms_amp = math.sqrt(config.subcarriers) config.rms_amplitude = rms_amp # check some bounds if config.fft_length < config.subcarriers: raise SystemError, "Subcarrier number must be less than FFT length" if config.fft_length < config.cp_length: raise SystemError, "Cyclic prefix length must be less than FFT length" ## shortcuts blen = config.block_length flen = config.frame_length dsubc = config.data_subcarriers vsubc = config.virtual_subcarriers # Adaptive Transmitter Concept used_id_bits = config.used_id_bits = 8 # TODO: no constant in source code rep_id_bits = config.rep_id_bits = config.data_subcarriers / used_id_bits # BPSK if config.data_subcarriers % used_id_bits <> 0: raise SystemError, "Data subcarriers need to be multiple of %d" % (used_id_bits) ## Allocation Control self.allocation_src = allocation_src( config.data_subcarriers, config.frame_data_blocks, config.coding, "tcp://*:3333", "tcp://" + options.rx_hostname + ":3322", ) if options.static_allocation: # DEBUG # how many bits per subcarrier if options.coding: mode = 1 # Coding mode 1-9 bitspermode = [0.5, 1, 1.5, 2, 3, 4, 4.5, 5, 6] # Information bits per mode modulbitspermode = [1, 2, 2, 4, 4, 6, 6, 6, 8] # Coding bits per mode bitcount_vec = [(int)(config.data_subcarriers * config.frame_data_blocks * bitspermode[mode - 1])] modul_bitcount_vec = [config.data_subcarriers * config.frame_data_blocks * modulbitspermode[mode - 1]] bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1) modul_bitcount_src = blocks.vector_source_i(modul_bitcount_vec, True, 1) bitloading = mode else: bitloading = 1 bitcount_vec = [config.data_subcarriers * config.frame_data_blocks * bitloading] bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1) modul_bitcount_src = bitcount_src # id's for frames id_vec = range(0, 256) id_src = blocks.vector_source_s(id_vec, True, 1) # bitloading for ID symbol and then once for data symbols # bitloading_vec = [1]*dsubc+[0]*(dsubc/2)+[2]*(dsubc/2) test_allocation = ( [bitloading] * (int)(config.data_subcarriers / 8) + [0] * (int)(config.data_subcarriers / 4 * 3) + [bitloading] * (int)(config.data_subcarriers / 8) ) # bitloading_vec = [1]*dsubc+[bitloading]*dsubc bitloading_vec = [1] * dsubc + test_allocation bitloading_src = blocks.vector_source_b(bitloading_vec, True, dsubc) # bitcount for frames # bitcount_vec = [config.data_subcarriers*config.frame_data_blocks*bitloading] bitcount_vec = [config.frame_data_blocks * sum(test_allocation)] bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1) # power loading, here same for all symbols power_vec = ( [1] * (int)(config.data_subcarriers / 8) + [0] * (int)(config.data_subcarriers / 4 * 3) + [1] * (int)(config.data_subcarriers / 8) ) power_src = blocks.vector_source_f(power_vec, True, dsubc) # mux control stream to mux id and data bits mux_vec = [0] * dsubc + [1] * bitcount_vec[0] mux_ctrl = blocks.vector_source_b(mux_vec, True, 1) else: id_src = (self.allocation_src, 0) bitcount_src = (self.allocation_src, 4) bitloading_src = (self.allocation_src, 2) power_src = (self.allocation_src, 1) if options.coding: modul_bitcount_src = (self.allocation_src, 5) else: modul_bitcount_src = bitcount_src mux_ctrl = ofdm.tx_mux_ctrl(dsubc) self.connect(modul_bitcount_src, mux_ctrl) # Initial allocation self.allocation_src.set_allocation([4] * config.data_subcarriers, [1] * config.data_subcarriers) if options.benchmarking: self.allocation_src.set_allocation([4] * config.data_subcarriers, [1] * config.data_subcarriers) if options.lab_special_case: self.allocation_src.set_allocation( [0] * (config.data_subcarriers / 4) + [2] * (config.data_subcarriers / 2) + [0] * (config.data_subcarriers / 4), [1] * config.data_subcarriers, ) if options.log: log_to_file(self, id_src, "data/id_src.short") log_to_file(self, bitcount_src, "data/bitcount_src.int") log_to_file(self, bitloading_src, "data/bitloading_src.char") log_to_file(self, power_src, "data/power_src.cmplx") ## GUI probe output zmq_probe_bitloading = zeromq.pub_sink(gr.sizeof_char, dsubc, "tcp://*:4445") # also skip ID symbol bitloading with keep_one_in_n (side effect) # factor 2 for bitloading because we have two vectors per frame, one for id symbol and one for all payload/data symbols # factor config.frame_data_part for power because there is one vector per ofdm symbol per frame self.connect(bitloading_src, blocks.keep_one_in_n(gr.sizeof_char * dsubc, 2 * 40), zmq_probe_bitloading) zmq_probe_power = zeromq.pub_sink(gr.sizeof_float, dsubc, "tcp://*:4444") # self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_gr_complex*dsubc,40), blocks.complex_to_real(dsubc), zmq_probe_power) self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_float * dsubc, 40), zmq_probe_power) ## Workaround to avoid periodic structure seed(1) whitener_pn = [randint(0, 1) for i in range(used_id_bits * rep_id_bits)] ## ID Encoder id_enc = self._id_encoder = repetition_encoder_sb(used_id_bits, rep_id_bits, whitener_pn) self.connect(id_src, id_enc) if options.log: id_enc_f = gr.char_to_float() self.connect(id_enc, id_enc_f) log_to_file(self, id_enc_f, "data/id_enc_out.float") ## Reference Data Source ber_ref_src = ber_reference_source(self._options) self.connect(id_src, (ber_ref_src, 0)) self.connect(bitcount_src, (ber_ref_src, 1)) if options.log: log_to_file(self, ber_ref_src, "data/ber_rec_src_tx.char") if options.log: log_to_file(self, btrig, "data/bitmap_trig.char") ## Frame Trigger ftrig_stream = [1] + [0] * (config.frame_data_part - 1) ftrig = self._frame_trigger = blocks.vector_source_b(ftrig_stream, True) ## Data Multiplexer # Input 0: control stream # Input 1: encoded ID stream # Inputs 2..n: data streams dmux = self._data_multiplexer = stream_controlled_mux_b() self.connect(mux_ctrl, (dmux, 0)) self.connect(id_enc, (dmux, 1)) if options.coding: fo = trellis.fsm(1, 2, [91, 121]) encoder = self._encoder = trellis.encoder_bb(fo, 0) unpack = self._unpack = blocks.unpack_k_bits_bb(2) self.connect(ber_ref_src, encoder, unpack) if options.interleave: int_object = trellis.interleaver(2000, 666) interlv = trellis.permutation(int_object.K(), int_object.INTER(), 1, gr.sizeof_char) if not options.nopunct: bmaptrig_stream_puncturing = [1] + [0] * (config.frame_data_blocks / 2 - 1) btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b( bmaptrig_stream_puncturing, True ) puncturing = self._puncturing = puncture_bb(config.data_subcarriers) self.connect(bitloading_src, (puncturing, 1)) self.connect(self._bitmap_trigger_puncturing, (puncturing, 2)) self.connect(unpack, puncturing) last_block = puncturing if options.interleave: self.connect(last_block, interlv) last_block = interlv if options.benchmarking: self.connect(last_block, blocks.head(gr.sizeof_char, options.N), (dmux, 2)) else: self.connect(last_block, (dmux, 2)) else: if options.benchmarking: self.connect(unpack, blocks.head(gr.sizeof_char, options.N), (dmux, 2)) else: self.connect(unpack, (dmux, 2)) else: if options.benchmarking: self.connect(ber_ref_src, blocks.head(gr.sizeof_char, options.N), (dmux, 2)) else: self.connect(ber_ref_src, (dmux, 2)) if options.log: dmux_f = gr.char_to_float() self.connect(dmux, dmux_f) log_to_file(self, dmux_f, "data/dmux_out.float") ## Modulator mod = self._modulator = generic_mapper_bcv(config.data_subcarriers, config.coding, config.frame_data_part) self.connect(dmux, (mod, 0)) self.connect(bitloading_src, (mod, 1)) if options.log: log_to_file(self, mod, "data/mod_out.compl") modi = blocks.complex_to_imag(config.data_subcarriers) modr = blocks.complex_to_real(config.data_subcarriers) self.connect(mod, modi) self.connect(mod, modr) log_to_file(self, modi, "data/mod_imag_out.float") log_to_file(self, modr, "data/mod_real_out.float") ## Power allocator pa = self._power_allocator = multiply_frame_fc(config.frame_data_part, config.data_subcarriers) self.connect(mod, (pa, 0)) self.connect(power_src, (pa, 1)) if options.log: log_to_file(self, pa, "data/pa_out.compl") if options.fbmc: psubc = pa else: psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter() self.connect(pa, psubc) if options.log: log_to_file(self, psubc, "data/psubc_out.compl") subcarriers = config.subcarriers # fbmc_pblocks_timing = self._fbmc_timing_pilot_block_inserter = fbmc_timing_pilot_block_inserter(5,False) oqam_prep = self._oqam_prep = fbmc_oqam_preprocessing_vcvc(config.subcarriers, 0, 0) self.connect(psubc, oqam_prep) fbmc_pblocks = self._fbmc_pilot_block_inserter = fbmc_pilot_block_inserter(5, False) self.connect(oqam_prep, fbmc_pblocks) # log_to_file(self, fbmc_pblocks, "data/fbmc_pblocks_out.compl") # fbmc_insert_pream = self._fbmc_insert_pream = fbmc_insert_preamble_vcvc(M, syms_per_frame, preamble) # log_to_file(self, oqam_prep, "data/oqam_prep.compl") # log_to_file(self, psubc, "data/psubc_out.compl") # fbmc_pblocks = fbmc_pblocks_timing # log_to_file(self, fbmc_pblocks, "data/fbmc_pblocks_out.compl") beta_mult = self._beta_mult = fbmc_beta_multiplier_vcvc(config.subcarriers, 4, 4 * config.fft_length - 1, 0) self.connect(fbmc_pblocks, beta_mult) log_to_file(self, beta_mult, "data/beta_mult.compl") ## Add virtual subcarriers if config.fft_length > subcarriers: vsubc = self._virtual_subcarrier_extender = vector_padding_dc_null( config.subcarriers, config.fft_length, config.dc_null ) self.connect(beta_mult, vsubc) else: vsubc = self._virtual_subcarrier_extender = beta_mult if options.log: log_to_file(self, vsubc, "data/vsubc_out.compl") ## IFFT, no window, block shift ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length, False, [], True) self.connect(vsubc, ifft) if options.log: log_to_file(self, ifft, "data/ifft_out.compl") # FBMC separate stream + filterbanks separate_oqam = self._separate_oqam = fbmc_separate_vcvc(config.fft_length, 2) poly_netw_1 = self._poly_netw_1 = fbmc_polyphase_network_vcvc( config.fft_length, 4, 4 * config.fft_length - 1, False ) poly_netw_2 = self._poly_netw_2 = fbmc_polyphase_network_vcvc( config.fft_length, 4, 4 * config.fft_length - 1, False ) overlap_p2s = self._overlap_p2s = fbmc_overlapping_parallel_to_serial_vcc(config.fft_length) self.connect(ifft, (separate_oqam, 0), poly_netw_1) self.connect((separate_oqam, 1), poly_netw_2) self.connect(poly_netw_1, (overlap_p2s, 0)) self.connect(poly_netw_2, (overlap_p2s, 1)) ## Pilot blocks (preambles) # pblocks = self._pilot_block_inserter = pilot_block_inserter2(5,False) # self.connect( overlap_p2s, blocks.stream_to_vector(gr.sizeof_gr_complex,config.fft_length/2), pblocks ) # log_to_file(self, pblocks, "data/fbmc_pilot_block_ins_out.compl") if options.log: log_to_file(self, pblocks, "data/pilot_block_ins_out.compl") ## Cyclic Prefix # cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length, # config.block_length) # cp= blocks.vector_to_stream(gr.sizeof_gr_complex, config.fft_length/2) # self.connect(pblocks, cp ) # self.connect( overlap_p2s,blocks.stream_to_vector(gr.sizeof_gr_complex,config.fft_length/2), cp ) lastblock = overlap_p2s if options.log: log_to_file(self, overlap_p2s, "data/overlap_p2s_out.compl") # Digital Amplifier for resource allocation if config.adaptive_fbmc: rep = blocks.repeat(gr.sizeof_gr_complex, config.frame_length * config.block_length) amp = blocks.multiply_cc() self.connect(lastblock, (amp, 0)) self.connect((self.allocation_src, 3), rep, (amp, 1)) lastblock = amp else: self.connect((self.allocation_src, 3), blocks.null_sink(gr.sizeof_gr_complex)) ## Digital Amplifier # amp = self._amplifier = gr.multiply_const_cc(1) amp = self._amplifier = ofdm.multiply_const_ccf(1.0) self.connect(lastblock, amp) self.set_rms_amplitude(rms_amp) # log_to_file(self, amp, "data/amp_tx_out.compl") if options.log: log_to_file(self, amp, "data/amp_tx_out.compl") ## Tx parameters bandwidth = options.bandwidth or 2e6 bits = 8 * config.data_subcarriers * config.frame_data_blocks # max. QAM256 samples_per_frame = config.frame_length * config.block_length tb = samples_per_frame / bandwidth # set dummy carrier frequency if none available due to baseband mode if options.tx_freq is None: options.tx_freq = 0.0 self.tx_parameters = { "carrier_frequency": options.tx_freq / 1e9, "fft_size": config.fft_length, "cp_size": config.cp_length, "subcarrier_spacing": options.bandwidth / config.fft_length / 1e3, "data_subcarriers": config.data_subcarriers, "bandwidth": options.bandwidth / 1e6, "frame_length": config.frame_length, "symbol_time": (config.cp_length + config.fft_length) / options.bandwidth * 1e6, "max_data_rate": (bits / tb) / 1e6, } ## Setup Output self.connect(amp, self) # Display some information about the setup if config._verbose: self._print_verbage()
def __init__(self, freq=88.5e6, gain=30, input_gain=.3, pilot_gain=.09, ps="DEFCON", rds_gain=.1, stereo_gain=.3, wavfile=""): gr.top_block.__init__(self, "Slackradio") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.input_gain = input_gain self.pilot_gain = pilot_gain self.ps = ps self.rds_gain = rds_gain self.stereo_gain = stereo_gain self.wavfile = wavfile ################################################## # Variables ################################################## self.usrp_rate = usrp_rate = 19e3*20 self.outbuffer = outbuffer = 1024 self.fm_max_dev = fm_max_dev = 80e3 ################################################## # Blocks ################################################## self.uhd_usrp_sink = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(1e6) self.uhd_usrp_sink.set_center_freq(freq, 0) self.uhd_usrp_sink.set_gain(gain, 0) self.uhd_usrp_sink.set_antenna("TX/RX", 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=100, decimation=38, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=380, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=380, decimation=48, taps=None, fractional_bw=None, ) self.low_pass_filter_0_0_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 2.5e3, .5e3, firdes.WIN_HAMMING, 6.76)) (self.low_pass_filter_0).set_max_output_buffer(1024) self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) (self.gr_unpack_k_bits_bb_0).set_max_output_buffer(4096) self.gr_sub_xx_0 = blocks.sub_ff(1) self.gr_sig_source_x_0_1 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 19e3, 1, 0) self.gr_sig_source_x_0_0 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 57e3, 1, 0) self.gr_sig_source_x_0 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 38e3, 1, 0) self.gr_rds_encoder_0 = rds.encoder(1, 8, True, ps, 89.8e6, True, False, 13, 3, 147, "CYBERSPECTRUM") (self.gr_rds_encoder_0).set_max_output_buffer(4096) self.gr_multiply_xx_1 = blocks.multiply_vff(1) self.gr_multiply_xx_0 = blocks.multiply_vff(1) (self.gr_multiply_xx_0).set_max_output_buffer(1024) self.gr_map_bb_1 = digital.map_bb(([1,2])) (self.gr_map_bb_1).set_max_output_buffer(4096) self.gr_map_bb_0 = digital.map_bb(([-1,1])) (self.gr_map_bb_0).set_max_output_buffer(4096) self.gr_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*fm_max_dev/usrp_rate) (self.gr_frequency_modulator_fc_0).set_max_output_buffer(1024) self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2) (self.gr_diff_encoder_bb_0).set_max_output_buffer(4096) self.gr_char_to_float_0 = blocks.char_to_float(1, 1) (self.gr_char_to_float_0).set_max_output_buffer(1024) self.gr_add_xx_1 = blocks.add_vff(1) (self.gr_add_xx_1).set_max_output_buffer(1024) self.gr_add_xx_0 = blocks.add_vff(1) self.blocks_wavfile_source_0 = blocks.wavfile_source(wavfile, True) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, 160) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((input_gain, )) self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((pilot_gain, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((rds_gain, )) (self.blocks_multiply_const_vxx_0_0).set_max_output_buffer(1024) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((input_gain, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.gr_rds_encoder_0, 'rds in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.gr_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_add_xx_1, 2)) self.connect((self.gr_rds_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sig_source_x_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1, 0)) self.connect((self.gr_sub_xx_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 3)) self.connect((self.low_pass_filter_0_0_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.uhd_usrp_sink, 0))
def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'): grc_wxgui.top_block_gui.__init__(self, title="Uplink") ################################################## # Parameters ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym self.nominal_uplink_freq = nominal_uplink_freq self.lo_off = lo_off self.tx_gain = tx_gain self.backoff = backoff self.record_path = record_path ################################################## # Variables ################################################## self.time_format = time_format = "%Y-%d-%m_%H-%M-%S" self.time_now = time_now = time.strftime(time_format) self.samp_rate = samp_rate = 250000 self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym self.f1 = f1 = 9000.0 self.f0 = f0 = 7500.0 self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate) self.pm = pm = 1.2*0 + 1.0 self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq self.manual_doppler = manual_doppler = 0 self.file_name = file_name = time_now + ".mcfile" self.doppler = doppler = 0 self.deviation = deviation = (f1 - f0) / 2.0 self.tx_gain_user = tx_gain_user = tx_gain self.subcarrier_freq = subcarrier_freq = f0 + deviation self.source = source = 'external' self.pm_txt = pm_txt = pm self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser self.lo_off_user = lo_off_user = lo_off self.length_mul = length_mul = float(samp_per_sym) * resamp_rate self.invert = invert = 1 self.final_record_path = final_record_path = os.path.join(record_path, file_name) self.final_doppler = final_doppler = doppler + manual_doppler self.backoff_user = backoff_user = backoff ################################################## # Blocks ################################################## _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._tx_gain_user_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, minimum=0, maximum=32, num_steps=32, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_user_sizer) self._nominal_uplink_freq_user_text_box = forms.text_box( parent=self.GetWin(), value=self.nominal_uplink_freq_user, callback=self.set_nominal_uplink_freq_user, label="Nominal Uplink Freq", converter=forms.float_converter(), ) self.Add(self._nominal_uplink_freq_user_text_box) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input") self.Add(self.nb) self._lo_off_user_text_box = forms.text_box( parent=self.GetWin(), value=self.lo_off_user, callback=self.set_lo_off_user, label="LO Offset", converter=forms.float_converter(), ) self.Add(self._lo_off_user_text_box) self._final_doppler_static_text = forms.static_text( parent=self.GetWin(), value=self.final_doppler, callback=self.set_final_doppler, label="Final Doppler", converter=forms.float_converter(), ) self.Add(self._final_doppler_static_text) self._doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.doppler, callback=self.set_doppler, label="Doppler Shift", converter=forms.float_converter(), ) self.Add(self._doppler_text_box) _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL) self._backoff_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, label="Backoff", converter=forms.float_converter(), proportion=0, ) self._backoff_user_slider = forms.slider( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_backoff_user_sizer) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.nb.GetPage(5).GetWin(), title="Scope Plot", sample_rate=pre_resamp_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.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).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.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=256, fft_rate=10, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, fft_in=False, always_run=False, fft_out=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F4A7C3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "", True, ) self.uhd_usrp_sink_0.set_clock_source(source, 0) self.uhd_usrp_sink_0.set_time_source(source, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0) self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(pre_resamp_rate), taps=None, fractional_bw=None, ) self._pm_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.pm_txt, callback=self.set_pm_txt, label="Phase Moduation Index", converter=forms.float_converter(), ) self.Add(self._pm_txt_static_text) self._nominal_uplink_freq_chooser_chooser = forms.drop_down( parent=self.GetWin(), value=self.nominal_uplink_freq_chooser, callback=self.set_nominal_uplink_freq_chooser, label="Nomial Uplink Frequency", choices=[2041.9479e6, 2090.66e6], labels=['B: 2041.9479', 'A: 2090.66'], ) self.Add(self._nominal_uplink_freq_chooser_chooser) self._manual_doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.manual_doppler, callback=self.set_manual_doppler, label="Manual Doppler", converter=forms.float_converter(), ) self.Add(self._manual_doppler_text_box) self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False) self.clock_and_data = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=pre_resamp_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.nb.GetPage(3).Add(self.clock_and_data.win) self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [1] * (samp_per_sym/4)), True, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.binary_to_pdu0 = isee3.binary_to_pdu() self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0) self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0) ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in") self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Direct-sequence spread spectrum") ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal ", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0_0.win, 2, 3, 1, 2) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Received DS Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 1, 1, 2) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1000) self.Spread_sync_0 = Spread.sync() self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_preamble_0 = Spread.preamble_bb(1389, (64*(1, 1))) self.Spread_msg_source_0 = Spread.msg_source(100, 100) self.Spread_framer_0 = Spread.framer(0) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader(samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.Spread_sync_0, 0), (self.Spread_preamble_0, 0)) self.connect((self.Spread_preamble_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.Spread_framer_0, "out", self.Spread_sync_0, "in") self.msg_connect(self.Spread_msg_source_0, "out", self.Spread_framer_0, "in") self.msg_connect(self.Spread_rx_sync_0, "out", self.Spread_deframer_0, "in")
def __init__(self): 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.Nt = Nt = 2 self.dft_coef = dft_coef = np.exp(-2*np.pi*1j/Nt) self.A = A = np.arange(Nt)[np.newaxis] self.tlen = tlen = 4000 self.samp_rate = samp_rate = 100000 self.dft_matrix = dft_matrix = np.power(dft_coef, np.dot(A.transpose(),A)) self.scramble_2 = scramble_2 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1 self.scramble_1 = scramble_1 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1 self.prefix = prefix = '/home/zhe/gr-PWF/examples' self.noise = noise = [np.identity(Nt), np.identity(Nt)] self.max_iteration = max_iteration = 20 self.interpo = interpo = samp_rate/1000 self.dft_pilot_seq = dft_pilot_seq = np.tile(dft_matrix,(tlen/Nt,1)) self.Q = Q = 4 self.L = L = 2 self.sigmagenfile = sigmagenfile = prefix+'/sigmagens/sigmagen_10.bin' self.pulse = pulse = filter.firdes.root_raised_cosine(Q,Q,1,0.35,11*Q) self.prewhiten1 = prewhiten1 = np.linalg.pinv(noise[1]) self.prewhiten0 = prewhiten0 = np.linalg.pinv(noise[0]) self.pilot_seq_2 = pilot_seq_2 = np.multiply(dft_pilot_seq,scramble_2) self.pilot_seq_1 = pilot_seq_1 = np.multiply(dft_pilot_seq,scramble_1) self.pilot2file = pilot2file = prefix+'/pilots/pilot2_4000.bin' self.pilot1file = pilot1file = prefix+'/pilots/pilot1_4000.bin' self.payload_size = payload_size = 0 self.npoints = npoints = max_iteration*interpo self.noise_hat = noise_hat = [np.identity(Nt), np.identity(Nt)] self.ichn_gain_dB = ichn_gain_dB = 10 self.channelfile = channelfile = prefix+'/channels/2x2channel_10dB_3.bin' self.channel = channel = np.true_divide(np.random.standard_normal(size=(L,L,Nt,Nt))+np.random.standard_normal(size=(L,L,Nt,Nt))*1j,np.sqrt(2)) self.Pt = Pt = 100 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( npoints, #size samp_rate, #samp_rate "Strong Interference (ichn_gain = 10dB)", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.1) self.qtgui_time_sink_x_0.set_y_axis(0, 20) self.qtgui_time_sink_x_0.set_y_label("Weighted Sum-Rate (bits/s/Hz)", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["Dual Link", "Identity Sigma", "", "", "", "", "", "", "", ""] 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.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.phase_corrector_0_2 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_1[:,0], ) self.phase_corrector_0_1_0 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_2[:,0], ) self.phase_corrector_0_1 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_2[:,0], ) self.phase_corrector_0_0_1 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_1[:,1], ) self.phase_corrector_0_0_0_0 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_2[:,1], ) self.phase_corrector_0_0_0 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_2[:,1], ) self.phase_corrector_0_0 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_1[:,1], ) self.phase_corrector_0 = phase_corrector( loop_bandwidth=2*np.pi*0.005, max_freq=2*np.pi*0.01, training_sequence=pilot_seq_1[:,0], ) self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccc(Q, (pulse)) self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_ccc(Q, (pulse)) self.interp_fir_filter_xxx_0_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(Q, (pulse)) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(Q, (pulse)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(Q, (pulse)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, (pulse)) self.fir_filter_xxx_0_0_0.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, (pulse)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(Q, (pulse)) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_vector_to_streams_1_2 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2) self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*4, 2) self.blocks_udp_source_1 = blocks.udp_source(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True) self.blocks_udp_sink_1_0 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True) self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True) self.blocks_streams_to_vector_1_2 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2) self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2) self.blocks_streams_to_vector_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, interpo) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, interpo) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*8, "/home/zhe/Dropbox/gnuradio_trunk/gnufiles/udp", False) self.blocks_file_sink_0.set_unbuffered(True) self.PWF_weighted_sum_rate_0 = PWF.weighted_sum_rate(L, Nt, Pt, channel, ichn_gain_dB, [1,1],[prewhiten0 ,prewhiten1], False, channelfile) self.PWF_sigmagen_0 = PWF.sigmagen(L, Nt, Pt, True, sigmagenfile) self.PWF_power_adjust_1_0 = PWF.power_adjust(Nt, Pt, L) self.PWF_power_adjust_1 = PWF.power_adjust(Nt, Pt, L) self.PWF_pilot_receive_tx_0_0 = PWF.pilot_receive_tx(True, pilot1file, pilot_seq_1, Nt, tlen,noise_hat[0], tlen, 1) self.PWF_pilot_receive_tx_0 = PWF.pilot_receive_tx(True, pilot2file, pilot_seq_2, Nt, tlen,noise_hat[1], tlen, 1) self.PWF_pilot_receive_rx_0_0 = PWF.pilot_receive_rx(True, pilot2file, pilot_seq_2, prewhiten1, Nt, tlen, tlen+payload_size, 1) self.PWF_pilot_receive_rx_0 = PWF.pilot_receive_rx(True, pilot1file, pilot_seq_1, prewhiten0, Nt, tlen, tlen+payload_size, 1) self.PWF_pilot_gen_tx_0_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_2, True, pilot2file) self.PWF_pilot_gen_tx_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_1, True, pilot1file) self.PWF_pilot_gen_rx_0_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten0, pilot_seq_1, True, pilot1file) self.PWF_pilot_gen_rx_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten1, pilot_seq_2, True, pilot2file) self.PWF_debug_printmsg_0 = PWF.debug_printmsg(L, Nt, False, 20) self.PWF_channel_1 = PWF.channel(L, Nt, ichn_gain_dB, channel, False,noise_hat, False, channelfile) self.PWF_channel_0 = PWF.channel(L, Nt, ichn_gain_dB, channel, True,noise, True, channelfile) ################################################## # Connections ################################################## self.connect((self.PWF_channel_0, 0), (self.blocks_vector_to_streams_1_1, 0)) self.connect((self.PWF_channel_0, 1), (self.blocks_vector_to_streams_1_1_0, 0)) self.connect((self.PWF_channel_1, 1), (self.blocks_vector_to_streams_1_1_0_0, 0)) self.connect((self.PWF_channel_1, 0), (self.blocks_vector_to_streams_1_1_1, 0)) self.connect((self.PWF_debug_printmsg_0, 0), (self.PWF_pilot_gen_tx_0, 0)) self.connect((self.PWF_debug_printmsg_0, 1), (self.PWF_pilot_gen_tx_0_0, 0)) self.connect((self.PWF_pilot_gen_rx_0, 0), (self.blocks_vector_to_streams_1_0_0, 0)) self.connect((self.PWF_pilot_gen_rx_0_0, 0), (self.blocks_vector_to_streams_1_2, 0)) self.connect((self.PWF_pilot_gen_tx_0, 0), (self.blocks_vector_to_streams_1, 0)) self.connect((self.PWF_pilot_gen_tx_0_0, 0), (self.blocks_vector_to_streams_1_0, 0)) self.connect((self.PWF_pilot_receive_rx_0, 0), (self.PWF_power_adjust_1, 0)) self.connect((self.PWF_pilot_receive_rx_0_0, 0), (self.PWF_power_adjust_1, 1)) self.connect((self.PWF_pilot_receive_tx_0, 0), (self.PWF_power_adjust_1_0, 1)) self.connect((self.PWF_pilot_receive_tx_0_0, 0), (self.PWF_power_adjust_1_0, 0)) self.connect((self.PWF_power_adjust_1, 1), (self.PWF_pilot_gen_rx_0, 0)) self.connect((self.PWF_power_adjust_1, 0), (self.PWF_pilot_gen_rx_0_0, 0)) self.connect((self.PWF_power_adjust_1_0, 0), (self.blocks_streams_to_vector_0_0, 0)) self.connect((self.PWF_power_adjust_1_0, 1), (self.blocks_streams_to_vector_0_0, 1)) self.connect((self.PWF_sigmagen_0, 0), (self.blocks_streams_to_vector_0, 0)) self.connect((self.PWF_sigmagen_0, 1), (self.blocks_streams_to_vector_0, 1)) self.connect((self.PWF_weighted_sum_rate_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.PWF_weighted_sum_rate_0, 1), (self.blocks_repeat_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_udp_sink_1, 0)) self.connect((self.blocks_streams_to_vector_0_0, 0), (self.blocks_udp_sink_1_0, 0)) self.connect((self.blocks_streams_to_vector_1, 0), (self.PWF_channel_0, 0)) self.connect((self.blocks_streams_to_vector_1_0, 0), (self.PWF_channel_0, 1)) self.connect((self.blocks_streams_to_vector_1_0_0, 0), (self.PWF_channel_1, 1)) self.connect((self.blocks_streams_to_vector_1_1, 0), (self.PWF_pilot_receive_rx_0, 0)) self.connect((self.blocks_streams_to_vector_1_1_0, 0), (self.PWF_pilot_receive_rx_0_0, 0)) self.connect((self.blocks_streams_to_vector_1_1_0_0, 0), (self.PWF_pilot_receive_tx_0, 0)) self.connect((self.blocks_streams_to_vector_1_1_1, 0), (self.PWF_pilot_receive_tx_0_0, 0)) self.connect((self.blocks_streams_to_vector_1_2, 0), (self.PWF_channel_1, 0)) self.connect((self.blocks_udp_source_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_udp_source_1, 0), (self.blocks_vector_to_streams_0, 0)) self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_debug_printmsg_0, 0)) self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_debug_printmsg_0, 1)) self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_weighted_sum_rate_0, 0)) self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_weighted_sum_rate_0, 1)) self.connect((self.blocks_vector_to_streams_1, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_vector_to_streams_1, 1), (self.interp_fir_filter_xxx_0_1, 0)) self.connect((self.blocks_vector_to_streams_1_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_vector_to_streams_1_0, 1), (self.interp_fir_filter_xxx_0_1_0, 0)) self.connect((self.blocks_vector_to_streams_1_0_0, 0), (self.blocks_streams_to_vector_1_0_0, 0)) self.connect((self.blocks_vector_to_streams_1_0_0, 1), (self.blocks_streams_to_vector_1_0_0, 1)) self.connect((self.blocks_vector_to_streams_1_1, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_vector_to_streams_1_1, 1), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_vector_to_streams_1_1_0, 1), (self.fir_filter_xxx_0_0_0, 0)) self.connect((self.blocks_vector_to_streams_1_1_0, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.blocks_vector_to_streams_1_1_0_0, 1), (self.phase_corrector_0_0_0_0, 0)) self.connect((self.blocks_vector_to_streams_1_1_0_0, 0), (self.phase_corrector_0_1_0, 0)) self.connect((self.blocks_vector_to_streams_1_1_1, 1), (self.phase_corrector_0_0_1, 0)) self.connect((self.blocks_vector_to_streams_1_1_1, 0), (self.phase_corrector_0_2, 0)) self.connect((self.blocks_vector_to_streams_1_2, 1), (self.blocks_streams_to_vector_1_2, 1)) self.connect((self.blocks_vector_to_streams_1_2, 0), (self.blocks_streams_to_vector_1_2, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.phase_corrector_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.phase_corrector_0_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.phase_corrector_0_0_0, 0)) self.connect((self.fir_filter_xxx_0_1, 0), (self.phase_corrector_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_streams_to_vector_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_streams_to_vector_1_0, 0)) self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.blocks_streams_to_vector_1, 1)) self.connect((self.interp_fir_filter_xxx_0_1_0, 0), (self.blocks_streams_to_vector_1_0, 1)) self.connect((self.phase_corrector_0, 0), (self.blocks_streams_to_vector_1_1, 0)) self.connect((self.phase_corrector_0_0, 0), (self.blocks_streams_to_vector_1_1, 1)) self.connect((self.phase_corrector_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0, 1)) self.connect((self.phase_corrector_0_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 1)) self.connect((self.phase_corrector_0_0_1, 0), (self.blocks_streams_to_vector_1_1_1, 1)) self.connect((self.phase_corrector_0_1, 0), (self.blocks_streams_to_vector_1_1_0, 0)) self.connect((self.phase_corrector_0_1_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 0)) self.connect((self.phase_corrector_0_2, 0), (self.blocks_streams_to_vector_1_1_1, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.variable_chooser_0 = variable_chooser_0 = 1 self.transition_width = transition_width = 10000 self.sym_per_sec = sym_per_sec = 2032 self.samp_rate = samp_rate = 2000000 self.rf_gain = rf_gain = 10 self.cutoff_freq = cutoff_freq = 10000 ################################################## # Blocks ################################################## _transition_width_sizer = wx.BoxSizer(wx.VERTICAL) self._transition_width_text_box = forms.text_box( parent=self.GetWin(), sizer=_transition_width_sizer, value=self.transition_width, callback=self.set_transition_width, label='transition_width', converter=forms.float_converter(), proportion=0, ) self._transition_width_slider = forms.slider( parent=self.GetWin(), sizer=_transition_width_sizer, value=self.transition_width, callback=self.set_transition_width, minimum=100, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_transition_width_sizer) _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label='rf_gain', converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=47, num_steps=47, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_rf_gain_sizer) _cutoff_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._cutoff_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_cutoff_freq_sizer, value=self.cutoff_freq, callback=self.set_cutoff_freq, label='cutoff_freq', converter=forms.int_converter(), proportion=0, ) self._cutoff_freq_slider = forms.slider( parent=self.GetWin(), sizer=_cutoff_freq_sizer, value=self.cutoff_freq, callback=self.set_cutoff_freq, minimum=100, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_cutoff_freq_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( 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=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self._variable_chooser_0_chooser = forms.drop_down( parent=self.GetWin(), value=self.variable_chooser_0, callback=self.set_variable_chooser_0, label='variable_chooser_0', choices=[1, 2, 3], labels=["a", "b", "c"], ) self.Add(self._variable_chooser_0_chooser) self.osmosdr_sink_c_0 = osmosdr.sink_c( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_c_0.set_sample_rate(samp_rate) self.osmosdr_sink_c_0.set_center_freq(27.14e6, 0) self.osmosdr_sink_c_0.set_freq_corr(0, 0) self.osmosdr_sink_c_0.set_gain(10, 0) self.osmosdr_sink_c_0.set_if_gain(rf_gain, 0) self.osmosdr_sink_c_0.set_bb_gain(20, 0) self.osmosdr_sink_c_0.set_antenna("", 0) self.osmosdr_sink_c_0.set_bandwidth(0, 0) self.low_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, samp_rate, cutoff_freq, transition_width, firdes.WIN_BLACKMAN, 6.76)) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f([1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0], True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_rate/sym_per_sec) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.osmosdr_sink_c_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 16000 self.repeat = repeat = samp_rate/80 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_uchar_to_float_0_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_short_to_char_0 = blocks.short_to_char(1) self.blocks_rms_xx_0_0 = blocks.rms_ff(1) self.blocks_rms_xx_0 = blocks.rms_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, repeat) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vss((256, )) self.blocks_integrate_xx_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_0 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0 = blocks.integrate_ff(repeat) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/home/sidekiq/Documents/Documentation_SDR/sdr.in", True) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/Documents/Documentation_SDR/text_output", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.blocks_abs_xx_0_2 = blocks.abs_ff(1) self.blocks_abs_xx_0_1 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="11111000", access_code="11111111", pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.audio_sink_1 = audio.sink(16000, "", True) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(100) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_short_to_char_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_uchar_to_float_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_short_to_char_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Two Channel PRB Sequence") Qt.QWidget.__init__(self) self.setWindowTitle("Two Channel PRB Sequence") 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", "PRBS_Two_Channel") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 3000000 self.my_rate = my_rate = 100000 self.my_amp2 = my_amp2 = 0.5 self.my_amp1 = my_amp1 = 0.7 self.interp = interp = samp_rate/my_rate ################################################## # Blocks ################################################## self._samp_rate_options = (1500000, 3000000, 6000000, 12000000, 20000000, ) self._samp_rate_labels = ("1.5M", "3M", "6M", "12M", "20M", ) self._samp_rate_group_box = Qt.QGroupBox("Sample Rate (NOTE: Keep Sample Rate higher than symbol rate!)") self._samp_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._samp_rate_button_group = variable_chooser_button_group() self._samp_rate_group_box.setLayout(self._samp_rate_box) for i, label in enumerate(self._samp_rate_labels): radio_button = Qt.QRadioButton(label) self._samp_rate_box.addWidget(radio_button) self._samp_rate_button_group.addButton(radio_button, i) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_button_group.buttonClicked[int].connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_group_box) self._my_amp2_range = Range(0, 1, 0.05, 0.5, 200) self._my_amp2_win = RangeWidget(self._my_amp2_range, self.set_my_amp2, "Amplitude 2", "counter_slider", float) self.top_layout.addWidget(self._my_amp2_win) self._my_amp1_range = Range(0, 1, 0.05, 0.7, 200) self._my_amp1_win = RangeWidget(self._my_amp1_range, self.set_my_amp1, "Amplitude 1", "counter_slider", float) self.top_layout.addWidget(self._my_amp1_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_rate(200e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(0, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self._my_rate_options = (100000, 500000, 1000000, 2000000, 4000000, ) self._my_rate_labels = ("100K", "500K", "1M", "2M", "4M", ) self._my_rate_group_box = Qt.QGroupBox("Symbol Rate") self._my_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._my_rate_button_group = variable_chooser_button_group() self._my_rate_group_box.setLayout(self._my_rate_box) for i, label in enumerate(self._my_rate_labels): radio_button = Qt.QRadioButton(label) self._my_rate_box.addWidget(radio_button) self._my_rate_button_group.addButton(radio_button, i) self._my_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._my_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._my_rate_options.index(i))) self._my_rate_callback(self.my_rate) self._my_rate_button_group.buttonClicked[int].connect( lambda i: self.set_my_rate(self._my_rate_options[i])) self.top_layout.addWidget(self._my_rate_group_box) self.blocks_vector_source_x_0 = blocks.vector_source_f((0, my_amp1), True, 1, []) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, interp) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_int*1, interp) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1/my_amp2) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_random_source_x_0 = blocks.vector_source_i(map(int, numpy.random.randint(0, 2, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_int_to_float_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Qpsk Tagged") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Tagged") 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_tagged") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(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) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_vector_source_x_0 = blocks.vector_source_c((-1+1j, -1-1j, 0), True, 1, []) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 10) self.GNU_tutorials_qpsk_tagged_demod_cb_py_0 = GNU_tutorials.qpsk_tagged_demod_cb_py(True) ################################################## # Connections ################################################## self.connect((self.GNU_tutorials_qpsk_tagged_demod_cb_py_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.GNU_tutorials_qpsk_tagged_demod_cb_py_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.payload_len = payload_len = 1 self.freq = freq = 2.48e9 self.bandwidth = bandwidth = 5e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(freq, 0) self.uhd_usrp_sink.set_gain(0, 0) self.uhd_usrp_sink.set_antenna("J1", 0) self.uhd_usrp_sink.set_bandwidth(bandwidth, 0) self.seniorproj_tos_add_header_dec_0 = seniorproj.tos_add_header_dec(65535, 1, 1, 34, 26) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc bandwidth, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/samp_rate) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]), 16) self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(4, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*payload_len, "/home/ted/Desktop/test.txt", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.seniorproj_tos_add_header_dec_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.seniorproj_tos_add_header_dec_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ask Keyer") ################################################## # Variables ################################################## self.tx_freq = tx_freq = 433.9e6 self.symbol_length = symbol_length = 750e-6 self.samp_rate = samp_rate = 2e6 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( 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.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(tx_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(20, 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_f([0,0,1,1,1,1,0,0,1,1,0,1,0,1,0,1,0,0,0,0,0,0,1,1,0], True, 1, []) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(symbol_length*samp_rate)) self.blocks_patterned_interleaver_0_0 = blocks.patterned_interleaver(gr.sizeof_float*1, ([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1])) self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(gr.sizeof_float*1, ([2,0,1])) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) 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_f(samp_rate, analog.GR_COS_WAVE, tx_freq, 1, 0) self.analog_const_source_x_0_1 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1) self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_patterned_interleaver_0, 2)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_patterned_interleaver_0_0, 1)) self.connect((self.analog_const_source_x_0_1, 0), (self.blocks_patterned_interleaver_0, 1)) 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.wxgui_scopesink2_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_patterned_interleaver_0, 0), (self.blocks_patterned_interleaver_0_0, 0)) self.connect((self.blocks_patterned_interleaver_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_patterned_interleaver_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Multi Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.audio_rate = audio_rate = 48000 self.wpm = wpm = 15 self.wbfm_on = wbfm_on = True self.usb_on = usb_on = True self.samp_rate = samp_rate = audio_rate * 40 self.q_offset = q_offset = 0 self.psk_on = psk_on = True self.phase = phase = 0 self.nbfm_on = nbfm_on = True self.magnitude = magnitude = 0 self.lsb_on = lsb_on = True self.i_offset = i_offset = 0 self.gain = gain = 25 self.cw_on = cw_on = True self.center_freq = center_freq = 441000000 self.am_on = am_on = True ################################################## # Blocks ################################################## self._wbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.wbfm_on, callback=self.set_wbfm_on, label="WBFM", true=True, false=False, ) self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1) self._usb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.usb_on, callback=self.set_usb_on, label="USB", true=True, false=False, ) self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1) _q_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._q_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, label="DC offset Q", converter=forms.float_converter(), proportion=0, ) self._q_offset_slider = forms.slider( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_q_offset_sizer, 3, 0, 1, 7) self._psk_on_check_box = forms.check_box( parent=self.GetWin(), value=self.psk_on, callback=self.set_psk_on, label="PSK31", true=True, false=False, ) self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1) _phase_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, label="Phase correction", converter=forms.float_converter(), proportion=0, ) self._phase_slider = forms.slider( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_phase_sizer, 0, 0, 1, 7) self._nbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.nbfm_on, callback=self.set_nbfm_on, label="NBFM", true=True, false=False, ) self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1) _magnitude_sizer = wx.BoxSizer(wx.VERTICAL) self._magnitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, label="Magnitude correction", converter=forms.float_converter(), proportion=0, ) self._magnitude_slider = forms.slider( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_magnitude_sizer, 1, 0, 1, 7) self._lsb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.lsb_on, callback=self.set_lsb_on, label="LSB", true=True, false=False, ) self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1) _i_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._i_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, label="DC offset I", converter=forms.float_converter(), proportion=0, ) self._i_offset_slider = forms.slider( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_i_offset_sizer, 2, 0, 1, 7) self._cw_on_check_box = forms.check_box( parent=self.GetWin(), value=self.cw_on, callback=self.set_cw_on, label="CW", true=True, false=False, ) self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1) self._am_on_check_box = forms.check_box( parent=self.GetWin(), value=self.am_on, callback=self.set_am_on, label="AM", true=True, false=False, ) self.GridAdd(self._am_on_check_box, 4, 2, 1, 1) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, audio_rate, 5, 0.35, 200)) 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_3 = filter.rational_resampler_ccc( interpolation=192, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=samp_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 2, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 4, decimation=1, taps=None, fractional_bw=None, ) 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(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 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.low_pass_filter_1 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.digital_map_bb_0 = digital.map_bb(([1,0])) self.blocks_wavfile_source_0 = blocks.wavfile_source("multi_tx.wav", True) self.blocks_vector_source_x_2 = blocks.vector_source_b((0,0, 1,1,0,1,1,0,1, 0,0, 1,0,1,0,1,1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1,1,0,1,0,1, 0,0, 1,1,1,0,1,1,1, 0,0, 1,1,1,1,1,1,1,1, 0,0, 1,1,1,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1, 0,0, 1,0,1, 0,0, 1,1, 0,0, 1,0,1,1,1, 0,0, 1,0,1, 0,0, 1,1,0,1, 0,0, 1,1,1,1, 0,0, 1,0,1,1,0,1,1, 0,0, 1,0,1,0,1,1,1, 0,0, 1,1,1,0,1), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c((1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_6 = blocks.multiply_vcc(1) self.blocks_multiply_xx_5 = blocks.multiply_vcc(1) self.blocks_multiply_xx_4 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vcc((i_offset + 1j * q_offset, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, )) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, ) self.analog_sig_source_x_6 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0) self.analog_sig_source_x_5 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0) self.analog_sig_source_x_4 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0) self.analog_sig_source_x_3_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0) self.analog_sig_source_x_3 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 2, tau=75e-6, max_dev=5e3, ) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0)) self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3)) self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0)) self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1)) self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_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_1, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))