def test_fir_filter_ccc_001(self):
     self.generate_ccc_source()
     expected_data = (
         (0.0036842757836 - 0.0114002721384j),
         (0.00324621866457 - 0.0108166672289j),
         (0.00206564785913 - 0.00923090614378j), (0.00109899020754 -
                                                  0.00656201224774j),
         (0.000506619049702 - 0.00402844604105j), (-0.000523390364833 -
                                                   0.00166808743961j),
         (-0.00140534969978 + 0.00103991874494j), (-0.00154365820345 +
                                                   0.00315759982914j),
         (-0.00180402118713 + 0.00427215453237j), (-0.00216706306674 +
                                                   0.00524478312582j),
         (-0.00178848754149 + 0.0057489364408j), (-0.00129876169376 +
                                                  0.00512680830434j),
         (-0.00122803379782 + 0.00427244976163j), (-0.000722666736692 +
                                                   0.00351428100839j),
         (5.53092104383e-05 + 0.00207865727134j), (0.000227351076319 +
                                                   0.000517217209563j),
         (0.000414477253798 - 0.000383921898901j), (0.000998671515845 -
                                                    0.00135387131013j),
         (0.00104933069088 - 0.00243046949618j), (0.000765930046327 -
                                                  0.0026717747096j))
     src = blocks.vector_source_c(self.src_data)
     op = filter.freq_xlating_fir_filter_ccc(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
 def test_fir_filter_ccc_001(self):
     self.generate_ccc_source()
     expected_data = ((0.0036842757836-0.0114002721384j),
                      (0.00324621866457-0.0108166672289j),
                      (0.00206564785913-0.00923090614378j),
                      (0.00109899020754-0.00656201224774j),
                      (0.000506619049702-0.00402844604105j),
                      (-0.000523390364833-0.00166808743961j),
                      (-0.00140534969978+0.00103991874494j),
                      (-0.00154365820345+0.00315759982914j),
                      (-0.00180402118713+0.00427215453237j),
                      (-0.00216706306674+0.00524478312582j),
                      (-0.00178848754149+0.0057489364408j),
                      (-0.00129876169376+0.00512680830434j),
                      (-0.00122803379782+0.00427244976163j),
                      (-0.000722666736692+0.00351428100839j),
                      (5.53092104383e-05+0.00207865727134j),
                      (0.000227351076319+0.000517217209563j),
                      (0.000414477253798-0.000383921898901j),
                      (0.000998671515845-0.00135387131013j),
                      (0.00104933069088-0.00243046949618j),
                      (0.000765930046327-0.0026717747096j))
     src = blocks.vector_source_c(self.src_data)
     op  = filter.freq_xlating_fir_filter_ccc(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
 def test_fir_filter_ccc_002(self):
     self.generate_ccc_source()
     expected_data = (
         (-0.000650451984257 + 0.00120697380044j),
         (-9.59713361226e-05 + 0.00102412770502j),
         (0.000958710326813 - 0.00145424995571j), (0.000901343999431 -
                                                   0.00290832063183j),
         (-0.000822560978122 + 0.000296717538731j), (-0.00211223773658 +
                                                     0.00519825471565j),
         (-0.00037001183955 + 0.00358242215589j), (0.00327983591706 -
                                                   0.00616005761549j),
         (0.00356886954978 - 0.0117237549275j), (-0.00328874029219 +
                                                 0.00182871113066j),
         (-0.0139285130426 + 0.0320657044649j), (-0.0198133718222 +
                                                 0.0562113076448j),
         (-0.0157803222537 + 0.0530290603638j), (-0.00550725404173 +
                                                 0.0255754813552j),
         (0.00252919178456 - 0.00232240976766j), (0.00368427345529 -
                                                  0.0114002330229j),
         (0.000506620621309 - 0.00402843113989j), (-0.00180401885882 +
                                                   0.00427213776857j),
         (-0.00122803344857 + 0.00427243299782j), (0.000414476031438 -
                                                   0.000383919978049j))
     src = blocks.vector_source_c(self.src_data)
     op = filter.freq_xlating_fir_filter_ccc(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
Esempio n. 4
0
    def __init__(self):
        gr.top_block.__init__(self, "Acoust In")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 1
        self.carrier = carrier = 23000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=interpolation,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate, sideband_rx,100)), carrier, samp_rate)
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=11000,
        	server=False,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.digital_gfsk_demod_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0))
Esempio n. 5
0
    def __init__(self):
        gr.top_block.__init__(self, "Acoust Out")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 0
        self.carrier = carrier = 13000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
 def test_fir_filter_ccc_002(self):
     self.generate_ccc_source()
     expected_data = ((-0.000650451984257+0.00120697380044j),
                      (-9.59713361226e-05+0.00102412770502j),
                      (0.000958710326813-0.00145424995571j),
                      (0.000901343999431-0.00290832063183j),
                      (-0.000822560978122+0.000296717538731j),
                      (-0.00211223773658+0.00519825471565j),
                      (-0.00037001183955+0.00358242215589j),
                      (0.00327983591706-0.00616005761549j),
                      (0.00356886954978-0.0117237549275j),
                      (-0.00328874029219+0.00182871113066j),
                      (-0.0139285130426+0.0320657044649j),
                      (-0.0198133718222+0.0562113076448j),
                      (-0.0157803222537+0.0530290603638j),
                      (-0.00550725404173+0.0255754813552j),
                      (0.00252919178456-0.00232240976766j),
                      (0.00368427345529-0.0114002330229j),
                      (0.000506620621309-0.00402843113989j),
                      (-0.00180401885882+0.00427213776857j),
                      (-0.00122803344857+0.00427243299782j),
                      (0.000414476031438-0.000383919978049j))
     src = blocks.vector_source_c(self.src_data)
     op  = filter.freq_xlating_fir_filter_ccc(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
Esempio n. 7
0
    def __init__(self,
                 infile,
                 outfile,
                 sample_rate,
                 shift=0,
                 decimation=1,
                 bandwidth=None):
        gr.top_block.__init__(self, "Top Block")

        taps = filter.firdes.low_pass_2(1, sample_rate, bandwidth,
                                        bandwidth / 10, 60)

        #make(int decimation, pmt_vector_cfloat taps, double center_freq, double sampling_freq) -> freq_xlating_fir_filter_ccc_sptr
        self.freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc(
            decimation, taps, shift, sample_rate)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, infile, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   outfile, False)
        self.blocks_file_sink_0.set_unbuffered(False)

        #self.connect((self.blocks_file_source_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.freq_xlating_fir_filter, 0))
        self.connect((self.freq_xlating_fir_filter, 0),
                     (self.blocks_file_sink_0, 0))
Esempio n. 8
0
    def __init__(self, bandwidth=125e3, input_file='', output_file='channelized.raw', samp_rate=1e6):
        gr.top_block.__init__(self, "Channelizer")

        ##################################################
        # Parameters
        ##################################################
        self.bandwidth = bandwidth
        self.input_file = input_file
        self.output_file = output_file
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################

        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(1.0, samp_rate, (bandwidth/2)+15000, 10000, firdes.WIN_HAMMING, 6.76)


        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (variable_low_pass_filter_taps_0), 0, samp_rate)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, input_file, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, output_file, False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_file_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))
