blob: 97ab633a87260625d4148f1b2be676c5ee7a2a3e [file] [log] [blame]
ptrkrysikdac3b2a2014-11-06 14:47:33 +01001#!/usr/bin/env python
2##################################################
3# Gnuradio Python Flow Graph
4# Title: GSM input adaptor
5# Author: Piotr Krysik
6# Description: Adaptor of input stream for the GSM receiver. Contains frequency ofset corrector doing also resampling to integer multiplies of GSM sample rate and LP filter filtering GSM channel.
ptrkrysik381253a2014-11-19 11:30:53 +01007# Generated: Wed Nov 19 08:23:52 2014
ptrkrysikdac3b2a2014-11-06 14:47:33 +01008##################################################
9
10from gnuradio import filter
11from gnuradio import gr
12from gnuradio.filter import firdes
Piotr Krysike3b652d2016-01-02 09:14:27 +010013from distutils.version import LooseVersion as version
ptrkrysik3be74a72014-12-13 10:11:00 +010014import grgsm
ptrkrysikdac3b2a2014-11-06 14:47:33 +010015
Piotr Krysik8715da02016-01-06 22:21:09 +010016class gsm_input(grgsm.hier_block):
ptrkrysikdac3b2a2014-11-06 14:47:33 +010017
18 def __init__(self, ppm=0, osr=4, fc=940e6, samp_rate_in=1e6):
Piotr Krysik8715da02016-01-06 22:21:09 +010019 grgsm.hier_block.__init__(
ptrkrysikdac3b2a2014-11-06 14:47:33 +010020 self, "GSM input adaptor",
21 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
22 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
23 )
24
25 ##################################################
26 # Parameters
27 ##################################################
28 self.ppm = ppm
29 self.osr = osr
30 self.fc = fc
31 self.samp_rate_in = samp_rate_in
32
33 ##################################################
ptrkrysik381253a2014-11-19 11:30:53 +010034 # Variables
35 ##################################################
36 self.samp_rate_out = samp_rate_out = 1625000.0/6.0*osr
37
38 ##################################################
ptrkrysikdac3b2a2014-11-06 14:47:33 +010039 # Blocks
40 ##################################################
Piotr Krysike403d9b2016-01-09 22:27:28 +010041 self.message_port_register_hier_in("ppm_in")
Piotr Krysik3a527f82016-01-01 16:01:26 +010042
ptrkrysikdac3b2a2014-11-06 14:47:33 +010043 self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
ptrkrysik381253a2014-11-19 11:30:53 +010044 1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))
ptrkrysik3be74a72014-12-13 10:11:00 +010045 self.gsm_clock_offset_corrector_0 = grgsm.clock_offset_corrector(
Piotr Krysik18f76902015-05-29 07:04:08 +020046 fc=fc,
47 ppm=ppm,
ptrkrysikdac3b2a2014-11-06 14:47:33 +010048 samp_rate_in=samp_rate_in,
ptrkrysikdac3b2a2014-11-06 14:47:33 +010049 )
ptrkrysik381253a2014-11-19 11:30:53 +010050 self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010051
52 ##################################################
53 # Connections
54 ##################################################
55 self.connect((self.low_pass_filter_0_0, 0), (self, 0))
ptrkrysik381253a2014-11-19 11:30:53 +010056 self.connect((self.fractional_resampler_xx_0, 0), (self.low_pass_filter_0_0, 0))
57 self.connect((self.gsm_clock_offset_corrector_0, 0), (self.fractional_resampler_xx_0, 0))
ptrkrysikdac3b2a2014-11-06 14:47:33 +010058 self.connect((self, 0), (self.gsm_clock_offset_corrector_0, 0))
59
60 ##################################################
61 # Asynch Message Connections
62 ##################################################
63 self.msg_connect(self, "ppm_in", self.gsm_clock_offset_corrector_0, "ppm_in")
64
65
66 def get_ppm(self):
67 return self.ppm
68
69 def set_ppm(self, ppm):
70 self.ppm = ppm
ptrkrysik381253a2014-11-19 11:30:53 +010071 self.gsm_clock_offset_corrector_0.set_ppm(self.ppm)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010072
73 def get_osr(self):
74 return self.osr
75
76 def set_osr(self, osr):
77 self.osr = osr
ptrkrysik381253a2014-11-19 11:30:53 +010078 self.set_samp_rate_out(1625000.0/6.0*self.osr)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010079
80 def get_fc(self):
81 return self.fc
82
83 def set_fc(self, fc):
84 self.fc = fc
85 self.gsm_clock_offset_corrector_0.set_fc(self.fc)
86
87 def get_samp_rate_in(self):
88 return self.samp_rate_in
89
90 def set_samp_rate_in(self, samp_rate_in):
91 self.samp_rate_in = samp_rate_in
ptrkrysik381253a2014-11-19 11:30:53 +010092 self.fractional_resampler_xx_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010093 self.gsm_clock_offset_corrector_0.set_samp_rate_in(self.samp_rate_in)
94
ptrkrysik381253a2014-11-19 11:30:53 +010095 def get_samp_rate_out(self):
96 return self.samp_rate_out
97
98 def set_samp_rate_out(self, samp_rate_out):
99 self.samp_rate_out = samp_rate_out
100 self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))
101 self.fractional_resampler_xx_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
102