def __init__(self, cf):
        gr.top_block.__init__(self, "FM radio FFT example")

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0 = fft.fft_vcc(2048, True, (window.rectangular(2048)), True, 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 2048)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*2048, "/home/pradeep/tutorial_btp/fm/out", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(2048)
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(2.0E6)
        self.RTL820T.set_center_freq(cf, 0)
        self.RTL820T.set_freq_corr(00, 0)
        self.RTL820T.set_dc_offset_mode(0, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(0, 0)
        self.RTL820T.set_if_gain(00000000000, 0)
        self.RTL820T.set_bb_gain(000000000000, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(0, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.RTL820T, 0), (self.blocks_stream_to_vector_0, 0))
        #self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_file_sink_0, 0))
예제 #2
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Gmsk Record")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.target_freq = target_freq = 871.75e6
        self.channel_wigth = channel_wigth = 2e6
        self.samp_rate = samp_rate = 10e6
        self.center_freq = center_freq = target_freq-channel_wigth

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/2,
        	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.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(10, 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(2, firdes.low_pass(
        	1, samp_rate, 1e6, 1.5e6, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/twilight/GMSK_test/GMSK_data_record.raw", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -channel_wigth, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))    
예제 #3
0
	def __init__(self, center_freq, offset_freq, decimate_am=1, play_audio=False):
		"""Configure the RTL-SDR and GNU Radio"""
		super(rtlsdr_am_stream, self).__init__()
		
		audio_rate = 44100
		device_rate = audio_rate * 25
		output_rate = audio_rate / float(decimate_am)
		self.rate = output_rate

		self.osmosdr_source = osmosdr.source("")
		self.osmosdr_source.set_center_freq(freq)
		self.osmosdr_source.set_sample_rate(device_rate)

		taps = filter.firdes_low_pass(1, device_rate, 40000, 5000, firdes.WIN_HAMMING, 6.76)
		self.freq_filter = freq_xlating_fir_filter_ccc(25, taps, -freq_offs, device_rate)

		self.am_demod = analog.am_demod_cf(
			channel_rate=audio_rate,
			audio_decim=1,
			audio_pass=5000,
			audio_stop=5500,
		)
		self.resampler = filter.rational_resampler_fff(
			interpolation=1,
			decimation=decimate_am,
		)
		self.sink = gr_queue.queue_sink_f()
		
		self.connect(self.osmosdr_source, self.freq_filter, self.am_demod)
		self.connect(self.am_demod, self.resampler, self.sink)
		
		if play_audio:
			self.audio_sink = audio.sink(audio_rate, "", True)
			self.connect(self.am_demod, self.audio_sink)
예제 #4
0
    def __init__(self, options, queue):
        gr.top_block.__init__(self, "rtl_flex_noX")
        self.options = options
        self.offset = 0.0
        self.adj_time = time.time()
        self.verbose = options.verbose
        self.log = options.log

        # Set up rtl source
        self.u = osmosdr.source(args="%s" % (options.device))
        # set Freq
        self.u.set_center_freq(options.freq + options.calibration, 0)

        # Grab 250 KHz of spectrum
        self.u.set_sample_rate(250e3)
        rate = self.u.get_sample_rate()
        if rate != 250e3:
            print "Unable to set required sample rate of 250 Ksps (got %f)" % rate
            sys.exit(1)
        # Set gain
        if options.rx_gain is None:
            grange = self.u.get_gain_range()
            options.rx_gain = float(grange.start() + grange.stop()) / 2.0
            print "\nNo gain specified."
            print "Setting gain to %f (from [%f, %f])" % (options.rx_gain, grange.start(), grange.stop())

        self.u.set_gain(options.rx_gain, 0)

        taps = optfir.low_pass(1.0, 250e3, 11000, 12500, 0.1, 60)

        self.chan = filter.freq_xlating_fir_filter_ccf(10, taps, 0.0, 250e3)
        self.flex = pager.flex_demod(queue, options.freq, options.verbose, options.log)

        self.connect(self.u, self.chan, self.flex)
예제 #5
0
    def __init__(self, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982):
        gr.top_block.__init__(self, "Capture Raw Nogui")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.shiftoff = shiftoff
        self.ppm = ppm
        self.gain = gain
        self.samp_rate = samp_rate

        ##################################################
        # 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(fc-shiftoff, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 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(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(250e3+abs(shiftoff), 0)
          
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/tmp/gsm_raw", False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_file_sink_0, 0))
예제 #6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="rx-PSK")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 24000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
        	self.GetWin(),
        	title="Constellation Plot",
        	sample_rate=samp_rate,
        	frame_rate=5,
        	const_size=2048,
        	M=4,
        	theta=0,
        	loop_bw=6.28/100.0,
        	fmax=0.06,
        	mu=0.5,
        	gain_mu=0.005,
        	symbol_rate=samp_rate/4.,
        	omega_limit=0.005,
        )
        self.Add(self.wxgui_constellationsink2_0.win)
        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(415e6, 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(10, 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.digital_psk_demod_0 = digital.psk.psk_demod(
          constellation_points=8,
          differential=True,
          samples_per_symbol=2,
          excess_bw=0.35,
          phase_bw=6.28/100.0,
          timing_bw=6.28/100.0,
          mod_code="gray",
          verbose=True,
          log=True,
          )
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/Users/majora/Code/BasicSloth/in.dat", False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_psk_demod_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.digital_psk_demod_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_constellationsink2_0, 0))    
예제 #7
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" )
        self.osmosdr_source_0.set_sample_rate(5e6)
        self.osmosdr_source_0.set_center_freq(2.412e9, 0)
        self.osmosdr_source_0.set_freq_corr(10, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(20, 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(5e6, 0)
        
        if(options.from_file is not None):
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        self.connect(self.osmosdr_source_0, self.rxpath)
예제 #8
0
    def __init__(self, frequency, sample_rate = 1.536e6, rf_gain = 45, port=7890, freq_corr=0.0):
        gr.top_block.__init__(self, "Groundstation_receiver")
        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.freq = frequency
        self.port = port
        
        self.osmosdr_source = osmosdr.source( args="nchan=" + str(1) )
        self.osmosdr_source.set_sample_rate(self.sample_rate)
        self.osmosdr_source.set_center_freq(self.freq, 0)
        self.osmosdr_source.set_freq_corr(freq_corr, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rf_gain, 0)
        self.osmosdr_source.set_if_gain(20, 0)
        self.osmosdr_source.set_bb_gain(20, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(0, 0)
        self.blks2_tcp_sink = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_gr_complex*1,
            addr="127.0.0.1",
            port=self.port,
            server=True,
            )

        self.connect((self.osmosdr_source, 0), (self.blks2_tcp_sink, 0))
    def __init__(self):
        gr.top_block.__init__(self)
        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # 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(1.626e9 + 150e3, 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(25, 0)
        self.rtlsdr_source_0.set_if_gain(25, 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(4, (filter.firdes.low_pass(1, samp_rate, 100e3, 25e3)), 250e3, samp_rate)
        #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/tmp/fifo", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/dev/fd/3", False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
예제 #10
0
    def __init__(self, samp_rate, freq, gain, bw, port):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate
        self.gain = gain
        self.freq = freq
        self.bw = bw

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "sdrplay")
        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(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(gain, 0)
        self.osmosdr_source_0.set_bb_gain(gain, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(bw, 0)

        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:' + str(port))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.zeromq_push_sink_0, 0))
    def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200'):
        gr.top_block.__init__(self, "Generic IQ samples receiver")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_gain = bb_gain
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.file_path = file_path
        self.if_gain = if_gain
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate']
        self.decimation_rx = decimation_rx = satnogs.fm_demod_settings[rx_sdr_device]['decimation_rx']

        self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76)

        self.quadrature_rate = quadrature_rate = samp_rate_rx / decimation_rx
        self.audio_samp_rate = audio_samp_rate = 44100
        self.audio_decimation = audio_decimation = 2

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000/doppler_correction_per_sec, 1500)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) )
        self.osmosdr_source_0.set_sample_rate(samp_rate_rx)
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation_rx, (taps), lo_offset, samp_rate_rx)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, file_path, False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
예제 #12
0
    def __init__(self, filename=None, capture=None, verbose=False, freq_error=-0.0021875):
        gr.top_block.__init__(self) 
        self.verbose = verbose
        self.rx_chips_min = 16
        self.chip_error_threshold = 10

        if None != filename:
            self.source = blocks.file_source(gr.sizeof_gr_complex, filename)
        else:
            self.source = osmosdr.source()
            #print self.source.get_gain_range().to_pp_string()
            self.source.set_sample_rate(1.6e6)
            self.source.set_center_freq(868.95e6, 0)
            self.source.set_freq_corr(0, 0)
            self.source.set_gain_mode(0, 0)
            # -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0
            self.source.set_gain(14, 0)
            self.source.set_if_gain(42, 0)

        if None != capture:
            self.sink = blocks.file_sink(gr.sizeof_gr_complex, capture)
        else:
            self.msgq = gr.msg_queue(4)
            self.sink = wmbus_phy1(msgq=self.msgq, verbose=verbose, freq_error=freq_error);
            self._watcher = _queue_watcher_thread(self.msgq, self.callback)
        
        self.connect(self.source, self.sink)
예제 #13
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))    
예제 #14
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.transition = transition = 1000000
        self.samp_rate = samp_rate = 2000000
        self.quadrature = quadrature = 500000
        self.cutoff = cutoff = 100000
        self.audio_decimation = audio_decimation = 10

        ##################################################
        # 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(107.8e6, 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(20, 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.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=2000,
                decimation=500,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, cutoff, transition, firdes.WIN_HAMMING, 6.76))
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=quadrature,
        	audio_decimation=audio_decimation,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_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_null_sink_0, 0))
예제 #15
0
파일: osmosdr.py 프로젝트: shadown/shinysdr
def OsmoSDRDevice(
		osmo_device,
		name=None,
		profile=OsmoSDRProfile(),
		sample_rate=None,
		external_freq_shift=0.0,  # deprecated
		correction_ppm=0.0):
	'''
	osmo_device: gr-osmosdr device string
	name: block name (usually not specified)
	profile: an OsmoSDRProfile (see docs)
	sample_rate: desired sample rate, or None == guess a good rate
	external_freq_shift: external (down|up)converter frequency (Hz) -- DEPRECATED, use shinysdr.devices.FrequencyShift
	correction_ppm: oscillator frequency calibration (parts-per-million)
	'''
	# The existence of the correction_ppm parameter is a workaround for the current inability to dynamically change an exported field's type (the frequency range), allowing them to be initialized early enough, in the configuration, to take effect. (Well, it's also nice to hardcode them in the config if you want to.)
	if name is None:
		name = 'OsmoSDR %s' % osmo_device
	
	source = osmosdr.source('numchan=1 ' + osmo_device)
	if source.get_num_channels() < 1:
		# osmosdr.source doesn't throw an exception, allegedly because gnuradio can't handle it in a hier_block2 initializer. But we want to fail understandably, so recover by detecting it (sample rate = 0, which is otherwise nonsense)
		raise LookupError('OsmoSDR device not found (device string = %r)' % osmo_device)
	elif source.get_num_channels() > 1:
		raise LookupError('Too many devices/channels; need exactly one (device string = %r)' % osmo_device)
	
	tuning = _OsmoSDRTuning(profile, correction_ppm, source)
	vfo_cell = tuning.get_vfo_cell()
	
	if sample_rate is None:
		# If sample_rate is unspecified, we pick the closest available rate to a reasonable value. (Reasonable in that it's within the data handling capabilities of this software and of USB 2.0 connections.) Previously, we chose the maximum sample rate, but that may be too high for the connection the RF hardware, or too high for the CPU to FFT/demodulate.
		source.set_sample_rate(convert_osmosdr_range(source.get_sample_rates())(2.4e6))
	else:
		source.set_sample_rate(sample_rate)
	
	rx_driver = _OsmoSDRRXDriver(
		source=source,
		name=name,
		sample_rate=sample_rate,
		tuning=tuning)
	
	hw_initial_freq = source.get_center_freq()
	if hw_initial_freq == 0.0:
		# If the hardware/driver isn't providing a reasonable default (RTLs don't), do it ourselves; go to the middle of the FM broadcast band (rounded up or down to what the hardware reports it supports).
		vfo_cell.set(100e6)
	else:
		print hw_initial_freq
		vfo_cell.set(tuning.from_hardware_freq(hw_initial_freq))
	
	self = Device(
		name=name,
		vfo_cell=vfo_cell,
		rx_driver=rx_driver)
	
	# implement legacy option in terms of new devices
	if external_freq_shift == 0.0:
		return self
	else:
		return merge_devices([self, FrequencyShift(-external_freq_shift)])
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.variable_slider_0 = variable_slider_0 = .846
        self.test = test = .005
        self.shift = shift = .906
        self.samp_rate_0 = samp_rate_0 = 1.2e6
        self.samp_rate = samp_rate = 1.2e6/4
        self.pows = pows = 1.3
        self.lpf = lpf = .724
        self.go = go = 0.564
        self.gm = gm = 1.61
        self.centre_freq = centre_freq = 439.95e6

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate_0)
        self.rtlsdr_source_0.set_center_freq(439.9e6, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(20, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(10, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_fff(10, firdes.low_pass(
        	1, samp_rate, 2.56e3*lpf, (2.56e3/2)*lpf, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass_2(1,samp_rate_0,100e3,50e3,40)), 0, samp_rate_0)
        self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_ff(11.6439*(1+test), 0.25*0.175*0.175*go, 0.5, 0.175*gm, 0.005*variable_slider_0)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-12*shift, ))
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=False,
        )
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40*pows, .001, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_1, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blks2_tcp_sink_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
예제 #17
0
    def __init__(self, device=None, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982):
        gr.top_block.__init__(self, "Tmsi Print Nogui")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.shiftoff = shiftoff
        self.ppm = ppm
        self.gain = gain
        self.samp_rate = samp_rate
        if device:
            self.device = device
        else:
            self.device = ''
        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + self.device )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(fc-shiftoff, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 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(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(250e3+abs(shiftoff), 0)
          
        self.gsm_tmsi_printer_0 = grgsm.tmsi_printer()
        self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]))
        self.gsm_input_0 = grgsm.gsm_input(
            ppm=0,
            osr=4,
            fc=fc,
            samp_rate_in=samp_rate,
        )
        self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder()
        self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff)
        self.gsm_bcch_ccch_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2]))
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0))
        self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts")
        self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in")
        self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts")
        self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
        self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_tmsi_printer_0, "msgs")