Esempio n. 10
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)
Esempio n. 11
0
    def __init__(self, port, channel_rate, samp_rate, offset):
        gr.hier_block2.__init__(
            self,
            "channel",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        self.samp_rate = samp_rate
        self.channel_rate = channel_rate
        self.port = port
        self.offset = offset
        self.in_use = False
        self.source_id = None

        decim = int(samp_rate / (channel_rate)) / 2
        taps = firdes.low_pass(1, self.samp_rate,
                               (self.channel_rate - 2000) / 2, 4000)
        #print 'taps: %s' % len(taps)
        self.prefilter = filter.freq_xlating_fir_filter_ccc(
            decim, (taps), offset, samp_rate)
        self.sink = zeromq.pub_sink(gr.sizeof_gr_complex * 1, 1,
                                    'tcp://0.0.0.0:%s' % port)

        self.connect(self, self.prefilter, self.sink)
        self.init_time = time.time()
        self.channel_close_time = 0
Esempio n. 12
0
    def __init__(self):
        gr.top_block.__init__(self, "METEOR-M2 receiver")

        ##################################################
        # Variables
        ##################################################
        self.symb_rate = symb_rate = 72e3
        self.samp_rate = samp_rate = 960e3
        self.decimation = decimation = 4
        self.samp_per_sym = samp_per_sym = samp_rate/decimation/symb_rate
        self.clock_alpha = clock_alpha = 30e-3
        self.bitstream_name = bitstream_name = os.getcwd() + "/Data/meteor_LRPT_" + datetime.now().strftime("%d%m%Y_%H%M") + ".s"
        self.Tuning_offset = Tuning_offset = 300e3
        self.LO_freq = LO_freq = 137.903e6
        self.BPF_width = BPF_width = 140e3

        ##################################################
        # 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(LO_freq-Tuning_offset, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(42, 0)
        self.rtlsdr_source_0.set_if_gain(20, 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.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, samp_rate/decimation, symb_rate, 0.3, 361))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation, (firdes.low_pass(1,samp_rate,BPF_width/2,20e3)), Tuning_offset, samp_rate)
        (self.freq_xlating_fir_filter_xxx_0).set_processor_affinity([0])
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1e-3, 4)
        (self.digital_costas_loop_cc_0).set_processor_affinity([1])
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base())
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sym*(1+0.0), clock_alpha**2/4.0, 0.5, clock_alpha, 0.005)
        (self.digital_clock_recovery_mm_xx_0).set_processor_affinity([2])
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, bitstream_name, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_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)
        ##################################################
        # 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))
    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))    
Esempio n. 15
0
    def __init__(self,
                 num_messages,
                 sample_rate=1000000,
                 freq_offset=10000,
                 sf=7,
                 name="rtl-sdr"):
        Thread.__init__(self)
        self.setDaemon(True)
        self.num_messages = num_messages
        self.sample_rate = sample_rate
        self.freq_offset = freq_offset
        self.frequency = 868e6
        self.name = name

        self.data = {'payloads': [], 'snrs': []}

        # Variables
        self.host = "127.0.0.1"
        self.port = 40868

        # Setup socket
        self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.server.bind((self.host, self.port))
        self.server.settimeout(1)

        # Build flowgraph
        self.tb = gr.top_block()
        self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " +
                                            '')
        self.rtlsdr_source.set_sample_rate(self.sample_rate)
        self.rtlsdr_source.set_center_freq(self.frequency, 0)
        self.rtlsdr_source.set_freq_corr(0, 0)
        self.rtlsdr_source.set_dc_offset_mode(0, 0)
        self.rtlsdr_source.set_iq_balance_mode(0, 0)
        self.rtlsdr_source.set_gain_mode(False, 0)
        self.rtlsdr_source.set_gain(10, 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(0, 0)
        self.freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, self.sample_rate, 500000, 100000,
                                firdes.WIN_HAMMING, 6.67)), self.freq_offset,
            self.sample_rate)
        self.lora_receiver = lora.lora_receiver(self.sample_rate,
                                                self.frequency, [868100000],
                                                sf, 1000000, False, 4, True)
        self.message_socket_sink = lora.message_socket_sink(
            "127.0.0.1", 40868, 0)

        # Make connections
        self.tb.connect((self.rtlsdr_source, 0),
                        (self.freq_xlating_fir_filter, 0))
        self.tb.connect((self.freq_xlating_fir_filter, 0),
                        (self.lora_receiver, 0))
        self.tb.msg_connect((self.lora_receiver, 'frames'),
                            (self.message_socket_sink, 'in'))
    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(('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) + " " + ''
        )
        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))
Esempio n. 17
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0_1 = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + '')
        self.osmosdr_source_0_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_0_1.set_gain_mode(False, 0)
        self.osmosdr_source_0_1.set_gain(10, 0)
        self.osmosdr_source_0_1.set_if_gain(24, 0)
        self.osmosdr_source_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_0_1.set_antenna('', 0)
        self.osmosdr_source_0_1.set_bandwidth(0, 0)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1,
            firdes.low_pass(1, samp_rate, cutoff, width, firdes.WIN_BLACKMAN,
                            6.76), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            'capture_' + datetime.today().strftime('%Y%m%d%H%M%S'), False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_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.blocks_file_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
Esempio n. 18
0
    def __init__(self, channels, decim, ch_width, ch_twidth, fc, band,
                 samp_rate, path):
        gr.top_block.__init__(self, "gsm_channelize")

        ##################################################
        # Parameters
        ##################################################
        self.channels = channels
        self.decim = decim
        self.ch_width = ch_width
        self.ch_twidth = ch_twidth
        self.fc = fc
        self.band = band
        self.samp_rate = samp_rate
        self.blocks_fir_filters = {}
        self.blocks_file_sinks = {}

        ##################################################
        # Blocks and connections
        ##################################################
        self.blocks_file_source = blocks.file_source(gr.sizeof_gr_complex,
                                                     path, False)
        self.blocks_throttle = blocks.throttle(gr.sizeof_gr_complex, samp_rate,
                                               True)

        self.connect((self.blocks_file_source, 0), (self.blocks_throttle, 0))

        c0_arfcn = arfcn.downlink2arfcn(fc, band)
        self.channels.insert(0, c0_arfcn)
        print(
            "Extracting channels %s, given that the center frequency is at ARFCN %d (%s)"
            % (str(channels), c0_arfcn, eng_notation.num_to_str(fc)))

        for channel in channels:
            channel_freq = arfcn.arfcn2downlink(channel, band)
            if channel_freq is None:
                print("Warning: invalid ARFCN %d for band %s" %
                      (channel, band))
                continue
            freq_diff = channel_freq - fc
            print("ARFCN %d is at C0 %+d KHz" %
                  (channel, int(freq_diff / 1000.0)))

            self.blocks_fir_filters[
                channel] = filter.freq_xlating_fir_filter_ccc(
                    decim,
                    (firdes.low_pass(1, samp_rate, ch_width, ch_twidth)),
                    freq_diff, samp_rate)
            self.connect((self.blocks_throttle, 0),
                         (self.blocks_fir_filters[channel], 0))

            self.blocks_file_sinks[channel] = blocks.file_sink(
                gr.sizeof_gr_complex,
                "./gsm_channelizer/out_" + str(channel) + ".cfile", False)
            self.blocks_file_sinks[channel].set_unbuffered(False)
            self.connect((self.blocks_fir_filters[channel], 0),
                         (self.blocks_file_sinks[channel], 0))
Esempio n. 19
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 200000
        self.width = width = 20000
        self.tuner = tuner = 434e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 134000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, cutoff, width,
                                firdes.WIN_BLACKMAN, 6.76)), -freq_offset,
            samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 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.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
Esempio n. 20
0
    def __init__(self,
                 tapdev,
                 samp_rate=44100,
                 carrier_freq=3000,
                 samples_per_symbol=None):
        gr.top_block.__init__(self, 'demod_top_block')
        ##################################################
        # Variables
        ##################################################
        self.transition_bw = transition_bw = 500
        self.samp_rate = samp_rate
        self.carrier_freq = carrier_freq
        if samples_per_symbol is None:
            #this will result in a bandwidth that touches 200 Hz on the lower side
            #this way we don't make aliases and don't use frequiencies under 200 Hz,
            #because transmission characteristics can be bad with cheap speakers.
            self.samples_per_symbol = 1 + samp_rate // (carrier_freq - 200)
        else:
            self.samples_per_symbol = samples_per_symbol
        self.bandwidth = samp_rate / self.samples_per_symbol * 2

        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, self.bandwidth, transition_bw)),
            carrier_freq, samp_rate)
        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=False,
            log=False,
        )
        self.tap_sink = tap_sink(tapdev)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_psk_demod_0, 0), (self.tap_sink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_psk_demod_0, 0))
Esempio n. 21
0
 def create_block(self, taps):
     assert taps is not None
     if self.freq_xlating:
         return grfilter.freq_xlating_fir_filter_ccc(
             self.decimation, taps, 0, self.input_rate)
     else:
         if len(taps) > 10:
             return grfilter.fft_filter_ccc(self.decimation, taps, 1)
         else:
             return grfilter.fir_filter_ccc(self.decimation, taps)
Esempio n. 22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="air band receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.udp_dest_port = udp_dest_port = 8082
        self.udp_dest_host = udp_dest_host = "192.168.10.30"
        self.sql = sql = -10.0
        self.samp_rate = samp_rate = 2.4e6
        self.rfgain = rfgain = 49.5
        self.frq_corr = frq_corr = 30.0
        self.device_arg = device_arg = "rtl_tcp=192.168.10.109:1235"
        self.base_freq = base_freq = 120.5e6

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device_arg )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(base_freq, 0)
        self.osmosdr_source_0.set_freq_corr(frq_corr, 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(rfgain, 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('RX', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dest_host, udp_dest_port, 1472, True)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(sql, 1e-4, 0, False)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=48e3,
        	audio_decim=1,
        	audio_pass=5000,
        	audio_stop=5500,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0)
        self.analog_agc2_xx_0.set_max_gain(5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.osmosdr_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))
Esempio n. 24
0
    def __init__(self, target_frequency, if_sampling_rate):
        super(source_rtlsdr, self).__init__(
            "source_rtlsdr",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        import osmosdr

        model = 'r820t'

        rf_sampling_rate = 2400000
        if model == 'e4000':
            offset_frequency = rf_sampling_rate / 4
            rf_gain = 42  # E4000, Gains set assuming a front-end filter keeps out-of-band noise down.
        elif model == 'r820t':
            offset_frequency = 0
            rf_gain = 42.1  # R820T, Gains set assuming a front-end filter keeps out-of-band noise down.
        else:
            raise RuntimeError('Unknown RTL-SDR receiver model')

        if_gain = 42
        bb_gain = 20  # Not sure this has an effect on RTL-SDR.
        baseband_bandwidth = 0  # No effect on RTL-SDR?
        if_filter_attenuation = 60

        rf_decimation, rf_decimation_remainder = divmod(
            rf_sampling_rate, if_sampling_rate)
        if rf_decimation_remainder != 0:
            raise RuntimeError('RF decimation must be an integer')
        rf_decimation = int(round(rf_decimation))
        tuning_frequency = target_frequency - offset_frequency

        self.source = osmosdr.source(args="numchan=1 rtl=0")
        self.source.set_sample_rate(rf_sampling_rate)
        self.source.set_center_freq(tuning_frequency, 0)
        self.source.set_freq_corr(0, 0)
        self.source.set_dc_offset_mode(0, 0)
        self.source.set_iq_balance_mode(0, 0)
        self.source.set_gain_mode(False, 0)
        self.source.set_gain(rf_gain, 0)
        self.source.set_if_gain(if_gain, 0)
        self.source.set_bb_gain(bb_gain, 0)
        self.source.set_antenna("", 0)
        self.source.set_bandwidth(baseband_bandwidth, 0)

        if_taps = firdes.low_pass_2(1.0, rf_sampling_rate,
                                    if_sampling_rate * 0.45,
                                    if_sampling_rate * 0.1,
                                    if_filter_attenuation)
        self.if_filter = filter.freq_xlating_fir_filter_ccc(
            rf_decimation, (if_taps), offset_frequency, rf_sampling_rate)
        #self.if_filter.set_min_output_buffer(1048576)

        self.connect(self.source, self.if_filter, self)
Esempio n. 25
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))
Esempio n. 26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Esempio n. 27
0
def filter_raw(burst_object):
    ### OOK_Demod  script
    ook_slicer = gr.top_block()  # Define the container

    ##################################################
    # Variables
    ##################################################
    ook_slicer.working_samp_rate = working_samp_rate = burst_object.working_samp_rate
    ook_slicer.samp_rate = samp_rate = burst_object.samp_rate
    ook_slicer.threshold = threshold = burst_object.threshold
    ook_slicer.offset = offset = burst_object.offset
    ook_slicer.filter_transition = filter_transition = burst_object.filter_transition
    ook_slicer.filter_decimation = filter_decimation = int(samp_rate /
                                                           working_samp_rate)
    ook_slicer.filter_cutoff = filter_cutoff = burst_object.filter_cutoff
    ook_slicer.raw_data_file = raw_data_file = burst_object.raw_input_file
    ook_slicer.filename_filtered = filename_filtered = raw_data_file + '.filtered'

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

    #ook_slicer.throttle = blocks.throttle(gr.sizeof_gr_complex*1, working_samp_rate,True)
    #ook_slicer.multiply_constant = blocks.multiply_const_vcc((4, ))
    ook_slicer.freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc(
        filter_decimation,
        (firdes.low_pass(1, samp_rate, filter_cutoff, filter_transition)),
        offset, samp_rate)
    ook_slicer.file_source = blocks.file_source(gr.sizeof_gr_complex * 1,
                                                raw_data_file, False)
    ook_slicer.file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                              filename_filtered, False)
    ook_slicer.file_sink_0.set_unbuffered(False)
    #ook_slicer.digital_binary_slicer = digital.binary_slicer_fb()
    #ook_slicer.complex_to_mag_squared = blocks.complex_to_mag_squared(1)
    #ook_slicer.blocks_uchar_to_float_0 = blocks.uchar_to_float()
    #ook_slicer.add_const = blocks.add_const_vff((-1*threshold, ))

    ##################################################
    # Connections
    ##################################################
    ook_slicer.connect((ook_slicer.file_source, 0),
                       (ook_slicer.freq_xlating_fir_filter, 0))
    ook_slicer.connect((ook_slicer.freq_xlating_fir_filter, 0),
                       (ook_slicer.file_sink_0, 0))

    # This thing now just pumps it out!
    ook_slicer.start()  # Start the flow graph
    ook_slicer.wait()  # wait for it to finish and return

    ## the returned object is mutated, and some basic info changes
    burst_object.raw_input_file = filename_filtered
    burst_object.samp_rate = burst_object.working_samp_rate
    return burst_object
Esempio n. 28
0
    def __init__(self, mod, alphabet_type, freq_offset, tx_len = int(30e4), approx_bw = 20, index = 0):
        gr.hier_block2.__init__(self, "transmitter_" + str(index),
            gr.io_signature(0, 0, 0) ,
            gr.io_signature(1, 1, gr.sizeof_gr_complex))
        self.mod = mod()
        self.freq_offset = freq_offset

        self.src = source_alphabet(alphabet_type, tx_len, True, False)
        self.approx_bw = approx_bw
        self.freq_shift_filter = filter.freq_xlating_fir_filter_ccc(1, ([1]), -1*self.freq_offset, SAMP_RATE)
        #self.connect(self, self.src, self.mod, self)
        self.connect(self.src, self.mod, (self.freq_shift_filter,0), self)
Esempio n. 29
0
    def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq,
                 channel_width, transition_width, threshold, iq_filename,
                 dig_out_filename):
        gr.top_block.__init__(self)

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

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

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

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

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

        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_message_sink_0, 0))
        if len(dig_out_filename) > 0:
            self.connect((self.digital_binary_slicer_fb_0, 0),
                         (self.blocks_file_sink_0, 0))
Esempio n. 30
0
    def __init__(self, bb_gain=20, destination="localhost", filter_width=20000, freq=0, freq_corr=0, gpredict_port=4532, if_gain=20, offset=50e3, port=7355, rf_gain=40):
        gr.top_block.__init__(self, "FM/FSK receiver for an RTL-SDR device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.filter_width = filter_width
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq-offset, 0)
        self.osmosdr_source_0.set_freq_corr(freq_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(rf_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.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, filter_width/2.0, filter_width/20.0)), doppler_freq-freq+offset, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, destination, port, 1472, True)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_short_0, 0))    
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Esempio n. 31
0
 def create_block(self, taps):
     assert taps is not None
     if self.freq_xlating:
         return grfilter.freq_xlating_fir_filter_ccc(
             self.decimation,
             taps,
             0,
             self.input_rate)
     else:
         if len(taps) > 10:
             return grfilter.fft_filter_ccc(self.decimation, taps, 1)
         else:
             return grfilter.fir_filter_ccc(self.decimation, taps)
Esempio n. 32
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")
Esempio n. 33
0
    def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq,
                 channel_width, transition_width, threshold, fsk_deviation,
                 fskSquelch, iq_filename, dig_out_filename):
        gr.top_block.__init__(self)

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

        ##################################################
        # Blocks
        ##################################################
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, iq_filename, False)
        self.blocks_tuning_filter_0 = filter.freq_xlating_fir_filter_ccc(
            int(samp_rate_in / samp_rate_out), (self.firdes_taps),
            tune_freq - center_freq, samp_rate_in)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            fskSquelch, 1, 1, False)
        self.blocks_quadrature_demod_0 = analog.quadrature_demod_cf(
            samp_rate_out / (2 * pi * fsk_deviation / 2))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1 * threshold, ))
        self.blocks_digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

        # swapped message sink for file sink
        #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, dig_out_filename, False)
        #self.blocks_file_sink_0.set_unbuffered(False)
        self.sink_queue = gr.msg_queue()
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, self.sink_queue, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_tuning_filter_0, 0))
        self.connect((self.blocks_tuning_filter_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.blocks_quadrature_demod_0, 0))
        self.connect((self.blocks_quadrature_demod_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_digital_binary_slicer_fb_0, 0))

        #self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_digital_binary_slicer_fb_0, 0),
                     (self.blocks_message_sink_0, 0))
