blob: 8c4ad5194e24a84bad5473a564e6603660e2b9e5 [file] [log] [blame]
Piotr Krysikea34c012016-10-02 18:53:43 +02001#!/usr/bin/env python2
Piotr Krysik83afe732016-07-17 22:48:35 +02002# -*- coding: utf-8 -*-
Piotr Krysikea34c012016-10-02 18:53:43 +02003# @file
Piotr Krysika6268a52017-08-23 16:02:19 +02004# @author (C) 2014 by Piotr Krysik <ptrkrysik@gmail.com>
Piotr Krysikea34c012016-10-02 18:53:43 +02005# @section LICENSE
6#
7# Gr-gsm is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3, or (at your option)
10# any later version.
11#
12# Gr-gsm is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with gr-gsm; see the file COPYING. If not, write to
19# the Free Software Foundation, Inc., 51 Franklin Street,
20# Boston, MA 02110-1301, USA.
21#
ptrkrysikdac3b2a2014-11-06 14:47:33 +010022##################################################
Piotr Krysik83afe732016-07-17 22:48:35 +020023# GNU Radio Python Flow Graph
ptrkrysikdac3b2a2014-11-06 14:47:33 +010024# Title: GSM input adaptor
25# Author: Piotr Krysik
26# 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.
Piotr Krysik83afe732016-07-17 22:48:35 +020027# Generated: Sun Jul 17 17:36:46 2016
ptrkrysikdac3b2a2014-11-06 14:47:33 +010028##################################################
29
30from gnuradio import filter
31from gnuradio import gr
32from gnuradio.filter import firdes
ptrkrysik3be74a72014-12-13 10:11:00 +010033import grgsm
ptrkrysikdac3b2a2014-11-06 14:47:33 +010034
Piotr Krysik83afe732016-07-17 22:48:35 +020035
Piotr Krysik8715da02016-01-06 22:21:09 +010036class gsm_input(grgsm.hier_block):
ptrkrysikdac3b2a2014-11-06 14:47:33 +010037
Piotr Krysik83afe732016-07-17 22:48:35 +020038 def __init__(self, fc=940e6, osr=4, ppm=0, samp_rate_in=1e6):
39 gr.hier_block2.__init__(
ptrkrysikdac3b2a2014-11-06 14:47:33 +010040 self, "GSM input adaptor",
41 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
42 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
43 )
Piotr Krysik83afe732016-07-17 22:48:35 +020044 self.message_port_register_hier_in("ctrl_in")
ptrkrysikdac3b2a2014-11-06 14:47:33 +010045
46 ##################################################
47 # Parameters
48 ##################################################
ptrkrysikdac3b2a2014-11-06 14:47:33 +010049 self.fc = fc
Piotr Krysik83afe732016-07-17 22:48:35 +020050 self.osr = osr
51 self.ppm = ppm
ptrkrysikdac3b2a2014-11-06 14:47:33 +010052 self.samp_rate_in = samp_rate_in
53
54 ##################################################
ptrkrysik381253a2014-11-19 11:30:53 +010055 # Variables
56 ##################################################
Piotr Krysik83afe732016-07-17 22:48:35 +020057 self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0
58 self.samp_rate_out = samp_rate_out = gsm_symb_rate*osr
ptrkrysik381253a2014-11-19 11:30:53 +010059
60 ##################################################
ptrkrysikdac3b2a2014-11-06 14:47:33 +010061 # Blocks
62 ##################################################
ptrkrysikdac3b2a2014-11-06 14:47:33 +010063 self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
ptrkrysik381253a2014-11-19 11:30:53 +010064 1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))
Piotr Krysikcbaf4762016-07-15 13:14:37 +020065 self.gsm_clock_offset_corrector_tagged_0 = grgsm.clock_offset_corrector_tagged(
Piotr Krysik18f76902015-05-29 07:04:08 +020066 fc=fc,
ptrkrysikdac3b2a2014-11-06 14:47:33 +010067 samp_rate_in=samp_rate_in,
Piotr Krysik83afe732016-07-17 22:48:35 +020068 ppm=ppm,
69 osr=osr,
ptrkrysikdac3b2a2014-11-06 14:47:33 +010070 )
71
72 ##################################################
73 # Connections
74 ##################################################
Piotr Krysik83afe732016-07-17 22:48:35 +020075 self.msg_connect((self, 'ctrl_in'), (self.gsm_clock_offset_corrector_tagged_0, 'ctrl'))
76 self.connect((self.gsm_clock_offset_corrector_tagged_0, 0), (self.low_pass_filter_0_0, 0))
77 self.connect((self.low_pass_filter_0_0, 0), (self, 0))
78 self.connect((self, 0), (self.gsm_clock_offset_corrector_tagged_0, 0))
ptrkrysikdac3b2a2014-11-06 14:47:33 +010079
Piotr Krysik83afe732016-07-17 22:48:35 +020080 def get_fc(self):
81 return self.fc
ptrkrysikdac3b2a2014-11-06 14:47:33 +010082
Piotr Krysikcbaf4762016-07-15 13:14:37 +020083 def set_fc(self, fc):
84 self.fc = fc
85 self.gsm_clock_offset_corrector_tagged_0.set_fc(self.fc)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010086
87 def get_osr(self):
88 return self.osr
89
90 def set_osr(self, osr):
91 self.osr = osr
Piotr Krysik83afe732016-07-17 22:48:35 +020092 self.set_samp_rate_out(self.gsm_symb_rate*self.osr)
93 self.gsm_clock_offset_corrector_tagged_0.set_osr(self.osr)
ptrkrysikdac3b2a2014-11-06 14:47:33 +010094
Piotr Krysikcbaf4762016-07-15 13:14:37 +020095 def get_ppm(self):
96 return self.ppm
ptrkrysikdac3b2a2014-11-06 14:47:33 +010097
Piotr Krysikcbaf4762016-07-15 13:14:37 +020098 def set_ppm(self, ppm):
99 self.ppm = ppm
100 self.gsm_clock_offset_corrector_tagged_0.set_ppm(self.ppm)
ptrkrysikdac3b2a2014-11-06 14:47:33 +0100101
102 def get_samp_rate_in(self):
103 return self.samp_rate_in
104
105 def set_samp_rate_in(self, samp_rate_in):
106 self.samp_rate_in = samp_rate_in
Piotr Krysikcbaf4762016-07-15 13:14:37 +0200107 self.gsm_clock_offset_corrector_tagged_0.set_samp_rate_in(self.samp_rate_in)
Piotr Krysik83afe732016-07-17 22:48:35 +0200108
109 def get_gsm_symb_rate(self):
110 return self.gsm_symb_rate
111
112 def set_gsm_symb_rate(self, gsm_symb_rate):
113 self.gsm_symb_rate = gsm_symb_rate
114 self.set_samp_rate_out(self.gsm_symb_rate*self.osr)
ptrkrysikdac3b2a2014-11-06 14:47:33 +0100115
ptrkrysik381253a2014-11-19 11:30:53 +0100116 def get_samp_rate_out(self):
117 return self.samp_rate_out
118
119 def set_samp_rate_out(self, samp_rate_out):
120 self.samp_rate_out = samp_rate_out
Piotr Krysikcbaf4762016-07-15 13:14:37 +0200121 self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))