Beispiel #1
0
 def _set_receiver(self):
     receiver = gsm.receiver_cf(self.tuner_callback,
                                self.synchronizer_callback,
                                self.options.osr,
                                self.options.key.replace(' ', '').lower(),
                                self.options.configuration.upper())
     return receiver
Beispiel #2
0
	def __init__(self):
		#grc_wxgui.top_block_gui.__init__(self, title="Top Block")
		gr.top_block.__init__(self)
		print "abc"
		##################################################
		# Variables
		##################################################
		#self.samp_rate = samp_rate = 32000
		self.osr = 4
		self.key = ''
		self.configuration = ''

		self.clock_rate = 52e6
		self.input_rate = self.clock_rate / 72		#TODO: what about usrp value?
		self.gsm_symb_rate = 1625000.0 / 6.0
		self.sps = self.input_rate / self.gsm_symb_rate




		# configure channel filter
		filter_cutoff	= 135e3		#135,417Hz is GSM bandwidth 
		filter_t_width	= 10e3
		offset = 0.0

		##################################################
		# Blocks
		##################################################
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1)

		print "Input files: ", downfile, " ", upfile
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, downfile, False)
		self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex*1, upfile, False)


		filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING)

		print len(filter_taps)

		self.filter0 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate)
		self.filter1 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate)

		self.interpolator_1 = gr.fractional_interpolator_cc(0, self.sps) 

        	self.tuner_callback = tuner(self)
	        self.synchronizer_callback = synchronizer(self)

		#self.buffer =  howto.buffer_cc()

		self.burst_cb = burst_callback(self)

		print ">>>>>Input rate: ", self.input_rate
		#self.burst = gsm.burst_cf(self.burst_cb,self.input_rate)
        	self.receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.osr, self.key.replace(' ', '').lower(), self.configuration.upper())
		##################################################
		# Connections
		##################################################
		#self.connect((self.gr_file_source_0, 0), (self.filter0, 0), (self.burst, 0))

		self.connect((self.gr_file_source_1, 0), (self.filter1, 0), (self.interpolator_1, 0), (self.receiver, 0))
Beispiel #3
0
    def gsm_receiver( self, input_rate = 400e3):
        filter_cutoff   = 145e3
        filter_t_width  = 10e3
        offset = 0

        #rates
        gsm_symb_rate = 1625000.0 / 6.0
        sps = input_rate / gsm_symb_rate / self.options.osr

        filter_taps    = gr.firdes.low_pass(1.0, input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING)
        filtr          = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, input_rate)
        interpolator   = gr.fractional_interpolator_cc(0, sps)

        tuner_callback = tuner(filtr)
        synchronizer_callback  = synchronizer(self)
        receiver       = gsm.receiver_cf( tuner_callback, synchronizer_callback, self.options.osr, self.options.key.replace(' ', '').lower(), self.options.configuration.upper())

        blocks = {}
        blocks[ "synchronizer_callback"]  = synchronizer_callback
        blocks[ "tuner_callback"]         = tuner_callback
        blocks[ "filter_taps"]            = filter_taps
        blocks[ "filtr"]                  = filtr
        blocks[ "interpolator"]           = interpolator
        blocks[ "receiver"]               = receiver
        self.connect( filtr,  interpolator, receiver)

        return blocks, filtr