Esempio n. 34
0
	def __init__(self, target_frequency, if_sampling_rate):
		super(source_rtlsdr, self).__init__(
			"source_rtlsdr",
			gr.io_signature(0, 0, 0),
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
		)

		import osmosdr

		model = 'r820t'

		rf_sampling_rate = 2400000
		if model == 'e4000':
			offset_frequency = rf_sampling_rate / 4
			rf_gain = 42			# E4000, Gains set assuming a front-end filter keeps out-of-band noise down.
		elif model == 'r820t':
			offset_frequency = 0
			rf_gain = 42.1			# R820T, Gains set assuming a front-end filter keeps out-of-band noise down.
		else:
			raise RuntimeError('Unknown RTL-SDR receiver model')
		
		if_gain = 42
		bb_gain = 20			# Not sure this has an effect on RTL-SDR.
		baseband_bandwidth = 0	# No effect on RTL-SDR?
		if_filter_attenuation = 60

		rf_decimation, rf_decimation_remainder = divmod(rf_sampling_rate, if_sampling_rate)
		if rf_decimation_remainder != 0:
			raise RuntimeError('RF decimation must be an integer')
		rf_decimation = int(round(rf_decimation))
		tuning_frequency = target_frequency - offset_frequency

		self.source = osmosdr.source(args="numchan=1 rtl=0")
		self.source.set_sample_rate(rf_sampling_rate)
		self.source.set_center_freq(tuning_frequency, 0)
		self.source.set_freq_corr(0, 0)
		self.source.set_dc_offset_mode(0, 0)
		self.source.set_iq_balance_mode(0, 0)
		self.source.set_gain_mode(False, 0)
		self.source.set_gain(rf_gain, 0)
		self.source.set_if_gain(if_gain, 0)
		self.source.set_bb_gain(bb_gain, 0)
		self.source.set_antenna("", 0)
		self.source.set_bandwidth(baseband_bandwidth, 0)

		if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate*0.45, if_sampling_rate*0.1, if_filter_attenuation)
		self.if_filter = filter.freq_xlating_fir_filter_ccc(rf_decimation, (if_taps), offset_frequency, rf_sampling_rate)
		#self.if_filter.set_min_output_buffer(1048576)

		self.connect(self.source, self.if_filter, self)
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        gr.hier_block2.__init__(
            self, "freq_timing_estimator_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
Esempio n. 36
0
    def __init__(self):
        gr.top_block.__init__(self, 'Top Block')

        # sample frequency = 44100 Hz
        # 44100 discrete samples per second to reconstruct the signal when playing it back
        self.samp_rate = samp_rate = 44100

        # data to hide centered at (44100 / 2 - 1000) = 21050 Hz
        # human ear can't catch sounds below 20 Hz or above 20 kHz (however regular audio players won't reproduce sounds at 21050 Hz)
        self.freq_xlating_fir_filter_xxx_0 = gnufilter.freq_xlating_fir_filter_ccc(1, (1, ), samp_rate / 2 - 1000, samp_rate)
        
        # one encoded bit each (44100 / 100) samples of audio
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol = samp_rate / 100,
            sensitivity = 0.01,
            bt = 0.35,
            verbose = False,
            log = False,
        )

        # block that defines the source audio file
        self.blocks_wavfile_source_0 = blocks.wavfile_source(tmp_audio_extracted, False)

        # block that defines the destination audio file
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(tmp_audio_modified, 1, samp_rate, 16)

        # block that defines the source data file to hide
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tmp_data_formatted, True)

        # block that defines sample rate when processing the audio
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True)

        # block that reduces the amplitude of both waves to half, avoiding any possible distorsion coming from wave overlapping
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((.5, ))

        # block that transforms the complex gmsk signal to a real one so that it can be embedded into a wav file
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)

        # block that adds the original audio wave and the forged one
        self.blocks_add_xx_0 = blocks.add_vff(1)

        # connections between blocks
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
Esempio n. 37
0
    def __init__(self, sim_bw, app_samp_rate, freq_shift, f_offset):
        """
        Parameters:

            sim_bw: float
            app_samp_rate: float
            freq_shift: float
        """
        gr.hier_block2.__init__(
            self, "Rx Channel Interface",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
        )

        ##################################################
        # Parameters
        ##################################################
        decimation = sim_bw / app_samp_rate

        if decimation % 1 != 0.0:
            sys.exit("[ERROR] WiNeLo - Simulation bandwidth is not an "
                     "integer multiple of app sample rate: %s" % decimation)
        else:
            print "[INFO] WiNeLo - Using decimation of %s for this node!" \
                  % int(decimation)

        if app_samp_rate > sim_bw:
            sys.exit("[ERROR] WiNeLo - Simulation bandwidth too small!")

        self.decimation = decimation
        self.sim_bw = sim_bw
        self.app_samp_rate = app_samp_rate
        self.f_offset = f_offset
        self.freq_shift = freq_shift + f_offset

        ##################################################
        # Blocks
        ##################################################
        self.channel_filter = filter.freq_xlating_fir_filter_ccc(
            int(self.decimation),
            gr.firdes.low_pass_2(1, self.sim_bw, self.app_samp_rate / 2,
                                 self.app_samp_rate / 10, 120,
                                 window=gr.firdes.WIN_BLACKMAN_hARRIS),
            self.freq_shift, self.sim_bw)

        ##################################################
        # Connections
        ##################################################
        self.connect(self, self.channel_filter)
        self.connect(self.channel_filter, self)
Esempio n. 38
0
 def create_update_freq_xlating_fir_filter(self):
   if self.sample_rate != None:
     self.update_offset_values()
     if self.mode == self.main.MODE_WFM:
       rate = self.if_sample_rate
     else:
       rate = self.audio_rate
       
     fir_taps = firdes.complex_band_pass(1, rate, -rate/2, rate/2,rate/2)
     if self.freq_xlating_fir_filter == None:
       self.freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc(1, (fir_taps), self.compute_offset_f(False), rate)
     else:
       self.freq_xlating_fir_filter.set_taps(fir_taps)
       self.freq_xlating_fir_filter.set_center_freq(self.compute_offset_f(False))
    def test_fir_filter_ccc_002(self):
        self.generate_ccc_source()

        decim = 4
        lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data))
        despun = mix(lo, self.src_data)
        expected_data = fir_filter(despun, self.taps, decim)

        src = blocks.vector_source_c(self.src_data)
        op  = filter.freq_xlating_fir_filter_ccc(decim, self.taps, self.fc, self.fs)
        dst = blocks.vector_sink_c()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
    def test_fir_filter_ccc_002(self):
        self.generate_ccc_source()

        decim = 4
        lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data))
        despun = mix(lo, self.src_data)
        expected_data = fir_filter(despun, self.taps, decim)

        src = blocks.vector_source_c(self.src_data)
        op  = filter.freq_xlating_fir_filter_ccc(decim, self.taps, self.fc, self.fs)
        dst = blocks.vector_sink_c()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
Esempio n. 41
0
    def __init__( self, if_rate, af_rate ):
        gr.hier_block2.__init__(self, "ssb_demod",
                                gr.io_signature(1,1,gr.sizeof_gr_complex),
                                gr.io_signature(1,1,gr.sizeof_float))

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

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

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

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

        self.split = blocks.complex_to_float()

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

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

        self.connect(self,             self.xlate)
        self.connect(self.xlate,       self.split)
        self.connect((self.split, 0), (self.sum, 0))
        self.connect((self.split, 1), (self.sum, 1))
        self.connect(self.sum,         self.sb_sel)
        self.connect(self.xlate,       self.am_det)
        self.connect(self.sb_sel,     (self.mixer, 0))
        self.connect(self.am_det,      self.am_sel)
        self.connect(self.am_sel,     (self.mixer, 1))
        self.connect(self.mixer,       self.lpf)
        self.connect(self.lpf,         self)
