Exemplo n.º 1
0
    def __init__(self, sample_rate, fac_size, fac_rate):
        gr.hier_block2.__init__(self, "fast_autocorrelator_c",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(1, 1, gr.sizeof_float))
        # Parameters
        self.sample_rate = sample_rate
        self.fac_size = fac_size
        self.fac_rate = fac_rate
        self.window = ()

        # Block Objects For Float Fast Autocorrelator
        self.stream_to_vector = blocks.stream_to_vector(
            gr.sizeof_float, fac_size)
        self.keep_one_in_n = blocks.keep_one_in_n(
            gr.sizeof_float * fac_size,
            max(1, int(sample_rate / fac_size / fac_rate)))
        self.fac_fft = fft.fft_vfc(fac_size, True, self.window)
        self.complex_to_mag = blocks.complex_to_mag(fac_size)
        self.fac_complex_to_mag = blocks.complex_to_mag(fac_size)
        self.nlog10_ff = blocks.nlog10_ff(20, fac_size,
                                          -20 * math.log10(fac_size))
        self.single_pole_iir_filter_ff = filter.single_pole_iir_filter_ff(
            1, fac_size)
        self.fft_vfc = fft.fft_vfc(fac_size, True, self.window)
        self.vector_to_stream = blocks.vector_to_stream(
            gr.sizeof_float, self.fac_size)

        # Connections for Auto Correlator
        self.connect(self, self.stream_to_vector, self.keep_one_in_n,
                     self.fft_vfc, self.complex_to_mag, self.fac_fft,
                     self.fac_complex_to_mag, self.single_pole_iir_filter_ff,
                     self.nlog10_ff, self.vector_to_stream, self)
Exemplo n.º 2
0
	def __init__(self, sample_rate, offset, deviation, decimation, symbol_rate):
		super(fsk_demodulator, self).__init__(
			"fsk_demodulator",
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
			gr.io_signature(1, 1, gr.sizeof_float*1),
		)

		symbol_taps_length = int(floor(float(sample_rate) / symbol_rate))
		symbol_taps = (1,) * symbol_taps_length

		self.symbol_filter_h = filter.freq_xlating_fir_filter_ccf(1, (symbol_taps), offset + deviation, sample_rate)
		self.symbol_filter_l = filter.freq_xlating_fir_filter_ccf(1, (symbol_taps), offset - deviation, sample_rate)

		self.mag_h = blocks.complex_to_mag(1)
		self.mag_l = blocks.complex_to_mag(1)
		self.sub = blocks.sub_ff(1)

		output_filter_cutoff = symbol_rate * 0.75
		output_filter_transition = symbol_rate * 0.25
		output_filter_attenuation = 40
		output_filter_taps = firdes.low_pass_2(1.0, sample_rate, output_filter_cutoff, output_filter_transition, output_filter_attenuation)
		self.output_filter = filter.fir_filter_fff(decimation, (output_filter_taps))

		self.connect((self, 0), (self.symbol_filter_h, 0))
		self.connect((self, 0), (self.symbol_filter_l, 0))
		self.connect((self.symbol_filter_h, 0), (self.mag_h, 0))
		self.connect((self.symbol_filter_l, 0), (self.mag_l, 0))
		self.connect((self.mag_h, 0), (self.sub, 0))
		self.connect((self.mag_l, 0), (self.sub, 1))
		self.connect((self.sub, 0), (self.output_filter, 0))
		self.connect((self.output_filter, 0), (self, 0))
Exemplo n.º 3
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "Amplitude Difference ",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.dpd_signum_func_0 = dpd.signum_func()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.dpd_signum_func_0, 0))
        self.connect((self.dpd_signum_func_0, 0), (self, 0))
        self.connect((self, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
Exemplo n.º 4
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "BER Computation",
            gr.io_signaturev(
                2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]),
            gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5)
        self.blocks_max_xx_0_0 = blocks.max_ff(1, 1)
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_cc(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_max_xx_0_0, 0), (self, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_max_xx_0_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self, 1), (self.blocks_sub_xx_0, 1))
Exemplo n.º 5
0
	def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code):
		super(FSKDemodulator, self).__init__()

		self._decoded = {}

		self._carrier_hz = carrier_hz
		self._deviation = deviation
		self._access_code = access_code

		samp_rate = sampling_rate
		#symbol_rate = 9920
		self.samples_per_symbol = float(samp_rate) / symbol_rate

		omega = self.samples_per_symbol * 1.0
		mu = 0.0
		gain_mu = 0.2
		gain_omega = 0.25 * gain_mu * gain_mu
		omega_relative_limit = 0.001

		tap_count = int(math.floor(self.samples_per_symbol))

		hz_n = (carrier_hz - deviation)
		taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate)
		hz_p = (carrier_hz + deviation)
		taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate)

		#source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False)
		# Concatenate data to compensate for correlate_access_code_bb latency
		source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64))
		source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64)))
		source = NumpySource(source_data)

		filter_n = filter.fir_filter_ccc(1, taps_n.tolist())
		self.connect(source, filter_n)
		filter_p = filter.fir_filter_ccc(1, taps_p.tolist())
		self.connect(source, filter_p)

		mag_n = blocks.complex_to_mag(1)
		self.connect(filter_n, mag_n)
		mag_p = blocks.complex_to_mag(1)
		self.connect(filter_p, mag_p)

		sub_pn = blocks.sub_ff()
		self.connect(mag_p, (sub_pn, 0))
		self.connect(mag_n, (sub_pn, 1))

		clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)
		self.connect(sub_pn, clock_recovery)

		slicer = digital.binary_slicer_fb()
		self.connect(clock_recovery, slicer)

		access_code_correlator = digital.correlate_access_code_bb(access_code, 0)
		self.connect(slicer, access_code_correlator)

		self.packetizer = Packetizer()
		self.connect(access_code_correlator, self.packetizer)
Exemplo n.º 6
0
	def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code):
		super(FSKDemodulator, self).__init__()

		self._decoded = {}

		self._carrier_hz = carrier_hz
		self._deviation = deviation
		self._access_code = access_code

		samp_rate = sampling_rate
		#symbol_rate = 9920
		self.samples_per_symbol = float(samp_rate) / symbol_rate

		omega = self.samples_per_symbol * 1.0
		mu = 0.0
		gain_mu = 0.2
		gain_omega = 0.25 * gain_mu * gain_mu
		omega_relative_limit = 0.001

		tap_count = int(math.floor(self.samples_per_symbol))

		hz_n = (carrier_hz - deviation)
		taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate)
		hz_p = (carrier_hz + deviation)
		taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate)

		#source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False)
		# Concatenate data to compensate for correlate_access_code_bb latency
		source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64))
		source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64)))
		source = NumpySource(source_data)

		filter_n = filter.fir_filter_ccc(1, taps_n.tolist())
		self.connect(source, filter_n)
		filter_p = filter.fir_filter_ccc(1, taps_p.tolist())
		self.connect(source, filter_p)

		mag_n = blocks.complex_to_mag(1)
		self.connect(filter_n, mag_n)
		mag_p = blocks.complex_to_mag(1)
		self.connect(filter_p, mag_p)

		sub_pn = blocks.sub_ff()
		self.connect(mag_p, (sub_pn, 0))
		self.connect(mag_n, (sub_pn, 1))

		clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)
		self.connect(sub_pn, clock_recovery)

		slicer = digital.binary_slicer_fb()
		self.connect(clock_recovery, slicer)

		access_code_correlator = digital.correlate_access_code_bb(access_code, 0)
		self.connect(slicer, access_code_correlator)

		self.packetizer = Packetizer()
		self.connect(access_code_correlator, self.packetizer)
