Пример #1
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))
Пример #2
0
    def __init__(self, channels, resamp_rate, fc, band, samp_rate, input_file, dest_dir, data_type="complex"):
        gr.top_block.__init__(self, "grgsm_channelize")

        ##################################################
        # Parameters
        ##################################################
        self.channels = channels
        self.resamp_rate = resamp_rate
        self.fc = fc
        self.band = band
        self.samp_rate = samp_rate
        self.blocks_resamplers = {}
        self.blocks_rotators = {}
        self.blocks_file_sinks = {}
        
        ##################################################
        # Blocks and connections
        ##################################################
        self.source = None
        if data_type == "ishort":
            self.blocks_file_source = blocks.file_source(gr.sizeof_short, input_file, False)
            self.source = blocks.interleaved_short_to_complex(False, False)
            self.connect((self.blocks_file_source, 0), (self.source, 0))
        elif data_type == "complex":
            self.source = blocks.file_source(gr.sizeof_gr_complex, input_file, False)

        fc_str = eng_notation.num_to_str(fc)
        print("Extracting channels %s, given center frequency at %sHz (ARFCN %d)" % (str(ca), fc_str, center_arfcn))

        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
            freq_diff_str = "+" if 0 <= freq_diff else ""
            freq_diff_str += eng_notation.num_to_str(freq_diff)
            print("ARFCN %d is at %sHz %sHz" % (channel, fc_str, freq_diff_str))

            self.blocks_resamplers[channel] = pfb.arb_resampler_ccf( resamp_rate, taps=None, flt_size=32)
            self.blocks_rotators[channel] = blocks.rotator_cc(-2*math.pi*(freq_diff)/samp_rate)
            self.connect( (self.source, 0), (self.blocks_rotators[channel], 0) )
            self.connect( (self.blocks_rotators[channel], 0), (self.blocks_resamplers[channel], 0) )

            self.blocks_file_sinks[channel] = blocks.file_sink(gr.sizeof_gr_complex, dest_dir+"/out_" + str(channel) + ".cfile", False)
            self.blocks_file_sinks[channel].set_unbuffered(False)
            self.connect((self.blocks_resamplers[channel], 0), (self.blocks_file_sinks[channel], 0))