Esempio n. 42
0
    def __init__(self, f_in, f_out, base_freq, freq_offset, samp_rate, bit_rate):
        gr.top_block.__init__(self, "Demod Fsk Gen")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate
        self.bit_rate = bit_rate
        self.samp_per_sym = samp_per_sym = int(samp_rate/bit_rate)
        self.fxff_decimation = fxff_decimation = 1
        self.fsk_deviation_hz = fsk_deviation_hz = 160000
        self.freq_offset = freq_offset
        self.base_freq = base_freq
        if not f_out:
            f_out = f_in + '.demod'

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate/fxff_decimation, bit_rate*0.8, bit_rate*.2, firdes.WIN_BLACKMAN, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(fxff_decimation, (firdes.low_pass(1, samp_rate, bit_rate*1.1, bit_rate*.4,  firdes.WIN_BLACKMAN, 6.76)), freq_offset, samp_rate)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/32,True)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, f_in, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, f_out, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_float*1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0)/fxff_decimation)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(30, 0.3, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_deinterleave_0, 0))
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
Esempio n. 43
0
    def __init__(self, target_frequency, if_sampling_rate):
        super(source_hackrf, self).__init__(
            "source_hackrf",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        import osmosdr

        rf_sampling_rate = 10000000
        baseband_bandwidth = 1750000
        offset_frequency = 400000  # Keep well below roll-off of baseband filter.
        rf_gain = 14  # Gains set assuming a front-end filter keeps out-of-band noise down.
        if_gain = 40
        bb_gain = 24
        if_filter_attenuation = 60

        rf_decimation, rf_decimation_remainder = divmod(
            rf_sampling_rate, if_sampling_rate)
        if rf_decimation_remainder != 0:
            raise RuntimeError('RF decimation must be an integer')
        rf_decimation = int(round(rf_decimation))
        tuning_frequency = target_frequency - offset_frequency

        self.source = osmosdr.source(args="numchan=1 hackrf=0")
        self.source.set_sample_rate(rf_sampling_rate)
        self.source.set_center_freq(tuning_frequency, 0)
        self.source.set_freq_corr(0, 0)
        self.source.set_dc_offset_mode(0, 0)
        self.source.set_iq_balance_mode(0, 0)
        self.source.set_gain_mode(False, 0)
        self.source.set_gain(rf_gain, 0)
        self.source.set_if_gain(if_gain, 0)
        self.source.set_bb_gain(bb_gain, 0)
        self.source.set_antenna("", 0)
        self.source.set_bandwidth(baseband_bandwidth, 0)

        if_taps = firdes.low_pass_2(1.0, rf_sampling_rate,
                                    if_sampling_rate * 0.45,
                                    if_sampling_rate * 0.1,
                                    if_filter_attenuation)
        self.if_filter = filter.freq_xlating_fir_filter_ccc(
            rf_decimation, (if_taps), offset_frequency, rf_sampling_rate)
        #self.if_filter.set_min_output_buffer(1048576)

        self.connect(self.source, self.if_filter, self)
Esempio n. 44
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e+06
        self.decim = decim = 3
        self.baud = baud = 40000
        self.samp_per_sym = samp_per_sym = float(samp_rate/decim)/baud
        self.clock_alpha = clock_alpha = 0.0037

        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.complex_band_pass(1, samp_rate, -samp_rate/(2*decim), samp_rate/(2*decim), 10000)), 1.4e6, samp_rate)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 0.1, (firdes.root_raised_cosine(32, 32, 1.0/float(samp_per_sym), 0.35, 11*int(samp_per_sym)*32)), 32, 16, 0.1, 1)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(50e-3, 4, False)
        self.blocks_wavfile_source_0 = blocks.wavfile_source('/Volumes/My Passport/Basebands/Satellites/GOES-16/gqrx_20170124_060211_1694100000_2500000_fc.wav', False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, 16)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*16,
        	addr='127.0.0.1',
        	port=5000,
        	server=False,
        )
        self.analog_feedforward_agc_cc_0_0 = analog.feedforward_agc_cc(1024, 2.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_feedforward_agc_cc_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_feedforward_agc_cc_0_0, 0))
Esempio n. 45
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * .1)
        self.demodgain = demodgain = 24
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 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.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0, 0))
Esempio n. 46
0
    def __init__(self,f_in,f_out):
        gr.top_block.__init__(self)
        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.file_out = file_out = f_out
        self.file_in = file_in = f_in

        ##################################################
        # Blocks
        ##################################################
        self.sat_observer_noaa_analog_decoder_f_0 = sat_observer.noaa_analog_decoder_f(file_out, "ac", 15)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=441,
                decimation=192,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=2,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (40, ), 10.966e3, samp_rate)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(file_in, False)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((6.5, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=samp_rate,
        	audio_decimation=5,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.sat_observer_noaa_analog_decoder_f_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
Esempio n. 47
0
    def __init__(self, rf_params, working_samp_rate):
        gr.hier_block2.__init__(
            self,
            "RX Tuner Block",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),  # single in
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1)  # single out
        )

        ##################################################
        # Parameters
        ##################################################
        # ADD VALIDITY CHECKS TO EACH OF THESE
        self.samp_rate = rf_params.samp_rate
        self.working_samp_rate = working_samp_rate
        self.center_freq = rf_params.center_freq
        self.freq = rf_params.freq
        self.channel_width = rf_params.channel_width
        self.freq_offset_corr = rf_params.freq_offset_corr
        if rf_params.transition_width == 0:
            self.transition_width = rf_params.channel_width / 5
        else:
            self.transition_width = rf_params.transition_width

        ##################################################
        # Variables
        ##################################################
        self.decimation = int(self.samp_rate / self.working_samp_rate)
        self.filter_taps = firdes.low_pass(1, self.samp_rate,
                                           self.channel_width / 2,
                                           self.transition_width)

        ##################################################
        # Blocks
        ##################################################
        self.xlating_fir = filter.freq_xlating_fir_filter_ccc(
            self.decimation, self.filter_taps,
            self.freq - self.center_freq - self.freq_offset_corr,
            self.samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.xlating_fir, 0), (self, 0))
        self.connect((self, 0), (self.xlating_fir, 0))
Esempio n. 48
0
    def __init__(self, params, freq, filename):
        # Super
        gr.hier_block2.__init__(self, "DirectOutputBranch",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, 0))

        prev = self

        # Delay
        if params.delay:
            self.delay = blocks.delay(
                gr.sizeof_gr_complex,
                int(round(params.delay)),
            )
            self.connect((prev, 0), (self.delay, 0))
            prev = self.delay

        # Freq xlating filter
        if params.decim1 > 1:
            self.filt1 = filter.freq_xlating_fir_filter_ccc(
                params.decim1, params.taps1, freq, params.samp_rate)

            self.connect((prev, 0), (self.filt1, 0))
            prev = self.filt1

        # Decimating FIR filter
        if params.decim2 > 1:
            self.filt2 = filter.fir_filter_ccc(params.decim2, params.taps2)

            self.connect((prev, 0), (self.filt2, 0))
            prev = self.filt2

        # PFB Arb Resampler
        if params.resamp != 1:
            self.resamp = pfb.arb_resampler_ccf(params.resamp,
                                                params.taps_resamp,
                                                flt_size=32)
            self.connect((prev, 0), (self.resamp, 0))
            prev = self.resamp

        # Output file
        self.sink = blocks.file_sink(gr.sizeof_gr_complex, filename, False)
        self.connect((prev, 0), (self.sink, 0))