Exemplo n.º 7
0
	def __init__(self, **kwargs):
		demod_rate = 48000
		
		SimpleAudioDemodulator.__init__(self, demod_rate=demod_rate, band_filter=5000, band_filter_transition=5000, **kwargs)
	
		input_rate = self.input_rate
		audio_rate = self.audio_rate
		
		inherent_gain = 0.5  # fudge factor so that our output is similar level to narrow FM
		self.agc_block = analog.feedforward_agc_cc(int(.02 * demod_rate), inherent_gain)
		self.demod_block = blocks.complex_to_mag(1)
		self.resampler_block = make_resampler(demod_rate, audio_rate)
		
		# assuming below 40Hz is not of interest
		dc_blocker = grfilter.dc_blocker_ff(audio_rate // 40, False)
		
		self.connect(
			self,
			self.band_filter_block,
			self.rf_squelch_block,
			self.agc_block,
			self.demod_block,
			dc_blocker,
			self.resampler_block)
		self.connect(self.band_filter_block, self.rf_probe_block)
		self.connect_audio_output(self.resampler_block, self.resampler_block)
Exemplo n.º 8
0
    def __init__(self, parent, baseband_freq=0,
                 y_per_div=10, ref_level=50, sample_rate=1, fft_size=512,
                 fft_rate=default_fft_rate, average=False, avg_alpha=None,
                 title='', size=default_fftsink_size, **kwargs):

        gr.hier_block2.__init__(self, "waterfall_sink_f",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0,0,0))

        waterfall_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq,
                               sample_rate=sample_rate, fft_size=fft_size,
                               fft_rate=fft_rate,
                               average=average, avg_alpha=avg_alpha, title=title)

        self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size)
        self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size,
                                             max(1, int(self.sample_rate/self.fft_size/self.fft_rate)))

        mywindow = window.blackmanharris(self.fft_size)
        self.fft = fft.fft_vfc(self.fft_size, True, mywindow)
        self.c2mag = blocks.complex_to_mag(self.fft_size)
        self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size)
        self.log = blocks.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size))
        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True)
	self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink)

        self.win = waterfall_window(self, parent, size=size)
        self.set_average(self.average)
Exemplo n.º 9
0
    def __init__(self, ber_block, ncorrelations, lfsr_bits = 16):
        gr.top_block.__init__(self)

        prn_len = 2**lfsr_bits
        prn = np.concatenate((scipy.signal.max_len_seq(lfsr_bits)[0], [1]))
        prn_fft_conj = np.conjugate(np.fft.fft(2*prn-1))

        self.source = blocks.vector_source_b(prn, True, 1, [])
        
        self.ber_block = ber_block
        
        self.char2float = blocks.char_to_float(1, 0.5)
        self.add_const = blocks.add_const_ff(-1.0)
        self.source_vector = blocks.stream_to_vector(gr.sizeof_float, prn_len)

        self.fft = fft.fft_vfc(prn_len, True, window.rectangular(prn_len), 1)
        self.prn_fft_source = blocks.vector_source_c(prn_fft_conj, True, prn_len, [])
        self.multiply_ffts = blocks.multiply_vcc(prn_len)
        self.ifft = fft.fft_vcc(prn_len, False, np.ones(prn_len)/prn_len**2, False, 1)
        self.corr_mag = blocks.complex_to_mag(prn_len)
        self.max_corr = blocks.max_ff(prn_len, 1)
        self.multiply_const = blocks.multiply_const_ff(-0.5)
        self.add_const2 = blocks.add_const_ff(0.5)
        
        self.head = blocks.head(gr.sizeof_float, ncorrelations)
        self.sink = blocks.vector_sink_f()

        self.connect(self.source, self.ber_block, self.char2float, self.add_const,
                         self.source_vector, self.fft, (self.multiply_ffts,0),
                         self.ifft, self.corr_mag, self.max_corr, self.multiply_const,
                         self.add_const2, self.head, self.sink)
        self.connect(self.prn_fft_source, (self.multiply_ffts,1))
Exemplo n.º 10
0
    def __init__(self, fft_len, rate, sample_rate):
        gr.hier_block2.__init__(self, "psd_logger",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, 0))
        self.fft_len = fft_len
        self.rate = rate
        self.sample_rate = sample_rate
        self.msgq = gr.msg_queue(2)
        self.log_file = open(
            '/tmp/psd_log' + '-' + time.strftime("%y%m%d") + '-' +
            time.strftime("%H%M%S"), 'w')

        self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
        self.one_in_n = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * self.fft_len,
            max(1, int(self.sample_rate / self.fft_len / self.rate)))

        mywindow = window.blackmanharris(self.fft_len)
        self.fft = fft.fft_vcc(self.fft_len, True, mywindow)
        power = 0
        for tap in mywindow:
            power += tap * tap

        self.c2mag = blocks.complex_to_mag(self.fft_len)

        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_len,
                                        self.msgq, True)
        self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag,
                     self.sink)

        self._watcher = _queue_watcher(self.msgq, self.log_file)
    def device_definition(options):
        """
        Definition of the devices used in the program.
        @param options
        """

        tb = OpERAFlow(name='US')

        the_source = blocks.file_source(gr.sizeof_gr_complex, "./%d_%d_%d_%d_noise.bin" % (options.fft_length, options.cp_length, options.ebn0, options.it), False)
        radio = RadioDevice(name="radio")

        det = Correlator()
        middle = gr.hier_block2(
                name='hier',
                input_signature  = gr.io_signature(1, 1, gr.sizeof_gr_complex),
                output_signature = gr.io_signature(1, 1, gr.sizeof_float * 1024),
        )
        middle.connect(middle, blocks.stream_to_vector(gr.sizeof_gr_complex, 1024), blocks.complex_to_mag(1024), middle)
        ed = EnergySSArch(1024, 1, EnergyDecision(th = options.threshold))

        radio.add_arch(source = the_source, arch = middle, sink =(det,0), uhd_device=the_source, name='estimator')
        radio.add_arch(source = the_source, arch = ed,     sink =(det,1), uhd_device=the_source, name = "ed")
        tb.add_radio(radio, "radio")

        return tb, radio, det
Exemplo n.º 12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.center_freq = center_freq = 433.8e6

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(center_freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(1, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.blocks_file_descriptor_sink_0 = blocks.file_descriptor_sink(gr.sizeof_float*1, 1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_file_descriptor_sink_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_mag_0, 0))    
Exemplo n.º 13
0
	def __init__(self, fft_len, rate, sample_rate):
		gr.hier_block2.__init__(self,
			"psd_logger",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),
			gr.io_signature(0,0,0))
		self.fft_len = fft_len
		self.rate = rate
		self.sample_rate = sample_rate
		self.msgq = gr.msg_queue(2)
		self.log_file = open('/tmp/psd_log'+'-'+ time.strftime("%y%m%d") + '-' + time.strftime("%H%M%S"),'w')

		self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
		self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_len,
		 max(1, int(self.sample_rate/self.fft_len/self.rate)))

		mywindow = window.blackmanharris(self.fft_len)
		self.fft = fft.fft_vcc(self.fft_len, True, mywindow)
		power = 0
		for tap in mywindow:
			power += tap*tap

		self.c2mag = blocks.complex_to_mag(self.fft_len)

		self.sink = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq, True)
		self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.sink)

		self._watcher = _queue_watcher(self.msgq, self.log_file)
Exemplo n.º 14
0
    def __init__(self, fft_len, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh):
        gr.hier_block2.__init__(self,
            "Coarse Dehopper",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1))
        '''
        Constructor
        
        @param fft_len - 
        @param freq_sample_delay_samps - 
        @param freq_samps_to_avg -
        @param mag_samps_to_avg - 
        @param thresh - 
        '''

        ##################################################
        # Parameters
        ##################################################
        self.fft_len = fft_len
        self.freq_sample_delay_samps = freq_sample_delay_samps
        self.freq_samps_to_avg = freq_samps_to_avg
        self.mag_samps_to_avg = mag_samps_to_avg
        self.thresh = thresh

        ##################################################
        # Blocks
        ##################################################
        self.s_and_h_detector = s_and_h_detector(
            freq_sample_delay_samps=freq_sample_delay_samps,
            freq_samps_to_avg=freq_samps_to_avg,
            mag_samps_to_avg=mag_samps_to_avg,
            thresh=thresh,
        )
        self.resamp = pfb.arb_resampler_ccf(1.0 / (fft_len / 4.0), taps=None, flt_size=32)
        self.resamp.declare_sample_delay(0)
        self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.30,.05,60)))
        self.fir.declare_sample_delay(0)
        self.fft_peak = fft_peak(fft_len=fft_len)
        self.vco = blocks.vco_c(1, 2.0 * pi / fft_len, 1)
        self.mult_conj = blocks.multiply_conjugate_cc(1)
        self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps)
        self.c2mag = blocks.complex_to_mag(1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.c2mag, 0), (self.s_and_h_detector, 0))
        self.connect((self.delay, 0), (self.mult_conj, 0))
        self.connect((self.mult_conj, 0), (self.fir, 0))
        self.connect((self.vco, 0), (self.mult_conj, 1))
        self.connect((self.fft_peak, 0), (self.s_and_h_detector, 1))
        self.connect((self.fir, 0), (self.resamp, 0))
        self.connect((self, 0), (self.c2mag, 0))
        self.connect((self, 0), (self.delay, 0))
        self.connect((self, 0), (self.fft_peak, 0))
        self.connect((self.resamp, 0), (self, 0))
        self.connect((self.s_and_h_detector, 0), (self.vco, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM RX")

        ##################################################
        # Variables
        ##################################################
        self.transmission_width = transmission_width = 100
        self.samp_rate = samp_rate = 256000
        self.resamp_factor = resamp_factor = 4
        self.cut_off_freq = cut_off_freq = 5000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/resamp_factor,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='FFT Plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=resamp_factor,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=resamp_factor,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, cut_off_freq, transmission_width, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab2/example6/am_usrp710.dat', True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.wxgui_fftsink2_0, 0))    