예제 #18
0
    def __init__(self, fc=927.2e6):
        gr.top_block.__init__(self, "Gsm Reciever")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc

        ##################################################
        # Variables
        ##################################################
        self.f_symb = f_symb = 1625000.0/6.0
        self.samp_rate = samp_rate = f_symb*4
        self.f_900_e = f_900_e = 959.8e6
        self.f_900_b = f_900_b = 921.2e6
        self.f_1800_e = f_1800_e = 1879.8e6
        self.f_1800_b = f_1800_b = 1805.2e6
        self.OSR = OSR = 4
        self.CCCH = CCCH = 2
        self.BCCH = BCCH = 1

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(fc, 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(30, 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(200000, 0)
          
        self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH]))
        self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]))
        self.gsm_input_0 = grgsm.gsm_input(
            ppm=0,
            osr=4,
            fc=fc,
            samp_rate_in=samp_rate,
        )
        self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder()
        self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in'))    
        self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements'))    
        self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_universal_ctrl_chans_demapper_0, 'bursts'))    
        self.msg_connect((self.gsm_universal_ctrl_chans_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts'))    
        self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.gsm_input_0, 0))    
예제 #19
0
 def _start_rx(self):
     self.disconnect_all()
     self.__source = osmosdr.source('numchan=1 ' + self.__osmo_device)
     self.__source.set_sample_rate(self.__signal_type.get_sample_rate())
     self.__tuning.set_block(self.__source)
     self.__gains = Gains(self.__source, self)
     self.connect(self.__source, self)
     self.state_from_json(self.__state_while_inactive)
예제 #20
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lora Receive Realtime")

        ##################################################
        # Variables
        ##################################################
        self.sf = sf = 11
        self.samp_rate = samp_rate = 1e6
        self.bw = bw = 125000
        self.target_freq = target_freq = 868.1e6
        self.symbols_per_sec = symbols_per_sec = float(bw) / (2**sf)
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, bw, 10000, firdes.WIN_HAMMING, 6.67)
        self.downlink = downlink = False
        self.decimation = decimation = 1
        self.capture_freq = capture_freq = 868e6
        self.bitrate = bitrate = sf * (1 / (2**sf / float(bw)))

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=capture_freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='FFT Plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.win)
        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(capture_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(10, 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.lora_message_socket_sink_0 = lora.message_socket_sink('127.0.0.1', 40868, 0)
        self.lora_lora_receiver_0 = lora.lora_receiver(1e6, capture_freq, ([target_freq]), bw, sf, False, 4, True, False, downlink, decimation, False, False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.lora_lora_receiver_0, 'frames'), (self.lora_message_socket_sink_0, 'in'))
        self.connect((self.osmosdr_source_0, 0), (self.lora_lora_receiver_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_1, 0))
	def __init__(self):
		gr.top_block.__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 = 32000
		self.samp_per_sym = samp_per_sym = 8

		##################################################
		# Blocks
		##################################################

		# Docs for osmosdr parms are in: http://cgit.osmocom.org/gr-osmosdr/tree/grc/gen_osmosdr_blocks.py

		self.rtlsdr_source_c_0 = osmosdr.source( args="nchan=1")
		self.rtlsdr_source_c_0.set_sample_rate(samp_rate)
		self.rtlsdr_source_c_0.set_center_freq(500e6, 0)
		self.rtlsdr_source_c_0.set_freq_corr(0, 0)
		self.rtlsdr_source_c_0.set_iq_balance_mode(0, 0) # 0 is off, 1 manual, 2 automatic
		self.rtlsdr_source_c_0.set_gain_mode(1, 0) # automatic gain. 0 means manual, 1 means automatic
#		self.rtlsdr_source_c_0.set_gain(10, 0)
#		self.rtlsdr_source_c_0.set_if_gain(20, 0)
#		self.rtlsdr_source_c_0.set_bb_gain(20, 0)
#		self.rtlsdr_source_c_0.set_antenna("", 0)
		self.rtlsdr_source_c_0.set_bandwidth(0, 0)
		  
		self.digital_dxpsk_demod_0 = digital.dqpsk_demod(
			mod_code='gray',
			samples_per_symbol=8,
			excess_bw=0.35,
			freq_bw=6.28/1000.0,
			phase_bw=6.28/1000.0,
			timing_bw=6.28/1000.0,
#			gray_coded=True,
			verbose=True,
			log=True
		)
		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/sdr_output.txt")
		self.blocks_file_sink_0.set_unbuffered(False)
		self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
				access_code="0001000100010001",
				threshold=-1,
				callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
			),
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
		self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))
		self.connect((self.rtlsdr_source_c_0, 0), (self.digital_dxpsk_demod_0, 0))
예제 #22
0
    def __init__(self, freq, ppm, osmosdr_args):
        gr.top_block.__init__(self, "gr_omnicon")

        self.msgq_out = blocks_message_sink_0_msgq_out = gr.msg_queue(0)
        ##################################################
        # Variables
        ##################################################
        self.xlate_bandwidth = xlate_bandwidth = 15.0e3
        self.samp_rate = samp_rate = 1.2e6
        self.xlate_decimation = xlate_decimation = int(samp_rate/(xlate_bandwidth*3.2))
        self.baud_rate = baud_rate = 2400
        self.lowpass_decimation = lowpass_decimation = int((samp_rate/xlate_decimation)/(baud_rate*4))
        self.freq_offset = freq_offset = 250000
        self.sps = sps = (samp_rate/xlate_decimation/lowpass_decimation)/baud_rate
        self.omega_rel_limit = omega_rel_limit = ((2450.0-2400.0)/2400.0)
        self.gain_omega = gain_omega = 0
        self.gain_mu = gain_mu = 0.1
        self.freq_tune = freq_tune = freq-freq_offset

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args=osmosdr_args)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq_tune, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 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(True, 0)
        self.rtlsdr_source_0.set_gain(42, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(10, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_fff(lowpass_decimation, firdes.low_pass(
        	1, samp_rate/xlate_decimation, baud_rate, (baud_rate)/10, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decimation, (firdes.low_pass(1, samp_rate, xlate_bandwidth, xlate_bandwidth/20 )), freq_offset, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps, gain_omega, 0.5, gain_mu, omega_rel_limit)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(500, True)
        self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, blocks_message_sink_0_msgq_out, False)
        self.analog_quadrature_demod_cf_0_0_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0_0_0, 0), (self.dc_blocker_xx_0, 0))
        #self.connect((self.blocks_message_sink_0, 'msg'), (self, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "SQ5BPF Tetra live receiver 1ch UDP HEADLESS")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.first_decim = first_decim = 32
        self.xlate_offset_fine1 = xlate_offset_fine1 = 0
        self.xlate_offset1 = xlate_offset1 = 500e3
        self.udp_packet_size = udp_packet_size = 1472
        self.udp_dest_addr = udp_dest_addr = "127.0.0.1"
        self.telive_receiver_name = telive_receiver_name = 'SQ5BPF 1-channel headless rx for telive'
        self.telive_receiver_channels = telive_receiver_channels = 1
        self.sdr_ifgain = sdr_ifgain = 20
        self.sdr_gain = sdr_gain = 38
        self.ppm_corr = ppm_corr = 56
        self.out_sample_rate = out_sample_rate = 36000
        self.options_low_pass = options_low_pass = 12500
        self.if_samp_rate = if_samp_rate = samp_rate/first_decim
        self.freq = freq = 435e6
        self.first_port = first_port = 42000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", first_port), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        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(ppm_corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(sdr_gain, 0)
        self.osmosdr_source_0.set_if_gain(sdr_ifgain, 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(first_decim, (firdes.low_pass(1, samp_rate, options_low_pass, options_low_pass*0.2)), xlate_offset1+xlate_offset_fine1, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, float(float(if_samp_rate)/float(out_sample_rate)))
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dest_addr, first_port+1, udp_packet_size, False)
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.analog_agc3_xx_0, 0), (self.fractional_resampler_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc3_xx_0, 0))
예제 #24
0
    def __init__(self):
        gr.top_block.__init__(self, "Scanner Grc")

        ##################################################
        # Variables
        ##################################################
        self.f_symb = f_symb = 1625000.0/6.0
        self.f_900_b = f_900_b = 921.2e6
        self.samp_rate = samp_rate = f_symb*4
        self.fs = fs = f_900_b
        self.f_900_e = f_900_e = 959.8e6
        self.f_1800_e = f_1800_e = 1879.8e6
        self.f_1800_b = f_1800_b = 1805.2e6
        self.OSR = OSR = 4

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(fs, 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(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(30, 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(200000, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.threshold_result = blocks.threshold_ff(0, 0.2, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR))
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0))    
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))    
예제 #25
0
	def __init__(self,
			osmo_device,
			name=None,
			profile=OsmoSDRProfile(),
			sample_rate=None,
			external_freq_shift=0.0,
			correction_ppm=0.0,
			**kwargs):
		'''
		osmo_device: gr-osmosdr device string
		name: block name (usually not specified)
		profile: an OsmoSDRProfile (see docs)
		sample_rate: desired sample rate, or None == guess a good rate
		external_freq_shift: external (down|up)converter frequency (Hz)
		correction_ppm: oscillator frequency calibration (parts-per-million)
		'''
		# The existence of the external_freq_shift and correction_ppm parameters (but not all of the others) is a workaround for the current inability to dynamically change an exported field's type (the frequency range), allowing them to be initialized early enough, in the configuration, to take effect.
		
		if name is None:
			name = 'OsmoSDR %s' % osmo_device
		Source.__init__(self, name=name, **kwargs)
		
		self.__osmo_device = osmo_device
		self.__profile = profile
		
		self.osmosdr_source_block = source = osmosdr.source('numchan=1 ' + osmo_device)
		if source.get_num_channels() < 1:
			# osmosdr.source doesn't throw an exception, allegedly because gnuradio can't handle it in a hier_block2 initializer. But we want to fail understandably, so recover by detecting it (sample rate = 0, which is otherwise nonsense)
			raise LookupError('OsmoSDR device not found (device string = %r)' % osmo_device)
		elif source.get_num_channels() > 1:
			raise LookupError('Too many devices/channels; need exactly one (device string = %r)' % osmo_device)
		
		if sample_rate is None:
			# If sample_rate is unspecified, we pick the closest available rate to a reasonable value. (Reasonable in that it's within the data handling capabilities of this software and of USB 2.0 connections.) Previously, we chose the maximum sample rate, but that may be too high for the connection the RF hardware, or too high for the CPU to FFT/demodulate.
			source.set_sample_rate(convert_osmosdr_range(source.get_sample_rates())(2.4e6))
		else:
			source.set_sample_rate(sample_rate)
		
		self.connect(self.osmosdr_source_block, self)
		
		# Misc state
		self.external_freq_shift = external_freq_shift
		self.correction_ppm = correction_ppm
		self.dc_state = 0
		self.iq_state = 0
		source.set_dc_offset_mode(self.dc_state, ch)  # no getter, set to known state
		source.set_iq_balance_mode(self.iq_state, ch)  # no getter, set to known state

		hw_initial_freq = source.get_center_freq()
		if hw_initial_freq == 0.0:
			# If the hardware/driver isn't providing a reasonable default (RTLs don't), do it ourselves; go to the middle of the FM broadcast band (rounded up or down to what the hardware reports it supports).
			self.set_freq(100e6)
		else:
			# Note: _invert_frequency won't actually do anything useful currently because external_freq_shift and correction_ppm aren't initialized at this point; it's just the most-correct expression. And if we add ctor args for the frequency modifiers, it'll do the right thing.
			self.freq = self._invert_frequency(hw_initial_freq)
예제 #26
0
파일: fft_spec.py 프로젝트: RScrusoe/sem_v
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.frq = []
        self.final = []
        ##################################################
        # 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(100e6, 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.fullfft_dft_py_fc_0 = fullfft.dft_py_fc()
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fullfft_dft_py_fc_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.fullfft_dft_py_fc_0, 0))    
예제 #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8e6

        ##################################################
        # 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(2.501e9, 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(14, 0)
        self.osmosdr_source_0.set_if_gain(40, 0)
        self.osmosdr_source_0.set_bb_gain(8, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.fosphor_qt_sink_c_0, 0))    
예제 #28
0
    def __init__(self, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982):
        gr.top_block.__init__(self, "Capture Bursts Nogui")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.shiftoff = shiftoff
        self.ppm = ppm
        self.gain = gain
        self.samp_rate = samp_rate

        ##################################################
        # 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(fc-shiftoff, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 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(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(250e3+abs(shiftoff), 0)
          
        self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]))
        self.gsm_input_0 = grgsm.gsm_input(
            ppm=0,
            osr=4,
            fc=fc,
            samp_rate_in=samp_rate,
        )
        self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff)
        self.gsm_burst_file_sink_0 = grgsm.burst_file_sink("/tmp/bursts")
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0))
        self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in")
        self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
        self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_burst_file_sink_0, "in")
예제 #29
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDMChatAppRx")

        ##################################################
        # Variables
        ##################################################
        self.tune_offset = tune_offset = 500e3
        self.samp_rate = samp_rate = 500000
        self.len_tag_key = len_tag_key = "packet_len"
        self.fft_len = fft_len = 128
        self.decimation = decimation = 4

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate*decimation)
        self.osmosdr_source_0.set_center_freq(400e6-tune_offset, 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(0, 0)
        self.osmosdr_source_0.set_gain(10, 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
                decimation,
                (filter.firdes.low_pass(1.0, samp_rate*decimation, 300e3, 100e3)),
                tune_offset,
                samp_rate*decimation
        )
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+"rx_len",
        	  packet_length_tag_key="rx_len",
        	  bps_header=1,
        	  bps_payload=2,
        	  debug_log=False,
        	  scramble_bits=True
         )
        self.tagged_stream_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'rx_len')
        self.pdu_receiver = fosdem.pdu_receiver()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_ofdm_rx_0, 0), self.tagged_stream_to_pdu)
        self.msg_connect(self.tagged_stream_to_pdu, "pdus", self.pdu_receiver, "pdus")