Esempio n. 49
0
    def __init__(self):
        gr.top_block.__init__(self, "Vdl2")

        ##################################################
        # Variables
        ##################################################
        self.center_freq = center_freq = 133e6

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=105,
            decimation=100,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            50, (firdes.complex_band_pass(1, 10e6, -50e3, 50e3, 5000)),
            136.975e6 - center_freq, 10e6)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((32767, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, "/tmp/decompress.iq", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short * 1,
                                                   "/tmp/vdl2.iq", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short(
            False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_interleaved_short_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_interleaved_short_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Esempio n. 50
0
    def __init__(self, channels, decim, ch_width, ch_twidth, fc, band, samp_rate, path):
        gr.top_block.__init__(self, "gsm_channelize")

        ##################################################
        # Parameters
        ##################################################
        self.channels = channels
        self.decim = decim
        self.ch_width = ch_width
        self.ch_twidth = ch_twidth
        self.fc = fc
        self.band = band
        self.samp_rate = samp_rate
        self.blocks_fir_filters = {}
        self.blocks_file_sinks = {}

        ##################################################
        # Blocks and connections
        ##################################################
        self.blocks_file_source = blocks.file_source(gr.sizeof_gr_complex, path, False)
        self.blocks_throttle = blocks.throttle(gr.sizeof_gr_complex, samp_rate,True)

        self.connect((self.blocks_file_source, 0), (self.blocks_throttle, 0))

        c0_arfcn = arfcn.downlink2arfcn(fc, band)
        self.channels.insert(0, c0_arfcn)
        print("Extracting channels %s, given that the center frequency is at ARFCN %d (%s)" % (str(channels), c0_arfcn, eng_notation.num_to_str(fc)))

        for channel in channels:
            channel_freq = arfcn.arfcn2downlink(channel, band)
            if channel_freq is None:
                print("Warning: invalid ARFCN %d for band %s" % (channel, band))
                continue
            freq_diff = channel_freq - fc
            print("ARFCN %d is at C0 %+d KHz" % (channel, int(freq_diff / 1000.0)))

            self.blocks_fir_filters[channel] = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, ch_width, ch_twidth)), freq_diff, samp_rate)
            self.connect((self.blocks_throttle, 0), (self.blocks_fir_filters[channel], 0))

            self.blocks_file_sinks[channel] = blocks.file_sink(gr.sizeof_gr_complex, "./gsm_channelizer/out_" + str(channel) + ".cfile", False)
            self.blocks_file_sinks[channel].set_unbuffered(False)
            self.connect((self.blocks_fir_filters[channel], 0), (self.blocks_file_sinks[channel], 0))
Esempio n. 51
0
	def __init__(self, target_frequency, if_sampling_rate):
		super(source_hackrf, self).__init__(
			"source_hackrf",
			gr.io_signature(0, 0, 0),
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
		)

		import osmosdr

		rf_sampling_rate = 10000000
		baseband_bandwidth = 1750000
		offset_frequency = 400000		# Keep well below roll-off of baseband filter.
		rf_gain = 14			# Gains set assuming a front-end filter keeps out-of-band noise down.
		if_gain = 40
		bb_gain = 24
		if_filter_attenuation = 60

		rf_decimation, rf_decimation_remainder = divmod(rf_sampling_rate, if_sampling_rate)
		if rf_decimation_remainder != 0:
			raise RuntimeError('RF decimation must be an integer')
		rf_decimation = int(round(rf_decimation))
		tuning_frequency = target_frequency - offset_frequency

		self.source = osmosdr.source(args="numchan=1 hackrf=0")
		self.source.set_sample_rate(rf_sampling_rate)
		self.source.set_center_freq(tuning_frequency, 0)
		self.source.set_freq_corr(0, 0)
		self.source.set_dc_offset_mode(0, 0)
		self.source.set_iq_balance_mode(0, 0)
		self.source.set_gain_mode(False, 0)
		self.source.set_gain(rf_gain, 0)
		self.source.set_if_gain(if_gain, 0)
		self.source.set_bb_gain(bb_gain, 0)
		self.source.set_antenna("", 0)
		self.source.set_bandwidth(baseband_bandwidth, 0)

		if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate*0.45, if_sampling_rate*0.1, if_filter_attenuation)
		self.if_filter = filter.freq_xlating_fir_filter_ccc(rf_decimation, (if_taps), offset_frequency, rf_sampling_rate)
		#self.if_filter.set_min_output_buffer(1048576)

		self.connect(self.source, self.if_filter, self)
Esempio n. 52
0
    def __init__(self, sequence1, sequence2, samp_rate, center_freq):
        """
	Description:
	This block is functionally equivalent to a conventional frequency xlating FIR filter, with filter taps given by the kronecker product of sequence1 with sequence2.
	This block consists of two filtering steps. First, the received samples are filtered using a frequency xlating filter with frequency offset equal to center_freq and taps equal to sequence2.  Second, the output is fed into a S/P converter to generate len(sequence2) parallel substreams, and each substream is filtered with identical filter with taps equal to sequence1. Then all substreams are connected to a P/S converter to generate the output sequence. 

	Complexity discussion:
	Originally the filter taps have length len(sequence1)*len(sequence2).
	For the kronecker we have one filter of len(sequence2), followed by a bank of len(sequence2) filters, each of length len(sequence1) operating at a rate 1/len(sequence2), for a total complexity of roughly len(sequence2)+len(sequence1), thus resulting in considerable complexity reduction.

	Args:
	     sequence1: the identical taps of each parallel filter in the filter bank.
	     sequence2: the taps of the first filter.
	     samp_rate: the samp_rate of the first freq_xlating_fir filter.
	     center_freq: the center frequency of the freq_xlating_fir filter.
        """

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

        self.n = n = len(sequence2)

        # Build  filterbank
        self._s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex,n)
        self._ss2s = blocks.streams_to_stream(gr.sizeof_gr_complex,n)
        self._filter2=filter.freq_xlating_fir_filter_ccc(1,sequence2,center_freq,samp_rate)
        self._filter=[0]*n
        for i in range(n):
          self._filter[i]=filter.interp_fir_filter_ccc(1,sequence1)

        # Connect blocks             
        self.connect(self, self._filter2)
        self.connect(self._filter2, self._s2ss)
        for i in range(n):
          self.connect((self._s2ss, i),self._filter[i])
          self.connect(self._filter[i],(self._ss2s, i))

        self.connect(self._ss2s,self)