Exemplo n.º 16
0
def test_complex_to_mag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mag = blocks.complex_to_mag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, mag, probe)

    return top, probe
Exemplo n.º 17
0
def test_complex_to_mag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mag = blocks.complex_to_mag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, mag, probe)

    return top, probe
Exemplo n.º 18
0
 def test_complex_to_mag(self):
     src_data = (1 + 2j, 3 - 4j, 5 + 6j, 7 - 8j, -9 + 10j)
     expected_data = (sqrt(5), sqrt(25), sqrt(61), sqrt(113), sqrt(181))
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_mag()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 5)
Exemplo n.º 19
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1800e3

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(433880e3, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('output.wav', 1, int(samp_rate), 8)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_mag_0, 0))
Exemplo n.º 20
0
 def test_complex_to_mag(self):
     src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j)
     expected_data = (sqrt(5), sqrt(25), sqrt(61), sqrt(113), sqrt(181))
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_mag()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 5)
Exemplo n.º 21
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_rx = samp_rate_rx = 500e3
        self.samp_rate = samp_rate = 48000
        self.initial_bandwidth = initial_bandwidth = 100e3
        self.first_stage_decimation = first_stage_decimation = 4
        self.audio_decimation = audio_decimation = 2

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_ogg_source_0 = satnogs.ogg_source('/home/mocha/Desktop/satnogs_1389117_2019-12-17T09-31-56.ogg', 1, False)
        self.satnogs_noaa_apt_sink_0_0 = satnogs.noaa_apt_sink('/home/mocha/Desktop/satnogs_1389117_2019-12-17T09-31-56_ogg.png', 2080, 1800, True, True)
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=int(samp_rate_rx/ ( first_stage_decimation  * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation),
                decimation=48000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=4*4160,
                decimation=int((samp_rate_rx/ ( first_stage_decimation  * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation)/2),
                taps=None,
                fractional_bw=None,
        )
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(2, ([0.5, 0.5]))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	6, samp_rate_rx/ ( first_stage_decimation  * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_1, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.satnogs_noaa_apt_sink_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.band_pass_filter_0, 0))
        self.connect((self.satnogs_ogg_source_0, 0), (self.rational_resampler_xxx_1, 0))
Exemplo n.º 22
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 10e3
        self.samp_rate = samp_rate = 1e6
        self.mult_const = mult_const = 100
        self.lowpass_decimation = lowpass_decimation = 10
        self.freq = freq = 344940000
        self.cutoff_freq = cutoff_freq = 50e3

        ##################################################
        # Blocks
        ##################################################
        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, 0)
        self.osmosdr_source_0.set_freq_corr(0, 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(True, 0)
        self.osmosdr_source_0.set_gain(0, 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_0 = filter.fir_filter_ccf(
            lowpass_decimation,
            firdes.low_pass(1, samp_rate, cutoff_freq, trans_width,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (mult_const, ))
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/grcfifo', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
Exemplo n.º 23
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.freq = freq = 310e6
        self.ChRate = ChRate = 1e5

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=ChRate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            10, (firdes.low_pass(1, samp_rate, 5e3, 2.5e3)), 0, samp_rate)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Exemplo n.º 24
0
    def __init__(self, n=512):
        gr.top_block.__init__(self, "SDR Spectrum Analyzer Server")

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan = 10
        self.fc = fc = 99700000
        self.ab = ab = 20000000
        self.N = N = 1024
        self.n = n
        self.IP = IP = "192.168.1.103"
        self.Antena = Antena = "RX2"
        self.ventana = ventana = window.blackmanharris
        self.base = base = "exponencial"

        ##################################################
        # Blocks
        ##################################################
        self.src = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.src.set_samp_rate(ab)
        self.src.set_center_freq(fc, 0)
        self.src.set_gain(gan, 0)
        self.src.set_antenna("RX2", 0)
        self.dbm = RadioGIS.dbm()
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, N)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, N)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, N*n)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, N)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(N)
        self.udp_sink_0 = blocks.udp_sink(gr.sizeof_float*1, IP, port, 1472, True)
        self.RadioGIS_fft_0 = RadioGIS.fft(N, base, (ventana(N)))
        self.RadioGIS_averager_0 = RadioGIS.averager(N, n)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_averager_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.dbm, 0), (self.udp_sink_0, 0))    
        self.connect((self.RadioGIS_fft_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.RadioGIS_fft_0, 0))    
        self.connect((self.blocks_stream_to_vector_1, 0), (self.RadioGIS_averager_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.dbm, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_stream_to_vector_1, 0))    
        self.connect((self.src, 0), (self.blocks_stream_to_vector_0, 0))
Exemplo n.º 25
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.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=4160,
                decimation=4800,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=9600,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_wavfile_source_0 = blocks.wavfile_source(sys.argv[1], False)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((255, ))
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, 2)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 2)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, sys.argv[1]+".gray", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, samp_rate, 500, 4200, 2000, firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_wavfile_source_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_0, 0))
Exemplo n.º 26
0
    def __init__(self, bias, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, resamp_rate, thresh):
        gr.hier_block2.__init__(self,
            "Fine Dehopper",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1))

        ##################################################
        # Parameters
        ##################################################
        self.bias = bias
        self.freq_sample_delay_samps = freq_sample_delay_samps
        self.freq_samps_to_avg = freq_samps_to_avg
        self.mag_samps_to_avg = mag_samps_to_avg
        self.resamp_rate = resamp_rate
        self.thresh = thresh

        ##################################################
        # Blocks
        ##################################################
        self.s_and_h_detector = s_and_h_detector(
            freq_sample_delay_samps=freq_sample_delay_samps,
            freq_samps_to_avg=freq_samps_to_avg,
            mag_samps_to_avg=mag_samps_to_avg,
            thresh=thresh,
        )
        self.resamp = pfb.arb_resampler_ccf(resamp_rate * 2.0, taps=None, flt_size=32)
        self.resamp.declare_sample_delay(0)
        self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.25,.05,60)))
        self.fir.declare_sample_delay(0)
        self.vco = blocks.vco_c(1, 1, 1)
        self.mult_conj = blocks.multiply_conjugate_cc(1)
        self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps)
        self.c2mag = blocks.complex_to_mag(1)
        self.add_const = blocks.add_const_vff((-1.0 * bias * (resamp_rate), ))
        self.demod = analog.quadrature_demod_cf(1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.demod, 0), (self.s_and_h_detector, 1))
        self.connect((self.add_const, 0), (self.vco, 0))
        self.connect((self.c2mag, 0), (self.s_and_h_detector, 0))
        self.connect((self.delay, 0), (self.mult_conj, 0))
        self.connect((self.mult_conj, 0), (self.fir, 0))
        self.connect((self.vco, 0), (self.mult_conj, 1))
        self.connect((self.fir, 0), (self.resamp, 0))
        self.connect((self, 0), (self.demod, 0))
        self.connect((self, 0), (self.c2mag, 0))
        self.connect((self, 0), (self.delay, 0))
        self.connect((self.resamp, 0), (self, 0))
        self.connect((self.s_and_h_detector, 0), (self.add_const, 0))
Exemplo n.º 27
0
    def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq,
                 channel_width, transition_width, threshold, iq_filename,
                 dig_out_filename):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.cutoff_freq = channel_width / 2
        self.firdes_taps = firdes.low_pass(1, samp_rate_in, self.cutoff_freq,
                                           transition_width)

        ##################################################
        # Blocks
        ##################################################
        self.tuning_filter_0 = filter.freq_xlating_fir_filter_ccc(
            int(samp_rate_in / samp_rate_out), (self.firdes_taps),
            tune_freq - center_freq, samp_rate_in)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, iq_filename, False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1 * threshold, ))

        # message sink is primary method of getting baseband data into waveconverter
        self.sink_queue = gr.msg_queue()
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, self.sink_queue, False)

        # if directed, we also dump the baseband data into a file
        if len(dig_out_filename) > 0:
            print "Outputing baseband to waveform to " + dig_out_filename
            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       dig_out_filename, False)
            self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.tuning_filter_0, 0))
        self.connect((self.tuning_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))

        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_message_sink_0, 0))
        if len(dig_out_filename) > 0:
            self.connect((self.digital_binary_slicer_fb_0, 0),
                         (self.blocks_file_sink_0, 0))