예제 #30
0
    def __init__(self, filename, options):
        gr.top_block.__init__(self, "MULTIRX testing")

        self.config = configuration.Configuration(filename)
        self.center_freq = center_freq = self.config.center()
        self.squelch = options.squelch

        print "high=%d low=%d span=%d" % (self.config.upper(), 
           self.config.lower(), (self.config.upper() - self.config.lower()))
        print "center=%d" % self.center_freq

        self.samp_rate = samp_rate = 1E6
        self.gain_db = gain_db = 30
        
        self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=00000001" )
        self.osmosdr_source.set_sample_rate(samp_rate)
        self.osmosdr_source.set_center_freq(center_freq, 0)
        self.osmosdr_source.set_freq_corr(69, 0) #move this to option
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(0, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(gain_db, 0)
        self.osmosdr_source.set_if_gain(20, 0)
        self.osmosdr_source.set_bb_gain(20, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(samp_rate*0.8, 0)
        
        self.blocks_adder = blocks.add_vss(1)

        for self.i, self.entry in enumerate(self.config.channel):
            self.demod_bb_freq = self.entry[1] - self.center_freq
            self.ctcss_freq = self.entry[3]
            self.demod = Demodulator.Demodulator(self.samp_rate, \
		self.demod_bb_freq, self.squelch, self.ctcss_freq)
            self.fname = self.setup_upstream_pipe(self.entry[0], self.entry[2])
            self.file_sink = blocks.file_sink(gr.sizeof_short*1, self.fname, True)
            self.connect((self.osmosdr_source, 0), (self.demod, 0), (self.file_sink, 0))    
	    self.connect((self.demod, 0), (self.blocks_adder, self.i))
            self.rec = Recorder.Recorder(16000, self.entry[0])
            self.connect((self.demod, 0), (blocks.short_to_float(1, 32768), 0), (self.rec, 0))
            time.sleep(1) #space things out a bit
        
	self.fname = self.setup_upstream_pipe("multiplex", "Multiplex Channel")
        self.file_sink = blocks.file_sink(gr.sizeof_short*1, self.fname, True)
        self.connect((self.blocks_adder, 0), (self.file_sink, 0))

        if options.local:
          self.audio_sink = audio.sink(16000, "", True)
          self.blocks_short_to_float = blocks.short_to_float(1, 32768)
	  self.connect((self.blocks_adder, 0), (self.blocks_short_to_float, 0), (self.audio_sink, 0))
예제 #31
0
파일: chu.py 프로젝트: artemies/gr-ham
    def __init__(self):
        gr.top_block.__init__(self, "Chu")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Chu")
        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", "chu")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 0
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate // 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 50, 0.4, 10, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain,
                                     'RX gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1, channel_rate, 300, 0.35, 100))
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)
        self.qtgui_waterfall_sink_x_1.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(
            chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_gain(gain, 0)
        self.osmosdr_source_1.set_if_gain(20, 0)
        self.osmosdr_source_1.set_bb_gain(20, 0)
        self.osmosdr_source_1.set_antenna('', 0)
        self.osmosdr_source_1.set_bandwidth(0, 0)
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, 20000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / decimation, 200, 2800, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate / decimation, analog.GR_COS_WAVE,
            -(space_tone + mark_tone) / 2, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -offset, 1, 0, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            channel_rate / (3.1416 * (mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ham_chu_decode_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.qtgui_waterfall_sink_x_1, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
예제 #32
0
    def __init__(self):
        gr.top_block.__init__(self, "DAB channel  decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DAB channel  decoder")
        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", "dab_channel_decoder")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2048000
        self.freq_offset = freq_offset = 0

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(218640000, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_gain(30, 0)
        self.rtlsdr_source_0_0.set_if_gain(20, 0)
        self.rtlsdr_source_0_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(0, 0)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            2048*96*2, #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(-1  * 3.1415 / 2048, 1 * 3.1415 / 2048)

        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1_0.enable_tags(True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_1_0.enable_stem_plot(False)


        labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(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_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048*5, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(True)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)


        labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)



        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
            "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024, #size
            "", #name
            1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-200, 200)
        self.qtgui_const_sink_x_1.set_x_axis(-200, 200)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)


        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
            "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
            0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
            0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self._freq_offset_range = Range(-1000, +1000, 10, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'freq_offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win)
        self.fft_vxx_0 = fft.fft_vcc(2048, True, [], True, 1)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1536)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, 'msc.dat', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, 'fic.dat', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.bad_qpsk_symbol_demapper_0 = bad.qpsk_symbol_demapper()
        self.bad_ofdm_symbols_selector_0_0 = bad.ofdm_symbols_selector()
        self.bad_ofdm_symbols_selector_0_0.select_msc_symbols()
        self.bad_ofdm_symbols_selector_0 = bad.ofdm_symbols_selector()
        self.bad_ofdm_symbols_selector_0.select_fic_symbols()
        self.bad_ofdm_sampler_0 = bad.ofdm_sampler()
        self.bad_ofdm_fine_frequency_correction_0 = bad.ofdm_fine_frequency_correction(0.1)
        self.bad_ofdm_differential_demodulator_0 = bad.ofdm_differential_demodulator()
        self.bad_ofdm_coarse_frequency_correction_0 = bad.ofdm_coarse_frequency_correction()
        self.bad_ns_detector_1 = bad.ns_detector()
        self.bad_msc_decoder_0 = bad.msc_decoder()
        self.bad_msc_decoder_0.set_eep_a_params(618, 72, 2)
        self.bad_frequency_deinterleaver_0 = bad.frequency_deinterleaver()
        self.bad_fic_decoder_0 = bad.fic_decoder()



        ##################################################
        # Connections
        ##################################################
        self.connect((self.bad_fic_decoder_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.bad_frequency_deinterleaver_0, 0), (self.bad_qpsk_symbol_demapper_0, 0))
        self.connect((self.bad_msc_decoder_0, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.bad_ns_detector_1, 0), (self.bad_ofdm_fine_frequency_correction_0, 0))
        self.connect((self.bad_ofdm_coarse_frequency_correction_0, 0), (self.bad_ofdm_differential_demodulator_0, 0))
        self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.bad_frequency_deinterleaver_0, 0))
        self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.bad_ofdm_fine_frequency_correction_0, 0), (self.bad_ofdm_sampler_0, 0))
        self.connect((self.bad_ofdm_fine_frequency_correction_0, 1), (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.bad_ofdm_sampler_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.bad_ofdm_symbols_selector_0, 0), (self.bad_fic_decoder_0, 0))
        self.connect((self.bad_ofdm_symbols_selector_0_0, 0), (self.bad_msc_decoder_0, 0))
        self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0, 0))
        self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.bad_ofdm_coarse_frequency_correction_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.bad_ns_detector_1, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
예제 #33
0
    def __init__(self):
        gr.top_block.__init__(self, "Multimon Flex Rtl 0")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.channel_1 = channel_1 = 929.65e6
        self.channel_0 = channel_0 = 929.6e6
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.sqlch = sqlch = -50
        self.if_gain = if_gain = -14
        self.gain = gain = 50
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.corr = corr = -14
        self.center_freq_0 = center_freq_0 = sum([channel_0, channel_1] ) / float(len([channel_0, channel_1]))
        self.bb_gain = bb_gain = 40

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=0' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq_0 - 100000, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_1 - center_freq_0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_0 - center_freq_0, samp_rate)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7301, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7300, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((0.1, ))
        self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32767)
        self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32767)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1, 0)
        self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_pwr_squelch_xx_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_1, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_0_1, 0), (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_float_to_short_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_float_to_short_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0_2, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
예제 #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Downlink for FM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Downlink for FM")
        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", "downlink_fm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.block_len_enc = block_len_enc = 1024 / 8 * 2

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 4, 1).base()

        self.samp_rate = samp_rate = 250000
        self.payload = payload = block_len_enc + 4
        self.oversample = oversample = 5
        self.frequency_offset_correction = frequency_offset_correction = 89e2

        ##################################################
        # Blocks
        ##################################################
        self._frequency_offset_correction_range = Range(
            -120000, 120000, 100, 89e2, 200)
        self._frequency_offset_correction_win = RangeWidget(
            self._frequency_offset_correction_range,
            self.set_frequency_offset_correction, 'Frequency Correction',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._frequency_offset_correction_win,
                                       0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            145.95e6,  #fc
            samp_rate * 4,  #bw
            "Vor Sync",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_1_win, 1, 0, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0_0_1.enable_rf_freq(False)

        self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 5,  #bw
            "Vor Sync",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_0_0_win, 2, 0, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0_0_0_0.enable_rf_freq(False)

        self.qtgui_sink_x_0_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 5,  #bw
            "Vor Sync",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_0_win, 3, 0, 1,
                                       1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0_0_0.enable_rf_freq(False)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate * oversample)
        self.osmosdr_source_0.set_center_freq(145.95e6, 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(30 * 1, 0)
        self.osmosdr_source_0.set_if_gain(30 * 1, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc(
            2, 0, 31.41e-3, -0.01, 0.01, 0.25, 0.05, samp_rate / 5 / 12.5e3,
            0.01, 0.005)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            variable_constellation_0)
        self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b()
        self.ccsds_send_nanolink_0 = ccsds.send_nanolink(
            "https://move2radio.lrt.mw.tum.de")
        self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits(
            0x95, 0xFF)
        self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f(
            2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0)
        self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder(
            '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT,
            ccsds.LDPC_PUNCT_BACK, 512, tuple(([])))
        self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            oversample,
            firdes.complex_band_pass(1, samp_rate * oversample, 40e3, 60e3,
                                     6e3, firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate * oversample, analog.GR_COS_WAVE,
            frequency_offset_correction, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -50000, 1, 0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'),
                         (self.ccsds_send_nanolink_0, 'in'))
        self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'),
                         (self.ccsds_softbits_msg_to_bytes_b_0, 'in'))
        self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'),
                         (self.ccsds_randomiser_softbits_0, 'in'))
        self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'),
                         (self.ccsds_ldpc_decoder_0, 'in'))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_sink_x_0_0_0_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.ccsds_mpsk_ambiguity_resolver_f_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.qtgui_sink_x_0_0_1, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.ccsds_blob_msg_sink_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.digital_mpsk_receiver_cc_0_0, 0))
