3 # Copyright 2005,2006 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gru, modulation_utils
24 from gnuradio import usrp
25 from gnuradio import eng_notation
26 from gnuradio.eng_option import eng_option
27 from optparse import OptionParser
34 from receive_path import receive_path
39 #raw_input('Attach and press enter: ')
42 class my_graph(gr.flow_graph):
44 def __init__(self, demod_class, rx_callback, options):
45 gr.flow_graph.__init__(self)
46 self.rxpath = receive_path(self, demod_class, rx_callback, options)
48 # /////////////////////////////////////////////////////////////////////////////
50 # /////////////////////////////////////////////////////////////////////////////
52 global n_rcvd, n_right
55 global n_rcvd, n_right
60 def rx_callback(ok, payload):
61 global n_rcvd, n_right
62 (pktno,) = struct.unpack('!H', payload[0:2])
67 print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d" % (
68 ok, pktno, n_rcvd, n_right)
71 demods = modulation_utils.type_1_demods()
73 # Create Options Parser:
74 parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
75 expert_grp = parser.add_option_group("Expert")
77 parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(),
79 help="Select modulation from: %s [default=%%default]"
80 % (', '.join(demods.keys()),))
82 receive_path.add_options(parser, expert_grp)
84 for mod in demods.values():
85 mod.add_options(expert_grp)
87 fusb_options.add_options(expert_grp)
88 (options, args) = parser.parse_args ()
91 parser.print_help(sys.stderr)
94 if options.rx_freq is None:
95 sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
96 parser.print_help(sys.stderr)
101 fg = my_graph(demods[options.modulation], rx_callback, options)
103 r = gr.enable_realtime_scheduling()
105 print "Warning: Failed to enable realtime scheduling."
107 fg.start() # start flow graph
108 fg.wait() # wait for it to finish
110 if __name__ == '__main__':
113 except KeyboardInterrupt: