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 3, 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, blks2
24 from gnuradio import usrp
25 from gnuradio import eng_notation
30 from pick_bitrate import pick_rx_bitrate
32 # /////////////////////////////////////////////////////////////////////////////
34 # /////////////////////////////////////////////////////////////////////////////
36 class receive_path(gr.hier_block2):
37 def __init__(self, rx_callback, options):
39 gr.hier_block2.__init__(self, "receive_path",
40 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
41 gr.io_signature(0, 0, 0)) # Output signature
44 options = copy.copy(options) # make a copy so we can destructively modify
46 self._verbose = options.verbose
47 self._log = options.log
48 self._rx_callback = rx_callback # this callback is fired when there's a packet available
52 blks2.ofdm_demod(options, callback=self._rx_callback)
54 # Carrier Sensing Blocks
56 thresh = 30 # in dB, will have to adjust
57 self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
59 self.connect(self, self.ofdm_rx)
60 self.connect(self.ofdm_rx, self.probe)
62 # Display some information about the setup
66 def carrier_sensed(self):
68 Return True if we think carrier is present.
70 #return self.probe.level() > X
71 return self.probe.unmuted()
73 def carrier_threshold(self):
75 Return current setting in dB.
77 return self.probe.threshold()
79 def set_carrier_threshold(self, threshold_in_db):
81 Set carrier threshold.
83 @param threshold_in_db: set detection threshold
84 @type threshold_in_db: float (dB)
86 self.probe.set_threshold(threshold_in_db)
89 def add_options(normal, expert):
91 Adds receiver-specific options to the Options Parser
93 normal.add_option("-v", "--verbose", action="store_true", default=False)
94 expert.add_option("", "--log", action="store_true", default=False,
95 help="Log all parts of flow graph to files (CAUTION: lots of data)")
97 # Make a static method to call before instantiation
98 add_options = staticmethod(add_options)
101 def _print_verbage(self):
103 Prints information about the receive path