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 __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option( "-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst)
def __init__(self, symbol00=1.0 / 3.0, symbol01=1.0, symbol10=-1.0 / 3.0, symbol11=-1.0): gr.hier_block2.__init__( self, "Symbol Mapper", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Parameters ################################################## self.symbol00 = symbol00 self.symbol01 = symbol01 self.symbol10 = symbol10 self.symbol11 = symbol11 ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ((symbol00, symbol01, symbol10, symbol11)), 1) ################################################## # Connections ################################################## self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self, 0)) self.connect((self, 0), (self.digital_chunks_to_symbols_xx_0, 0))
def __init__(self, bt=0.3, samples_per_symbol=2): gr.hier_block2.__init__( self, "msk_demod", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex) ) ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 # Turn it into NRZ data. self.unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.nrz = digital.chunks_to_symbols_bf([-1, 1], 1) # note could also invert bits here # Form Gaussian filter # Generate Gaussian response (Needs to be convolved with window below). self.gaussian_taps = gr.firdes.gaussian(1, samples_per_symbol, bt, ntaps) self.sqwave = (1,) * samples_per_symbol # rectangular window self.taps = numpy.convolve(numpy.array(self.gaussian_taps), numpy.array(self.sqwave)) self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) # TODO: this is hardcoded, how to figure out this value? self.offset = gr.add_const_vff((-0.5,)) # CC430 RF core is inverted with respect to USRP for some reason self.invert = gr.multiply_const_vff((-1,)) # Connect & Initialize base class self.connect(self, self.unpack, self.nrz, self.invert, self.offset, self.gaussian_filter, self.fmmod, 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, 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): 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.sigma = sigma = 0.3 self.samp_rate = samp_rate = 32000 self.max_iterations = max_iterations = 50 ################################################## # Blocks ################################################## self.ldpc_lh_detector_fb_0 = ldpc.lh_detector_fb() self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([1.0, -1.0]), 1) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/home/manu/Downloads/in.flac", False) self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_char * 1, "/home/manu/val") self.blocks_file_sink_2.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1, "/home/manu/ref") self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "/home/manu/out") self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, sigma, 1) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_lh_detector_fb_0, 0)) self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_file_sink_2, 0)) self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Example1") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sigma = sigma = 0.5 self.samp_rate = samp_rate = 32000 self.max_iterations = max_iterations = 50 self.alist_file = alist_file = "/home/manu/repos/ldpc/gr-ldpc/python/alist-files" ################################################## # Blocks ################################################## self.ldpc_ldpc_hier_encoder_bb_0 = ldpc.ldpc_hier_encoder_bb( "/home/manu/1920.1280.3.303/H1920.1280.3.303") self.ldpc_ldpc_hier_decoder_fb_0 = ldpc.ldpc_hier_decoder_fb( "/home/manu/1920.1280.3.303/H1920.1280.3.303", sigma, max_iterations) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([1.0, -1.0]), 1) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_LSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/home/manu/Downloads/06 - Coming Back To Life.flac", False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "/home/manu/Downloads/out", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, sigma, 0) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.ldpc_ldpc_hier_decoder_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ldpc_ldpc_hier_encoder_bb_0, 0)) self.connect((self.ldpc_ldpc_hier_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_ldpc_hier_decoder_fb_0, 0))
def __init__(self, output_sample_rate=_def_output_sample_rate, reverse=_def_reverse, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered P25 FM modulation. The input is a dibit (P25 symbol) stream (char, not packed) and the output is the float "C4FM" signal at baseband, suitable for application to an FM modulator stage Input is at the base symbol rate (4800), output sample rate is typically either 32000 (USRP TX chain) or 48000 (sound card) @param output_sample_rate: output sample rate @type output_sample_rate: integer @param reverse: reverse polarity flag @type reverse: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modulation data to files? @type debug: bool """ gr.hier_block2.__init__(self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature input_sample_rate = 4800 # P25 baseband symbol rate lcm = gru.lcm(input_sample_rate, output_sample_rate) self._interp_factor = int(lcm // input_sample_rate) self._decimation = int(lcm // output_sample_rate) mod_map = [1.0/3.0, 1.0, -(1.0/3.0), -1.0] self.C2S = digital.chunks_to_symbols_bf(mod_map) if reverse: self.polarity = blocks.multiply_const_ff(-1) else: self.polarity = blocks.multiply_const_ff( 1) self.filter = filter.interp_fir_filter_fff(self._interp_factor, c4fm_taps(sample_rate=output_sample_rate).generate()) if verbose: self._print_verbage() if log: self._setup_logging() self.connect(self, self.C2S, self.polarity, self.filter) if (self._decimation > 1): self.decimator = filter.rational_resampler_fff(1, self._decimation) self.connect(self.filter, self.decimator, self) else: self.connect(self.filter, self)
def __init__(self): """ Especifíca la primera función que se ejecutará al crear un objeto de la clase my_top_block con el argumento self, por lo que servirá para cualquier proceso de inicializacián, este se define como el constructor de la clase,la interconexión de los bloques es la siguiente: +------------------------+ +------------------------+ +--------------------+ | GLFSR Source +-----+ Chunks to Symbol bf +-----+ Audio Sink | +------------------------+ +------------------------+ +--------------------+ Con gr.top_block.__init__(self) se llama a la función inicial del modulo top_block del paquete gr y se pasa como argumento el objeto creado. digital.glfsr_sorce_b Fuente pseudoaleatoria LFSR de Galois que genera salidas flotantes -1.0 - 1.0 chunks_to_symbols_bf Asigna un flujo de índices de símbolos desempaquetados al flujo de puntos de constelación flotantes o complejos en dimensiones D (D = 1 por defecto). audio.sink Este módulo envía las señales a la tarjeta de audio para poder reproducirlas. """ gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 """ Las siguientes instrucciones definen la tasa de muestreo (obtenida de options) y la amplitud """ sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) """ se debe realizar la conexión entre los bloques que se han definido anteriormente paracompletar el grafo: Con esto se crea la conexión logica del grafo uniendo los puertos de entrada y salida (src-fuente y dst-destino). """ self.connect(src, b2f, dst)
def __init__(self): gr.top_block.__init__(self, "Ask Tx Top Raspi") ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 44000 self.samples_per_symbol = samples_per_symbol = 19 self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol self.bits_per_symbol = bits_per_symbol = 1 self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine( 15, sound_card_sample_rate, symbol_rate, 0.5, 70) self.bit_rate = bit_rate = symbol_rate / bits_per_symbol ################################################## # Blocks ################################################## self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( samples_per_symbol, (variable_rrc_filter_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([-1, 1]), 1) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, bit_rate, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 32, "packet_len") self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, './test_src_file.txt', True) self.audio_sink_0 = audio.sink(int(sound_card_sample_rate), '', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self, bt = 0.3, samples_per_symbol = 2, ti_adj=False): gr.hier_block2.__init__(self, "msk_demod", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.sps = 2 self.bt = 0.35 self.mu = 0.5 self.gain_mu = 0.175 self.freq_error = 0.0 self.omega_relative_limit = 0.005 self.omega = self.sps * (1 + self.freq_error) self.gain_omega = .25 * self.gain_mu * self.gain_mu # critically damped ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 # Turn it into NRZ data. self.unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.nrz = digital.chunks_to_symbols_bf([-1, 1], 1) # note could also invert bits here # Form Gaussian filter # Generate Gaussian response (Needs to be convolved with window below). self.gaussian_taps = gr.firdes.gaussian(1, samples_per_symbol, bt, ntaps) self.sqwave = (1,) * samples_per_symbol # rectangular window self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps) # the clock recovery block tracks the symbol clock and resamples as needed. # the output of the block is a stream of soft symbols (float) self.clock_recovery = digital.clock_recovery_mm_ff(self.omega, self.gain_omega, self.mu, self.gain_mu, self.omega_relative_limit) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) # TODO: this is hardcoded, how to figure out this value? self.offset = gr.add_const_vff((-.5, )) # CC430 RF core is inverted with respect to USRP for some reason self.invert = gr.multiply_const_vff((-1, )) # Connect & Initialize base class if ti_adj: self.connect(self, self.unpack, self.nrz, self.invert, self.offset, self.gaussian_filter, self.fmmod, self) else: self.connect(self, self.unpack, self.nrz, self.gaussian_filter, self.fmmod, self)
def test_bf_002(self): const = [-3, -1, 1, 3] src_data = (0, 1, 2, 3, 3, 2, 1, 0) expected_result = [-3, -1, 1, 3, 3, 1, -1, -3] src = blocks.vector_source_b(src_data) op = digital.chunks_to_symbols_bf(const) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() self.assertEqual(expected_result, actual_result)
def test_002_correlation_b(self): for degree in range(1,11): # Higher degrees take too long to correlate src = digital.glfsr_source_b(degree, False) b2f = digital.chunks_to_symbols_bf((-1.0,1.0), 1) dst = blocks.vector_sink_f() del self.tb # Discard existing top block self.tb = gr.top_block() self.tb.connect(src, b2f, dst) self.tb.run() self.tb.disconnect_all() actual_result = dst.data() R = auto_correlate(actual_result) self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin for i in range(len(R)-1): self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-O", "--audio-output", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_argument("-r", "--sample-rate", type=eng_float, default=48000, help="set sample rate to RATE (48000)") args = parser.parse_args() sample_rate = int(args.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, args.audio_output) self.connect(src, b2f, dst)
def test_bf_002(self): const = [-3, -1, 1, 3] src_data = (0, 1, 2, 3, 3, 2, 1, 0) expected_result = (-3, -1, 1, 3, 3, 1, -1, -3) src = blocks.vector_source_b(src_data) op = digital.chunks_to_symbols_bf(const) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() self.assertEqual(expected_result, actual_result)
def __init__(self): fsk_source.__init__(self, mod_name="8gfsk", samp_per_sym=8) self.pack = blocks.packed_to_unpacked_bb(3, gr.GR_MSB_FIRST) self.map = digital.chunks_to_symbols_bf(np.linspace(-2, 2, 8), 1) # This design mirrors the internals of the GMSK mod block self.taps = np.convolve( firdes.gaussian(1, self.samp_per_sym, .35, 4 * self.samp_per_sym), (1, ) * self.samp_per_sym) self.filt = \ filter.interp_fir_filter_fff( self.samp_per_sym, self.taps, ) self.filt.declare_sample_delay(0) self.mod = analog.frequency_modulator_fc(1) self.connect(self.random_source, self.pack, self.map, self.filt, self.mod, 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, 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 __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst)
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.sigma = sigma = 0.3 self.samp_rate = samp_rate = 32000 self.max_iterations = max_iterations = 50 ################################################## # Blocks ################################################## self.ldpc_lh_detector_fb_0 = ldpc.lh_detector_fb() self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([1.0, -1.0]), 1) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/manu/Downloads/in.flac", False) self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/val") self.blocks_file_sink_2.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/ref") self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/out") self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, sigma, 1) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_lh_detector_fb_0, 0)) self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_file_sink_2, 0)) self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
def test_bf_3d(self): maxval = 48 dimensions = 3 const = list(range(maxval * dimensions)) src_data = [v * 13 % maxval for v in range(maxval)] expected_result = [] for data in src_data: for i in range(dimensions): expected_result += [const[data * dimensions + i]] self.assertEqual(len(src_data) * dimensions, len(expected_result)) src = blocks.vector_source_b(src_data) op = digital.chunks_to_symbols_bf(const, dimensions) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() self.assertEqual(expected_result, actual_result)
def __init__(self, BT=4, pulse_duration=4, sps=4): gr.hier_block2.__init__( self, "GMSK Modulator for GSM", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.BT = BT self.pulse_duration = pulse_duration self.sps = sps ################################################## # Blocks ################################################## self.digital_gmskmod_bc_0 = digital.gmskmod_bc(sps, pulse_duration, BT) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([1, -1]), 1) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", sps) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_float_to_char_0, 0), (self.digital_gmskmod_bc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_gmskmod_bc_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self, 0), (self.digital_diff_decoder_bb_0, 0))
def __init__(self, dibit_map, log_level, filename): self.dibit_map = dibit_map self.log_level = log_level self.filename = filename gr.hier_block2.__init__( self, "dibit_mapper_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self.loggername = uuid.uuid4().hex self.logger = logging.getLogger(self.loggername) self.formatter = logging.Formatter( '%(asctime)s | %(levelname)s | {} | %(message)s'.format(__name__)) self.console = logging.StreamHandler() self.console.setLevel(self.log_level) self.console.setFormatter(self.formatter) self.logger.addHandler(self.console) if self.filename: self.fhandler = logging.FileHandler(self.filename) self.fhandler.setLevel(self.log_level) self.fhandler.setFormatter(self.formatter) self.logger.addHandler(self.fhandler) self.logger.setLevel(self.log_level) if log_level == logging.NOTSET: self.logger.disabled = True self.logger.debug("Dibit mapping: {}".format(self.dibit_map)) # Convert dibits to symbol map [00, 01, 10, 11] -> [1, 3, -1, -3]. self.dibits_to_symbols = digital.chunks_to_symbols_bf(dibit_map) # Define blocks and connect them self.connect(self, self.dibits_to_symbols, self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Example1") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sigma = sigma = 0.5 self.samp_rate = samp_rate = 32000 self.max_iterations = max_iterations = 50 self.alist_file = alist_file = "/home/manu/repos/ldpc/gr-ldpc/python/alist-files" ################################################## # Blocks ################################################## self.ldpc_ldpc_hier_encoder_bb_0 = ldpc.ldpc_hier_encoder_bb("/home/manu/1920.1280.3.303/H1920.1280.3.303") self.ldpc_ldpc_hier_decoder_fb_0 = ldpc.ldpc_hier_decoder_fb("/home/manu/1920.1280.3.303/H1920.1280.3.303", sigma, max_iterations) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([1.0, -1.0]), 1) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/manu/Downloads/06 - Coming Back To Life.flac", False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/Downloads/out", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, sigma, 0) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.ldpc_ldpc_hier_decoder_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ldpc_ldpc_hier_encoder_bb_0, 0)) self.connect((self.ldpc_ldpc_hier_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_ldpc_hier_decoder_fb_0, 0))
def __init__(self, fname, epsilon, max_iterations): gr.top_block.__init__(self) self.src = blocks.vector_source_b(()) print "initializing encoder" self.encoder = ldpc.ldpc_encoder_bb(fname) print "encoder initialized" self.K = self.encoder.get_K() self.N = self.encoder.get_N() print self.K print self.N str2Kvec = blocks.stream_to_vector(1, self.K) chk2symb = digital.chunks_to_symbols_bf(([1, -1]), 1) str2Nvec = blocks.stream_to_vector(4, self.N) self.channel = ldpc.bsc_bb(self.N, epsilon) self.decoder = ldpc.ldpc_decoder_bb(fname, epsilon, max_iterations) print "decoder initialized" self.noise = analog.noise_source_f(analog.GR_GAUSSIAN, epsilon, 0) self.adder = blocks.add_vff(1) Kvec2str = blocks.vector_to_stream(1, self.K) Nvec2str = blocks.vector_to_stream(4, self.N) self.dst = blocks.vector_sink_b() self.connect(self.src, str2Kvec, self.encoder, self.channel, self.decoder, Kvec2str, self.dst)
def test_convolutional_encoder(self): """ Tests convolutional encoder """ src_data = make_transport_stream() constellation = [.7, .7,.7,-.7,-.7,.7,-.7,-.7] src = blocks.vector_source_b(src_data) unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) enc = dvb_convolutional_encoder_bb.convolutional_encoder_bb() repack1 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) repack2 = blocks.packed_to_unpacked_bb(2, gr.GR_MSB_FIRST) mapper = digital.chunks_to_symbols_bf(constellation, dvb.dimensionality) viterbi = trellis.viterbi_combined_fb(trellis.fsm(dvb.k, dvb.n, dvb_convolutional_encoder_bb.G), dvb.K, -1, -1, dvb.dimensionality, constellation, trellis.TRELLIS_EUCLIDEAN) pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) dst = blocks.vector_sink_b() self.tb.connect(src, unpack, enc, repack1, repack2, mapper) self.tb.connect(mapper, viterbi, pack, dst) self.tb.run() result_data = dst.data() self.assertEqual(tuple(src_data[:len(result_data)]), result_data)
def __init__(self, bt=0.3, samples_per_symbol=2): gr.hier_block2.__init__(self, "msk_demod", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 # Turn it into NRZ data. self.unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.nrz = digital.chunks_to_symbols_bf( [-1, 1], 1) # note could also invert bits here # Form Gaussian filter # Generate Gaussian response (Needs to be convolved with window below). self.gaussian_taps = gr.firdes.gaussian(1, samples_per_symbol, bt, ntaps) self.sqwave = (1, ) * samples_per_symbol # rectangular window self.taps = numpy.convolve(numpy.array(self.gaussian_taps), numpy.array(self.sqwave)) self.gaussian_filter = filter.interp_fir_filter_fff( samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) # TODO: this is hardcoded, how to figure out this value? self.offset = gr.add_const_vff((-.5, )) # CC430 RF core is inverted with respect to USRP for some reason self.invert = gr.multiply_const_vff((-1, )) # Connect & Initialize base class self.connect(self, self.unpack, self.nrz, self.invert, self.offset, self.gaussian_filter, self.fmmod, self)
def run_test(seed,blocksize): tb = gr.top_block() ################################################## # Variables ################################################## M = 2 K = 1 P = 2 h = (1.0*K)/P L = 3 Q = 4 frac = 0.99 f = trellis.fsm(P,M,L) # CPFSK signals #p = numpy.ones(Q)/(2.0) #q = numpy.cumsum(p)/(1.0*Q) # GMSK signals BT=0.3; tt=numpy.arange(0,L*Q)/(1.0*Q)-L/2.0; #print tt p=(0.5*scipy.special.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.special.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0; p=p/sum(p)*Q/2.0; #print p q=numpy.cumsum(p)/Q; q=q/q[-1]/2.0; #print q (f0T,SS,S,F,Sf,Ff,N) = fsm_utils.make_cpm_signals(K,P,M,L,q,frac) #print N #print Ff Ffa = numpy.insert(Ff,Q,numpy.zeros(N),axis=0) #print Ffa MF = numpy.fliplr(numpy.transpose(Ffa)) #print MF E = numpy.sum(numpy.abs(Sf)**2,axis=0) Es = numpy.sum(E)/f.O() #print Es constellation = numpy.reshape(numpy.transpose(Sf),N*f.O()) #print Ff #print Sf #print constellation #print numpy.max(numpy.abs(SS - numpy.dot(Ff , Sf))) EsN0_db = 10.0 N0 = Es * 10.0**(-(1.0*EsN0_db)/10.0) #N0 = 0.0 #print N0 head = 4 tail = 4 numpy.random.seed(seed*666) data = numpy.random.randint(0, M, head+blocksize+tail+1) #data = numpy.zeros(blocksize+1+head+tail,'int') for i in range(head): data[i]=0 for i in range(tail+1): data[-i]=0 ################################################## # Blocks ################################################## random_source_x_0 = blocks.vector_source_b(data.tolist(), False) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf((-1, 1), 1) filter_interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Q, p) analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) blocks_add_vxx_0 = blocks.add_vcc(1) analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed)) blocks_multiply_vxx_0 = blocks.multiply_vcc(1) analog_sig_source_x_0 = analog.sig_source_c(Q, analog.GR_COS_WAVE, -f0T, 1, 0) # only works for N=2, do it manually for N>2... filter_fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, MF[0].conjugate()) filter_fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, MF[1].conjugate()) blocks_streams_to_stream_0 = blocks.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), constellation, digital.TRELLIS_EUCLIDEAN) blocks_vector_sink_x_0 = blocks.vector_sink_b() ################################################## # Connections ################################################## tb.connect((random_source_x_0, 0), (digital_chunks_to_symbols_xx_0, 0)) tb.connect((digital_chunks_to_symbols_xx_0, 0), (filter_interp_fir_filter_xxx_0, 0)) tb.connect((filter_interp_fir_filter_xxx_0, 0), (analog_frequency_modulator_fc_0, 0)) tb.connect((analog_frequency_modulator_fc_0, 0), (blocks_add_vxx_0, 0)) tb.connect((analog_noise_source_x_0, 0), (blocks_add_vxx_0, 1)) tb.connect((blocks_add_vxx_0, 0), (blocks_multiply_vxx_0, 0)) tb.connect((analog_sig_source_x_0, 0), (blocks_multiply_vxx_0, 1)) tb.connect((blocks_multiply_vxx_0, 0), (filter_fir_filter_xxx_0_0, 0)) tb.connect((blocks_multiply_vxx_0, 0), (filter_fir_filter_xxx_0_0_0, 0)) tb.connect((filter_fir_filter_xxx_0_0, 0), (blocks_streams_to_stream_0, 0)) tb.connect((filter_fir_filter_xxx_0_0_0, 0), (blocks_streams_to_stream_0, 1)) tb.connect((blocks_streams_to_stream_0, 0), (blocks_skiphead_0, 0)) tb.connect((blocks_skiphead_0, 0), (viterbi, 0)) tb.connect((viterbi, 0), (blocks_vector_sink_x_0, 0)) tb.run() dataest = blocks_vector_sink_x_0.data() #print data #print numpy.array(dataest) perr = 0 err = 0 for i in range(blocksize): if data[head+i] != dataest[head+i]: #print i err += 1 if err != 0 : perr = 1 return (err,perr)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="VA3ODG") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1920000 self.offset = offset = 50000 self.gain = gain = 40 self.fsk_deviation_hz = fsk_deviation_hz = 8000 self.freq = freq = 444850000 self.corr = corr = 0 ################################################## # Blocks ################################################## _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='RX gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label='Freq. correction', converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_corr_sizer) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=48000, fft_size=512, fft_rate=3, average=False, avg_alpha=None, title='Waterfall Plot', ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=48000, v_scale=0.25, v_offset=0, t_scale=0.001, 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.root_raised_cosine_filter_0 = filter.interp_fir_filter_fff( 10, firdes.root_raised_cosine(1, 48000, 4800, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq - offset, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff( 1, firdes.low_pass(1, 48000, 8000, 2000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 40, firdes.low_pass(20, samp_rate, 3500, 2000, firdes.WIN_HAMMING, 6.76)) self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_DSTAR, dsd.dsd_MOD_AUTO_SELECT, 3, True, 2) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 10.0, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([-1, 1]), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.audio_sink_0 = audio.sink(8000, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.dsd_block_ff_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Top") Qt.QWidget.__init__(self) self.setWindowTitle("Tx Top") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_top") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 96000 self.samples_per_symbol = samples_per_symbol = 19 self.symbol_rate = symbol_rate = sound_card_sample_rate/samples_per_symbol self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine(15, sound_card_sample_rate, symbol_rate, 0.5, 70) self.bits_per_symbol = bits_per_symbol = 1 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #size sound_card_sample_rate, #samp_rate "Baseband TX signal", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.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(False) 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.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(samples_per_symbol, (variable_rrc_filter_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len') self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('tx_signal.wav', 1, sound_card_sample_rate, 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, sound_card_sample_rate,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 32, "packet_len") self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/usr/src/app/test_src_file.txt', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_wavfile_sink_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.sps = sps = 8 self.nfilts = nfilts = 128 self.timing_loop_bandwidth = timing_loop_bandwidth = .063 self.samp_rate = samp_rate = 1000000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.noise_voltage = noise_voltage = .063 self.freq_offset = freq_offset = 0 self.code2 = code2 = '11011010110111011000110011110101100010010011110111' self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001' self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200) self._timing_loop_bandwidth_win = RangeWidget( self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth, "timing_loop_bandwidth", "counter_slider", float) self.top_grid_layout.addWidget(self._timing_loop_bandwidth_win, 0, 0, 1, 1) self._noise_voltage_range = Range(0.0, 1, .001, .063, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "noise_voltage", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_voltage_win, 0, 1, 1, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 15, #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(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ 'Real part', 'Imaginary Part', '', '', '', '', '', '', '', '' ] 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 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 15, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(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 = ['Binary output (1 or 0)', '', '', '', '', '', '', '', '', ''] 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 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( (0, 1), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=freq_offset / samp_rate, epsilon=1.0, taps=(1, ), 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_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example6/cat.png', True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example8/hello_out.png', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code=code2, pad_for_usrp=False, ), payload_length=4, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code=code2, threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_packet_encoder_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
def __init__(self, output_sample_rate=_def_output_sample_rate, excess_bw=_def_excess_bw, reverse=_def_reverse, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered P25 FM modulation. The input is a dibit (P25 symbol) stream (char, not packed) and the output is the float "C4FM" signal at baseband, suitable for application to an FM modulator stage Input is at the base symbol rate (4800), output sample rate is typically either 32000 (USRP TX chain) or 48000 (sound card) @param output_sample_rate: output sample rate @type output_sample_rate: integer @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param reverse: reverse polarity flag @type reverse: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modulation data to files? @type debug: bool """ gr.hier_block2.__init__(self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature input_sample_rate = 4800 # P25 baseband symbol rate lcm = gru.lcm(input_sample_rate, output_sample_rate) self._interp_factor = int(lcm // input_sample_rate) self._decimation = int(lcm // output_sample_rate) self._excess_bw = excess_bw mod_map = [1.0/3.0, 1.0, -(1.0/3.0), -1.0] self.C2S = digital.chunks_to_symbols_bf(mod_map) if reverse: self.polarity = blocks.multiply_const_ff(-1) else: self.polarity = blocks.multiply_const_ff( 1) ntaps = 11 * self._interp_factor rrc_taps = filter.firdes.root_raised_cosine( self._interp_factor, # gain (since we're interpolating by sps) lcm, # sampling rate input_sample_rate, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) # rrc_coeffs work slightly differently: each input sample # (from mod_map above) at 4800 rate, then 9 zeros are inserted # to bring to 48000 rate, then this filter is applied: # rrc_filter = gr.fir_filter_fff(1, rrc_coeffs) # FIXME: how to insert the 9 zero samples using gr ? # rrc_coeffs = [0, -0.003, -0.006, -0.009, -0.012, -0.014, -0.014, -0.013, -0.01, -0.006, 0, 0.007, 0.014, 0.02, 0.026, 0.029, 0.029, 0.027, 0.021, 0.012, 0, -0.013, -0.027, -0.039, -0.049, -0.054, -0.055, -0.049, -0.038, -0.021, 0, 0.024, 0.048, 0.071, 0.088, 0.098, 0.099, 0.09, 0.07, 0.039, 0, -0.045, -0.091, -0.134, -0.17, -0.193, -0.199, -0.184, -0.147, -0.085, 0, 0.105, 0.227, 0.36, 0.496, 0.629, 0.751, 0.854, 0.933, 0.983, 1, 0.983, 0.933, 0.854, 0.751, 0.629, 0.496, 0.36, 0.227, 0.105, 0, -0.085, -0.147, -0.184, -0.199, -0.193, -0.17, -0.134, -0.091, -0.045, 0, 0.039, 0.07, 0.09, 0.099, 0.098, 0.088, 0.071, 0.048, 0.024, 0, -0.021, -0.038, -0.049, -0.055, -0.054, -0.049, -0.039, -0.027, -0.013, 0, 0.012, 0.021, 0.027, 0.029, 0.029, 0.026, 0.02, 0.014, 0.007, 0, -0.006, -0.01, -0.013, -0.014, -0.014, -0.012, -0.009, -0.006, -0.003, 0] self.rrc_filter = filter.interp_fir_filter_fff(self._interp_factor, rrc_taps) # FM pre-emphasis filter shaping_coeffs = [-0.018, 0.0347, 0.0164, -0.0064, -0.0344, -0.0522, -0.0398, 0.0099, 0.0798, 0.1311, 0.121, 0.0322, -0.113, -0.2499, -0.3007, -0.2137, -0.0043, 0.2825, 0.514, 0.604, 0.514, 0.2825, -0.0043, -0.2137, -0.3007, -0.2499, -0.113, 0.0322, 0.121, 0.1311, 0.0798, 0.0099, -0.0398, -0.0522, -0.0344, -0.0064, 0.0164, 0.0347, -0.018] self.shaping_filter = filter.fir_filter_fff(1, shaping_coeffs) if verbose: self._print_verbage() if log: self._setup_logging() self.connect(self, self.C2S, self.polarity, self.rrc_filter, self.shaping_filter) if (self._decimation > 1): self.decimator = filter.rational_resampler_fff(1, self._decimation) self.connect(self.shaping_filter, self.decimator, self) else: self.connect(self.shaping_filter, self)
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): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 128 self.timing_loop_bandwidth = timing_loop_bandwidth = .063 self.samp_rate = samp_rate = 100E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.noise_voltage = noise_voltage = .063 self.freq_offset = freq_offset = 0 self.QAM = QAM = digital.constellation_calcdist(([ -3 - 3j, -3 - 1j, -3 + 3j, -3 + 1j, -1 - 3j, -1 - 1j, -1 + 3j, -1 + 1j, 3 - 3j, 3 - 1j, 3 + 3j, 3 + 1j, 1 - 3j, 1 - 1j, 1 + 3j, 1 + 1j ]), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), 10, 1).base() ################################################## # Blocks ################################################## self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200) self._timing_loop_bandwidth_win = RangeWidget( self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth, "timing_loop_bandwidth", "counter_slider", float) self.top_layout.addWidget(self._timing_loop_bandwidth_win) self._noise_voltage_range = Range(0.0, 1, .001, .063, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "noise_voltage", "counter_slider", float) self.top_layout.addWidget(self._noise_voltage_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 15, #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(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ 'Real part', 'Imaginary Part', '', '', '', '', '', '', '', '' ] 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 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 15, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(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 = ['Binary output (1 or 0)', '', '', '', '', '', '', '', '', ''] 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 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=QAM, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=freq_offset / samp_rate, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 4, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 16, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "On Off Keying") Qt.QWidget.__init__(self) self.setWindowTitle("On Off Keying") 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", "OnOffKeying") 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 = 44100 self.carrier_freq = carrier_freq = 10000 self.samp_delay = samp_delay = 0 self.noise = noise = 0 self.modulating_freq = modulating_freq = 100 self.lf = lf = 100 self.filter_taps = filter_taps = firdes.low_pass( 1, samp_rate, carrier_freq, 25000, firdes.WIN_HAMMING, 6.76) self.bit_delay = bit_delay = 0 self.Glow = Glow = 3 ################################################## # Blocks ################################################## self._samp_delay_range = Range(0, 1000, 1, 0, 200) self._samp_delay_win = RangeWidget(self._samp_delay_range, self.set_samp_delay, 'samp_delay', "counter_slider", float) self.top_grid_layout.addWidget(self._samp_delay_win) self._noise_range = Range(0, 1, 1e-3, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'noise in [mV]', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win) self._lf_range = Range(50, 200, 1, 100, 200) self._lf_win = RangeWidget(self._lf_range, self.set_lf, 'Low-pass filter cut-off frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._lf_win) self._carrier_freq_range = Range(10000, 100000, 1, 10000, 200) self._carrier_freq_win = RangeWidget(self._carrier_freq_range, self.set_carrier_freq, 'carrier_freq', "counter_slider", float) self.top_grid_layout.addWidget(self._carrier_freq_win) self._Glow_range = Range(0.1, 100, 0.1, 3, 200) self._Glow_win = RangeWidget(self._Glow_range, self.set_Glow, 'Low-pass filter gain', "counter_slider", float) self.top_grid_layout.addWidget(self._Glow_win) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=10, taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=10, decimation=1, taps=None, fractional_bw=None) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(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(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self._modulating_freq_range = Range(10, 1000, 1, 100, 200) self._modulating_freq_win = RangeWidget(self._modulating_freq_range, self.set_modulating_freq, 'modulating_freq', "counter_slider", float) self.top_grid_layout.addWidget(self._modulating_freq_win) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(Glow, samp_rate, lf, 1000, firdes.WIN_HAMMING, 6.76)) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( 20, np.convolve(np.array(filter.firdes.gaussian(1, 20, 1.0, 4 * 20)), np.array((1, ) * 20))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, filter_taps, 0, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff( 20, np.convolve(np.array(filter.firdes.gaussian(1, 20, 1.0, 4 * 20)), np.array((1, ) * 20))) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 1, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( [0, 1], 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(320, True) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, 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_float * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.9) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/mnt/c/Users/David Fernandez Pina/sdr/MyTest.txt', True, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, '/dev/pts/0', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char * 1, 0) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, samp_delay) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self._bit_delay_range = Range(0, 8, 1, 0, 200) self._bit_delay_win = RangeWidget(self._bit_delay_range, self.set_bit_delay, 'bit_delay', "counter_slider", int) self.top_grid_layout.addWidget(self._bit_delay_win) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, carrier_freq, 1, 0, 0) self.analog_sig_source_x_0.set_block_alias("Carrier") ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.fir_filter_xxx_0, 0))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Audio modem FSK loop back test") Qt.QWidget.__init__(self) self.setWindowTitle("Audio modem FSK loop back test") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.hdr_format = hdr_format ################################################## # Variables ################################################## self.nfilts = nfilts = 32 self.SPS = SPS = 147 self.RX_decimation = RX_decimation = 49 self.EBW = EBW = .05 self.samp_rate = samp_rate = 44.1E3 self.fsk_deviation_hz = fsk_deviation_hz = 100 self.carrier_freq = carrier_freq = 1.75E3 self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, EBW, 5 * SPS * nfilts / RX_decimation) ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=RX_decimation, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / RX_decimation, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / RX_decimation, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '', False, False, '') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win) self.epy_block_0 = epy_block_0.msg_block() self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( SPS / RX_decimation, 6.28 / 400.0 * 2 / 70, (RRC_filter_taps), nfilts, nfilts / 2, 2, 1) self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 2, 'len_key2') 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.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0), True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 1, 1) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'len_key2') self.blocks_tagged_stream_mux_1 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 200, 'len_key') self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, SPS - 1) self.blocks_repack_bits_bb_0_0_0_0 = blocks.repack_bits_bb( 1, 8, 'len_key2', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, 1, 'len_key', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'len_key') self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.audio_source_0 = audio.source(44100, '', True) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -carrier_freq, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0) / (RX_decimation)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-60, .01, 0, True) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1.0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_message_debug_0_0, 'print')) self.msg_connect((self.epy_block_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.epy_block_0, 'msg_in')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_mux_1, 1)) self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_1, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_pwr_squelch_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="VA3ODG") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1920000 self.offset = offset = 50000 self.gain = gain = 40 self.fsk_deviation_hz = fsk_deviation_hz = 8000 self.freq = freq = 444850000 self.corr = corr = 0 ################################################## # Blocks ################################################## _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='RX gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label='Freq. correction', converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_corr_sizer) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=48000, fft_size=512, fft_rate=3, average=False, avg_alpha=None, title='Waterfall Plot', ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=48000, v_scale=0.25, v_offset=0, t_scale=0.001, 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.root_raised_cosine_filter_0 = filter.interp_fir_filter_fff(10, firdes.root_raised_cosine( 1, 48000, 4800, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq - offset, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 8000, 2000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(40, firdes.low_pass( 20, samp_rate, 3500, 2000, firdes.WIN_HAMMING, 6.76)) self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_DSTAR,dsd.dsd_MOD_AUTO_SELECT,3,True,2) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10.0, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.audio_sink_0 = audio.sink(8000, '', True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.dsd_block_ff_0, 0))
def __init__(self): gr.top_block.__init__(self, "Aprs Regenerate") Qt.QWidget.__init__(self) self.setWindowTitle("Aprs Regenerate") 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", "aprs_regenerate") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 ################################################## # Blocks ################################################## self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._show_text_0_win) self.satellites_nrzi_encode_0 = satellites.nrzi_encode() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_framer_0 = satellites.hdlc_framer(preamble_bytes=80, postamble_bytes=4) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/40, #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(-4.5, 4.5) 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(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [2, 0, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, 0, -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.fsk_demod_0 = fsk_demod( baud=1200, fsk_hi_tone=2200, fsk_lo_tone=1200, in_sps=40, out_sps=2, ) self.epy_block_0 = epy_block_0.blk() self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf((1200,2200), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/handiko/aprs_regenerate.wav', True) self.blocks_vco_f_0 = blocks.vco_f(48000, 2*math.pi, 0.1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001', 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, 40) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.audio_sink_0 = audio.sink(48000, '', True) self.afsk_afsk1200_0 = afsk.afsk1200(48000,4) ################################################## # Connections ################################################## self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.epy_block_0, 'in')) self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.satellites_hdlc_framer_0, 'in')) self.msg_connect((self.epy_block_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.satellites_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.afsk_afsk1200_0, 0), (self.show_text_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.satellites_nrzi_encode_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fsk_demod_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.afsk_afsk1200_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fsk_demod_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_hdlc_deframer_bp_0, 0)) self.connect((self.satellites_nrzi_encode_0, 0), (self.blocks_repeat_0, 0))
def __init__(self, output_sample_rate=_def_output_sample_rate, reverse=_def_reverse, verbose=_def_verbose, generator=transfer_function_tx, dstar=False, bt=_def_bt, rc=None, log=_def_log): """ Hierarchical block for RRC-filtered P25 FM modulation. The input is a dibit (P25 symbol) stream (char, not packed) and the output is the float "C4FM" signal at baseband, suitable for application to an FM modulator stage Input is at the base symbol rate (4800), output sample rate is typically either 32000 (USRP TX chain) or 48000 (sound card) @param output_sample_rate: output sample rate @type output_sample_rate: integer @param reverse: reverse polarity flag @type reverse: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modulation data to files? @type debug: bool """ gr.hier_block2.__init__( self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature input_sample_rate = 4800 # P25/ysf/dmr/dstar baseband symbol rate if rc == 'nxdn48': input_sample_rate = 2400 # only exception is nxdn48 = 2400 rate intermediate_rate = 48000 self._interp_factor = intermediate_rate / input_sample_rate self.dstar = dstar self.bt = bt if self.dstar: self.C2S = digital.chunks_to_symbols_bf([-1, 1], 1) else: mod_map = [1.0 / 3.0, 1.0, -(1.0 / 3.0), -1.0] self.C2S = digital.chunks_to_symbols_bf(mod_map) if reverse: self.polarity = blocks.multiply_const_ff(-1) else: self.polarity = blocks.multiply_const_ff(1) self.generator = generator assert rc is None or rc == 'rc' or rc == 'rrc' or rc.startswith('nxdn') if rc: coeffs = filter.firdes.root_raised_cosine(1.0, intermediate_rate, input_sample_rate, 0.2, 91) if rc == 'rc': coeffs = c4fm_taps(sample_rate=intermediate_rate).generate() elif self.dstar: coeffs = gmsk_taps(sample_rate=intermediate_rate, bt=self.bt).generate() elif rc.startswith('nxdn'): coeffs = c4fm_taps(sample_rate=intermediate_rate, generator=transfer_function_nxdn_tx, symbol_rate=input_sample_rate).generate() elif not rc: coeffs = c4fm_taps(sample_rate=intermediate_rate, generator=self.generator).generate() self.filter = filter.interp_fir_filter_fff(self._interp_factor, coeffs) if verbose: self._print_verbage() if log: self._setup_logging() self.connect(self, self.C2S, self.polarity, self.filter) if intermediate_rate != output_sample_rate: self.arb_resamp = filter.pfb.arb_resampler_fff( float(output_sample_rate) / intermediate_rate) self.connect(self.filter, self.arb_resamp, self) else: self.connect(self.filter, self)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.snr_db = snr_db = 3 self.noiseAmplitude = noiseAmplitude = sqrt(1 / (10**(0.1 * snr_db))) self.constellation = constellation = [-1.3416, -0.4472, 0.4472, 1.3416] self.bits = bits = 2 ################################################## # Blocks ################################################## self.random_source_x_0 = gr.vector_source_b( map(int, numpy.random.randint(0, 4, 10000)), True) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 400, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 100) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_1_win) self.gr_tag_debug_0 = gr.tag_debug(gr.sizeof_float * 1, "") self.gr_noise_source_x_0 = gr.noise_source_f(gr.GR_GAUSSIAN, noiseAmplitude, 0) self.gr_file_sink_1 = gr.file_sink(gr.sizeof_gr_complex * 1, "symbols.bin") self.gr_file_sink_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "output.bin") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "input.bin") self.gr_file_sink_0.set_unbuffered(False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-3, -1, 1, 3], [], 1, 1).base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( (constellation), 1) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 100) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000, bits_per_symbol=bits, ) ################################################## # Connections ################################################## self.connect((self.random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.random_source_x_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.gr_file_sink_1, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_tag_debug_0, 0))