Beispiel #4
0
 def _set_receiver(self):
     receiver = gsm.receiver_cf(
         self.tuner_callback,
         self.synchronizer_callback,
         self.options.osr,
         self.options.key.replace(" ", "").lower(),
         self.options.configuration.upper(),
     )
     return receiver
    def __init__(self):
        gr.top_block.__init__(self)
        options = get_options()
        self.tune_corrector_callback = tune_corrector(self)
        self.synchronizer_callback = synchronizer(self)
        self.converter = blocks.vector_to_stream(gr.sizeof_float, 142)

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

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

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

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

        gsm_symb_rate = 1625000.0 / 6.0
        sps = sample_rate / gsm_symb_rate / 4
        out_sample_rate = gsm_symb_rate * 4

        self.offset = 0

        taps = filter.firdes.low_pass(1.0, sample_rate, 145e3, 10e3,
                                      filter.firdes.WIN_HANN)
        self.tuner = filter.freq_xlating_fir_filter_ccf(
            1, taps, self.offset, sample_rate)

        self.interpolator = filter.fractional_resampler_cc(0, sps)

        self.receiver = gsm.receiver_cf(self.tune_corrector_callback,
                                        self.synchronizer_callback, 4,
                                        options.key.replace(' ', '').lower(),
                                        options.configuration.upper())

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

        self.connect(self.src, self.tuner, self.interpolator, self.receiver,
                     self.converter, self.output)
    def resetapp(void):
	pre_status = getServerStatus()
	if getServerStatus() == True:
		setServerStatus(False)
		self.serverlabel_state.SetLabel("Not Connected:")
		self.btnstart_server.SetLabel("Start Server")
	time.sleep(0.2)

        tb.stop()
        tb.wait()
        self.disconnect(self.src, self.tuner, self.interpolator,self.receiver, self.converter, self.output)
        sample_rate = self.src.get_sample_rate()
        sys.stderr.write("sample rate: %d\n" % (sample_rate))

        gsm_symb_rate = 1625000.0 / 6.0
        sps = sample_rate / gsm_symb_rate / 4
        out_sample_rate = gsm_symb_rate * 4

        self.offset = 0

        taps = gr.firdes.low_pass(1.0, sample_rate, 145e3, 10e3, gr.firdes.WIN_HANN)
        self.tuner = gr.freq_xlating_fir_filter_ccf(1, taps, self.offset, sample_rate)

        self.interpolator = gr.fractional_interpolator_cc(0, sps)
        #channel type
        options.configuration = self.channel_combo_box.get_value()
        #use key or not
        options.key = "0000000000000000"#use this as default        
        if self.cb_imsi.GetValue() == True:
            options.key = str(self.edit_key.GetValue())

       
        self.receiver = gsm.receiver_cf(
        self.tune_corrector_callback, self.synchronizer_callback, 4,
        options.key.replace(' ', '').lower(),
        options.configuration.upper())

        self.output = gr.file_sink(gr.sizeof_float, options.output_file)
    #self.interpolator, self.receiver,
        self.connect(self.src, self.tuner, self.interpolator,self.receiver, self.converter, self.output)
        #ending
        time.sleep(0.3)

        tb.Run(True)
 def _set_receiver(self):
     receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.options.osr, self.options.c0pos, self.options.ma.replace(' ', '').lower(), self.options.maio, self.options.hsn, self.options.key.replace(' ', '').lower(), self.options.configuration.upper())
     return receiver
  def __init__(self):
    grc_wxgui.top_block_gui.__init__(self, title="Top Block")

    options = get_options()

    self.tune_corrector_callback = tune_corrector(self)
    self.synchronizer_callback = synchronizer(self)
    self.converter = gr.vector_to_stream(gr.sizeof_float, 142)

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

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

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

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

    gsm_symb_rate = 1625000.0 / 6.0
    sps = sample_rate / gsm_symb_rate / 4
    out_sample_rate = gsm_symb_rate * 4

    self.offset = 0

    taps = gr.firdes.low_pass(1.0, sample_rate, 145e3, 10e3, gr.firdes.WIN_HANN)
    self.tuner = gr.freq_xlating_fir_filter_ccf(1, taps, self.offset, sample_rate)

    self.interpolator = gr.fractional_interpolator_cc(0, sps)

    self.receiver = gsm.receiver_cf(
        self.tune_corrector_callback, self.synchronizer_callback, 4,
        options.key.replace(' ', '').lower(),
        options.configuration.upper())

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

    self.connect(self.src, self.tuner, self.interpolator, self.receiver, self.converter, self.output)

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

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

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

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

    self.Add(self._agc_check_box)

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

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

    self.Add(_rfgain_sizer)

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

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

    self.Add(self.scope.win)
    self.scope.set_callback(fftsink2_callback)

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

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

    self.scope2 = fftsink2.fft_sink_c(self.GetWin(),
        title="Channel Spectrum (click to fine tune)",
        fft_size=1024,
        sample_rate=gsm_symb_rate * 4,
        ref_scale=2.0,
        ref_level=-20,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.3)

    self.Add(self.scope2.win)
    self.scope2.set_callback(fftsink2_callback2)

    self.connect(self.interpolator, self.scope2)