예제 #35
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "ofdm_separate")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32768
        self.cutoff = cutoff = 4000
        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(
            1.0, samp_rate, cutoff, cutoff / 10, firdes.WIN_HAMMING, 6.76)
        self.thres = thres = -65
        self.sig = sig = 0
        self.freq = freq = 869005700
        self.fft_length = fft_length = 1024
        self.decimation = decimation = 32768 / 8

        ##################################################
        # Blocks
        ##################################################
        self._thres_range = Range(-120, 50, 1, -65, 200)
        self._thres_win = RangeWidget(self._thres_range, self.set_thres,
                                      'Threshold', "counter_slider", float)
        self.top_grid_layout.addWidget(self._thres_win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0.set_sample_rate(1e6)
        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(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(40, 0)
        self.rtlsdr_source_0.set_if_gain(40, 0)
        self.rtlsdr_source_0.set_bb_gain(40, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            fft_length,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            decimation,  #bw
            "Extracted Signal " + str(sig + 1),  #name
            2)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        labels = [
            'Signal  Separator', 'Xlating FIR', '', '', '', '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            int(samp_rate / decimation), variable_low_pass_filter_taps_0, freq,
            samp_rate)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_null_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
예제 #36
0
파일: rx.py 프로젝트: mattames/op25
    def __init__(self, options):

        self.trunk_rx = None
        self.plot_sinks = []

        gr.top_block.__init__(self)

        self.channel_rate = 0
        self.baseband_input = False
        self.rtl_found = False
        self.channel_rate = options.sample_rate
        self.fft_sink = None
        self.constellation_sink = None
        self.symbol_sink = None
        self.eye_sink = None
        self.mixer_sink = None
        self.tuner_sink = None
        self.target_freq = 0.0
        self.last_error_update = 0
        self.error_band = 0
        self.tuning_error = 0
        self.freq_correction = 0
        self.last_set_freq = 0
        self.last_set_freq_at = time.time()
        self.last_set_ppm = 0
        self.last_change_freq = 0
        self.last_change_freq_at = time.time()
        self.last_freq_params = {
            'freq': 0.0,
            'tgid': None,
            'tag': "",
            'tdma': None
        }
        self.meta_server = None
        self.stream_url = ""
        self.ui_last_update = 0
        self.ui_timeout = 5.0

        self.src = None
        if (not options.ifile) and (not options.input) and (
                not options.audio) and (not options.audio_if) and (
                    not options.symbols):
            # check if osmocom is accessible
            try:
                import osmosdr
                self.src = osmosdr.source(options.args)
            except Exception:
                sys.stdout.write("osmosdr source_c creation failure\n")
                ignore = True

            if any(x in options.args.lower()
                   for x in ['rtl', 'airspy', 'hackrf', 'uhd']):
                self.rtl_found = True

            if options.gain_mode is not None:
                if options.gain_mode:
                    self.src.set_gain_mode(True, 0)
                else:
                    self.src.set_gain_mode(
                        True,
                        0)  # UGH! Ugly workaround for gr-osmosdr airspy bug
                    self.src.set_gain_mode(False, 0)
                sys.stderr.write("gr-osmosdr driver gain_mode: %s\n" %
                                 self.src.get_gain_mode())

            gain_names = self.src.get_gain_names()
            for name in gain_names:
                g_range = self.src.get_gain_range(name)
                sys.stderr.write(
                    "gain: name: %s range: start %d stop %d step %d\n" %
                    (name, g_range[0].start(), g_range[0].stop(),
                     g_range[0].step()))
            if options.gains:
                for tup in options.gains.split(","):
                    name, gain = tup.split(":")
                    gain = int(gain)
                    sys.stderr.write("setting gain %s to %d\n" % (name, gain))
                    self.src.set_gain(gain, name)

            rates = self.src.get_sample_rates()
            try:
                sys.stderr.write("supported sample rates %d-%d step %d\n" %
                                 (rates.start(), rates.stop(), rates.step()))
            except:
                pass  # ignore

            if options.freq_corr:
                self.src.set_freq_corr(options.freq_corr)
                self.last_set_ppm = options.freq_corr

        if options.audio:
            self.channel_rate = 48000
            self.baseband_input = True

        if options.audio_if:
            self.channel_rate = 96000

        # setup (read-only) attributes
        if options.tdma_cc:
            self.symbol_rate = 6000
        else:
            self.symbol_rate = 4800
        self.symbol_deviation = 600.0
        self.basic_rate = 24000
        _default_speed = self.symbol_rate
        self.options = options
        #
        self.set_sps(_default_speed)

        # keep track of flow graph connections
        self.cnxns = []

        self.datascope_raw_input = False
        self.data_scope_connected = False

        self.constellation_scope_connected = False

        for i in range(len(speeds)):
            if speeds[i] == _default_speed:
                self.current_speed = i
                self.default_speed_idx = i

        if options.hamlib_model:
            self.hamlib_attach(options.hamlib_model)

        # wait for gdb
        if options.pause:
            sys.stdout.write("Ready for GDB to attach (pid = %d)\n" %
                             (os.getpid(), ))
            if sys.version[0] > '2':
                input("Press 'Enter' to continue...")
            else:
                raw_input("Press 'Enter' to continue...")

        self.input_q = gr.msg_queue(10)
        self.output_q = gr.msg_queue(10)
        self.meta_q = gr.msg_queue(10)

        # configure specified data source
        if options.input:
            self.open_file(options.input)
        elif (self.rtl_found or options.frequency):
            self.open_usrp()
        elif options.audio_if:
            self.open_audio_c(self.channel_rate, options.gain,
                              options.audio_input)
        elif options.audio:
            self.open_audio(self.channel_rate, options.gain,
                            options.audio_input)
        elif options.ifile:
            self.open_ifile2(self.channel_rate, options.ifile)
        elif options.symbols:
            self.open_symbols(self.symbol_rate, options.symbols, options.seek)
        else:
            pass

        # attach terminal thread and make sure currently tuned frequency is displayed
        self.terminal = op25_terminal(self.input_q, self.output_q,
                                      self.options.terminal_type)
        if self.terminal is None:
            sys.exit(1)

        # attach meta server thread
        if self.options.metacfg is not None:
            from icemeta import meta_server
            self.meta_server = meta_server(self.meta_q,
                                           self.options.metacfg,
                                           debug=self.options.verbosity)
            try:
                with open(self.options.metacfg) as json_file:
                    meta_cfg = json.load(json_file)
                self.stream_url = "http://" + meta_cfg[
                    'icecastServerAddress'] + "/" + meta_cfg[
                        'icecastMountpoint'] + meta_cfg['icecastMountExt']
                sys.stderr.write("streaming server url=\"%s\"\n" %
                                 self.stream_url)
            except (ValueError, KeyError):
                sys.stderr.write(
                    "error reading metadata config file: %s, streaming server url disabled\n"
                    % self.options.metacfg)
        else:
            self.meta_server = None
            sys.stderr.write("metadata update not enabled\n")

        # attach audio thread
        if self.options.udp_player:
            self.audio = audio_thread("127.0.0.1", self.options.wireshark_port,
                                      self.options.audio_output, False,
                                      self.options.audio_gain)
        else:
            self.audio = None
예제 #37
0
  def __init__(self):
    grc_wxgui.top_block_gui.__init__(self, title="Top Block")

    options = get_options()

    self.ifreq = options.frequency
    self.rfgain = options.gain

    self.src = osmosdr.source(options.args)
    self.src.set_center_freq(self.ifreq)
    self.src.set_sample_rate(int(options.sample_rate))

    if self.rfgain is None:
        self.src.set_gain_mode(True)
        self.iagc = 1
        self.rfgain = 0
    else:
        self.iagc = 0
        self.src.set_gain_mode(False)
        self.src.set_gain(self.rfgain)

    # may differ from the requested rate
    sample_rate = self.src.get_sample_rate()
    sys.stderr.write("sample rate: %d\n" % (sample_rate))

    symbol_rate = 18000
    sps = 2 # output rate will be 36,000
    out_sample_rate = symbol_rate * sps

    options.low_pass = options.low_pass / 2.0

    if sample_rate == 96000: # FunCube Dongle
        first_decim = 2
    else:
        first_decim = 10

    self.offset = 0

    taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.2, filter.firdes.WIN_HANN)
    self.tuner = filter.freq_xlating_fir_filter_ccf(first_decim, taps, self.offset, sample_rate)

    self.demod = cqpsk.cqpsk_demod(
        samples_per_symbol = sps,
        excess_bw=0.35,
        costas_alpha=0.03,
        gain_mu=0.05,
        mu=0.05,
        omega_relative_limit=0.05,
        log=options.log,
        verbose=options.verbose)

    self.output = blocks.file_sink(gr.sizeof_float, options.output_file)

    rerate = float(sample_rate / float(first_decim)) / float(out_sample_rate)
    sys.stderr.write("resampling factor: %f\n" % rerate)

    if rerate.is_integer():
        sys.stderr.write("using pfb decimator\n")
        self.resamp = pfb.decimator_ccf(int(rerate))
    else:
        sys.stderr.write("using pfb resampler\n")
        self.resamp = pfb.arb_resampler_ccf(1 / rerate)

    self.connect(self.src, self.tuner, self.resamp, self.demod, self.output)

    self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Wideband Spectrum")
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Channel Spectrum")
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Soft Bits")

    def set_ifreq(ifreq):
        self.ifreq = ifreq
        self._ifreq_text_box.set_value(self.ifreq)
        self.src.set_center_freq(self.ifreq)

    self._ifreq_text_box = forms.text_box(
        parent=self.GetWin(),
        value=self.ifreq,
        callback=set_ifreq,
        label="Center Frequency",
        converter=forms.float_converter(),
    )
    self.Add(self._ifreq_text_box)

    def set_iagc(iagc):
        self.iagc = iagc
        self._agc_check_box.set_value(self.iagc)
        self.src.set_gain_mode(bool(self.iagc))
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    self._agc_check_box = forms.check_box(
        parent=self.GetWin(),
        value=self.iagc,
        callback=set_iagc,
        label="Automatic Gain",
        true=1,
        false=0,
    )

    self.Add(self._agc_check_box)

    def set_rfgain(rfgain):
        self.rfgain = rfgain
        self._rfgain_slider.set_value(self.rfgain)
        self._rfgain_text_box.set_value(self.rfgain)
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
    self._rfgain_text_box = forms.text_box(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        label="RF Gain",
        converter=forms.float_converter(),
        proportion=0,
    )
    self._rfgain_slider = forms.slider(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        minimum=0,
        maximum=50,
        num_steps=200,
        style=wx.SL_HORIZONTAL,
        cast=float,
        proportion=1,
    )

    self.Add(_rfgain_sizer)

    self.Add(self.Main)

    def fftsink2_callback(x, y):
        if abs(x / (sample_rate / 2)) > 0.9:
            set_ifreq(self.ifreq + x / 2)
        else:
            sys.stderr.write("coarse tuned to: %d Hz\n" % x)
            self.offset = x
            self.tuner.set_center_freq(self.offset)

    self.scope = fftsink2.fft_sink_c(self.Main.GetPage(0).GetWin(),
        title="Wideband Spectrum (click to coarse tune)",
        fft_size=1024,
        sample_rate=sample_rate,
        ref_scale=2.0,
        ref_level=0,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.6)

    self.Main.GetPage(0).Add(self.scope.win)
    self.scope.set_callback(fftsink2_callback)

    self.connect(self.src, self.scope)

    def fftsink2_callback2(x, y):
        self.offset = self.offset - (x / 10)
        sys.stderr.write("fine tuned to: %d Hz\n" % self.offset)
        self.tuner.set_center_freq(self.offset)

    self.scope2 = fftsink2.fft_sink_c(self.Main.GetPage(1).GetWin(),
        title="Channel Spectrum (click to fine tune)",
        fft_size=1024,
        sample_rate=out_sample_rate,
        ref_scale=2.0,
        ref_level=-20,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.6)

    self.Main.GetPage(1).Add(self.scope2.win)
    self.scope2.set_callback(fftsink2_callback2)

    self.connect(self.resamp, self.scope2)

    self.scope3 = scopesink2.scope_sink_f(
        self.Main.GetPage(2).GetWin(),
        title="Soft Bits",
        sample_rate=out_sample_rate,
        v_scale=0,
        v_offset=0,
        t_scale=0.001,
        ac_couple=False,
        xy_mode=False,
        num_inputs=1,
        trig_mode=TRIG_MODE_AUTO,
        y_axis_label="Counts",
    )
    self.Main.GetPage(2).Add(self.scope3.win)

    self.connect(self.demod, self.scope3)
예제 #38
0
    def __init__(self):
        gr.top_block.__init__(
            self, "Downlink from TVAC (This should run all the time)")

        ##################################################
        # Variables
        ##################################################
        self.block_len_enc = block_len_enc = 1024 / 8 * 2

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 4, 1).base()

        self.samp_rate_factor = samp_rate_factor = 5
        self.samp_rate = samp_rate = 250000
        self.rgain = rgain = 0
        self.payload = payload = block_len_enc + 4
        self.freq_offset = freq_offset = 0

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'rtl_tcp=10.0.0.51:1234')
        self.osmosdr_source_0.set_sample_rate(samp_rate * samp_rate_factor)
        self.osmosdr_source_0.set_center_freq(145.95, 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(rgain, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, ))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc(
            2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            variable_constellation_0)
        self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b()
        self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits(
            0x95, 0xFF)
        self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f(
            2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0)
        self.ccsds_message_info_0 = ccsds.message_info(
            "Block received and sent to Nanolink: ", 10)
        self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder(
            '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT,
            ccsds.LDPC_PUNCT_BACK, 512, tuple(([])))
        self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2)
        self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1,
                                                   '127.0.0.1', 5431, 256,
                                                   True)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                   '127.0.0.1', 5433, 1472,
                                                   True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 '127.0.0.1', 5435, 1472, True)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate * samp_rate_factor, 40e3,
                                     60e3, 6e3, firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1,
            0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -50000, 1, 0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'),
                         (self.ccsds_message_info_0, 'in'))
        self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'),
                         (self.ccsds_softbits_msg_to_bytes_b_0, 'in'))
        self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'),
                         (self.ccsds_randomiser_softbits_0, 'in'))
        self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'),
                         (self.ccsds_ldpc_decoder_0, 'in'))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.ccsds_mpsk_ambiguity_resolver_f_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.blocks_udp_sink_0_1, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.ccsds_blob_msg_sink_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.digital_mpsk_receiver_cc_0_0, 0))