Esempio n. 53
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Dsd Grc")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self._config_freq_config = ConfigParser.ConfigParser()
		self._config_freq_config.read(".grc_op25")
		try: config_freq = self._config_freq_config.getfloat("main", "freq")
		except: config_freq = 489900000
		self.config_freq = config_freq
		self.freq = freq = config_freq
		self._config_xlate_offset_config = ConfigParser.ConfigParser()
		self._config_xlate_offset_config.read(".grc_op25")
		try: config_xlate_offset = self._config_xlate_offset_config.getfloat("main", "xlate_offset")
		except: config_xlate_offset = 0
		self.config_xlate_offset = config_xlate_offset
		self.click_freq = click_freq = freq-config_xlate_offset
		self.xlate_offset_fine = xlate_offset_fine = 0
		self.xlate_offset = xlate_offset = freq-click_freq
		self.samp_rate = samp_rate = 1000000
		self.samp_per_sym = samp_per_sym = 10
		self.decim = decim = 20
		self._config_xlate_bandwidth_config = ConfigParser.ConfigParser()
		self._config_xlate_bandwidth_config.read(".grc_op25")
		try: config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat("main", "xlate_bandwidth")
		except: config_xlate_bandwidth = 24000
		self.config_xlate_bandwidth = config_xlate_bandwidth
		self.auto_tune_offset = auto_tune_offset = 0
		self.xlate_bandwidth = xlate_bandwidth = config_xlate_bandwidth
		self.variable_static_text_0 = variable_static_text_0 = freq+xlate_offset+xlate_offset_fine+auto_tune_offset
		self.squelch = squelch = -65
		self.pre_channel_rate = pre_channel_rate = samp_rate/decim
		self.gain = gain = 25
		self.fine_click_freq = fine_click_freq = 0
		self.channel_rate = channel_rate = 4800*samp_per_sym
		self.audio_mul = audio_mul = 0

		##################################################
		# Blocks
		##################################################
		_xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._xlate_offset_fine_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_xlate_offset_fine_sizer,
			value=self.xlate_offset_fine,
			callback=self.set_xlate_offset_fine,
			label="Fine Offset",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._xlate_offset_fine_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_xlate_offset_fine_sizer,
			value=self.xlate_offset_fine,
			callback=self.set_xlate_offset_fine,
			minimum=-10000,
			maximum=10000,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_xlate_offset_fine_sizer)
		self._xlate_offset_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.xlate_offset,
			callback=self.set_xlate_offset,
			label="Xlate Offset",
			converter=forms.float_converter(),
		)
		self.Add(self._xlate_offset_text_box)
		_xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
		self._xlate_bandwidth_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_xlate_bandwidth_sizer,
			value=self.xlate_bandwidth,
			callback=self.set_xlate_bandwidth,
			label="Xlate BW",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._xlate_bandwidth_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_xlate_bandwidth_sizer,
			value=self.xlate_bandwidth,
			callback=self.set_xlate_bandwidth,
			minimum=5000,
			maximum=50000,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_xlate_bandwidth_sizer)
		self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-1")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-2")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-1")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-2")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "4FSK")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Dibits")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Traffic")
		self.Add(self.nb)
		_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			label="Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			minimum=0,
			maximum=50,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_gain_sizer)
		self._freq_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq,
			callback=self.set_freq,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.Add(self._freq_text_box)
		_audio_mul_sizer = wx.BoxSizer(wx.VERTICAL)
		self._audio_mul_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_audio_mul_sizer,
			value=self.audio_mul,
			callback=self.set_audio_mul,
			label="Audio mul",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._audio_mul_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_audio_mul_sizer,
			value=self.audio_mul,
			callback=self.set_audio_mul,
			minimum=-30,
			maximum=10,
			num_steps=40,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_audio_mul_sizer)
		self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
			self.nb.GetPage(3).GetWin(),
			baseband_freq=0,
			dynamic_range=100,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=channel_rate,
			fft_size=512,
			fft_rate=15,
			average=False,
			avg_alpha=None,
			title="Waterfall Plot",
		)
		self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0_0.win)
		self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
			self.nb.GetPage(1).GetWin(),
			baseband_freq=freq,
			dynamic_range=100,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=512,
			fft_rate=15,
			average=False,
			avg_alpha=None,
			title="Waterfall Plot",
		)
		self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
		self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
			self.nb.GetPage(4).GetWin(),
			title="Scope Plot",
			sample_rate=channel_rate,
			v_scale=1.5,
			v_offset=0,
			t_scale=0.05,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win)
		self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
			self.nb.GetPage(2).GetWin(),
			baseband_freq=fine_click_freq,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=channel_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0.win)
		def wxgui_fftsink2_0_0_callback(x, y):
			self.set_fine_click_freq(x)
		
		self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.nb.GetPage(0).GetWin(),
			baseband_freq=freq,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		def wxgui_fftsink2_0_callback(x, y):
			self.set_click_freq(x)
		
		self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
		self._variable_static_text_0_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.variable_static_text_0,
			callback=self.set_variable_static_text_0,
			label="Final freq",
			converter=forms.float_converter(),
		)
		self.Add(self._variable_static_text_0_static_text)
		_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
		self._squelch_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_squelch_sizer,
			value=self.squelch,
			callback=self.set_squelch,
			label="Squelch",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._squelch_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_squelch_sizer,
			value=self.squelch,
			callback=self.set_squelch,
			minimum=-100,
			maximum=100,
			num_steps=40,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_squelch_sizer)
		self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "hackrf=0" )
		self.osmosdr_source_c_0.set_sample_rate(samp_rate)
		self.osmosdr_source_c_0.set_center_freq(freq, 0)
		self.osmosdr_source_c_0.set_freq_corr(0, 0)
		self.osmosdr_source_c_0.set_dc_offset_mode(0, 0)
		self.osmosdr_source_c_0.set_iq_balance_mode(0, 0)
		self.osmosdr_source_c_0.set_gain_mode(0, 0)
		self.osmosdr_source_c_0.set_gain(14, 0)
		self.osmosdr_source_c_0.set_if_gain(gain, 0)
		self.osmosdr_source_c_0.set_bb_gain(gain, 0)
		self.osmosdr_source_c_0.set_antenna("", 0)
		self.osmosdr_source_c_0.set_bandwidth(0, 0)
		  
		self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 6000)), xlate_offset+xlate_offset_fine-fine_click_freq, samp_rate)
		self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym))
		self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_P25_PHASE_1,dsd.dsd_MOD_C4FM,3,3,True)
		self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), ))
		self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc(
			interpolation=channel_rate,
			decimation=pre_channel_rate,
			taps=None,
			fractional_bw=None,
		)
		self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff(
			interpolation=44100,
			decimation=8000,
			taps=None,
			fractional_bw=None,
		)
		self.audio_sink_0 = audio.sink(44100, "", True)
		self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6)

		##################################################
		# Connections
		##################################################
		self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_waterfallsink2_0_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_waterfallsink2_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
		self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
		self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0))
		self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Decoder 433Mhz")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.target_rate_IM = target_rate_IM = 50000
        self.target_rate = target_rate = 1200
        self.samp_rate = samp_rate = 2000000
        self.xlate_offset = xlate_offset = -47000
        self.variable_text_box_0 = variable_text_box_0 = variable_function_probe_0
        self.variable_static_text_0 = variable_static_text_0 = target_rate
        self.samp_per_sym = samp_per_sym = 5
        self.gain = gain = 1
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 2000, target_rate_IM/4, firdes.WIN_HAMMING, 6.76)

        ##################################################
        # Blocks
        ##################################################
        _target_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._target_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_target_rate_sizer,
        	value=self.target_rate,
        	callback=self.set_target_rate,
        	label='target_rate',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._target_rate_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_target_rate_sizer,
        	value=self.target_rate,
        	callback=self.set_target_rate,
        	minimum=1000,
        	maximum=2000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_target_rate_sizer)
        _xlate_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_sizer,
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="xlate_offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_sizer,
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	minimum=-samp_rate/10,
        	maximum=samp_rate/10,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_xlate_offset_sizer, 2, 2, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0.01,
        	maximum=10,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 3, 2, 1, 1)
        self.ask_demod_my_ask_clock_detector_0 = ask_demod.my_ask_clock_detector(0.01, target_rate, samp_per_sym)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=10,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=target_rate*samp_per_sym,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Max level",
        	peak_hold=True,
        	show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0.win, 4, 2, 1, 1)
        self.wxgui_fftsink2_1 = 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=target_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=True,
        )
        self.GridAdd(self.wxgui_fftsink2_1.win, 1, 2, 1, 1)
        self._variable_text_box_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.variable_text_box_0,
        	callback=self.set_variable_text_box_0,
        	label="te",
        	converter=forms.int_converter(),
        )
        self.Add(self._variable_text_box_0_text_box)
        self._variable_static_text_0_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text_0,
        	callback=self.set_variable_static_text_0,
        	label="Sample rate out (target_rate * samp_pre_sym)",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 6, 2, 1, 1)
        def _variable_function_probe_0_probe():
            while True:
                val = self.ask_demod_my_ask_clock_detector_0.samp_adjust()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(int(samp_rate/target_rate_IM), (firdes_tap), xlate_offset, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, (target_rate_IM)/(target_rate*samp_per_sym))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((gain, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/ubuntu/433/2M_sample_record", True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "/tmp/gnu_radio_out", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.ask_demod_my_ask_clock_detector_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))    
        self.connect((self.fractional_resampler_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.fractional_resampler_xx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_1, 0))    
Esempio n. 55
0
    def __init__(self, modulator, options):
        gr.top_block.__init__(self)

        self.txpath = []
        use_sink = None
        if options.tx_freq is not None:
            # Work-around to get the modulation's bits_per_symbol
            args = modulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / modulator(**args).bits_per_symbol()

            self.sink = uhd_transmitter(
                options.args,
                symbol_rate,
                options.samples_per_symbol,
                options.tx_freq,
                options.tx_gain,
                options.spec,
                options.antenna,
                options.verbose,
            )
            sample_rate = self.sink.get_sample_rate()
            options.samples_per_symbol = self.sink._sps
            use_sink = self.sink
        elif options.to_file is not None:
            sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file)))
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
            self.throttle = gr.throttle(gr.sizeof_gr_complex * 1, options.file_samp_rate)
            self.connect(self.throttle, self.sink)
            use_sink = self.throttle
        else:
            sys.stderr.write("No sink defined, dumping samples to null sink.\n\n")
            self.sink = gr.null_sink(gr.sizeof_gr_complex)

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath.append(transmit_path(modulator, options))
        self.txpath.append(transmit_path(modulator, options))

        samp_rate = 0
        if options.tx_freq is not None:
            samp_rate = self.sink.get_sample_rate()
        else:
            samp_rate = options.file_samp_rate

        volume = options.split_amplitude
        band_transition = options.band_trans_width
        low_transition = options.low_trans_width
        guard_width = options.guard_width

        self.low_pass_filter_qv0 = gr.interp_fir_filter_ccf(
            2, firdes.low_pass(1, samp_rate, samp_rate / 4 - guard_width / 2, low_transition, firdes.WIN_HAMMING, 6.76)
        )
        self.freq_translate_qv0 = filter.freq_xlating_fir_filter_ccc(1, (options.num_taps,), samp_rate / 4, samp_rate)
        self.band_pass_filter_qv0 = gr.fir_filter_ccc(
            1,
            firdes.complex_band_pass(
                1, samp_rate, -samp_rate / 2 + guard_width, 0 - guard_width, band_transition, firdes.WIN_HAMMING, 6.76
            ),
        )

        self.low_pass_filter_qv1 = gr.interp_fir_filter_ccf(
            2, firdes.low_pass(1, samp_rate, samp_rate / 4 - guard_width / 2, low_transition, firdes.WIN_HAMMING, 6.76)
        )
        self.freq_translate_qv1 = filter.freq_xlating_fir_filter_ccc(1, (options.num_taps,), -samp_rate / 4, samp_rate)
        self.band_pass_filter_qv1 = gr.fir_filter_ccc(
            1,
            firdes.complex_band_pass(
                1, samp_rate, 0 + guard_width, samp_rate / 2 - guard_width, band_transition, firdes.WIN_HAMMING, 6.76
            ),
        )

        self.combiner = gr.add_vcc(1)
        self.volume_multiply = blocks.multiply_const_vcc((volume,))

        self.connect((self.txpath[0], 0), (self.low_pass_filter_qv0, 0))
        self.connect((self.txpath[1], 0), (self.low_pass_filter_qv1, 0))

        self.connect((self.low_pass_filter_qv0, 0), (self.freq_translate_qv0, 0))
        self.connect((self.freq_translate_qv0, 0), (self.band_pass_filter_qv0, 0))

        self.connect((self.low_pass_filter_qv1, 0), (self.freq_translate_qv1, 0))
        self.connect((self.freq_translate_qv1, 0), (self.band_pass_filter_qv1, 0))

        self.connect((self.band_pass_filter_qv0, 0), (self.combiner, 0))
        self.connect((self.band_pass_filter_qv1, 0), (self.combiner, 1))

        self.connect((self.combiner, 0), (self.volume_multiply, 0))

        self.connect(self.volume_multiply, use_sink)