Beispiel #9
0
    sample_rate = self.src.get_sample_rate()
    sys.stderr.write("sample rate: %d\n" % (sample_rate))

    gsm_symb_rate = 1625000.0 / 6.0
    sps = sample_rate / gsm_symb_rate / 4
    out_sample_rate = gsm_symb_rate * 4

    self.offset = 0

    taps = gr.firdes.low_pass(1.0, sample_rate, 145e3, 10e3, gr.firdes.WIN_HANN)
    self.tuner = gr.freq_xlating_fir_filter_ccf(1, taps, self.offset, sample_rate)

    self.interpolator = gr.fractional_interpolator_cc(0, sps)
    #options.configuration = "2S"
    self.receiver = gsm.receiver_cf(
         self.tune_corrector_callback, self.synchronizer_callback, 4,
         options.key.replace(' ', '').lower(),
         options.configuration.upper())

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

    self.connect(self.src, self.tuner, self.interpolator,self.receiver, self.converter, self.output)

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


    def fftsink2_callback(x, y):
        if abs(x / (sample_rate / 2)) > 0.9:
            set_ifreq(self.ifreq + x / 2)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        options = get_options()

        self.tune_corrector_callback = tune_corrector(self)
        self.synchronizer_callback = synchronizer(self)
        self.converter = blocks.vector_to_stream(gr.sizeof_float, 142)

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

        self.src = osmosdr.source(options.args)

        # added by scateu @ 2014-1-9
        self.src.set_freq_corr(0, 0)
        self.src.set_dc_offset_mode(1, 0)
        self.src.set_iq_balance_mode(0, 0)
        self.src.set_gain_mode(0, 0)
        self.src.set_gain(14, 0)
        self.src.set_if_gain(58, 0)
        self.src.set_bb_gain(20, 0)
        self.src.set_antenna("", 0)
        self.src.set_bandwidth(0, 0)

        self.src.set_center_freq(self.ifreq)
        self.src.set_sample_rate(int(options.sample_rate))

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

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

        gsm_symb_rate = 1625000.0 / 6.0
        sps = sample_rate / gsm_symb_rate / 4
        out_sample_rate = gsm_symb_rate * 4

        self.offset = 0

        taps = firdes.low_pass(1.0, sample_rate, 145e3, 10e3, firdes.WIN_HANN)
        self.tuner = freq_xlating_fir_filter_ccf(1, taps, self.offset,
                                                 sample_rate)

        self.interpolator = fractional_interpolator_cc(0, sps)

        self.receiver = gsm.receiver_cf(self.tune_corrector_callback,
                                        self.synchronizer_callback, 4,
                                        options.key.replace(' ', '').lower(),
                                        options.configuration.upper())

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

        self.connect(self.src, self.tuner, self.interpolator, self.receiver,
                     self.converter, self.output)

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

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

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

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

        self.Add(self._agc_check_box)

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

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

        self.Add(_rfgain_sizer)

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

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

        self.Add(self.scope.win)
        self.scope.set_callback(fftsink2_callback)

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

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

        self.scope2 = fftsink2.fft_sink_c(
            self.GetWin(),
            title="Channel Spectrum (click to fine tune)",
            fft_size=1024,
            sample_rate=gsm_symb_rate * 4,
            ref_scale=2.0,
            ref_level=-20,
            y_divs=10,
            fft_rate=10,
            average=False,
            avg_alpha=0.3)

        self.Add(self.scope2.win)
        self.scope2.set_callback(fftsink2_callback2)

        self.connect(self.interpolator, self.scope2)
