2014-11-06 13:47:33 +00:00
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: GSM input adaptor
# Author: Piotr Krysik
# 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.
2014-11-19 10:30:53 +00:00
# Generated: Wed Nov 19 08:23:52 2014
2014-11-06 13:47:33 +00:00
##################################################
from gnuradio import filter
from gnuradio import gr
from gnuradio . filter import firdes
2014-12-13 09:11:00 +00:00
import grgsm
2014-11-06 13:47:33 +00:00
class gsm_input ( gr . hier_block2 ) :
def __init__ ( self , ppm = 0 , osr = 4 , fc = 940e6 , samp_rate_in = 1e6 ) :
gr . hier_block2 . __init__ (
self , " GSM input adaptor " ,
gr . io_signature ( 1 , 1 , gr . sizeof_gr_complex * 1 ) ,
gr . io_signature ( 1 , 1 , gr . sizeof_gr_complex * 1 ) ,
)
##################################################
# Parameters
##################################################
self . ppm = ppm
self . osr = osr
self . fc = fc
self . samp_rate_in = samp_rate_in
2014-11-19 10:30:53 +00:00
##################################################
# Variables
##################################################
self . samp_rate_out = samp_rate_out = 1625000.0 / 6.0 * osr
2014-11-06 13:47:33 +00:00
##################################################
# Blocks
##################################################
self . ppm_in = None ; self . message_port_register_hier_out ( " ppm_in " )
self . low_pass_filter_0_0 = filter . fir_filter_ccf ( 1 , firdes . low_pass (
2014-11-19 10:30:53 +00:00
1 , samp_rate_out , 125e3 , 5e3 , firdes . WIN_HAMMING , 6.76 ) )
2014-12-13 09:11:00 +00:00
self . gsm_clock_offset_corrector_0 = grgsm . clock_offset_corrector (
2014-11-19 10:30:53 +00:00
fc = 936.6e6 ,
2014-11-06 13:47:33 +00:00
ppm = 0 ,
samp_rate_in = samp_rate_in ,
)
2014-11-19 10:30:53 +00:00
self . fractional_resampler_xx_0 = filter . fractional_resampler_cc ( 0 , samp_rate_in / samp_rate_out )
2014-11-06 13:47:33 +00:00
##################################################
# Connections
##################################################
self . connect ( ( self . low_pass_filter_0_0 , 0 ) , ( self , 0 ) )
2014-11-19 10:30:53 +00:00
self . connect ( ( self . fractional_resampler_xx_0 , 0 ) , ( self . low_pass_filter_0_0 , 0 ) )
self . connect ( ( self . gsm_clock_offset_corrector_0 , 0 ) , ( self . fractional_resampler_xx_0 , 0 ) )
2014-11-06 13:47:33 +00:00
self . connect ( ( self , 0 ) , ( self . gsm_clock_offset_corrector_0 , 0 ) )
##################################################
# Asynch Message Connections
##################################################
self . msg_connect ( self , " ppm_in " , self . gsm_clock_offset_corrector_0 , " ppm_in " )
def get_ppm ( self ) :
return self . ppm
def set_ppm ( self , ppm ) :
self . ppm = ppm
2014-11-19 10:30:53 +00:00
self . gsm_clock_offset_corrector_0 . set_ppm ( self . ppm )
2014-11-06 13:47:33 +00:00
def get_osr ( self ) :
return self . osr
def set_osr ( self , osr ) :
self . osr = osr
2014-11-19 10:30:53 +00:00
self . set_samp_rate_out ( 1625000.0 / 6.0 * self . osr )
2014-11-06 13:47:33 +00:00
def get_fc ( self ) :
return self . fc
def set_fc ( self , fc ) :
self . fc = fc
self . gsm_clock_offset_corrector_0 . set_fc ( self . fc )
def get_samp_rate_in ( self ) :
return self . samp_rate_in
def set_samp_rate_in ( self , samp_rate_in ) :
self . samp_rate_in = samp_rate_in
2014-11-19 10:30:53 +00:00
self . fractional_resampler_xx_0 . set_resamp_ratio ( self . samp_rate_in / self . samp_rate_out )
2014-11-06 13:47:33 +00:00
self . gsm_clock_offset_corrector_0 . set_samp_rate_in ( self . samp_rate_in )
2014-11-19 10:30:53 +00:00
def get_samp_rate_out ( self ) :
return self . samp_rate_out
def set_samp_rate_out ( self , samp_rate_out ) :
self . samp_rate_out = samp_rate_out
self . low_pass_filter_0_0 . set_taps ( firdes . low_pass ( 1 , self . samp_rate_out , 125e3 , 5e3 , firdes . WIN_HAMMING , 6.76 ) )
self . fractional_resampler_xx_0 . set_resamp_ratio ( self . samp_rate_in / self . samp_rate_out )