Exemplo n.º 28
0
    def __init__(self, decay=0.001, samp_rate=48000, attack=0.1, Frequency=1200):
        gr.hier_block2.__init__(
            self, "Detectmarkspace",
            gr.io_signature(1, 1, gr.sizeof_float*1),
            gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.decay = decay
        self.samp_rate = samp_rate
        self.attack = attack
        self.Frequency = Frequency

        ##################################################
        # Variables
        ##################################################
        self.Baud = Baud = 1200

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, samp_rate, Baud, 0.35, samp_rate/Baud))
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -Frequency, 1, 0)
        self.analog_agc2_xx_0 = analog.agc2_ff(attack, decay, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(1.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self, 1))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.root_raised_cosine_filter_0, 0))    
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_sub_xx_0, 0), (self, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
Exemplo n.º 29
0
    def __init__(self, sample_rate, fac_size, fac_decimation, use_db):
        gr.hier_block2.__init__(
            self,
            "AutoCorrelator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input sig
            gr.io_signature(1, 1, gr.sizeof_float * fac_size))  # Output sig

        self.fac_size = fac_size
        self.fac_decimation = fac_decimation
        self.sample_rate = sample_rate

        streamToVec = blocks.stream_to_vector(gr.sizeof_gr_complex,
                                              self.fac_size)
        # Make sure N is at least 1
        decimation = int(self.sample_rate / self.fac_size /
                         self.fac_decimation)
        self.one_in_n = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * self.fac_size, max(1, decimation))

        # FFT Note: No windowing.
        fac = fft.fft_vcc(self.fac_size, True, ())

        complex2Mag = blocks.complex_to_mag(self.fac_size)
        self.avg = filter.single_pole_iir_filter_ff(1.0, self.fac_size)

        fac_fac = fft.fft_vfc(self.fac_size, True, ())
        fac_c2mag = blocks.complex_to_mag(fac_size)

        # There's a note in Baz's block about needing to add 3 dB to each bin but the DC bin, however it was never implemented
        n = 20
        k = -20 * math.log10(self.fac_size)
        log = blocks.nlog10_ff(n, self.fac_size, k)

        if use_db:
            self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag,
                         fac_fac, fac_c2mag, self.avg, log, self)
        else:
            self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag,
                         fac_fac, fac_c2mag, self.avg, self)
Exemplo n.º 30
0
    def __init__(self):
        gr.hier_block2.__init__(self, "CORDIC from I,Q floats",
                                gr.io_signature(2,2,gr.sizeof_float),
                                gr.io_signature(2,2,gr.sizeof_float))

        ftc = blocks.float_to_complex()
        mag = blocks.complex_to_mag()
        arg = blocks.complex_to_arg()

        self.connect((self,0), (ftc,0))
        self.connect((self,1), (ftc,1))
        self.connect(ftc,mag,(self,0))
        self.connect(ftc,arg,(self,1))
Exemplo n.º 31
0
    def __init__(self, path=None, output_path=None):
        gr.top_block.__init__(self, "Rx")

        if path != None:
            am_demod = blocks.file_source(gr.sizeof_float * 1, path)
        else:
            osmosdr_h = osmosdr.source(args="numchan=" + str(1) + " " + "")

            osmosdr_h.set_sample_rate(Fs)
            osmosdr_h.set_center_freq(Fc, 0)
            osmosdr_h.set_gain_mode(True)  # enable hw agc

            lpf_carrier = firdes.low_pass(1.0, Fs, 10000, 1000,
                                          firdes.WIN_HAMMING, 6.76)

            carrier_xlate = filter.freq_xlating_fir_filter_ccc(
                xlate_decim, lpf_carrier, Foffset, Fs)

            am_demod = blocks.complex_to_mag(1)

            self.connect(osmosdr_h, carrier_xlate, am_demod)

            if options.output_path:
                file_sink = blocks.file_sink(gr.sizeof_float * 1, output_path,
                                             False)
                self.connect(am_demod, file_sink)

        if PLAY_AUDIO:
            audio_sink = audio.sink(Fa, "", True)
            self.connect(am_demod, audio_sink)

        audio_to_vec = blocks.stream_to_vector(gr.sizeof_float * 1, fft_width)
        audio_fft = fft.fft_vfc(fft_width, True,
                                (window.blackmanharris(fft_width)), 1)
        fft_mag = blocks.complex_to_mag(fft_width)
        self.connect(am_demod, audio_to_vec, audio_fft, fft_mag)

        decoder = Decoder()
        self.connect(fft_mag, decoder)
Exemplo n.º 32
0
    def __init__(self, infile="", outfile=""):
        gr.top_block.__init__(self, "Demod")

        ##################################################
        # Parameters
        ##################################################
        self.infile = infile
        self.outfile = outfile

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.offset = offset = 220e3
        self.key_freq = key_freq = 433.92e6

        ##################################################
        # Blocks
        ##################################################
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10000, ))
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, infile, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, outfile,
                                                   False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((-0.5, ))
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(100, samp_rate, 220e3, 270e3, 50e3,
                             firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_file_sink_0, 0))
Exemplo n.º 33
0
    def __init__(self, sample_rate, offset, deviation, decimation,
                 symbol_rate):
        super(fsk_demodulator, self).__init__(
            "fsk_demodulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        symbol_taps_length = int(floor(float(sample_rate) / symbol_rate))
        symbol_taps = (1, ) * symbol_taps_length

        self.symbol_filter_h = filter.freq_xlating_fir_filter_ccf(
            1, (symbol_taps), offset + deviation, sample_rate)
        self.symbol_filter_l = filter.freq_xlating_fir_filter_ccf(
            1, (symbol_taps), offset - deviation, sample_rate)

        self.mag_h = blocks.complex_to_mag(1)
        self.mag_l = blocks.complex_to_mag(1)
        self.sub = blocks.sub_ff(1)

        output_filter_cutoff = symbol_rate * 0.75
        output_filter_transition = symbol_rate * 0.25
        output_filter_attenuation = 40
        output_filter_taps = firdes.low_pass_2(1.0, sample_rate,
                                               output_filter_cutoff,
                                               output_filter_transition,
                                               output_filter_attenuation)
        self.output_filter = filter.fir_filter_fff(decimation,
                                                   (output_filter_taps))

        self.connect((self, 0), (self.symbol_filter_h, 0))
        self.connect((self, 0), (self.symbol_filter_l, 0))
        self.connect((self.symbol_filter_h, 0), (self.mag_h, 0))
        self.connect((self.symbol_filter_l, 0), (self.mag_l, 0))
        self.connect((self.mag_h, 0), (self.sub, 0))
        self.connect((self.mag_l, 0), (self.sub, 1))
        self.connect((self.sub, 0), (self.output_filter, 0))
        self.connect((self.output_filter, 0), (self, 0))
Exemplo n.º 34
0
    def __init__(self, config):
        gr.top_block.__init__(self, self.__class__.__name__)

        self._start_time = -1
        self._end_time = 0
        self._running = False

        self.source = RadioSource(preferred_sample_rate=config.sample_rate,
                                  gains=config.gains,
                                  frequency_offset=config.frequency_offset)

        self.fft = fft.fft_vfc(config.fft_resolution, True,
                               (window.rectangular(config.fft_resolution)), 1)
        self.stream_to_vector = blocks.stream_to_vector(
            gr.sizeof_float * 1, config.fft_resolution)
        self.psd = blocks.multiply_vcc(config.fft_resolution)
        self.complex_to_real = blocks.complex_to_real(1)
        self.complex_to_mag = blocks.complex_to_mag(config.fft_resolution)
        self.bpf = filter.fir_filter_ccf(
            1,
            firdes.band_pass(
                100, config.sample_rate,
                self.source.frequency_offset - (config.signal_bandwidth / 2),
                self.source.frequency_offset + (config.signal_bandwidth / 2),
                600, firdes.WIN_RECTANGULAR, 6.76))

        self.processing = select_detection_method(config.detection_method)(
            num_bins=config.fft_resolution,
            center_frequency=0,
            signal_frequency=config.frequency_offset,
            signal_bandwidth=config.signal_bandwidth,
            threshold=config.snr_threshold,
            decay_time=config.decay_time,
            decay_strength=config.decay_strength)

        self.extract = AsyncSink()

        self.connect(self.source, self.bpf)
        self.connect(self.bpf, self.complex_to_real)
        self.connect(self.complex_to_real, self.stream_to_vector)
        self.connect(self.stream_to_vector, self.fft)
        self.connect((self.fft, 0), (self.psd, 1))
        self.connect((self.fft, 0), (self.psd, 0))
        self.connect(self.psd, self.complex_to_mag)
        self.connect(self.complex_to_mag, self.processing)
        self.connect(self.processing, self.extract)

        self.processing.set_sample_rate(config.sample_rate /
                                        config.fft_resolution)
Exemplo n.º 35
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.vec_length = vec_length = int(100e3)
        self.samp_rate = samp_rate = 2e6
        self.folder = folder = "/home/erik/Dev/mini-hackathon/HackaCurtain/data/test/"
        self.center_freq = center_freq = 433.5e6

        ##################################################
        # Blocks
        ##################################################
        self.trigger_trigger_ff_0 = trigger.trigger_ff(0.5, int(200))
        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(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 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(20, 0)
        self.osmosdr_source_0.set_if_gain(30, 0)
        self.osmosdr_source_0.set_bb_gain(30, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.08, 0.14, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_float*1, int(samp_rate))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag("burst",True)
        self.blocks_burst_tagger_0.set_false_tag("burst",False)
        	

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_burst_tagger_0, 1))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_burst_tagger_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.trigger_trigger_ff_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.trigger_trigger_ff_0, 0), (self.blocks_float_to_short_0, 0))    
Exemplo n.º 36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Fft To Tcp")

        ##################################################
        # Variables
        ##################################################
        self.veclen = veclen = 8192
        self.test = test = 1420e6
        self.samp_rate = samp_rate = 1500000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "")
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(test, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(1, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.fft_vxx_0 = fft.fft_vcc(veclen, True, (window.blackmanharris(veclen)), True, 1)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, samp_rate)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, veclen)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(veclen)
        self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_gr_complex * samp_rate, addr="127.0.0.1", port=10002, server=True
        )
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_float * veclen, addr="127.0.0.1", port=10001, server=True
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.blks2_tcp_sink_0_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_1, 0))
Exemplo n.º 37
0
    def __init__(self, gan=10, fi=70000000, ab=32000000, sc=10, t=1, base="exponencial", escala="dBm"):
        gr.top_block.__init__(self, "SDR RNI Meter")

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan
        self.fi = fi
        self.ab = ab
        self.fc = fc = fi + ab / 2
        self.N = N = 1024
        self.sc = sc
        self.t = t
        self.IP = IP = "192.168.1.108"
        self.Antena = Antena = "RX2"
        self.ventana = ventana = window.blackmanharris
        self.base = base
        self.escala = escala
        self.gps = gps = "n: 0.0 deg 0.0 deg 0.0m lat/lon/al"

        ##################################################
        # Blocks
        ##################################################
        self.src = uhd.usrp_source(",".join(("", "")), uhd.stream_args(cpu_format="fc32", channels=range(1)))
        self.src.set_samp_rate(ab)
        self.src.set_center_freq(fc, 0)
        self.src.set_gain(gan, 0)
        self.src.set_antenna("RX2", 0)
        self.dbm = RadioGIS.dbm()
        self.dbm.set_enabled(escala == "dBm")
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float * 1, N)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, N)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(N)
        self.RadioGIS_time_averager_0 = RadioGIS.time_averager(N, t)
        self.udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, IP, port, 1472, True)
        self.RadioGIS_fft_0 = RadioGIS.fft(N, base, (ventana(N)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_fft_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.RadioGIS_time_averager_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.RadioGIS_fft_0, 0))
        self.connect((self.RadioGIS_time_averager_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.dbm, 0))
        self.connect((self.dbm, 0), (self.udp_sink_0, 0))
        self.connect((self.src, 0), (self.blocks_stream_to_vector_0, 0))