Beispiel #11
0
    def __init__(self):
        #grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        gr.top_block.__init__(self)

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

        self.osr = 4
        self.key = 'AD 6A 3E C2 B4 42 E4 00'
        self.configuration = ch
        self.ch0 = ch_0
        self.ch1 = ch_1

        self.clock_rate = 52e6
        self.input_rate = self.clock_rate / 72  #TODO: what about usrp value?
        self.gsm_symb_rate = 1625000.0 / 6.0
        self.sps = self.input_rate / self.gsm_symb_rate / self.osr

        # configure channel filter
        filter_cutoff = 145e3  #135,417Hz is GSM bandwidth
        filter_t_width = 10e3
        offset = 0.0

        ##################################################
        # Blocks
        ##################################################
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex * 1)

        print "Input files: ", file_0, " ", file_1
        self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex * 1,
                                               file_0, False)

        self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex * 1,
                                               file_1, False)

        filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff,
                                         filter_t_width, gr.firdes.WIN_HAMMING)

        self.filter_0 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset,
                                                       self.input_rate)
        self.filter_1 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset,
                                                       self.input_rate)

        self.interpolator_0 = gr.fractional_interpolator_cc(0, self.sps)
        self.interpolator_1 = gr.fractional_interpolator_cc(0, self.sps)

        self.tuner_callback = tuner(self)
        self.synchronizer_callback = synchronizer(self)

        #print ">>>>>Input rate: ", self.input_rate

        self.receiver = gsm.receiver_cf(self.tuner_callback,
                                        self.synchronizer_callback, self.osr,
                                        self.key.replace(' ', '').lower(),
                                        self.configuration.upper(), self.ch0,
                                        self.ch1, "127.0.0.1", 8080)

        #		self.receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.osr, self.key.replace(' ', '').lower(), self.configuration.upper(), self.ch0, self.ch1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_file_source_1, 0), (self.filter_1, 0),
                     (self.interpolator_1, 0), (self.receiver, 1))

        #		self.connect((self.gr_file_source_1, 0), (self.filter_1, 0), (self.interpolator_1, 0), (self.receiver, 1))

        self.connect((self.gr_file_source_0, 0), (self.filter_0, 0),
                     (self.interpolator_0, 0), (self.receiver, 0))
  def __init__(self):
    gr.top_block.__init__(self)
    # grc_wxgui.top_block_gui.__init__(self, title="Top Block")

    options = get_options()

    self.tune_corrector_callback = tune_corrector(self)
    self.synchronizer_callback = synchronizer(self)
    self.converter = blocks.vector_to_stream(gr.sizeof_float, 142)

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

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

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

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

    gsm_symb_rate = 1625000.0 / 6.0
    sps = sample_rate / gsm_symb_rate / 4
    out_sample_rate = gsm_symb_rate * 4

    self.offset = 0

    taps = filter.firdes.low_pass(1.0, sample_rate, 145e3, 10e3, filter.firdes.WIN_HANN)
    self.tuner = filter.freq_xlating_fir_filter_ccf(1, taps, self.offset, sample_rate)

    self.interpolator = filter.fractional_resampler_cc(0, sps)

    self.receiver = gsm.receiver_cf(
        self.tune_corrector_callback, self.synchronizer_callback, 4,
        options.key.replace(' ', '').lower(),
        options.configuration.upper())

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

    self.connect(self.src, self.tuner, self.interpolator, self.receiver, self.converter, self.output)

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

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

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

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

    def fftsink2_callback2(x, y):
        self.offset = self.offset - (x / 10)
        sys.stderr.write("fine tuned to: %d Hz\n" % self.offset)
        self.tuner.set_center_freq(self.offset)
