blob: 231f2bccea3305379ee202e7146dc12c047284b2 [file] [log] [blame]
piotr6fbc7322014-08-06 14:18:02 +02001#!/usr/bin/env python
2##################################################
3# Gnuradio Python Flow Graph
4# Title: Gsm Receiver Test
5# Generated: Wed Aug 6 13:56:15 2014
6##################################################
7
8execfile("/home/piotr/.grc_gnuradio/clk_offset_corrector.py")
9from gnuradio import blocks
10from gnuradio import eng_notation
11from gnuradio import gr
12from gnuradio.eng_option import eng_option
13from gnuradio.filter import firdes
14from grc_gnuradio import wxgui as grc_wxgui
15from optparse import OptionParser
16import gsm
17import wx
18
19class gsm_receiver_test(grc_wxgui.top_block_gui):
20
21 def __init__(self, input_file_name="input.cfile"):
22 grc_wxgui.top_block_gui.__init__(self, title="Gsm Receiver Test")
23 _icon_path = "/home/piotr/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
24 self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
25
26 ##################################################
27 # Parameters
28 ##################################################
29 self.input_file_name = input_file_name
30
31 ##################################################
32 # Variables
33 ##################################################
34 self.samp_rate = samp_rate = 1625000/6*4
35
36 ##################################################
37 # Blocks
38 ##################################################
39 self.gsm_receiver_hier_0 = gsm.receiver_hier(samp_rate, 4)
40 self.gsm_message_printer_0 = gsm.message_printer()
41 self.gsm_get_bcch_or_ccch_bursts_0 = gsm.get_bcch_or_ccch_bursts(2)
42 self.gsm_control_channels_decoder_0 = gsm.control_channels_decoder()
43 self.gsm_clock_offset_control_0 = gsm.clock_offset_control(940e6, samp_rate)
44 self.clk_offset_corrector_0 = clk_offset_corrector(
45 ppm=0,
46 samp_rate=samp_rate,
47 fc=936.6e6,
48 )
49 self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, input_file_name, False)
50
51 ##################################################
52 # Connections
53 ##################################################
54 self.connect((self.clk_offset_corrector_0, 0), (self.gsm_receiver_hier_0, 0))
55 self.connect((self.blocks_file_source_0, 0), (self.clk_offset_corrector_0, 0))
56
57 ##################################################
58 # Asynch Message Connections
59 ##################################################
60 self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.clk_offset_corrector_0, "ppm_msg")
61 self.msg_connect(self.gsm_receiver_hier_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
62 self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_0, "msgs")
63 self.msg_connect(self.gsm_get_bcch_or_ccch_bursts_0, "bursts", self.gsm_control_channels_decoder_0, "bursts")
64 self.msg_connect(self.gsm_receiver_hier_0, "bursts", self.gsm_get_bcch_or_ccch_bursts_0, "bursts")
65
66
67 def get_input_file_name(self):
68 return self.input_file_name
69
70 def set_input_file_name(self, input_file_name):
71 self.input_file_name = input_file_name
72 self.blocks_file_source_0.open(self.input_file_name, False)
73
74 def get_samp_rate(self):
75 return self.samp_rate
76
77 def set_samp_rate(self, samp_rate):
78 self.samp_rate = samp_rate
79 self.clk_offset_corrector_0.set_samp_rate(self.samp_rate)
80
81if __name__ == '__main__':
82 import ctypes
83 import sys
84 if sys.platform.startswith('linux'):
85 try:
86 x11 = ctypes.cdll.LoadLibrary('libX11.so')
87 x11.XInitThreads()
88 except:
89 print "Warning: failed to XInitThreads()"
90 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
91 parser.add_option("-i", "--input-file-name", dest="input_file_name", type="string", default="input.cfile",
92 help="Set input.cfile [default=%default]")
93 (options, args) = parser.parse_args()
94 tb = gsm_receiver_test(input_file_name=options.input_file_name)
95 tb.Start(True)
96 tb.Wait()