ptrkrysik | dac3b2a | 2014-11-06 14:47:33 +0100 | [diff] [blame^] | 1 | #!/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. |
| 7 | # Generated: Thu Nov 6 14:41:06 2014 |
| 8 | ################################################## |
| 9 | |
| 10 | from gnuradio import filter |
| 11 | from gnuradio import gr |
| 12 | from gnuradio.filter import firdes |
| 13 | import gsm |
| 14 | |
| 15 | class gsm_input(gr.hier_block2): |
| 16 | |
| 17 | def __init__(self, ppm=0, osr=4, fc=940e6, samp_rate_in=1e6): |
| 18 | gr.hier_block2.__init__( |
| 19 | self, "GSM input adaptor", |
| 20 | gr.io_signature(1, 1, gr.sizeof_gr_complex*1), |
| 21 | gr.io_signature(1, 1, gr.sizeof_gr_complex*1), |
| 22 | ) |
| 23 | |
| 24 | ################################################## |
| 25 | # Parameters |
| 26 | ################################################## |
| 27 | self.ppm = ppm |
| 28 | self.osr = osr |
| 29 | self.fc = fc |
| 30 | self.samp_rate_in = samp_rate_in |
| 31 | |
| 32 | ################################################## |
| 33 | # Blocks |
| 34 | ################################################## |
| 35 | self.ppm_in = None;self.message_port_register_hier_out("ppm_in") |
| 36 | self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( |
| 37 | 1, 1625000.0/6.0*osr, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) |
| 38 | self.gsm_clock_offset_corrector_0 = gsm.clock_offset_corrector( |
| 39 | fc=fc, |
| 40 | ppm=0, |
| 41 | samp_rate_in=samp_rate_in, |
| 42 | samp_rate_out=1625000.0/6.0*4.0, |
| 43 | ) |
| 44 | |
| 45 | ################################################## |
| 46 | # Connections |
| 47 | ################################################## |
| 48 | self.connect((self.low_pass_filter_0_0, 0), (self, 0)) |
| 49 | self.connect((self.gsm_clock_offset_corrector_0, 0), (self.low_pass_filter_0_0, 0)) |
| 50 | self.connect((self, 0), (self.gsm_clock_offset_corrector_0, 0)) |
| 51 | |
| 52 | ################################################## |
| 53 | # Asynch Message Connections |
| 54 | ################################################## |
| 55 | self.msg_connect(self, "ppm_in", self.gsm_clock_offset_corrector_0, "ppm_in") |
| 56 | |
| 57 | |
| 58 | def get_ppm(self): |
| 59 | return self.ppm |
| 60 | |
| 61 | def set_ppm(self, ppm): |
| 62 | self.ppm = ppm |
| 63 | |
| 64 | def get_osr(self): |
| 65 | return self.osr |
| 66 | |
| 67 | def set_osr(self, osr): |
| 68 | self.osr = osr |
| 69 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, 1625000.0/6.0*self.osr, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) |
| 70 | |
| 71 | def get_fc(self): |
| 72 | return self.fc |
| 73 | |
| 74 | def set_fc(self, fc): |
| 75 | self.fc = fc |
| 76 | self.gsm_clock_offset_corrector_0.set_fc(self.fc) |
| 77 | |
| 78 | def get_samp_rate_in(self): |
| 79 | return self.samp_rate_in |
| 80 | |
| 81 | def set_samp_rate_in(self, samp_rate_in): |
| 82 | self.samp_rate_in = samp_rate_in |
| 83 | self.gsm_clock_offset_corrector_0.set_samp_rate_in(self.samp_rate_in) |
| 84 | |