[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5970 - gnuradio/branches/features/pager/gr-pager/src
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r5970 - gnuradio/branches/features/pager/gr-pager/src |
Date: |
Sun, 15 Jul 2007 18:48:25 -0600 (MDT) |
Author: jcorgan
Date: 2007-07-15 18:48:25 -0600 (Sun, 15 Jul 2007)
New Revision: 5970
Modified:
gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py
Log:
Cleanup before converson to hier_block2
Modified: gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py
===================================================================
--- gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py 2007-07-15
22:01:19 UTC (rev 5969)
+++ gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py 2007-07-16
00:48:25 UTC (rev 5970)
@@ -31,120 +31,93 @@
This example application demonstrates receiving and demodulating the
FLEX pager protocol.
-A receive chain is built up of the following signal processing
-blocks:
-
-USRP - Daughter board source generating complex baseband signal.
-CHAN - Low pass filter to select channel bandwidth
-AGC - Automatic gain control leveling signal at [-1.0, +1.0]
-FLEX - FLEX pager protocol decoder
-
The following are required command line parameters:
--f FREQ USRP receive frequency
+-f FREQ USRP receive frequency
The following are optional command line parameters:
-R SUBDEV Daughter board specification, defaults to first found
+-F FILE Read samples from a file instead of USRP.
-c FREQ Calibration offset. Gets added to receive frequency.
Defaults to 0.0 Hz.
-g GAIN Daughterboard gain setting. Defaults to mid-range.
--r RFSQL RF squelch in db. Defaults to -50.0.
+-l Log flow graph to files (LOTS of data)
+-v Verbose output
Once the program is running, ctrl-break (Ctrl-C) stops operation.
"""
-class usrp_source_c(gr.hier_block):
- """
- Create a USRP source object supplying complex floats.
-
- Selects user supplied subdevice or chooses first available one.
-
- Calibration value is the offset from the tuned frequency to
- the actual frequency.
- """
- def __init__(self, fg, subdev_spec, decim, gain=None, calibration=0.0,
verbose=False):
- self._decim = decim
- self._verbose = verbose
- self._src = usrp.source_c()
- if subdev_spec is None:
- subdev_spec = usrp.pick_rx_subdevice(self._src)
- self._subdev = usrp.selected_subdev(self._src, subdev_spec)
- self._src.set_mux(usrp.determine_rx_mux_value(self._src, subdev_spec))
- self._src.set_decim_rate(self._decim)
-
- # If no gain specified, set to midrange
- if gain is None:
- g = self._subdev.gain_range()
- gain = (g[0]+g[1])/2.0
-
- self._subdev.set_gain(gain)
- self._cal = calibration
-
- if verbose:
- print "Using RX daughterboard", self._subdev.side_and_name()
- print "USRP decimation is", self._decim
- print "USRP gain is", gain
-
- gr.hier_block.__init__(self, fg, self._src, self._src)
-
- def tune(self, freq):
- if self._verbose:
- print "Tuning daugherboard to", freq+self._cal
- result = usrp.tune(self._src, 0, self._subdev, freq+self._cal)
- if not result:
- sys.stderr.write("Failed to set center frequency\n")
- return result
-
- def rate(self):
- return self._src.adc_rate()/self._decim
-
class app_flow_graph(gr.flow_graph):
def __init__(self, options, queue):
gr.flow_graph.__init__(self)
self.options = options
if options.from_file is None:
- USRP = usrp_source_c(self, # Flow graph
- options.rx_subdev_spec, # Daugherboard spec
- 256, # IF decimation ratio
gets 250K if_rate
- options.gain, # Receiver gain
- options.calibration, # Frequency offset
- options.verbose) # Verbose display
-
- if not USRP.tune(options.frequency):
+ # Set up USRP source with specified RX daughterboard
+ src = usrp.source_c()
+ if options.rx_subdev_spec == None:
+ options.subdev_spec = usrp.pick_rx_subdevice(src)
+ subdev = usrp.selected_subdev(src, options.rx_subdev_spec)
+ src.set_mux(usrp.determine_rx_mux_value(src,
options.rx_subdev_spec))
+
+ # Grab 250 KHz of spectrum (sample rate becomes 250 ksps complex)
+ src.set_decim_rate(256)
+
+ # If no gain specified, set to midrange
+ if options.gain is None:
+ g = subdev.gain_range()
+ options.gain = (g[0]+g[1])/2.0
+ subdev.set_gain(options.gain)
+
+ # Tune daughterboard
+ actual_frequency = options.frequency+options.calibration
+ tune_result = usrp.tune(src, 0, subdev, actual_frequency)
+ if not result:
+ sys.stderr.write("Failed to set center frequency
to"+`actual_frequency`+"\n")
sys.exit(1)
-
- if options.log:
- usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
- self.connect(USRP, usrp_sink)
+
+ if verbose:
+ print "Using RX daughterboard", self._subdev.side_and_name()
+ print "USRP decimation is", self._decim
+ print "USRP gain is", gain
+ print "USRP tuned to", actual_frequency
+
else:
- USRP = gr.file_source(gr.sizeof_gr_complex, options.from_file)
+ # Use supplied file as source of samples
+ src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
if options.verbose:
print "Reading samples from", options.from_file
+
+ if options.log and not options.from_file:
+ usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
+ self.connect(src, usrp_sink)
- CHAN_taps = optfir.low_pass(1.0, # Filter gain
- 250e3, # Sample rate
- 11000, # One-sided modulation
bandwidth
- 12500, # One-sided channel bandwidth
- 0.1, # Passband ripple
- 60) # Stopband attenuation
+ # Set up 22KHz-wide bandpass about center frequency. Decimate by 10
+ # to get channel rate of 25Ksps
+ taps = optfir.low_pass(1.0, # Filter gain
+ 250e3, # Sample rate
+ 11000, # One-sided modulation bandwidth
+ 12500, # One-sided channel bandwidth
+ 0.1, # Passband ripple
+ 60) # Stopband attenuation
if options.verbose:
- print "Channel filter has", len(CHAN_taps), "taps."
-
- CHAN = gr.freq_xlating_fir_filter_ccf(10, # Decimation rate
- CHAN_taps, # Filter taps
- 0.0, # Offset frequency
- 250e3) # Sample rate
+ print "Channel filter has", len(taps), "taps."
+ chan = gr.freq_xlating_fir_filter_ccf(10, # Decimation rate
+ taps, # Filter taps
+ 0.0, # Offset frequency
+ 250e3) # Sample rate
+
if options.log:
chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat')
- self.connect(CHAN, chan_sink)
+ self.connect(chan, chan_sink)
- FLEX = pager.flex_demod(self, queue, options.frequency,
options.verbose, options.log)
+ # FLEX protocol demodulator
+ flex = pager.flex_demod(self, queue, options.frequency,
options.verbose, options.log)
- self.connect(USRP, CHAN, FLEX.INPUT)
+ self.connect(src, chan, flex.INPUT)
def main():
parser = OptionParser(option_class=eng_option)
@@ -171,15 +144,10 @@
if options.frequency == None:
options.frequency = 0.0
- if options.frequency < 1e6:
- options.frequency *= 1e6
-
- if options.verbose:
- print options
-
+ # Flow graph emits pages into message queue
queue = gr.msg_queue()
-
fg = app_flow_graph(options, queue)
+
try:
fg.start()
while 1:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5970 - gnuradio/branches/features/pager/gr-pager/src,
jcorgan <=