Exemplo n.º 38
0
    def __init__(self):
        gr.top_block.__init__(self, "Signals")

        ##################################################
        # Variables
        ##################################################
        self.tune_freq = tune_freq = 315000000
        self.samp_rate = samp_rate = 1.024e6

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_float, 1,
                                                   'tcp://127.0.0.1:5557', 100,
                                                   False, -1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(tune_freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(5, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(200000, 0)

        self.low_pass_filter_1 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 20000, 10000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            5,
            firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.zeromq_push_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
Exemplo n.º 39
0
    def __init__(self):
        gr.top_block.__init__(self, "Ornl 1")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_magphase_to_complex_1 = blocks.magphase_to_complex(1)
        self.blocks_magphase_to_complex_0 = blocks.magphase_to_complex(1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                         50 * samp_rate)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   'ornl_1.bin', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_magphase_to_complex_1, 1))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_magphase_to_complex_1, 0))
        self.connect((self.blocks_complex_to_magphase_0, 1),
                     (self.blocks_magphase_to_complex_0, 1))
        self.connect((self.blocks_complex_to_magphase_0, 0),
                     (self.blocks_magphase_to_complex_0, 0))
        self.connect((self.blocks_head_0, 0),
                     (self.blocks_complex_to_magphase_0, 0))
        self.connect((self.blocks_magphase_to_complex_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_magphase_to_complex_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_magphase_to_complex_1, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_head_0, 0))
Exemplo n.º 40
0
    def __init__( self, if_rate, af_rate ):
        gr.hier_block2.__init__(self, "ssb_demod",
                                gr.io_signature(1,1,gr.sizeof_gr_complex),
                                gr.io_signature(1,1,gr.sizeof_float))

        self.if_rate  = int(if_rate)
        self.af_rate  = int(af_rate)
        self.if_decim = int(if_rate / af_rate)
        self.sideband = 1

        self.xlate_taps = ([complex(v) for v in file('ssb_taps').readlines()])

        self.audio_taps = filter.firdes.low_pass(
            1.0,
            self.af_rate,
            3e3,
            600,
            filter.firdes.WIN_HAMMING )

        self.xlate = filter.freq_xlating_fir_filter_ccc(
            self.if_decim,
            self.xlate_taps,
            0,
            self.if_rate )

        self.split = blocks.complex_to_float()

        self.lpf = filter.fir_filter_fff(
            1, self.audio_taps )

        self.sum   = blocks.add_ff( )
        self.am_sel = blocks.multiply_const_ff( 0 )
        self.sb_sel = blocks.multiply_const_ff( 1 )
        self.mixer  = blocks.add_ff()
        self.am_det = blocks.complex_to_mag()

        self.connect(self,             self.xlate)
        self.connect(self.xlate,       self.split)
        self.connect((self.split, 0), (self.sum, 0))
        self.connect((self.split, 1), (self.sum, 1))
        self.connect(self.sum,         self.sb_sel)
        self.connect(self.xlate,       self.am_det)
        self.connect(self.sb_sel,     (self.mixer, 0))
        self.connect(self.am_det,      self.am_sel)
        self.connect(self.am_sel,     (self.mixer, 1))
        self.connect(self.mixer,       self.lpf)
        self.connect(self.lpf,         self)
Exemplo n.º 41
0
    def __init__(self,
                 parent,
                 baseband_freq=0,
                 y_per_div=10,
                 ref_level=50,
                 sample_rate=1,
                 fft_size=512,
                 fft_rate=default_fft_rate,
                 average=False,
                 avg_alpha=None,
                 title='',
                 size=default_fftsink_size,
                 **kwargs):

        gr.hier_block2.__init__(self, "waterfall_sink_f",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))

        waterfall_sink_base.__init__(self,
                                     input_is_real=True,
                                     baseband_freq=baseband_freq,
                                     sample_rate=sample_rate,
                                     fft_size=fft_size,
                                     fft_rate=fft_rate,
                                     average=average,
                                     avg_alpha=avg_alpha,
                                     title=title)

        self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size)
        self.one_in_n = blocks.keep_one_in_n(
            gr.sizeof_float * self.fft_size,
            max(1, int(self.sample_rate / self.fft_size / self.fft_rate)))

        mywindow = window.blackmanharris(self.fft_size)
        self.fft = fft.fft_vfc(self.fft_size, True, mywindow)
        self.c2mag = blocks.complex_to_mag(self.fft_size)
        self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size)
        self.log = blocks.nlog10_ff(20, self.fft_size,
                                    -20 * math.log10(self.fft_size))
        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size,
                                        self.msgq, True)
        self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag,
                     self.avg, self.log, self.sink)

        self.win = waterfall_window(self, parent, size=size)
        self.set_average(self.average)
Exemplo n.º 42
0
    def __init__(self, channel_rate, audio_decim, audio_pass, audio_stop):
	gr.hier_block2.__init__(self, "am_demod_cf",
				gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float))      # Input signature

	MAG = blocks.complex_to_mag()
	DCR = blocks.add_const_ff(-1.0)

	audio_taps = filter.optfir.low_pass(0.5, 	  # Filter gain
                                            channel_rate, # Sample rate
                                            audio_pass,   # Audio passband
                                            audio_stop,   # Audio stopband
                                            0.1, 	  # Passband ripple
                                            60)	          # Stopband attenuation
	LPF = filter.fir_filter_fff(audio_decim, audio_taps)

	self.connect(self, MAG, DCR, LPF, self)