Пример #3
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))
Пример #4
0
    def __init__(self,
                 ppm=0,
                 osr=4,
                 fc=925.2e6,
                 samp_rate_in=20e6,
                 ca=[],
                 band='P-GSM'):
        self.num_streams = len(ca)
        grgsm.hier_block.__init__(
            self,
            "GSM wideband input adaptor",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(self.num_streams, self.num_streams,
                            gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ppm = ppm
        self.osr = osr
        self.fc = fc
        self.samp_rate_in = samp_rate_in
        self.ca = ca
        self.blocks_fir_filters = {}
        self.blocks_resamplers = {}
        self.blocks_ocs = {}
        self.band = band

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_out = samp_rate_out = 1625000.0 / 6.0 * osr

        ##################################################
        # Blocks
        ##################################################
        self.ppm_in = None
        self.message_port_register_hier_in("ppm_in")
        #self.lpf = firdes.low_pass(1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)
        self.lpf = firdes.low_pass(1, samp_rate_in, 125e3, 75e3,
                                   firdes.WIN_HAMMING, 6.76)
        self.gsm_clock_offset_corrector_0 = grgsm.clock_offset_corrector(
            fc=fc,
            ppm=ppm,
            samp_rate_in=samp_rate_in,
        )

        center_arfcn = arfcn.downlink2arfcn(fc, band)
        fc_str = eng_notation.num_to_str(fc)
        print(
            "Extracting channels %s, given center frequency at %sHz (ARFCN %d)"
            % (str(ca), fc_str, center_arfcn))

        self.connect((self, 0), (self.gsm_clock_offset_corrector_0, 0))

        output_port = 0
        for channel in ca:
            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
            freq_diff_str = "+" if 0 <= freq_diff else ""
            freq_diff_str += eng_notation.num_to_str(freq_diff)
            print("ARFCN %d is at %sHz %sHz" %
                  (channel, fc_str, freq_diff_str))

            self.blocks_resamplers[channel] = filter.fractional_resampler_cc(
                0, samp_rate_in / samp_rate_out)
            self.blocks_fir_filters[
                channel] = filter.freq_xlating_fir_filter_ccc(
                    1, self.lpf, freq_diff, samp_rate_in)
            self.connect((self.gsm_clock_offset_corrector_0, 0),
                         (self.blocks_fir_filters[channel], 0))
            self.connect((self.blocks_fir_filters[channel], 0),
                         (self.blocks_resamplers[channel], 0))
            self.connect((self.blocks_resamplers[channel], 0),
                         (self, output_port))
            output_port += 1

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self, "ppm_in", self.gsm_clock_offset_corrector_0,
                         "ppm_in")
Пример #5
0
    def __init__(self,
                 channels,
                 resamp_rate,
                 fc,
                 band,
                 samp_rate,
                 input_file,
                 dest_dir,
                 data_type="complex"):
        gr.top_block.__init__(self, "grgsm_channelize")

        ##################################################
        # Parameters
        ##################################################
        self.channels = channels
        self.resamp_rate = resamp_rate
        self.fc = fc
        self.band = band
        self.samp_rate = samp_rate
        self.blocks_resamplers = {}
        self.blocks_rotators = {}
        self.blocks_file_sinks = {}

        ##################################################
        # Blocks and connections
        ##################################################
        self.source = None
        if data_type == "ishort":
            self.blocks_file_source = blocks.file_source(
                gr.sizeof_short, input_file, False)
            self.source = blocks.interleaved_short_to_complex(False, False)
            self.connect((self.blocks_file_source, 0), (self.source, 0))
        elif data_type == "complex":
            self.source = blocks.file_source(gr.sizeof_gr_complex, input_file,
                                             False)

        fc_str = eng_notation.num_to_str(fc)
        print(
            "Extracting channels %s, given that the center frequency is at %s"
            % (str(channels), 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
            freq_diff_str = "+" if 0 <= freq_diff else ""
            freq_diff_str += eng_notation.num_to_str(freq_diff)
            print("ARFCN %d is at %sHz %sHz" %
                  (channel, fc_str, freq_diff_str))

            self.blocks_resamplers[channel] = pfb.arb_resampler_ccf(
                resamp_rate, taps=None, flt_size=32)
            self.blocks_rotators[channel] = blocks.rotator_cc(
                -2 * math.pi * (freq_diff) / samp_rate)
            self.connect((self.source, 0), (self.blocks_rotators[channel], 0))
            self.connect((self.blocks_rotators[channel], 0),
                         (self.blocks_resamplers[channel], 0))

            self.blocks_file_sinks[channel] = blocks.file_sink(
                gr.sizeof_gr_complex,
                dest_dir + "/out_" + str(channel) + ".cfile", False)
            self.blocks_file_sinks[channel].set_unbuffered(False)
            self.connect((self.blocks_resamplers[channel], 0),
                         (self.blocks_file_sinks[channel], 0))
Пример #6
0
    def __init__(self, ppm=0, osr=4, fc=925.2e6, samp_rate_in=20e6, ca=[]):
        self.num_streams = len(ca)
        gr.hier_block2.__init__(
            self, "GSM wideband input adaptor",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(self.num_streams, self.num_streams, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ppm = ppm
        self.osr = osr
        self.fc = fc
        self.samp_rate_in = samp_rate_in
        self.ca = ca
        self.blocks_fir_filters = {}
        self.blocks_resamplers = {}
        self.blocks_ocs = {}
        self.band = band = 'E-GSM'  # TODO make selectable

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_out = samp_rate_out = 1625000.0/6.0*osr

        ##################################################
        # Blocks
        ##################################################
        self.ppm_in = None
        self.message_port_register_hier_out("ppm_in")
        #self.lpf = firdes.low_pass(1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)
        self.lpf = firdes.low_pass(1, samp_rate_in, 125e3, 75e3, firdes.WIN_HAMMING, 6.76)
        self.gsm_clock_offset_corrector_0 = grgsm.clock_offset_corrector(
            fc=fc,
            ppm=ppm,
            samp_rate_in=samp_rate_in,
        )

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

        self.connect((self, 0), (self.gsm_clock_offset_corrector_0, 0))

        output_port = 0
        for channel in ca:
            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_resamplers[channel] = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
            self.blocks_fir_filters[channel] = filter.freq_xlating_fir_filter_ccc(1, self.lpf, freq_diff, samp_rate_in)
            self.connect((self.gsm_clock_offset_corrector_0, 0), (self.blocks_fir_filters[channel], 0))
            self.connect((self.blocks_fir_filters[channel], 0), (self.blocks_resamplers[channel], 0))
            self.connect((self.blocks_resamplers[channel], 0), (self, output_port))
            output_port += 1

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self, "ppm_in", self.gsm_clock_offset_corrector_0, "ppm_in")