piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | ################################################## |
| 3 | # Gnuradio Python Flow Graph |
| 4 | # Title: Gsm Receiver Test |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 5 | # Generated: Wed Aug 6 15:17:29 2014 |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 6 | ################################################## |
| 7 | |
| 8 | execfile("/home/piotr/.grc_gnuradio/clk_offset_corrector.py") |
| 9 | from gnuradio import blocks |
| 10 | from gnuradio import eng_notation |
| 11 | from gnuradio import gr |
| 12 | from gnuradio.eng_option import eng_option |
| 13 | from gnuradio.filter import firdes |
| 14 | from grc_gnuradio import wxgui as grc_wxgui |
| 15 | from optparse import OptionParser |
| 16 | import gsm |
| 17 | import wx |
| 18 | |
| 19 | class gsm_receiver_test(grc_wxgui.top_block_gui): |
| 20 | |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 21 | def __init__(self, fc=937e6, samp_rate=1e6, input_file_name="/home/piotr/Odbiornik_gsm/gr-gsm/examples/input.cfile"): |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 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 | ################################################## |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 29 | self.fc = fc |
| 30 | self.samp_rate = samp_rate |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 31 | self.input_file_name = input_file_name |
| 32 | |
| 33 | ################################################## |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 34 | # 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() |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 40 | self.gsm_clock_offset_control_0 = gsm.clock_offset_control(fc, samp_rate) |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 41 | 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 | |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 64 | def get_fc(self): |
| 65 | return self.fc |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 66 | |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 67 | def set_fc(self, fc): |
| 68 | self.fc = fc |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 69 | |
| 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 | |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 77 | 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 | |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 84 | if __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]") |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 94 | 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]") |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 100 | (options, args) = parser.parse_args() |
piotr | 82c774f | 2014-08-06 15:20:12 +0200 | [diff] [blame] | 101 | tb = gsm_receiver_test(fc=options.fc, samp_rate=options.samp_rate, input_file_name=options.input_file_name) |
piotr | 6fbc732 | 2014-08-06 14:18:02 +0200 | [diff] [blame] | 102 | tb.Start(True) |
| 103 | tb.Wait() |