blob: 09be58703f28bd47ccfbe984c8ce7efbaea0d37c [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
piotr82c774f2014-08-06 15:20:12 +02005# Generated: Wed Aug 6 15:17:29 2014
piotr6fbc7322014-08-06 14:18:02 +02006##################################################
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
piotr82c774f2014-08-06 15:20:12 +020021 def __init__(self, fc=937e6, samp_rate=1e6, input_file_name="/home/piotr/Odbiornik_gsm/gr-gsm/examples/input.cfile"):
piotr6fbc7322014-08-06 14:18:02 +020022 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 ##################################################
piotr82c774f2014-08-06 15:20:12 +020029 self.fc = fc
30 self.samp_rate = samp_rate
piotr6fbc7322014-08-06 14:18:02 +020031 self.input_file_name = input_file_name
32
33 ##################################################
piotr6fbc7322014-08-06 14:18:02 +020034 # Blocks
35 ##################################################
36 self.gsm_receiver_hier_0 = gsm.receiver_hier(samp_rate, 4)
37 self.gsm_message_printer_0 = gsm.message_printer()
38 self.gsm_get_bcch_or_ccch_bursts_0 = gsm.get_bcch_or_ccch_bursts(2)
39 self.gsm_control_channels_decoder_0 = gsm.control_channels_decoder()
piotr82c774f2014-08-06 15:20:12 +020040 self.gsm_clock_offset_control_0 = gsm.clock_offset_control(fc, samp_rate)
piotr6fbc7322014-08-06 14:18:02 +020041 self.clk_offset_corrector_0 = clk_offset_corrector(
42 ppm=0,
43 samp_rate=samp_rate,
44 fc=936.6e6,
45 )
46 self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, input_file_name, False)
47
48 ##################################################
49 # Connections
50 ##################################################
51 self.connect((self.clk_offset_corrector_0, 0), (self.gsm_receiver_hier_0, 0))
52 self.connect((self.blocks_file_source_0, 0), (self.clk_offset_corrector_0, 0))
53
54 ##################################################
55 # Asynch Message Connections
56 ##################################################
57 self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.clk_offset_corrector_0, "ppm_msg")
58 self.msg_connect(self.gsm_receiver_hier_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
59 self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_0, "msgs")
60 self.msg_connect(self.gsm_get_bcch_or_ccch_bursts_0, "bursts", self.gsm_control_channels_decoder_0, "bursts")
61 self.msg_connect(self.gsm_receiver_hier_0, "bursts", self.gsm_get_bcch_or_ccch_bursts_0, "bursts")
62
63
piotr82c774f2014-08-06 15:20:12 +020064 def get_fc(self):
65 return self.fc
piotr6fbc7322014-08-06 14:18:02 +020066
piotr82c774f2014-08-06 15:20:12 +020067 def set_fc(self, fc):
68 self.fc = fc
piotr6fbc7322014-08-06 14:18:02 +020069
70 def get_samp_rate(self):
71 return self.samp_rate
72
73 def set_samp_rate(self, samp_rate):
74 self.samp_rate = samp_rate
75 self.clk_offset_corrector_0.set_samp_rate(self.samp_rate)
76
piotr82c774f2014-08-06 15:20:12 +020077 def get_input_file_name(self):
78 return self.input_file_name
79
80 def set_input_file_name(self, input_file_name):
81 self.input_file_name = input_file_name
82 self.blocks_file_source_0.open(self.input_file_name, False)
83
piotr6fbc7322014-08-06 14:18:02 +020084if __name__ == '__main__':
85 import ctypes
86 import sys
87 if sys.platform.startswith('linux'):
88 try:
89 x11 = ctypes.cdll.LoadLibrary('libX11.so')
90 x11.XInitThreads()
91 except:
92 print "Warning: failed to XInitThreads()"
93 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
piotr82c774f2014-08-06 15:20:12 +020094 parser.add_option("-f", "--fc", dest="fc", type="eng_float", default=eng_notation.num_to_str(937e6),
95 help="Set fc [default=%default]")
96 parser.add_option("-s", "--samp-rate", dest="samp_rate", type="eng_float", default=eng_notation.num_to_str(1e6),
97 help="Set samp_rate [default=%default]")
98 parser.add_option("-i", "--input-file-name", dest="input_file_name", type="string", default="/home/piotr/Odbiornik_gsm/gr-gsm/examples/input.cfile",
99 help="Set /home/piotr/Odbiornik_gsm/gr-gsm/examples/input.cfile [default=%default]")
piotr6fbc7322014-08-06 14:18:02 +0200100 (options, args) = parser.parse_args()
piotr82c774f2014-08-06 15:20:12 +0200101 tb = gsm_receiver_test(fc=options.fc, samp_rate=options.samp_rate, input_file_name=options.input_file_name)
piotr6fbc7322014-08-06 14:18:02 +0200102 tb.Start(True)
103 tb.Wait()