예제 #39
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.slider = slider = 0
        self.samp_rate = samp_rate = 2e6

        ##################################################
        # Blocks
        ##################################################
        _slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_slider_sizer,
            value=self.slider,
            callback=self.set_slider,
            label='slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_slider_sizer,
            value=self.slider,
            callback=self.set_slider,
            minimum=-100,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_slider_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.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(1155.002e6 + slider * 1e3, 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(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(40, 0)
        self.rtlsdr_source_0.set_if_gain(40, 0)
        self.rtlsdr_source_0.set_bb_gain(40, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_scopesink2_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "bladeRF_transceiver")

        ##################################################
        # Variables
        ##################################################
        self.symbole_rate = symbole_rate = 10e3
        self.samp_rate = samp_rate = 1e6
        self.rat_interop = rat_interop = 8
        self.rat_decim = rat_decim = 5
        self.firdes_transition_width = firdes_transition_width = 15000
        self.firdes_decim = firdes_decim = 4
        self.firdes_cuttoff = firdes_cuttoff = 21e3
        self.tx_valve_value = tx_valve_value = False
        self.tx_rf_gain = tx_rf_gain = 10
        self.tx_bb_gain = tx_bb_gain = -20
        self.samp_per_sym_source = samp_per_sym_source = ((samp_rate/2/firdes_decim)*rat_interop/rat_decim) / symbole_rate
        self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate)
        self.rx_valve_value = rx_valve_value = False
        self.rx_rf_gain = rx_rf_gain = 3
        self.rx_bb_gain = rx_bb_gain = 20
        self.preamble = preamble = '0101010101010101'
        self.msg_source_msgq_in = msg_source_msgq_in = gr.msg_queue(2)
        self.msg_sink_msgq_out = msg_sink_msgq_out = gr.msg_queue(2)
        self.frequency_tx = frequency_tx = 450e6
        self.frequency_shift = frequency_shift = 520000
        self.frequency_rx = frequency_rx = 450.0e6
        self.firdes_filter = firdes_filter = firdes.low_pass(1,samp_rate/2, firdes_cuttoff, firdes_transition_width)
        self.bit_per_sym = bit_per_sym = 1
        self.bandwith = bandwith = 6e6
        self.access_code = access_code = '11010011100100011101001110010001'

        ##################################################
        # Blocks
        ##################################################
        self.xlating_fir_filter_1 = filter.freq_xlating_fir_filter_ccc(2, (1, ), frequency_shift, samp_rate)
        self.xlating_fir_filter_0 = filter.freq_xlating_fir_filter_ccc(firdes_decim, (firdes_filter), 0, samp_rate/2)
        self.tx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(tx_valve_value))
        self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/2,True)
        self.rx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rx_valve_value))
        self.rational_resampler = filter.rational_resampler_ccc(
                interpolation=rat_interop,
                decimation=rat_decim,
                taps=None,
                fractional_bw=None,
        )
        self.quadrature_demod = analog.quadrature_demod_cf(2)
        self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source.set_sample_rate(samp_rate)
        self.osmosdr_source.set_center_freq(frequency_rx-frequency_shift, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(2, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rx_rf_gain, 0)
        self.osmosdr_source.set_if_gain(0, 0)
        self.osmosdr_source.set_bb_gain(rx_bb_gain, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(bandwith, 0)
          
        self.osmosdr_sink = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_sink.set_sample_rate(samp_rate)
        self.osmosdr_sink.set_center_freq(frequency_tx, 0)
        self.osmosdr_sink.set_freq_corr(0, 0)
        self.osmosdr_sink.set_gain(tx_rf_gain, 0)
        self.osmosdr_sink.set_if_gain(0, 0)
        self.osmosdr_sink.set_bb_gain(tx_bb_gain, 0)
        self.osmosdr_sink.set_antenna("", 0)
        self.osmosdr_sink.set_bandwidth(bandwith, 0)
          
        self.gmsk_mod = digital.gmsk_mod(
        	samples_per_symbol=int(samp_per_sym),
        	bt=0.5,
        	verbose=False,
        	log=False,
        )
        self.correlate_access_code = digital.correlate_access_code_bb(access_code, 4)
        self.clock_recovery = digital.clock_recovery_mm_ff(samp_per_sym_source*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.cc1111_packet_encoder = cc1111.cc1111_packet_mod_base(cc1111.cc1111_packet_encoder(
                        samples_per_symbol=samp_per_sym,
                        bits_per_symbol=bit_per_sym,
                        preamble=preamble,
                        access_code=access_code,
                        pad_for_usrp=True,
        		do_whitening=True,
        		add_crc=True
                ),
        	source_queue=msg_source_msgq_in
        	)
        self.cc1111_packet_decoder = cc1111.cc1111_packet_decoder(msg_sink_msgq_out,True, True, False, True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.binary_slicer = digital.binary_slicer_fb()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.binary_slicer, 0), (self.correlate_access_code, 0))    
        self.connect((self.cc1111_packet_decoder, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.cc1111_packet_encoder, 0), (self.gmsk_mod, 0))    
        self.connect((self.clock_recovery, 0), (self.binary_slicer, 0))    
        self.connect((self.correlate_access_code, 0), (self.cc1111_packet_decoder, 0))    
        self.connect((self.gmsk_mod, 0), (self.tx_valve, 0))    
        self.connect((self.osmosdr_source, 0), (self.rx_valve, 0))    
        self.connect((self.quadrature_demod, 0), (self.clock_recovery, 0))    
        self.connect((self.rational_resampler, 0), (self.quadrature_demod, 0))    
        self.connect((self.rx_valve, 0), (self.xlating_fir_filter_1, 0))    
        self.connect((self.throttle, 0), (self.xlating_fir_filter_0, 0))    
        self.connect((self.tx_valve, 0), (self.osmosdr_sink, 0))    
        self.connect((self.xlating_fir_filter_0, 0), (self.rational_resampler, 0))    
        self.connect((self.xlating_fir_filter_1, 0), (self.throttle, 0))    
예제 #41
0
    def __init__(self,
                 bind_addr="0.0.0.0",
                 dest_addr="127.0.0.1",
                 lo_offset=100e3,
                 recv_port=16886,
                 rx_sdr_device="usrpb200",
                 send_port=5022,
                 tx_sdr_device="usrpb200",
                 wod_port=5023):
        gr.top_block.__init__(self, "Upsat Transceiver Cli")

        ##################################################
        # Parameters
        ##################################################
        self.bind_addr = bind_addr
        self.dest_addr = dest_addr
        self.lo_offset = lo_offset
        self.recv_port = recv_port
        self.rx_sdr_device = rx_sdr_device
        self.send_port = send_port
        self.tx_sdr_device = tx_sdr_device
        self.wod_port = wod_port

        ##################################################
        # Variables
        ##################################################
        self.samples_per_symbol_tx = samples_per_symbol_tx = 4 * 8
        self.sq_wave = sq_wave = (1.0, ) * samples_per_symbol_tx
        self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[
            rx_sdr_device]['samp_rate']
        self.gaussian_taps = gaussian_taps = filter.firdes.gaussian(
            1.0, samples_per_symbol_tx, 1.0, 4 * samples_per_symbol_tx)
        self.deviation = deviation = 3.9973e3
        self.decimation_rx = decimation_rx = 20
        self.baud_rate_uplink = baud_rate_uplink = 1200
        self.baud_rate_downlink = baud_rate_downlink = 9600
        self.tx_frequency = tx_frequency = 145.835e6

        self.taps = taps = firdes.low_pass(1.0, samp_rate_rx, 20000, 60000,
                                           firdes.WIN_HAMMING, 6.76)

        self.samp_rate_tx = samp_rate_tx = satnogs.hw_tx_settings[
            rx_sdr_device]['samp_rate']
        self.rx_frequency = rx_frequency = 435.765e6
        self.modulation_index_uplink = modulation_index_uplink = deviation / (
            baud_rate_uplink / 2.0)
        self.modulation_index_downlink = modulation_index_downlink = deviation / (
            baud_rate_downlink / 2.0)
        self.interp_taps = interp_taps = numpy.convolve(
            numpy.array(gaussian_taps), numpy.array(sq_wave))
        self.first_stage_samp_rate_rx = first_stage_samp_rate_rx = samp_rate_rx / decimation_rx

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_upsat_fsk_frame_encoder_0 = satnogs.upsat_fsk_frame_encoder(
            [0x33] * 8, [0x7A, 0x0E], False, False, False, True, True, "ABCD",
            0, "ON02GR", 0, 64)
        self.satnogs_udp_msg_source_0 = satnogs.udp_msg_source(
            bind_addr, recv_port, 1500)
        self.satnogs_udp_msg_sink_0_0_0 = satnogs.udp_msg_sink(
            dest_addr, wod_port, 1500)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            dest_addr, send_port, 1500)
        self.satnogs_qb50_deframer_0 = satnogs.qb50_deframer(0xe)
        self.satnogs_multi_format_msg_sink_0 = satnogs.multi_format_msg_sink(1)
        self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm(
            'GND', 0, False, True, 256, 3)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            samp_rate_tx / (baud_rate_uplink * samples_per_symbol_tx),
            taps=(firdes.low_pass_2(32, 32, 0.8, 0.1, 60)),
            flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " +
            satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'])
        self.osmosdr_source_0.set_sample_rate(samp_rate_rx)
        self.osmosdr_source_0.set_center_freq(rx_frequency - lo_offset, 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(
            satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'], 0)
        self.osmosdr_source_0.set_if_gain(
            satnogs.hw_rx_settings[rx_sdr_device]['if_gain'], 0)
        self.osmosdr_source_0.set_bb_gain(
            satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'], 0)
        self.osmosdr_source_0.set_antenna(
            satnogs.hw_rx_settings[rx_sdr_device]['antenna'], 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0)

        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " +
            satnogs.hw_tx_settings[rx_sdr_device]['dev_arg'])
        self.osmosdr_sink_0.set_sample_rate(samp_rate_tx)
        self.osmosdr_sink_0.set_center_freq(tx_frequency - lo_offset, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(
            satnogs.hw_tx_settings[tx_sdr_device]['rf_gain'], 0)
        self.osmosdr_sink_0.set_if_gain(
            satnogs.hw_tx_settings[tx_sdr_device]['if_gain'], 0)
        self.osmosdr_sink_0.set_bb_gain(
            satnogs.hw_tx_settings[tx_sdr_device]['bb_gain'], 0)
        self.osmosdr_sink_0.set_antenna(
            satnogs.hw_tx_settings[tx_sdr_device]['antenna'], 0)
        self.osmosdr_sink_0.set_bandwidth(samp_rate_tx, 0)

        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            samples_per_symbol_tx, (interp_taps))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            decimation_rx, (taps), lo_offset, samp_rate_rx)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            first_stage_samp_rate_rx / baud_rate_downlink,
            0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate_tx, analog.GR_COS_WAVE, lo_offset, 1, 0)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(
            ((first_stage_samp_rate_rx) / baud_rate_downlink) /
            (math.pi * modulation_index_downlink))
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            (math.pi * modulation_index_uplink) / samples_per_symbol_tx)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'failed_pdu'),
                         (self.satnogs_multi_format_msg_sink_0, 'in'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'),
                         (self.satnogs_qb50_deframer_0, 'in'))
        self.msg_connect((self.satnogs_qb50_deframer_0, 'out'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_qb50_deframer_0, 'wod'),
                         (self.satnogs_udp_msg_sink_0_0_0, 'in'))
        self.msg_connect((self.satnogs_udp_msg_source_0, 'msg'),
                         (self.satnogs_upsat_fsk_frame_encoder_0, 'pdu'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satnogs_ax25_decoder_bm_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.satnogs_upsat_fsk_frame_encoder_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
예제 #42
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Cellband")
        _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 = 20e6
        self.center_freq = center_freq = 1725000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=60,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	y_per_div=10,
        	y_divs=6,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.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(10, 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.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-128-128j, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_add_const_vxx_0, 0))    
예제 #43
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 = 20e6
        self.channel_width = channel_width = 200e3
        self.channel_freq = channel_freq = 100e6
        self.center_freq = center_freq = 95e6
        self.audio_gain = audio_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_channel_freq_sizer,
            value=self.channel_freq,
            callback=self.set_channel_freq,
            label='channel_freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._channel_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_channel_freq_sizer,
            value=self.channel_freq,
            callback=self.set_channel_freq,
            minimum=90e6,
            maximum=110e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_channel_freq_sizer)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            label='audio_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._audio_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_audio_gain_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=center_freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=12,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'hackrf')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(97.9e6, 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(2, 0)
        self.osmosdr_source_0.set_gain_mode(False, 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(
            int(samp_rate / channel_width),
            firdes.low_pass(1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=480e3,
            audio_decimation=10,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, center_freq - channel_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
예제 #44
0
    def __init__(self, uri='ip:192.168.2.1'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.uri = uri

        ##################################################
        # Variables
        ##################################################
        self.sampsym = sampsym = 16
        self.samp_rate = samp_rate = 1000000
        self.period_samples = period_samples = 0x8000
        self.constellations = constellations = 4

        ##################################################
        # 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(920e6, 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.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', 920000000,
                                           samp_rate, 20000000, 0x4000, False,
                                           10.0, '', True)
        self.digital_qam_mod_0 = digital.qam.qam_mod(
            constellation_points=constellations,
            mod_code="gray",
            differential=True,
            samples_per_symbol=sampsym,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_qam_demod_0 = digital.qam.qam_demod(
            constellation_points=constellations,
            differential=True,
            samples_per_symbol=sampsym,
            excess_bw=0.35,
            freq_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            phase_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(
            4, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/dchaffee/gnuradio/latency/TimeStamp.bin', True)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/dchaffee/gnuradio/latency/TSTestReceive', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.digital_qam_mod_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_qam_demod_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0, 0))
        self.connect((self.digital_qam_mod_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.digital_qam_mod_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.digital_qam_demod_0, 0))
예제 #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Rtl Sdr Rx Dqpsk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rtl Sdr Rx Dqpsk")
        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", "rtl_sdr_rx_dqpsk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.samp_rate = samp_rate = 250e3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.fc = fc = 868e6
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: BW', "slider", float)
        self.top_layout.addWidget(self._timing_loop_bw_win)
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "slider", float)
        self.top_layout.addWidget(self._phase_bw_win)
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain,
                                        'Equalizer: rate', "slider", float)
        self.top_layout.addWidget(self._eq_gain_win)
        self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              'rtl_tcp=127.0.0.1:1234')
        self.rtlsdr_source_0.set_sample_rate(250e3)
        self.rtlsdr_source_0.set_center_freq(fc, 0)
        self.rtlsdr_source_0.set_freq_corr(36, 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(20, 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(250e3, 0)

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate * 4,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 1, 1,
                                       1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 2, 0, 1,
                                       1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0, 1, 2, 3]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, arity, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            11, 1, eq_gain, 2)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/tochou/SDR-ACARS/dqpsk_receiver/out_files/txt_RX.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.tutorial_my_qpsk_demod_cb_1, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.tutorial_my_qpsk_demod_cb_1, 0),
                     (self.digital_map_bb_0, 0))