Esempio n. 56
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	label="Fine Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	minimum=-10000,
        	maximum=10000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="Xlate Offset",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	label="Xlate Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	minimum=2500,
        	maximum=250000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	label='volume',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_volume_sizer)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label='squelch',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.main_freq,
        	callback=self.set_main_freq,
        	label="Main Freq",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.main_notebook.GetPage(2).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=512,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.main_notebook.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	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.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.main_notebook.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	v_scale=10,
        	v_offset=0,
        	t_scale=10000,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.main_notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=1024,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.main_notebook.GetPage(0).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(main_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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 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_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Esempio n. 57
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Ud T")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 9
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 5
        self.interpolation = interpolation = 500
        self.carrier = carrier = 23000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=500,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=10004,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
Esempio n. 58
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dsd Grc")

        ##################################################
        # Variables
        ##################################################
        self.xlate_offset_fine = xlate_offset_fine = 0
        self.target_freq = target_freq = 855462000
        self.samp_rate = samp_rate = 1000000
        self.samp_per_sym = samp_per_sym = 10
        self.decim = decim = 15
        self.center_freq = center_freq = 855700000
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.variable_static_text_0 = variable_static_text_0 = target_freq+xlate_offset_fine
        self.tuning_error = tuning_error = 0
        self.tune_offset = tune_offset = target_freq - center_freq
        self.pre_channel_rate = pre_channel_rate = samp_rate/decim
        self.gain = gain = 25
        self.channel_rate = channel_rate = 4800*samp_per_sym
        self.audio_mul = audio_mul = 0

        ##################################################
        # Blocks
        ##################################################
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	label="Fine Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	minimum=-10000,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_xlate_offset_fine_sizer)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	label="Xlate BW",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	minimum=5000,
        	maximum=50000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_xlate_bandwidth_sizer)
        self._tuning_error_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.tuning_error,
        	callback=self.set_tuning_error,
        	label="Tuning Error",
        	converter=forms.float_converter(),
        )
        self.Add(self._tuning_error_text_box)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-1")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-2")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-1")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-2")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "4FSK")
        self.Add(self.nb)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	baseband_freq=0,
        	dynamic_range=10,
        	ref_level=10,
        	ref_scale=2.0,
        	sample_rate=channel_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=100,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.flattop,
        )
        self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.nb.GetPage(4).GetWin(),
        	title="Scope Plot",
        	sample_rate=channel_rate,
        	v_scale=1.5,
        	v_offset=0,
        	t_scale=0.05,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=channel_rate,
        	fft_size=1024,
        	fft_rate=30,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        	win=window.flattop,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0.win)
        def wxgui_fftsink2_0_0_callback(x, y):
        	self.set_0(x)
        
        self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=center_freq,
        	y_per_div=20,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=30,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        def wxgui_fftsink2_0_callback(x, y):
        	self.set_target_freq(x)
        
        self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
        self._variable_static_text_0_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text_0,
        	callback=self.set_variable_static_text_0,
        	label="Final freq",
        	converter=forms.float_converter(),
        )
        self.Add(self._variable_static_text_0_static_text)
        self._target_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.target_freq,
        	callback=self.set_target_freq,
        	label="Target freq",
        	converter=forms.float_converter(),
        )
        self.Add(self._target_freq_text_box)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=pre_channel_rate,
                decimation=channel_rate,
                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(center_freq+tuning_error, 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(gain, 0)
        self.osmosdr_source_0.set_bb_gain(gain, 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, channel_rate, 6000, 500, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 3000)), tune_offset+xlate_offset_fine, samp_rate)
        _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_mul_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_audio_mul_sizer,
        	value=self.audio_mul,
        	callback=self.set_audio_mul,
        	label="Audio mul",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._audio_mul_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_audio_mul_sizer,
        	value=self.audio_mul,
        	callback=self.set_audio_mul,
        	minimum=-30,
        	maximum=10,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_audio_mul_sizer)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_scopesink2_1, 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.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))    
Esempio n. 59
0
    def __init__(self, options, queue):
        grc_wxgui.top_block_gui.__init__(self, title="Pager Rx")

        ##################################################
        # Variables
        ##################################################
        self.band = band = 929.5e6
        self.click_freq = click_freq = band - 500000 + 12500
        self.channel = channel = round((click_freq - (band - 500000 - 12500)) / 25000)
        self.samp_rate = samp_rate = 1200000
        self.freq = freq = band - 512500 + (channel * 25000)
        self.corr = corr = 0
        self.gain = gain = 40.0
        self.channel_rate = channel_rate = 25000

        ##################################################
        # Blocks
        ##################################################
        self._freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_static_text, 1, 2, 1, 1)
        _corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._corr_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_corr_sizer,
        	value=self.corr,
        	callback=self.set_corr,
        	label="Frequency correction",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._corr_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_corr_sizer,
        	value=self.corr,
        	callback=self.set_corr,
        	minimum=-150,
        	maximum=150,
        	num_steps=300,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_corr_sizer, 0, 2, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=49.6,
        	num_steps=124,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 2)
        self._band_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.band,
        	callback=self.set_band,
        	label='band',
        	choices=[929.5e6,931.5e6],
        	labels=["929-930","931-932"],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._band_chooser, 1, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=50,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=channel_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Channel Waterfall",
        )
        self.Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=band,
        	dynamic_range=50,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Band Waterfall",
        )
        self.GridAdd(self.wxgui_waterfallsink2_0.win, 2, 0, 1, 3)
        def wxgui_waterfallsink2_0_callback(x, y):
        	self.set_click_freq(x)

        self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
        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(band, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(samp_rate / channel_rate, (filter.optfir.low_pass(1.0, samp_rate, 11000, 12500, 0.1, 60)), freq - band, samp_rate)
        _channel_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_channel_sizer,
        	value=self.channel,
        	callback=self.set_channel,
        	label='channel',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._channel_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_channel_sizer,
        	value=self.channel,
        	callback=self.set_channel,
        	minimum=1,
        	maximum=40,
        	num_steps=39,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_channel_sizer, 1, 1, 1, 1)

        # FLEX protocol demodulator
        self.flex = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
        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.wxgui_waterfallsink2_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.flex, 0))