Exemplo n.º 43
0
    def __init__(self, channel_rate, audio_decim, audio_pass, audio_stop):
        gr.hier_block2.__init__(self, "am_demod_cf",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float))      # Input signature

        MAG = blocks.complex_to_mag()
        DCR = blocks.add_const_ff(-1.0)

        audio_taps = filter.optfir.low_pass(0.5,          # Filter gain
                                            channel_rate, # Sample rate
                                            audio_pass,   # Audio passband
                                            audio_stop,   # Audio stopband
                                            0.1,          # Passband ripple
                                            60)           # Stopband attenuation
        LPF = filter.fir_filter_fff(audio_decim, audio_taps)

        self.connect(self, MAG, DCR, LPF, self)
Exemplo n.º 44
0
    def __init__(self, parent, baseband_freq=0, ref_scale=2.0,
                 y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512,
                 fft_rate=default_fft_rate, average=False, avg_alpha=None,
                 title='', size=default_fftsink_size, peak_hold=False,
                 use_persistence=False, persist_alpha=0.2, **kwargs):

        gr.hier_block2.__init__(self, "fft_sink_c",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0,0,0))

        fft_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq,
                               y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level,
                               sample_rate=sample_rate, fft_size=fft_size,
                               fft_rate=fft_rate,
                               average=average, avg_alpha=avg_alpha, title=title,
                               peak_hold=peak_hold, use_persistence=use_persistence,
                               persist_alpha=persist_alpha)

        self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
        self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size,
                                             max(1, int(self.sample_rate/self.fft_size/self.fft_rate)))

        mywindow = window.blackmanharris(self.fft_size)
        self.fft = fft.fft_vcc(self.fft_size, True, mywindow)
        power = 0
        for tap in mywindow:
            power += tap*tap

        self.c2mag = blocks.complex_to_mag(self.fft_size)
        self.avg = grfilter.single_pole_iir_filter_ff(1.0, self.fft_size)

        # FIXME  We need to add 3dB to all bins but the DC bin
        self.log = blocks.nlog10_ff(20, self.fft_size,
                                -20*math.log10(self.fft_size)                # Adjust for number of bins
                                -10*math.log10(power/self.fft_size)        # Adjust for windowing loss
                                -20*math.log10(ref_scale/2))                # Adjust for reference scale

        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True)
        self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink)

        self.win = fft_window(self, parent, size=size)
        self.set_average(self.average)
        self.set_use_persistence(self.use_persistence)
        self.set_persist_alpha(self.persist_alpha)
        self.set_peak_hold(self.peak_hold)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="File Fft To Tcp Nogui")

        ##################################################
        # Variables
        ##################################################
        self.veclen = veclen = 8192
        self.test = test = 1420e6
        self.samp_rate = samp_rate = 1500000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.fft_vxx_0 = fft.fft_vcc(veclen, True, (window.blackmanharris(veclen)), True, 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, samp_rate)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, veclen)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bill/Desktop/radiotelescope/default.iqstream", True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(veclen)
        self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_gr_complex*samp_rate,
        	addr="127.0.0.1",
        	port=10002,
        	server=True,
        )
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_float*veclen,
        	addr="127.0.0.1",
        	port=10001,
        	server=True,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_tcp_sink_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_1, 0), (self.blks2_tcp_sink_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_1, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_0, 0))    
Exemplo n.º 46
0
    def __init__(self, fft_len):
        gr.hier_block2.__init__(self,
            "FFT Peak",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]))
        '''
        Constructor
        
        @param fft_len -
        '''

        ##################################################
        # Parameters
        ##################################################
        self.fft_len = fft_len

        ##################################################
        # Blocks
        ##################################################
        self.fft = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), False, 1)
        self.v2s = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len)
        self.s2f = blocks.short_to_float(1, 1)
        self.repeat = blocks.repeat(gr.sizeof_short*1, fft_len)
        self.null_0 = blocks.null_sink(gr.sizeof_float*1)
        self.null_1 = blocks.null_sink(gr.sizeof_short*1)
        self.c2mag = blocks.complex_to_mag(fft_len)
        self.argmax = blocks.argmax_fs(fft_len)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.argmax, 1), (self.null_1, 0))
        self.connect((self.argmax, 0), (self.repeat, 0))
        self.connect((self.c2mag, 0), (self.argmax, 0))
        self.connect((self.c2mag, 0), (self.v2s, 0))
        self.connect((self.repeat, 0), (self.s2f, 0))
        self.connect((self.s2f, 0), (self, 0))
        self.connect((self.s2v, 0), (self.fft, 0))
        self.connect((self.v2s, 0), (self.null_0, 0))
        self.connect((self.v2s, 0), (self, 1))
        self.connect((self.fft, 0), (self.c2mag, 0))
        self.connect((self, 0), (self.s2v, 0))
Exemplo n.º 47
0
Arquivo: am_chain.py Projeto: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "AM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=2,
            decimation=75,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=3,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.low_pass_filter_0, 0))
Exemplo n.º 48
0
    def __init__(self, use_entire_input_band=False, **kwargs):
        demod_rate = 10000

        SimpleAudioDemodulator.__init__(
            self, audio_rate=demod_rate, demod_rate=demod_rate, band_filter=5000, band_filter_transition=5000, **kwargs
        )

        self.__use_entire_input_band = bool(use_entire_input_band)
        self.__rec_freq_input = 0.0

        inherent_gain = 0.5  # fudge factor so that our output is similar level to narrow FM
        self.agc_block = analog.feedforward_agc_cc(int(0.02 * demod_rate), inherent_gain)
        self.demod_block = blocks.complex_to_mag(1)

        # assuming below 40Hz is not of interest
        self.dc_blocker = grfilter.dc_blocker_ff(demod_rate // 40, False)

        self.__do_connect()
Exemplo n.º 49
0
    def __init__(self, options):

        gr.hier_block2.__init__(self, "sensing_path",
                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                gr.io_signature(0, 0, 0)) # Output signature


        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose        = options.verbose
       
        # linklab, fft size for sensing, different from fft length for tx/rx
        self.fft_size = FFT_SIZE

        # interpolation rate: sensing fft size / ofdm fft size
        self.interp_rate = self.fft_size/options.fft_length

        self._fft_length      = options.fft_length
        self._occupied_tones  = options.occupied_tones
        self.msgq             = gr.msg_queue()

        # linklab , setup the sensing path
        # FIXME: some components are not necessary
        self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
        mywindow = window.blackmanharris(self.fft_size)
        self.fft = fft.fft_vcc(self.fft_size, True, mywindow)
        power = 0
        for tap in mywindow:
            power += tap*tap
        self.c2mag = blocks.complex_to_mag(self.fft_size)
        self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size)

        # linklab, ref scale value from default ref_scale in usrp_fft.py
        ref_scale = 13490.0

        # FIXME  We need to add 3dB to all bins but the DC bin
        self.log = blocks.nlog10_ff(20, self.fft_size,
                                -10*math.log10(self.fft_size)              # Adjust for number of bins
                                -10*math.log10(power/self.fft_size)        # Adjust for windowing loss
                                -20*math.log10(ref_scale/2))               # Adjust for reference scale

        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True)
        self.connect(self, self.s2p, self.fft, self.c2mag, self.avg, self.log, self.sink)
Exemplo n.º 50
0
 def __do_connect(self):
     inherent_gain = 0.5  # fudge factor so that our output is similar level to narrow FM
     if self.__demod_method != 'async':
         inherent_gain *= 2
     
     agc_block = analog.feedforward_agc_cc(int(.005 * self.__demod_rate), inherent_gain)
     
     # non-method-specific elements
     self.disconnect_all()
     self.connect(
         self,
         self.band_filter_block,  # from SimpleAudioDemodulator
         self.rf_squelch_block,  # from SquelchMixin
         agc_block)
     self.connect(self.band_filter_block, self.rf_probe_block)
     before_demod = agc_block
     
     if self.__demod_method == u'async':
         dc_blocker = self.__make_dc_blocker()
         self.connect(
             before_demod,
             blocks.complex_to_mag(1),
             dc_blocker)
         self.connect_audio_output(dc_blocker, dc_blocker)
         self.__pll = None
     else:
         # all other methods use carrier tracking
         # TODO: refine PLL parameters further
         pll = self.__pll = analog.pll_carriertracking_cc(.01 * pi, .1 * pi, -.1 * pi)
         pll.set_lock_threshold(dB(-20))
         # pll.squelch_enable(True)
         self.connect(before_demod, pll)
         
         if self.__demod_method == u'stereo':
             left_input, left_output = self.__make_sideband_demod(False)
             right_input, right_output = self.__make_sideband_demod(True)
             self.connect(pll, left_input)
             self.connect(pll, right_input)
             self.connect_audio_output(left_output, right_output)
         else:
             (demod_input, demod_output) = self.__make_sideband_demod(self.__demod_method == u'usb')
             self.connect(pll, demod_input)
             self.connect_audio_output(demod_output, demod_output)