예제 #46
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx Rftap Nox")

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2.4e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "")
        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(False, 0)
        self.osmosdr_source_0.set_gain(10, 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.ieee802_11_sync_short_0 = ieee802_11.sync_short(
            0.56, 2, False, False)
        self.ieee802_11_sync_long_0 = ieee802_11.sync_long(
            sync_length, False, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(
            self.freq, True, False)
        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.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, 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_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        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_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_decode_mac_0, 'out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_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_delay_0, 0),
                     (self.ieee802_11_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_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_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_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_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.ieee802_11_sync_long_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
예제 #47
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3e6

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_time_source('gpsdo', 0)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(462.621e6, 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.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 100e3, 50e3, firdes.WIN_HAMMING,
                            6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
예제 #48
0
    def __init__(self):
        gr.top_block.__init__(
            self, "SQ5BPF Tetra live receiver 1ch UDP HEADLESS for slow CPU")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 256000
        self.first_decim = first_decim = 4
        self.xlate_offset_fine1 = xlate_offset_fine1 = 0
        self.xlate_offset1 = xlate_offset1 = 500e3
        self.udp_packet_size = udp_packet_size = 1472
        self.udp_dest_addr = udp_dest_addr = "127.0.0.1"
        self.telive_receiver_name = telive_receiver_name = 'SQ5BPF 1-channel headless rx for telive; 256ks/s version'
        self.telive_receiver_channels = telive_receiver_channels = 1
        self.sdr_ifgain = sdr_ifgain = 20
        self.sdr_gain = sdr_gain = 38
        self.ppm_corr = ppm_corr = 56
        self.out_sample_rate = out_sample_rate = 36000
        self.options_low_pass = options_low_pass = 12500
        self.if_samp_rate = if_samp_rate = samp_rate / first_decim
        self.freq = freq = 435e6
        self.first_port = first_port = 42000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer(('0.0.0.0', first_port),
                                                  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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'rtl=0,buflen=4096')
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        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(ppm_corr, 0)
        self.osmosdr_source_0.set_gain(sdr_gain, 0)
        self.osmosdr_source_0.set_if_gain(sdr_ifgain, 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.mmse_resampler_xx_0 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset1 + xlate_offset_fine1, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 udp_dest_addr, first_port + 1,
                                                 udp_packet_size, False)
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc3_xx_0, 0), (self.mmse_resampler_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc3_xx_0, 0))
        self.connect((self.mmse_resampler_xx_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self,
                 channel_in_hackrf="hackrf=0000000000000000909864c8385824cf",
                 channel_out_hackrf="hackrf=0000000000000000909864c8365e56cf",
                 freq=2480e6):
        gr.top_block.__init__(self, "HackRF Software Channel")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("HackRF Software Channel")
        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", "hackrf_software_channel")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.channel_in_hackrf = channel_in_hackrf
        self.channel_out_hackrf = channel_out_hackrf
        self.freq = freq

        ##################################################
        # Variables
        ##################################################
        self.tx_rf_gain = tx_rf_gain = 7
        self.tx_if_gain = tx_if_gain = 21
        self.tx_bb_gain = tx_bb_gain = 15
        self.shift = shift = 0
        self.samp_rate = samp_rate = 5e6
        self.rx_rf_gain = rx_rf_gain = 0
        self.rx_if_gain = rx_if_gain = 21
        self.rx_bb_gain = rx_bb_gain = 15

        ##################################################
        # Blocks
        ##################################################
        self._tx_rf_gain_range = Range(0, 10, 0.1, 7, 200)
        self._tx_rf_gain_win = RangeWidget(self._tx_rf_gain_range,
                                           self.set_tx_rf_gain, "tx_rf_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._tx_rf_gain_win)
        self._tx_if_gain_range = Range(15, 30, 1, 21, 200)
        self._tx_if_gain_win = RangeWidget(self._tx_if_gain_range,
                                           self.set_tx_if_gain, "tx_if_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._tx_if_gain_win)
        self._tx_bb_gain_range = Range(15, 30, 1, 15, 200)
        self._tx_bb_gain_win = RangeWidget(self._tx_bb_gain_range,
                                           self.set_tx_bb_gain, "tx_bb_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._tx_bb_gain_win)
        self._samp_rate_range = Range(1e6, 10e6, 1e5, 5e6, 200)
        self._samp_rate_win = RangeWidget(self._samp_rate_range,
                                          self.set_samp_rate, "samp_rate",
                                          "counter_slider", float)
        self.top_layout.addWidget(self._samp_rate_win)
        self._rx_rf_gain_range = Range(0, 10, 0.1, 0, 200)
        self._rx_rf_gain_win = RangeWidget(self._rx_rf_gain_range,
                                           self.set_rx_rf_gain, "rx_rf_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._rx_rf_gain_win)
        self._rx_if_gain_range = Range(15, 30, 1, 21, 200)
        self._rx_if_gain_win = RangeWidget(self._rx_if_gain_range,
                                           self.set_rx_if_gain, "rx_if_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._rx_if_gain_win)
        self._rx_bb_gain_range = Range(15, 30, 1, 15, 200)
        self._rx_bb_gain_win = RangeWidget(self._rx_bb_gain_range,
                                           self.set_rx_bb_gain, "rx_bb_gain",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._rx_bb_gain_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               channel_in_hackrf)
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq + shift, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rx_rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(rx_if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(rx_bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           channel_out_hackrf)
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(tx_rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(tx_if_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(tx_bb_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(
            self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.osmosdr_sink_0, 0))
    def __init__(self,
                 antenna=satnogs.not_set_antenna,
                 bb_gain=satnogs.not_set_rx_bb_gain,
                 decoded_data_file_path='/tmp/.satnogs/data/data',
                 dev_args=satnogs.not_set_dev_args,
                 doppler_correction_per_sec=1000,
                 enable_iq_dump=0,
                 file_path='test.wav',
                 if_gain=satnogs.not_set_rx_if_gain,
                 iq_file_path='/tmp/iq.dat',
                 lo_offset=100e3,
                 ppm=0,
                 rf_gain=satnogs.not_set_rx_rf_gain,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 rx_sdr_device='usrpb200',
                 udp_IP='127.0.0.1',
                 udp_port=16887,
                 waterfall_file_path='/tmp/waterfall.dat'):
        gr.top_block.__init__(self, "FSK9600 AX.25 decoder with G3RUH support")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_gain = bb_gain
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[
            rx_sdr_device]['samp_rate']
        self.deviation = deviation = 5000
        self.baud_rate = baud_rate = 9600
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76)

        self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000,
                                           firdes.WIN_HAMMING, 6.76)

        self.modulation_index = modulation_index = deviation / (baud_rate /
                                                                2.0)
        self.filter_rate = filter_rate = 250000
        self.audio_samp_rate = audio_samp_rate = 48000
        self.audio_gain = audio_gain = satnogs.fm_demod_settings[
            rx_sdr_device]['audio_gain']

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(
            audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source(
            "127.0.0.1", rigctl_port, False, 1000, 1500)
        self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff(
            ((audio_samp_rate) / baud_rate) / (math.pi * modulation_index))
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 1.0)
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                 enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(
            decoded_data_file_path, 0)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(
            rx_freq, samp_rate_rx)
        self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm(
            'GND', 0, True, True, 1024)
        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " +
            satnogs.handle_rx_dev_args(rx_sdr_device, dev_args))
        self.osmosdr_source_0.set_sample_rate(samp_rate_rx)
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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(
            satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(
            satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(
            satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(
            satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0)

        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, audio_samp_rate, 7850, audio_samp_rate * 0.15,
                            firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            int(samp_rate_rx / filter_rate), (xlate_filter_taps), lo_offset,
            samp_rate_rx)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            2.0 * math.pi / 100.0, 2, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            48e3 / 9600, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=48000,
            decimation=int(samp_rate_rx / (int(samp_rate_rx / filter_rate))),
            taps=None,
            fractional_bw=None,
        )
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(
            ((audio_samp_rate) / baud_rate) / (math.pi * modulation_index))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'),
                         (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0),
                     (self.satnogs_iq_sink_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0),
                     (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satnogs_ax25_decoder_bm_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.satnogs_quad_demod_filter_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blks2_rational_resampler_xxx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.satnogs_quad_demod_filter_ff_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
예제 #51
0
    def __init__(self, fc, gain, samp_rate, ppm, arfcn, cfile=None, burst_file=None, band=None, verbose=False, rec_length=None, args=""):

        gr.top_block.__init__(self, "Gr-gsm Capture")
                
        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.gain = gain
        self.samp_rate = samp_rate
        self.ppm = ppm
        self.arfcn = arfcn
        self.cfile = cfile
        self.burst_file = burst_file
        self.band = band
        self.verbose = verbose
        self.shiftoff = shiftoff = 400e3
        self.rec_length = rec_length
        
        ##################################################
        # Processing Blocks
        ##################################################

        self.rtlsdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source.set_sample_rate(samp_rate)
        self.rtlsdr_source.set_center_freq(fc - shiftoff, 0)
        self.rtlsdr_source.set_freq_corr(ppm, 0)
        self.rtlsdr_source.set_dc_offset_mode(2, 0)
        self.rtlsdr_source.set_iq_balance_mode(2, 0)
        self.rtlsdr_source.set_gain_mode(True, 0)
        self.rtlsdr_source.set_gain(gain, 0)
        self.rtlsdr_source.set_if_gain(20, 0)
        self.rtlsdr_source.set_bb_gain(20, 0)
        self.rtlsdr_source.set_antenna("", 0)
        self.rtlsdr_source.set_bandwidth(250e3+abs(shiftoff), 0)
        self.blocks_rotator = blocks.rotator_cc(-2*pi*shiftoff/samp_rate)
        
        if self.rec_length is not None:
            self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex, int(samp_rate*rec_length))
        
        if self.verbose or self.burst_file:
            self.gsm_receiver = grgsm.receiver(4, ([self.arfcn]), ([]))
            self.gsm_input = grgsm.gsm_input(
                ppm=0,
                osr=4,
                fc=fc,
                samp_rate_in=samp_rate,
            )
            self.gsm_clock_offset_control = grgsm.clock_offset_control(fc-shiftoff)

        if self.burst_file:
            self.gsm_burst_file_sink = grgsm.burst_file_sink(self.burst_file)

        if self.cfile:
            self.blocks_file_sink = blocks.file_sink(gr.sizeof_gr_complex*1, self.cfile, False)
            self.blocks_file_sink.set_unbuffered(False)

        if self.verbose:
            self.gsm_bursts_printer_0 = grgsm.bursts_printer(pmt.intern(""),
                                                             False, False, False, False)

        ##################################################
        # Connections
        ##################################################

        if self.rec_length is not None: #if recording length is defined connect head block after the source
            self.connect((self.rtlsdr_source, 0), (self.blocks_head_0, 0))
            self.connect((self.blocks_head_0, 0), (self.blocks_rotator, 0))
        else:
            self.connect((self.rtlsdr_source, 0), (self.blocks_rotator, 0))

        if self.cfile:
            self.connect((self.blocks_rotator, 0), (self.blocks_file_sink, 0))

        if self.verbose or self.burst_file:
            self.connect((self.gsm_input, 0), (self.gsm_receiver, 0))
            self.connect((self.blocks_rotator, 0), (self.gsm_input, 0))
            self.msg_connect(self.gsm_clock_offset_control, "ppm", self.gsm_input, "ppm_in")
            self.msg_connect(self.gsm_receiver, "measurements", self.gsm_clock_offset_control, "measurements")

            if self.burst_file:
                self.msg_connect(self.gsm_receiver, "C0", self.gsm_burst_file_sink, "in")
            if self.verbose:
                self.msg_connect(self.gsm_receiver, "C0", self.gsm_bursts_printer_0, "bursts")
예제 #52
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.freq = freq = 97.8e6

        ##################################################
        # Blocks
        ##################################################
        self._freq_range = Range(87.5e6, 107.9e6, 100e3, 97.8e6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq",
                                     "counter_slider", float)
        self.top_layout.addWidget(self._freq_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=250,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        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(False, 0)
        self.osmosdr_source_0.set_gain(10, 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(
            4,
            firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.audio_sink_0 = audio.sink(48000, '', False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=250e3,
            audio_decimation=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "PFB Channelizer Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("PFB Channelizer Demo")
        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", "pfb_channelizer_demo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.noaa_num_chans = noaa_num_chans = 7
        self.noaa_chan_width = noaa_chan_width = int(25e3)
        self.noaa_band_start = noaa_band_start = 162.4e6
        self.oversampled_width = oversampled_width = noaa_chan_width * (noaa_num_chans + 1)
        self.noaa_fm_dev = noaa_fm_dev = int(5e3)
        self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans
        self.noaa_band_center = noaa_band_center = noaa_band_start + (noaa_num_chans / 2 * noaa_chan_width)
        self.hardware_rate = hardware_rate = int(1e6)
        self.tuner_freq = tuner_freq = 162.3e6
        self.target_freq = target_freq = noaa_band_center
        self.ppm = ppm = 0
        
        self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev * 2, 2500, firdes.WIN_HAMMING, 6.76)
          
        
        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, noaa_band_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76)
          
        self.channel_map = channel_map = range(0, noaa_num_chans+1)
        self.tuner_offset = tuner_offset = target_freq - tuner_freq
        self.ppm_corr = ppm_corr = tuner_freq * (ppm/1e6)
        self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps)
        self.noaa_band_end = noaa_band_end = noaa_band_start + (noaa_num_chans * noaa_chan_width)
        self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps)
        self.fftwidth = fftwidth = 512
        self.fft_interval = fft_interval = 1.0/20
        self.decimation = decimation = hardware_rate / oversampled_width
        self.channel_names = channel_names = map(lambda x: "%.3fMHz" % (162.4 + (x*0.025)), channel_map)
        self.chan_num = chan_num = channel_map[0]

        ##################################################
        # Blocks
        ##################################################
        self._chan_num_options = channel_map
        self._chan_num_labels = channel_names
        self._chan_num_tool_bar = Qt.QToolBar(self)
        self._chan_num_tool_bar.addWidget(Qt.QLabel("Channel"+": "))
        self._chan_num_combo_box = Qt.QComboBox()
        self._chan_num_tool_bar.addWidget(self._chan_num_combo_box)
        for label in self._chan_num_labels: self._chan_num_combo_box.addItem(label)
        self._chan_num_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_num_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chan_num_options.index(i)))
        self._chan_num_callback(self.chan_num)
        self._chan_num_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_chan_num(self._chan_num_options[i]))
        self.top_grid_layout.addWidget(self._chan_num_tool_bar, 0,0,1,2)
        self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	target_freq, #fc
        	oversampled_width, #bw
        	"Band Monitor", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0_0.set_update_time(fft_interval)
        self.qtgui_waterfall_sink_x_0_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-80, -35)
        
        self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_0_win, 1,0,1,2)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	noaa_chan_width, #bw
        	"Channel Monitor", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(fft_interval)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-67, -37)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 1,2,1,2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	noaa_chan_width, #bw
        	"Channelizer Output", #name
        	noaa_num_chans +1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(fft_interval)
        self.qtgui_freq_sink_x_0.set_y_axis(-80, -35)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = [channel_names[0], channel_names[1], channel_names[2], channel_names[3], channel_names[4],
                  channel_names[5], channel_names[6], channel_names[7], "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(noaa_num_chans +1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2,0,1,4)
        self._ppm_range = Range(-20, 20, 0.5, 0, 100)
        self._ppm_win = RangeWidget(self._ppm_range, self.set_ppm, "ppm", "counter_slider", float)
        self.top_grid_layout.addWidget(self._ppm_win, 0,2,1,2)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
        	  noaa_num_chans+1,
        	  (pfb_taps),
        	  1,
        	  100)
        self.pfb_channelizer_ccf_0.set_channel_map((channel_map))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + "type=usrp2" )
        self.osmosdr_source_0_0.set_sample_rate(hardware_rate)
        self.osmosdr_source_0_0.set_center_freq(tuner_freq, 0)
        self.osmosdr_source_0_0.set_freq_corr(0, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0_0.set_gain_mode(True, 0)
        self.osmosdr_source_0_0.set_gain(10, 0)
        self.osmosdr_source_0_0.set_if_gain(20, 0)
        self.osmosdr_source_0_0.set_bb_gain(20, 0)
        self.osmosdr_source_0_0.set_antenna("TX/RX", 0)
        self.osmosdr_source_0_0.set_bandwidth(0, 0)
          
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(int(decimation), (lpf_taps), tuner_offset  + ppm_corr, hardware_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.blocks_multiply_const_vxx_0_5_0 = blocks.multiply_const_vcc((1, ))
        self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vcc((1 if chan_num is 6 else 0, ))
        self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vcc((1 if chan_num is 5 else 0, ))
        self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vcc((1 if chan_num is 4 else 0, ))
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((1 if chan_num is 3 else 0, ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((1 if chan_num is 2 else 0, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((1 if chan_num is 1 else 0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1 if chan_num is 0 else 0, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(24000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=noaa_chan_width,
        	quad_rate=noaa_chan_width,
        	tau=75e-6,
        	max_dev=noaa_fm_dev,
          )
        (self.analog_nbfm_rx_0).set_max_output_buffer(512)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0, 4))    
        self.connect((self.blocks_multiply_const_vxx_0_4, 0), (self.blocks_add_xx_0, 5))    
        self.connect((self.blocks_multiply_const_vxx_0_5, 0), (self.blocks_add_xx_0, 6))    
        self.connect((self.blocks_multiply_const_vxx_0_5_0, 0), (self.blocks_add_xx_0, 7))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_waterfall_sink_x_0_0_0, 0))    
        self.connect((self.osmosdr_source_0_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_multiply_const_vxx_0_2, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_multiply_const_vxx_0_3, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_multiply_const_vxx_0_4, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_multiply_const_vxx_0_5, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_multiply_const_vxx_0_5_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.qtgui_freq_sink_x_0, 1))    
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.qtgui_freq_sink_x_0, 2))    
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.qtgui_freq_sink_x_0, 3))    
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.qtgui_freq_sink_x_0, 4))    
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.qtgui_freq_sink_x_0, 5))    
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.qtgui_freq_sink_x_0, 6))    
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.qtgui_freq_sink_x_0, 7))    
예제 #54
0
    def __init__(self,
                 default_bandwidth=20e3,
                 default_baud=9600,
                 default_bin_file_sink="/tmp/rx_data.bin",
                 default_freq=437.5e6,
                 default_gain=1,
                 default_ip_0='127.0.0.1',
                 default_port_0=5000,
                 default_samp=1000000,
                 sdr_dev="rtl=0"):
        gr.top_block.__init__(self, "GFSK Receiver")

        ##################################################
        # Parameters
        ##################################################
        self.default_bandwidth = default_bandwidth
        self.default_baud = default_baud
        self.default_bin_file_sink = default_bin_file_sink
        self.default_freq = default_freq
        self.default_gain = default_gain
        self.default_ip_0 = default_ip_0
        self.default_port_0 = default_port_0
        self.default_samp = default_samp
        self.sdr_dev = sdr_dev

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               sdr_dev)
        self.osmosdr_source_0.set_sample_rate(default_samp)
        self.osmosdr_source_0.set_center_freq(default_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(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_1 = filter.fir_filter_fff(
            100,
            firdes.low_pass(1, default_samp, default_baud, default_baud / 6,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, default_samp, default_bandwidth / 2,
                            default_bandwidth / 2 / 6, firdes.WIN_HAMMING,
                            6.76))
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            default_samp / (default_baud * 100), 0.001, 0, 0.25, 0.001)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1,
                                                   default_bin_file_sink,
                                                   False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_char * 1,
            addr=default_ip_0,
            port=default_port_0,
            server=True,
        )
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            default_gain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
예제 #55
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM Radio")

        ##################################################
        # Variables
        ##################################################
        self.am_center_freq = am_center_freq = 1536e3
        self.samp_rate = samp_rate = 20e6
        self.audio_gain = audio_gain = 3
        self.am_min_freq = am_min_freq = 540e3
        self.am_max_freq = am_max_freq = 1600e3
        self.am_channel_width = am_channel_width = 10e3
        self.am_channel_freq = am_channel_freq = am_center_freq

        ##################################################
        # Blocks
        ##################################################
        self.notebook_main = self.notebook_main = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.notebook_main.AddPage(grc_wxgui.Panel(self.notebook_main),
                                   "Controls")
        self.Add(self.notebook_main)
        self.notebook_radio = self.notebook_radio = wx.Notebook(
            self.notebook_main.GetPage(0).GetWin(), style=wx.NB_TOP)
        self.notebook_radio.AddPage(grc_wxgui.Panel(self.notebook_radio),
                                    "Spectrum Analysis")
        self.notebook_main.GetPage(0).Add(self.notebook_radio)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
            parent=self.notebook_main.GetPage(0).GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            label='Volume',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._audio_gain_slider = forms.slider(
            parent=self.notebook_main.GetPage(0).GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.notebook_main.GetPage(0).GridAdd(_audio_gain_sizer, 0, 2, 1, 13)
        _am_channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._am_channel_freq_text_box = forms.text_box(
            parent=self.notebook_radio.GetPage(0).GetWin(),
            sizer=_am_channel_freq_sizer,
            value=self.am_channel_freq,
            callback=self.set_am_channel_freq,
            label='Station',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._am_channel_freq_slider = forms.slider(
            parent=self.notebook_radio.GetPage(0).GetWin(),
            sizer=_am_channel_freq_sizer,
            value=self.am_channel_freq,
            callback=self.set_am_channel_freq,
            minimum=am_min_freq,
            maximum=am_max_freq,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.notebook_radio.GetPage(0).GridAdd(_am_channel_freq_sizer, 0, 1, 1,
                                               39)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook_radio.GetPage(0).GetWin(),
            baseband_freq=am_channel_freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.notebook_radio.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=12,
            decimation=16,
            taps=None,
            fractional_bw=None,
        )
        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(am_channel_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(10, 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (10, ), am_center_freq, samp_rate)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=48e3,
            audio_decim=10,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-1, 1e-2, .7, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)
        self.am_low_pass_filter = filter.fir_filter_ccf(
            int(samp_rate / am_channel_width),
            firdes.low_pass(1, samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.am_fosphor_wx_sink_c = fosphor.wx_sink_c(
            self.notebook_main.GetPage(0).GetWin())
        self.am_fosphor_wx_sink_c.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.am_fosphor_wx_sink_c.set_frequency_range(am_channel_freq,
                                                      samp_rate)
        self.notebook_main.GetPage(0).Add(self.am_fosphor_wx_sink_c.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.am_low_pass_filter, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc3_xx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.am_low_pass_filter, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.am_fosphor_wx_sink_c, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.analog_agc3_xx_0, 0))
예제 #56
0
    def __init__(self):
        gr.top_block.__init__(self, "Nsf RTLSDR Event Detect: 3MHz")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Nsf RTLSDR Event Detect: 3MHz")
        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", "NsfDetect30")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.ObsName = ObsName = "Detect30"
        self.ConfigFile = ConfigFile = ObsName+".conf"
        self._telescope_save_config = ConfigParser.ConfigParser()
        self._telescope_save_config.read(ConfigFile)
        try: telescope_save = self._telescope_save_config.get('main', 'telescope')
        except: telescope_save = 'My Horn'
        self.telescope_save = telescope_save
        self._observer_save_config = ConfigParser.ConfigParser()
        self._observer_save_config.read(ConfigFile)
        try: observer_save = self._observer_save_config.get('main', 'observer')
        except: observer_save = 'Science Aficionado'
        self.observer_save = observer_save
        self._fftsize_save_config = ConfigParser.ConfigParser()
        self._fftsize_save_config.read(ConfigFile)
        try: fftsize_save = self._fftsize_save_config.getint('main', 'samplesize')
        except: fftsize_save = 1024
        self.fftsize_save = fftsize_save
        self._device_save_config = ConfigParser.ConfigParser()
        self._device_save_config.read(ConfigFile)
        try: device_save = self._device_save_config.get('main', 'device')
        except: device_save = 'rtlsdr=0,bias=1'
        self.device_save = device_save
        self._Gain1s_config = ConfigParser.ConfigParser()
        self._Gain1s_config.read(ConfigFile)
        try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1')
        except: Gain1s = 49.
        self.Gain1s = Gain1s
        self._Frequencys_config = ConfigParser.ConfigParser()
        self._Frequencys_config.read(ConfigFile)
        try: Frequencys = self._Frequencys_config.getfloat('main', 'frequency')
        except: Frequencys = 1420.4e6
        self.Frequencys = Frequencys
        self._Elevation_save_config = ConfigParser.ConfigParser()
        self._Elevation_save_config.read(ConfigFile)
        try: Elevation_save = self._Elevation_save_config.getfloat('main', 'elevation')
        except: Elevation_save = 90.
        self.Elevation_save = Elevation_save
        self._Bandwidths_config = ConfigParser.ConfigParser()
        self._Bandwidths_config.read(ConfigFile)
        try: Bandwidths = self._Bandwidths_config.getfloat('main', 'bandwidth')
        except: Bandwidths = 3.e6
        self.Bandwidths = Bandwidths
        self._Azimuth_save_config = ConfigParser.ConfigParser()
        self._Azimuth_save_config.read(ConfigFile)
        try: Azimuth_save = self._Azimuth_save_config.getfloat('main', 'azimuth')
        except: Azimuth_save = 180.
        self.Azimuth_save = Azimuth_save
        self.nsigma = nsigma = 5.0
        self.fftsize = fftsize = fftsize_save
        self.Telescope = Telescope = telescope_save
        self.Observer = Observer = observer_save
        self.Mode = Mode = 2
        self.Gain1 = Gain1 = Gain1s
        self.Frequency = Frequency = Frequencys
        self.EventMode = EventMode = 0
        self.Elevation = Elevation = Elevation_save
        self.Device = Device = device_save
        self.Bandwidth = Bandwidth = Bandwidths
        self.Azimuth = Azimuth = Azimuth_save

        ##################################################
        # Blocks
        ##################################################
        self._nsigma_range = Range(0., 10., .1, 5.0, 100)
        self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float)
        self.top_grid_layout.addWidget(self._nsigma_win, 7, 0, 1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fftsize_tool_bar = Qt.QToolBar(self)
        self._fftsize_tool_bar.addWidget(Qt.QLabel('Sample_Size'+": "))
        self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize))
        self._fftsize_tool_bar.addWidget(self._fftsize_line_edit)
        self._fftsize_line_edit.returnPressed.connect(
        	lambda: self.set_fftsize(int(str(self._fftsize_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Telescope_tool_bar = Qt.QToolBar(self)
        self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel'+": "))
        self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope))
        self._Telescope_tool_bar.addWidget(self._Telescope_line_edit)
        self._Telescope_line_edit.returnPressed.connect(
        	lambda: self.set_Telescope(str(str(self._Telescope_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Observer_tool_bar = Qt.QToolBar(self)
        self._Observer_tool_bar.addWidget(Qt.QLabel('Who'+": "))
        self._Observer_line_edit = Qt.QLineEdit(str(self.Observer))
        self._Observer_tool_bar.addWidget(self._Observer_line_edit)
        self._Observer_line_edit.returnPressed.connect(
        	lambda: self.set_Observer(str(str(self._Observer_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Observer_tool_bar, 0, 0, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Mode_options = (0, 2, )
        self._Mode_labels = ('Monitor', 'Detect', )
        self._Mode_tool_bar = Qt.QToolBar(self)
        self._Mode_tool_bar.addWidget(Qt.QLabel('Data Mode'+": "))
        self._Mode_combo_box = Qt.QComboBox()
        self._Mode_tool_bar.addWidget(self._Mode_combo_box)
        for label in self._Mode_labels: self._Mode_combo_box.addItem(label)
        self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._Mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Mode_options.index(i)))
        self._Mode_callback(self.Mode)
        self._Mode_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_Mode(self._Mode_options[i]))
        self.top_grid_layout.addWidget(self._Mode_tool_bar, 6, 0, 1, 2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Gain1_tool_bar = Qt.QToolBar(self)
        self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1'+": "))
        self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1))
        self._Gain1_tool_bar.addWidget(self._Gain1_line_edit)
        self._Gain1_line_edit.returnPressed.connect(
        	lambda: self.set_Gain1(eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Gain1_tool_bar, 0, 2, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Frequency_tool_bar = Qt.QToolBar(self)
        self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz'+": "))
        self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency))
        self._Frequency_tool_bar.addWidget(self._Frequency_line_edit)
        self._Frequency_line_edit.returnPressed.connect(
        	lambda: self.set_Frequency(eng_notation.str_to_num(str(self._Frequency_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 5, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._EventMode_options = (0, 1, )
        self._EventMode_labels = ('Wait', 'Write', )
        self._EventMode_tool_bar = Qt.QToolBar(self)
        self._EventMode_tool_bar.addWidget(Qt.QLabel('Write Mode'+": "))
        self._EventMode_combo_box = Qt.QComboBox()
        self._EventMode_tool_bar.addWidget(self._EventMode_combo_box)
        for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label)
        self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i)))
        self._EventMode_callback(self.EventMode)
        self._EventMode_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_EventMode(self._EventMode_options[i]))
        self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 1, 2)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Elevation_tool_bar = Qt.QToolBar(self)
        self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation'+": "))
        self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation))
        self._Elevation_tool_bar.addWidget(self._Elevation_line_edit)
        self._Elevation_line_edit.returnPressed.connect(
        	lambda: self.set_Elevation(eng_notation.str_to_num(str(self._Elevation_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 7, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 9):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Device_tool_bar = Qt.QToolBar(self)
        self._Device_tool_bar.addWidget(Qt.QLabel('Dev'+": "))
        self._Device_line_edit = Qt.QLineEdit(str(self.Device))
        self._Device_tool_bar.addWidget(self._Device_line_edit)
        self._Device_line_edit.returnPressed.connect(
        	lambda: self.set_Device(str(str(self._Device_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Bandwidth_tool_bar = Qt.QToolBar(self)
        self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth'+": "))
        self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth))
        self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit)
        self._Bandwidth_line_edit.returnPressed.connect(
        	lambda: self.set_Bandwidth(eng_notation.str_to_num(str(self._Bandwidth_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 5, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Azimuth_tool_bar = Qt.QToolBar(self)
        self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth'+": "))
        self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth))
        self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit)
        self._Azimuth_line_edit.returnPressed.connect(
        	lambda: self.set_Azimuth(eng_notation.str_to_num(str(self._Azimuth_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 7, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 9):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + Device )
        self.rtlsdr_source_0.set_sample_rate(Bandwidth*1e6)
        self.rtlsdr_source_0.set_center_freq(Frequency*1e6, 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(float(Gain1), 0)
        self.rtlsdr_source_0.set_if_gain(12, 0)
        self.rtlsdr_source_0.set_bb_gain(12, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(Bandwidth*1e6, 0)

        (self.rtlsdr_source_0).set_processor_affinity([3])
        self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink(ObsName+".not", fftsize, Frequency*1.E-6, Bandwidth*1.E-6, EventMode, 'Event Detection', Observer, Telescope, Device, float(Gain1), Azimuth, Elevation)
        self.radio_astro_detect_0 = radio_astro.detect(fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, Mode)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
        	fftsize, #size
        	Bandwidth, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(1)
        self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3)

        self.qtgui_time_sink_x_0_0.set_y_label('Event', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['I', 'Q', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 2, 5, 7)
        for r in range(3, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 9):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
        	fftsize,
        	100,
                -.5,
                .5,
        	"",
        	2
        )

        self.qtgui_histogram_sink_x_0.set_update_time(1)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_histogram_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 3, 0, 2, 2)
        for r in range(3, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fftsize)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.radio_astro_detect_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))
예제 #57
0
    def __init__(self):
        gr.top_block.__init__(self, "Recepteur ADSB -Mode-S")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Recepteur ADSB -Mode-S")
        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", "adsb_receiver")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.seuil = seuil = 0.003
        self.samp_rate = samp_rate = 2000000
        self.freq = freq = 1090000000

        ##################################################
        # Blocks
        ##################################################
        self._seuil_range = Range(0.0001, 0.3, 0.0001, 0.003, 200)
        self._seuil_win = RangeWidget(self._seuil_range, self.set_seuil, 'Seuil', "counter_slider", float)
        self.top_grid_layout.addWidget(self._seuil_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_range = Range(950000000, 1093000000, 10000, 1090000000, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.figures = Qt.QTabWidget()
        self.figures_widget_0 = Qt.QWidget()
        self.figures_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_0)
        self.figures_grid_layout_0 = Qt.QGridLayout()
        self.figures_layout_0.addLayout(self.figures_grid_layout_0)
        self.figures.addTab(self.figures_widget_0, 'Waterfall (recu)')
        self.figures_widget_1 = Qt.QWidget()
        self.figures_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_1)
        self.figures_grid_layout_1 = Qt.QGridLayout()
        self.figures_layout_1.addLayout(self.figures_grid_layout_1)
        self.figures.addTab(self.figures_widget_1, 'Spectre (recu)')
        self.figures_widget_2 = Qt.QWidget()
        self.figures_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_2)
        self.figures_grid_layout_2 = Qt.QGridLayout()
        self.figures_layout_2.addLayout(self.figures_grid_layout_2)
        self.figures.addTab(self.figures_widget_2, 'Rx: temporel / bits')
        self.top_grid_layout.addWidget(self.figures, 1, 0, 3, 2)
        for r in range(1, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rtlsdr_source_0_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_gain(14, 0)
        self.rtlsdr_source_0_0.set_if_gain(24, 0)
        self.rtlsdr_source_0_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(samp_rate, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate, #bw
            "Spectre", #name
            1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)



        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.figures_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f(
            250, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_2.set_update_time(0.10)
        self.qtgui_time_sink_x_0_2.set_y_axis(-0.1, 1.1)

        self.qtgui_time_sink_x_0_2.set_y_label('Manchester bits', "")

        self.qtgui_time_sink_x_0_2.enable_tags(True)
        self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0.000008, 0, "burst")
        self.qtgui_time_sink_x_0_2.enable_autoscale(False)
        self.qtgui_time_sink_x_0_2.enable_grid(False)
        self.qtgui_time_sink_x_0_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_2.enable_control_panel(True)
        self.qtgui_time_sink_x_0_2.enable_stem_plot(False)


        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [8, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_2.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_2_win = sip.wrapinstance(self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget)
        self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_2_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.figures_grid_layout_2.setRowStretch(r, 1)
        for c in range(1, 2):
            self.figures_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Rx mag2', "")

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(True)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(True)


        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.figures_grid_layout_2.setRowStretch(r, 1)
        for c in range(0, 1):
            self.figures_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            freq, #fc
            samp_rate, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)



        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
            "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.figures_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb('010100001010000001001010110', 0, 'burst')
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_threshold_ff_0 = blocks.threshold_ff(seuil, seuil, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_char*1, samp_rate)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_char)
        self.blocks_burst_tagger_0.set_true_tag('',True)
        self.blocks_burst_tagger_0.set_false_tag('burst',False)
        self.analog_sig_source_x_1 = analog.sig_source_s(samp_rate, analog.GR_COS_WAVE, 80, 1, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_null_sink_0, 0))
        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_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_burst_tagger_0, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
예제 #58
0
    def __init__(self):

        self.trunk_rx = None
        self.kill_sink = None

        gr.top_block.__init__(self)

        # command line argument parsing
        parser = OptionParser(option_class=eng_option)
        parser.add_option("--args",
                          type="string",
                          default="",
                          help="device args")
        parser.add_option("--antenna",
                          type="string",
                          default="",
                          help="select antenna")
        parser.add_option("-a",
                          "--audio",
                          action="store_true",
                          default=False,
                          help="use direct audio input")
        parser.add_option(
            "-A",
            "--audio-if",
            action="store_true",
            default=False,
            help="soundcard IF mode (use --calibration to set IF freq)")
        parser.add_option(
            "-I",
            "--audio-input",
            type="string",
            default="",
            help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-i",
                          "--input",
                          default=None,
                          help="input file name")
        parser.add_option("-b",
                          "--excess-bw",
                          type="eng_float",
                          default=0.2,
                          help="for RRC filter",
                          metavar="Hz")
        parser.add_option("-c",
                          "--calibration",
                          type="eng_float",
                          default=0.0,
                          help="USRP offset or audio IF frequency",
                          metavar="Hz")
        parser.add_option("-C",
                          "--costas-alpha",
                          type="eng_float",
                          default=0.04,
                          help="value of alpha for Costas loop",
                          metavar="Hz")
        parser.add_option("-D",
                          "--demod-type",
                          type="choice",
                          default="cqpsk",
                          choices=('cqpsk', 'fsk4'),
                          help="cqpsk | fsk4")
        parser.add_option("-P",
                          "--plot-mode",
                          type="choice",
                          default=None,
                          choices=(None, 'constellation', 'fft', 'symbol',
                                   'datascope'),
                          help="constellation | fft | symbol | datascope")
        parser.add_option("-f",
                          "--frequency",
                          type="eng_float",
                          default=0.0,
                          help="USRP center frequency",
                          metavar="Hz")
        parser.add_option("-F",
                          "--ifile",
                          type="string",
                          default=None,
                          help="read input from complex capture file")
        parser.add_option("-H",
                          "--hamlib-model",
                          type="int",
                          default=None,
                          help="specify model for hamlib")
        parser.add_option("-s",
                          "--seek",
                          type="int",
                          default=0,
                          help="ifile seek in K")
        parser.add_option("-L",
                          "--logfile-workers",
                          type="int",
                          default=None,
                          help="number of demodulators to instantiate")
        parser.add_option("-S",
                          "--sample-rate",
                          type="int",
                          default=320e3,
                          help="source samp rate")
        parser.add_option("-t",
                          "--tone-detect",
                          action="store_true",
                          default=False,
                          help="use experimental tone detect algorithm")
        parser.add_option("-T",
                          "--trunk-conf-file",
                          type="string",
                          default=None,
                          help="trunking config file name")
        parser.add_option("-v",
                          "--verbosity",
                          type="int",
                          default=0,
                          help="message debug level")
        parser.add_option("-V",
                          "--vocoder",
                          action="store_true",
                          default=False,
                          help="voice codec")
        parser.add_option(
            "-o",
            "--offset",
            type="eng_float",
            default=0.0,
            help="tuning offset frequency [to circumvent DC offset]",
            metavar="Hz")
        parser.add_option("-p",
                          "--pause",
                          action="store_true",
                          default=False,
                          help="block on startup")
        parser.add_option("-w",
                          "--wireshark",
                          action="store_true",
                          default=False,
                          help="output data to Wireshark")
        parser.add_option("-W",
                          "--wireshark-host",
                          type="string",
                          default="127.0.0.1",
                          help="Wireshark host")
        parser.add_option("-r",
                          "--raw-symbols",
                          type="string",
                          default=None,
                          help="dump decoded symbols to file")
        parser.add_option("-R",
                          "--rx-subdev-spec",
                          type="subdev",
                          default=(0, 0),
                          help="select USRP Rx side A or B (default=A)")
        parser.add_option(
            "-g",
            "--gain",
            type="eng_float",
            default=None,
            help="set USRP gain in dB (default is midpoint) or set audio gain")
        parser.add_option("-G",
                          "--gain-mu",
                          type="eng_float",
                          default=0.025,
                          help="gardner gain")
        parser.add_option("-N",
                          "--gains",
                          type="string",
                          default=None,
                          help="gain settings")
        parser.add_option("-O",
                          "--audio-output",
                          type="string",
                          default="default",
                          help="audio output device name")
        parser.add_option("-U",
                          "--udp-player",
                          action="store_true",
                          default=False,
                          help="enable built-in udp audio player")
        parser.add_option("-q",
                          "--freq-corr",
                          type="eng_float",
                          default=0.0,
                          help="frequency correction")
        parser.add_option("-d",
                          "--fine-tune",
                          type="eng_float",
                          default=0.0,
                          help="fine tuning")
        parser.add_option("-2",
                          "--phase2-tdma",
                          action="store_true",
                          default=False,
                          help="enable phase2 tdma decode")
        parser.add_option("-Z",
                          "--decim-amt",
                          type="int",
                          default=1,
                          help="spectrum decimation")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.channel_rate = 0
        self.baseband_input = False
        self.rtl_found = False
        self.channel_rate = options.sample_rate
        self.fft_sink = None

        self.src = None
        if not options.input:
            # check if osmocom is accessible
            try:
                import osmosdr
                self.src = osmosdr.source(options.args)
            except Exception:
                print("osmosdr source_c creation failure")
                ignore = True

            if "rtl" in options.args.lower():
                #print "'rtl' has been found in options.args (%s)" % (options.args)
                self.rtl_found = True

            gain_names = self.src.get_gain_names()
            for name in gain_names:
                range = self.src.get_gain_range(name)
                print(
                    "gain: name: %s range: start %d stop %d step %d" %
                    (name, range[0].start(), range[0].stop(), range[0].step()))
            if options.gains:
                for tuple in options.gains.split(","):
                    name, gain = tuple.split(":")
                    gain = int(gain)
                    print("setting gain %s to %d" % (name, gain))
                    self.src.set_gain(gain, name)

            rates = self.src.get_sample_rates()
            try:
                print('supported sample rates %d-%d step %d' %
                      (rates.start(), rates.stop(), rates.step()))
            except:
                pass  # ignore

            if options.freq_corr:
                self.src.set_freq_corr(options.freq_corr)

        if options.audio:
            self.channel_rate = 48000
            self.baseband_input = True

        if options.audio_if:
            self.channel_rate = 96000

        if options.ifile:
            self.channel_rate = 96000  # TODO: fixme

        # setup (read-only) attributes
        self.symbol_rate = 4800
        self.symbol_deviation = 600.0
        self.basic_rate = 48000
        _default_speed = 4800

        # keep track of flow graph connections
        self.cnxns = []

        self.datascope_raw_input = False
        self.data_scope_connected = False

        self.constellation_scope_connected = False

        self.options = options

        for i in range(len(speeds)):
            if speeds[i] == _default_speed:
                self.current_speed = i
                self.default_speed_idx = i

        if options.hamlib_model:
            self.hamlib_attach(options.hamlib_model)

        # wait for gdb
        if options.pause:
            print('Ready for GDB to attach (pid = %d)' % (os.getpid(), ))
            input("Press 'Enter' to continue...")

        self.input_q = gr.msg_queue(10)
        self.output_q = gr.msg_queue(10)

        # configure specified data source
        if options.input:
            self.open_file(options.input)
        elif options.frequency:
            self.open_usrp()
        elif options.audio_if:
            self.open_audio_c(self.channel_rate, options.gain,
                              options.audio_input)
        elif options.audio:
            self.open_audio(self.channel_rate, options.gain,
                            options.audio_input)
        elif options.ifile:
            self.open_ifile(self.channel_rate, options.gain, options.ifile,
                            options.seek)
        else:
            pass

        # attach terminal thread
        self.terminal = curses_terminal(self.input_q, self.output_q)

        # attach audio thread
        if self.options.udp_player:
            self.audio = socket_audio("127.0.0.1", WIRESHARK_PORT,
                                      self.options.audio_output)
        else:
            self.audio = None
예제 #59
0
    def __init__(self, antenna=satnogs.not_set_antenna, baudrate=9600.0, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', samp_rate_rx=satnogs.not_set_samp_rate_rx, udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'):
        gr.top_block.__init__(self, "satnogs_msk_ax25")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.baudrate = baudrate
        self.bb_gain = bb_gain
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.samp_rate_rx = samp_rate_rx
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000, 1500)
        self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff(1.2)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0)
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(decoded_data_file_path, 0)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.satnogs_ax25_decoder_bm_0_0 = satnogs.ax25_decoder_bm('GND', 0, True, False, 1024)
        self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm('GND', 0, True, True, 1024)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
        	  (2.0*baudrate)/audio_samp_rate,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  audio_samp_rate/satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx),
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) )
        self.osmosdr_source_0.set_sample_rate(satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0)

        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)))
        self.analog_quadrature_demod_cf_0_0_0 = analog.quadrature_demod_cf(0.9)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1.2)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0_0, 0), (self.dc_blocker_xx_0_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.satnogs_quad_demod_filter_ff_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.satnogs_quad_demod_filter_ff_0, 0), (self.digital_binary_slicer_fb_0, 0))
예제 #60
0
파일: top_block.py 프로젝트: jkbecker/snout
    def __init__(self, channel=908.4e6, gain=40):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.channel = channel
        self.gain = gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 800000
        self.taps = taps = firdes.low_pass(1, samp_rate, 150e3, 50e3,
                                           firdes.WIN_HAMMING)
        self.seuil = seuil = -40

        ##################################################
        # Blocks
        ##################################################
        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.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(channel + 200e3, 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(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 40e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (taps), -200e3, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            20, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_CLIENT",
                                                       '127.0.0.1', '52002',
                                                       10000, False)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(seuil, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            2 * (samp_rate) / (2 * math.pi * 20e3 / 8.0))
        self.Zwave_packet_sink_0 = Zwave.packet_sink()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Zwave_packet_sink_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.Zwave_packet_sink_0, 'out'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.Zwave_packet_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))