Piotr Krysik | ea34c01 | 2016-10-02 18:53:43 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 2 | # -*- coding: utf-8 -*- |
Piotr Krysik | ea34c01 | 2016-10-02 18:53:43 +0200 | [diff] [blame] | 3 | # @file |
Piotr Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 4 | # @author (C) 2014 by Piotr Krysik <ptrkrysik@gmail.com> |
Piotr Krysik | ea34c01 | 2016-10-02 18:53:43 +0200 | [diff] [blame] | 5 | # @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 | # |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 22 | ################################################## |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 23 | # GNU Radio Python Flow Graph |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 24 | # 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 Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 27 | # Generated: Sun Jul 17 17:36:46 2016 |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 28 | ################################################## |
| 29 | |
| 30 | from gnuradio import filter |
| 31 | from gnuradio import gr |
| 32 | from gnuradio.filter import firdes |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 33 | import grgsm |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 34 | |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 35 | |
Piotr Krysik | 8715da0 | 2016-01-06 22:21:09 +0100 | [diff] [blame] | 36 | class gsm_input(grgsm.hier_block): |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 37 | |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 38 | def __init__(self, fc=940e6, osr=4, ppm=0, samp_rate_in=1e6): |
| 39 | gr.hier_block2.__init__( |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 40 | 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 Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 44 | self.message_port_register_hier_in("ctrl_in") |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 45 | |
| 46 | ################################################## |
| 47 | # Parameters |
| 48 | ################################################## |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 49 | self.fc = fc |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 50 | self.osr = osr |
| 51 | self.ppm = ppm |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 52 | self.samp_rate_in = samp_rate_in |
| 53 | |
| 54 | ################################################## |
ptrkrysik | 381253a | 2014-11-19 11:30:53 +0100 | [diff] [blame] | 55 | # Variables |
| 56 | ################################################## |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 57 | self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0 |
| 58 | self.samp_rate_out = samp_rate_out = gsm_symb_rate*osr |
ptrkrysik | 381253a | 2014-11-19 11:30:53 +0100 | [diff] [blame] | 59 | |
| 60 | ################################################## |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 61 | # Blocks |
| 62 | ################################################## |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 63 | self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( |
ptrkrysik | 381253a | 2014-11-19 11:30:53 +0100 | [diff] [blame] | 64 | 1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) |
Piotr Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 65 | self.gsm_clock_offset_corrector_tagged_0 = grgsm.clock_offset_corrector_tagged( |
Piotr Krysik | 18f7690 | 2015-05-29 07:04:08 +0200 | [diff] [blame] | 66 | fc=fc, |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 67 | samp_rate_in=samp_rate_in, |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 68 | ppm=ppm, |
| 69 | osr=osr, |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 70 | ) |
| 71 | |
| 72 | ################################################## |
| 73 | # Connections |
| 74 | ################################################## |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 75 | 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)) |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 79 | |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 80 | def get_fc(self): |
| 81 | return self.fc |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 82 | |
Piotr Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 83 | def set_fc(self, fc): |
| 84 | self.fc = fc |
| 85 | self.gsm_clock_offset_corrector_tagged_0.set_fc(self.fc) |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 86 | |
| 87 | def get_osr(self): |
| 88 | return self.osr |
| 89 | |
| 90 | def set_osr(self, osr): |
| 91 | self.osr = osr |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 92 | self.set_samp_rate_out(self.gsm_symb_rate*self.osr) |
| 93 | self.gsm_clock_offset_corrector_tagged_0.set_osr(self.osr) |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 94 | |
Piotr Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 95 | def get_ppm(self): |
| 96 | return self.ppm |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 97 | |
Piotr Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 98 | def set_ppm(self, ppm): |
| 99 | self.ppm = ppm |
| 100 | self.gsm_clock_offset_corrector_tagged_0.set_ppm(self.ppm) |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 101 | |
| 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 Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 107 | self.gsm_clock_offset_corrector_tagged_0.set_samp_rate_in(self.samp_rate_in) |
Piotr Krysik | 83afe73 | 2016-07-17 22:48:35 +0200 | [diff] [blame] | 108 | |
| 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) |
ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame] | 115 | |
ptrkrysik | 381253a | 2014-11-19 11:30:53 +0100 | [diff] [blame] | 116 | 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 Krysik | cbaf476 | 2016-07-15 13:14:37 +0200 | [diff] [blame] | 121 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) |