Exemplo n.º 51
0
    def __do_connect(self):
        inherent_gain = 0.5  # fudge factor so that our output is similar level to narrow FM
        if self.__demod_method != 'async':
            inherent_gain *= 2

        agc_block = analog.feedforward_agc_cc(int(.005 * self.__demod_rate),
                                              inherent_gain)

        # non-method-specific elements
        self.disconnect_all()
        self.connect(
            self,
            self.band_filter_block,  # from SimpleAudioDemodulator
            self.rf_squelch_block,  # from SquelchMixin
            agc_block)
        self.connect(self.band_filter_block, self.rf_probe_block)
        before_demod = agc_block

        if self.__demod_method == u'async':
            dc_blocker = self.__make_dc_blocker()
            self.connect(before_demod, blocks.complex_to_mag(1), dc_blocker)
            self.connect_audio_output(dc_blocker, dc_blocker)
            self.__pll = None
        else:
            # all other methods use carrier tracking
            # TODO: refine PLL parameters further
            pll = self.__pll = analog.pll_carriertracking_cc(
                .01 * pi, .1 * pi, -.1 * pi)
            pll.set_lock_threshold(dB(-20))
            # pll.squelch_enable(True)
            self.connect(before_demod, pll)

            if self.__demod_method == u'stereo':
                left_input, left_output = self.__make_sideband_demod(False)
                right_input, right_output = self.__make_sideband_demod(True)
                self.connect(pll, left_input)
                self.connect(pll, right_input)
                self.connect_audio_output(left_output, right_output)
            else:
                (demod_input, demod_output) = self.__make_sideband_demod(
                    self.__demod_method == u'usb')
                self.connect(pll, demod_input)
                self.connect_audio_output(demod_output, demod_output)
Exemplo n.º 52
0
    def __init__(self, mode, input_rate, context):
        channels = 2
        audio_rate = 10000
        
        gr.hier_block2.__init__(
            self, str('%s demodulator' % (mode,)),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float * channels))

        self.__input_rate = input_rate
        self.__rec_freq_input = 0.0
        self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate)

        # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate.
        agc_block = analog.agc2_cc(reference=dB(-8))
        agc_block.set_attack_rate(8e-3)
        agc_block.set_decay_rate(8e-3)
        agc_block.set_max_gain(dB(40))
        
        self.connect(
            self,
            agc_block)
        
        channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels)
        self.connect(channel_joiner, self)
        
        for channel in xrange(0, channels):
            self.connect(
                agc_block,
                grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)),
                blocks.complex_to_mag(1),
                blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
                MultistageChannelFilter(
                    input_rate=input_rate,
                    output_rate=audio_rate,
                    cutoff_freq=5000,
                    transition_width=5000),
                blocks.complex_to_real(),
                # assuming below 40Hz is not of interest
                grfilter.dc_blocker_ff(audio_rate // 40, False),
                (channel_joiner, channel))
Exemplo n.º 53
0
    def __init__(self, parent, baseband_freq=0,
                 y_per_div=10, ref_level=50, sample_rate=1, fac_size=512,
                 fac_rate=default_fac_rate, 
                 average=False, avg_alpha=None,
                 title='', size=default_facsink_size, peak_hold=False):

        fac_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq,
                               y_per_div=y_per_div, ref_level=ref_level,
                               sample_rate=sample_rate, fac_size=fac_size,
                               fac_rate=fac_rate,  
                               average=average, avg_alpha=avg_alpha, title=title,
                               peak_hold=peak_hold)
                               
        s2p = blocks.stream_to_vector(gr.sizeof_float, self.fac_size)
        self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fac_size,
                                         max(1, int(self.sample_rate/self.fac_size/self.fac_rate)))

        # windowing removed... 

        #fac = gr.fft_vfc(self.fac_size, True, ())
        fac = fft.fft_vfc(self.fac_size, True, ())

        c2mag = blocks.complex_to_mag(self.fac_size)
        self.avg = filter.single_pole_iir_filter_ff_make(1.0, self.fac_size)

        fac_fac   = fft.fft_vfc(self.fac_size, True, ())
        fac_c2mag = blocks.complex_to_mag_make(fac_size)

        # FIXME  We need to add 3dB to all bins but the DC bin
        log = blocks.nlog10_ff_make(20, self.fac_size,
                           -20*math.log10(self.fac_size) )
        sink = blocks.message_sink(gr.sizeof_float * self.fac_size, self.msgq, True)

        self.connect(s2p, self.one_in_n, fac, c2mag,  fac_fac, fac_c2mag, self.avg, log, sink)

#        gr.hier_block.__init__(self, fg, s2p, sink)

        self.win = fac_window(self, parent, size=size)
        self.set_average(self.average)

        self.wxgui_connect(self, s2p)
Exemplo n.º 54
0
Arquivo: am_chain.py Projeto: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self, "AM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=2,
                decimation=75,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=3,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0))    