Beispiel #13
0
    def __init__(self):
        #grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        gr.top_block.__init__(self)
        print "abc"
        ##################################################
        # Variables
        ##################################################
        #self.samp_rate = samp_rate = 32000
        self.osr = 4
        self.key = ''
        self.configuration = ''

        self.clock_rate = 52e6
        self.input_rate = self.clock_rate / 72  #TODO: what about usrp value?
        self.gsm_symb_rate = 1625000.0 / 6.0
        self.sps = self.input_rate / self.gsm_symb_rate

        # configure channel filter
        filter_cutoff = 135e3  #135,417Hz is GSM bandwidth
        filter_t_width = 10e3
        offset = 0.0

        ##################################################
        # Blocks
        ##################################################
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex * 1)

        print "Input files: ", downfile, " ", upfile
        self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex * 1,
                                               downfile, False)
        self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex * 1,
                                               upfile, False)

        filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff,
                                         filter_t_width, gr.firdes.WIN_HAMMING)

        print len(filter_taps)

        self.filter0 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset,
                                                      self.input_rate)
        self.filter1 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset,
                                                      self.input_rate)

        self.interpolator_1 = gr.fractional_interpolator_cc(0, self.sps)

        self.tuner_callback = tuner(self)
        self.synchronizer_callback = synchronizer(self)

        #self.buffer =  howto.buffer_cc()

        self.burst_cb = burst_callback(self)

        print ">>>>>Input rate: ", self.input_rate
        #self.burst = gsm.burst_cf(self.burst_cb,self.input_rate)
        self.receiver = gsm.receiver_cf(self.tuner_callback,
                                        self.synchronizer_callback, self.osr,
                                        self.key.replace(' ', '').lower(),
                                        self.configuration.upper())
        ##################################################
        # Connections
        ##################################################
        #self.connect((self.gr_file_source_0, 0), (self.filter0, 0), (self.burst, 0))

        self.connect((self.gr_file_source_1, 0), (self.filter1, 0),
                     (self.interpolator_1, 0), (self.receiver, 0))
Beispiel #14
0
	def __init__(self):
		#grc_wxgui.top_block_gui.__init__(self, title="Top Block")
		gr.top_block.__init__(self)
		
		##################################################
		# Variables
		##################################################
		#self.samp_rate = samp_rate = 32000

		self.osr = 4
		self.key = 'AD 6A 3E C2 B4 42 E4 00'
		self.configuration = ch
		self.ch0 = ch_0
		self.ch1 = ch_1

		self.clock_rate = 52e6
		self.input_rate = self.clock_rate / 72		#TODO: what about usrp value?
		self.gsm_symb_rate = 1625000.0 / 6.0
        	self.sps = self.input_rate / self.gsm_symb_rate / self.osr

		# configure channel filter
		filter_cutoff	= 145e3		#135,417Hz is GSM bandwidth 
		filter_t_width	= 10e3
		offset = 0.0

		##################################################
		# Blocks
		##################################################
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1)

		print "Input files: ", file_0, " ", file_1
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, file_0, False)
					
		self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex*1, file_1, False)

		filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING)

		self.filter_0 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate)
		self.filter_1 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate)

		self.interpolator_0 = gr.fractional_interpolator_cc(0, self.sps) 
		self.interpolator_1 = gr.fractional_interpolator_cc(0, self.sps) 

		self.tuner_callback = tuner(self)
		self.synchronizer_callback = synchronizer(self)

		#print ">>>>>Input rate: ", self.input_rate		

		
		

		self.receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.osr, self.key.replace(' ', '').lower(), self.configuration.upper(), self.ch0, self.ch1, "127.0.0.1", 8080)

#		self.receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.osr, self.key.replace(' ', '').lower(), self.configuration.upper(), self.ch0, self.ch1)


		##################################################
		# Connections
		##################################################
		self.connect((self.gr_file_source_1, 0), (self.filter_1, 0), (self.interpolator_1, 0), (self.receiver, 1))

#		self.connect((self.gr_file_source_1, 0), (self.filter_1, 0), (self.interpolator_1, 0), (self.receiver, 1))

		self.connect((self.gr_file_source_0, 0), (self.filter_0, 0), (self.interpolator_0, 0), (self.receiver, 0))