Exemplo n.º 55
0
    def __init__(self, alpha=0.001):
        gr.hier_block2.__init__(
            self, "amp_var_est_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0_0_1_0 = filter.single_pole_iir_filter_cc(alpha, 1)
        self.single_pole_iir_filter_xx_0_0_1 = filter.single_pole_iir_filter_ff(alpha, 1)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, ))
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.single_pole_iir_filter_xx_0_0_1_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0_1, 0), (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0_1_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0), (self, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 1))
Exemplo n.º 56
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Pager 6Ch Decode")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.xlate_decimation = xlate_decimation = 40
        self.hunter_freq_5 = hunter_freq_5 = 0
        self.hunter_freq_4 = hunter_freq_4 = 0
        self.hunter_freq_3 = hunter_freq_3 = 0
        self.hunter_freq_2 = hunter_freq_2 = 0
        self.hunter_freq_1 = hunter_freq_1 = 0
        self.hunter_freq_0 = hunter_freq_0 = 0
        self.gain = gain = 10
        self.frequency = frequency = 929000000
        self.filter_width = filter_width = 5120
        self.fft_taps = fft_taps = filter.firdes.low_pass_2(1, samp_rate, 2000, 1000, 0.1)
        self.fft_n_elements = fft_n_elements = 2048

        ##################################################
        # Blocks
        ##################################################
        _hunter_freq_5_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_5_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_5_sizer,
        	value=self.hunter_freq_5,
        	callback=self.set_hunter_freq_5,
        	label='hunter_freq_5',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_5_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_5_sizer,
        	value=self.hunter_freq_5,
        	callback=self.set_hunter_freq_5,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_5_sizer)
        _hunter_freq_4_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_4_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_4_sizer,
        	value=self.hunter_freq_4,
        	callback=self.set_hunter_freq_4,
        	label='hunter_freq_4',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_4_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_4_sizer,
        	value=self.hunter_freq_4,
        	callback=self.set_hunter_freq_4,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_4_sizer)
        _hunter_freq_3_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_3_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_3_sizer,
        	value=self.hunter_freq_3,
        	callback=self.set_hunter_freq_3,
        	label='hunter_freq_3',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_3_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_3_sizer,
        	value=self.hunter_freq_3,
        	callback=self.set_hunter_freq_3,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_3_sizer)
        _hunter_freq_2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_2_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_2_sizer,
        	value=self.hunter_freq_2,
        	callback=self.set_hunter_freq_2,
        	label='hunter_freq_2',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_2_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_2_sizer,
        	value=self.hunter_freq_2,
        	callback=self.set_hunter_freq_2,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_2_sizer)
        _hunter_freq_1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_1_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_1_sizer,
        	value=self.hunter_freq_1,
        	callback=self.set_hunter_freq_1,
        	label='hunter_freq_1',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_1_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_1_sizer,
        	value=self.hunter_freq_1,
        	callback=self.set_hunter_freq_1,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_1_sizer)
        _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_0_sizer,
        	value=self.hunter_freq_0,
        	callback=self.set_hunter_freq_0,
        	label='hunter_freq_0',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_0_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_0_sizer,
        	value=self.hunter_freq_0,
        	callback=self.set_hunter_freq_0,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_0_sizer)
        _frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	label='Frequency',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	minimum=80000000,
        	maximum=1100000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_frequency_sizer)
        self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, fft_n_elements, 'tcp://127.0.0.1:9000', 100, False, -1)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=frequency,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='master_plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(frequency, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        _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='gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self.freq_xlating_fft_filter_ccc_0_0_3 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_5, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_3.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_3.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_2 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_4, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_2.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_2.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_1 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_3, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_1.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_1.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_2, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_1, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        _filter_width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._filter_width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_filter_width_sizer,
        	value=self.filter_width,
        	callback=self.set_filter_width,
        	label='filter_width',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._filter_width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_filter_width_sizer,
        	value=self.filter_width,
        	callback=self.set_filter_width,
        	minimum=2048,
        	maximum=40960,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_filter_width_sizer)
        self.fft_vxx_0 = fft.fft_vcc(fft_n_elements, True, (window.blackmanharris(fft_n_elements)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_n_elements)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_n_elements)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_n_elements)
        self.blocks_null_sink_0_0_3 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_2 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_stream_to_vector_1, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_1, 0), (self.zeromq_push_sink_0_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_1, 0), (self.blocks_null_sink_0_0_1, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_2, 0), (self.blocks_null_sink_0_0_2, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_3, 0), (self.blocks_null_sink_0_0_3, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_2, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_3, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Exemplo n.º 57
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Rx")
        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", "wifi_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 5e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 20
        self.freq = freq = 943000000.0
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [1e6, 5e6, 10e6, 20e6]
        self._samp_rate_labels = ["1 MHz",  "5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-0.1, 1.4)
        
        self.qtgui_time_sink_x_1_0_0_0.set_y_label("Amplitude ----", "")
        
        self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.63, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0_0.disable_legend()
        
        labels = ["RATIO", "", "", "", "",
                  "", "", "", "", ""]
        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 = [2.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-0.001, 0.2)
        
        self.qtgui_time_sink_x_1_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.05, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0.disable_legend()
        
        labels = ["Power av.", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-0.001, 0.2)
        
        self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.05, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()
        
        labels = ["Correlation av.", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.nutaq_rtdex_source_0 = nutaq.rtdex_source("nutaq_carrier_perseus_0",gr.sizeof_short,1,3)
        self.nutaq_rtdex_source_0.set_type(0)
        self.nutaq_rtdex_source_0.set_packet_size(8192)
        self.nutaq_rtdex_source_0.set_channels("1")
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 1, 0)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(943e6)
        self.nutaq_radio420_tx_0_0.set_default_reference(0)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0_0.set_default_band(0)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(943e6)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0.set_default_band(0)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(16)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(5)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_0",4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_default_value(6)
        self.nutaq_custom_register_0.set_update_rate(1)
          
        self.nutaq_carrier_perseus_0 = nutaq.carrier(0,"nutaq_carrier_perseus_0", "192.168.0.103")
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.85 * 0.75, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(ieee802_11.LMS, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        self._gain_range = Range(0, 100, 1, 20, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider")
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0]
        self._freq_labels = ['  0 | 943.0 | ??', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("Channel"+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 2**11-1)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 2**11-1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*48)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length)
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_short_to_float_0, 0))    
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_short_to_float_0_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1))    
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_1_0_0_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.qtgui_time_sink_x_1_0_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.nutaq_rtdex_source_0, 0), (self.blocks_deinterleave_0, 0))    
Exemplo n.º 58
0
def complex_to_mag(N):
    op = blocks.complex_to_mag()
    tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1)
    return tb
Exemplo n.º 59
0
    def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, ogrx_freq=915e6, ogtx_freq=915e6, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0):
        grc_wxgui.top_block_gui.__init__(self, title="Broadcastwithfreqandmac")

        self._lock = threading.RLock()

        ##################################################
        # Parameters
        ##################################################
        self.ampl = ampl
        self.args = args
        self.arq_timeout = arq_timeout
        self.dest_addr = dest_addr
        self.iface = iface
        self.max_arq_attempts = max_arq_attempts
        self.mtu = mtu
        self.ogradio_addr = ogradio_addr
        self.ogrx_freq = ogrx_freq
        self.ogtx_freq = ogtx_freq
        self.port = port
        self.rate = rate
        self.rx_antenna = rx_antenna
        self.rx_gain = rx_gain
        self.rx_lo_offset = rx_lo_offset
        self.samps_per_sym = samps_per_sym
        self.tx_gain = tx_gain
        self.tx_lo_offset = tx_lo_offset

        ##################################################
        # Variables
        ##################################################
        self.user_tx_gain = user_tx_gain = tx_gain
        self.user_rx_gain = user_rx_gain = rx_gain
        self.tx_freq = tx_freq = 915e6
        self.samp_rate = samp_rate = rate
        self.rx_freq = rx_freq = 915e6
        self.radio_addr = radio_addr = 84

        ##################################################
        # Blocks
        ##################################################
        _user_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._user_tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_user_tx_gain_sizer,
        	value=self.user_tx_gain,
        	callback=self.set_user_tx_gain,
        	label="TX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._user_tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_user_tx_gain_sizer,
        	value=self.user_tx_gain,
        	callback=self.set_user_tx_gain,
        	minimum=0,
        	maximum=90,
        	num_steps=90,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_user_tx_gain_sizer)
        _user_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._user_rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_user_rx_gain_sizer,
        	value=self.user_rx_gain,
        	callback=self.set_user_rx_gain,
        	label="RX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._user_rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_user_rx_gain_sizer,
        	value=self.user_rx_gain,
        	callback=self.set_user_rx_gain,
        	minimum=0,
        	maximum=90,
        	num_steps=90,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_user_rx_gain_sizer)
        self._tx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.tx_freq,
        	callback=self.set_tx_freq,
        	label='tx_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._tx_freq_text_box)
        self._rx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label='rx_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._rx_freq_text_box)
        self._radio_addr_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.radio_addr,
        	callback=self.set_radio_addr,
        	label="Local address",
        	converter=forms.int_converter(),
        )
        self.Add(self._radio_addr_text_box)
        self.mac_802_3_tracker = mac.tracker_802_3(verbose=False)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="RX",
        	sample_rate=samp_rate,
        	v_scale=0.02,
        	v_offset=0,
        	t_scale=0.0001,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_NORM,
        	y_axis_label="Counts",
        )
        self.GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1)
        self.simple_mac_1 = mac.simple_mac(
        radio_addr,
        arq_timeout,
        max_arq_attempts,
        2.0,
        False,
        0.05,
        node_expiry_delay=10.0,
        expire_on_arq_failure=False,
        only_send_if_alive=False,
        prepend_dummy=False,
        )
        self.mac_virtual_channel_encoder_0_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu,
        chan_id=1,
        prepend_dummy=False,
        chan_tracker=self.mac_802_3_tracker,
        )
        self.mac_virtual_channel_encoder_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu,
        chan_id=0,
        prepend_dummy=False,
        )
        self.mac_virtual_channel_decoder_0 = mac.virtual_channel_decoder(3, [0, 1])
        self.gmsk_radio_0 = gmsk_radio(
            access_code_threshold=0 + 12 + 4*0,
            samps_per_sym=samps_per_sym,
            tx_lo_offset=tx_lo_offset,
            rx_lo_offset=rx_lo_offset,
            ampl=ampl,
            rx_gain=user_rx_gain,
            rx_freq=rx_freq,
            rx_ant=rx_antenna,
            tx_freq=tx_freq,
            tx_gain=user_tx_gain,
            args=args,
            rate=samp_rate,
        )
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1514, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", port, mtu, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1./10000, 40000/4)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("T"), 1)
        self.blocks_message_debug_0_0_1 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.simple_mac_1, 'ctrl_in'))    
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0, 'in'))    
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0_0, 'in'))    
        self.msg_connect((self.gmsk_radio_0, 'msg_out'), (self.simple_mac_1, 'from_radio'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out2'), (self.blocks_message_debug_0_0_1, 'print'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out0'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.mac_802_3_tracker, 'in'))    
        self.msg_connect((self.mac_virtual_channel_encoder_0, 'out'), (self.simple_mac_1, 'from_app_arq'))    
        self.msg_connect((self.mac_virtual_channel_encoder_0_0, 'out'), (self.simple_mac_1, 'from_app_arq'))    
        self.msg_connect((self.simple_mac_1, 'to_radio'), (self.gmsk_radio_0, 'msg_in'))    
        self.msg_connect((self.simple_mac_1, 'to_app'), (self.mac_virtual_channel_decoder_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_scopesink2_0_0, 1))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.gmsk_radio_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.gmsk_radio_0, 0), (self.wxgui_scopesink2_0_0, 0))