[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5963 - gnuradio/branches/features/pager/gr-pager/src
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r5963 - gnuradio/branches/features/pager/gr-pager/src |
Date: |
Sat, 14 Jul 2007 11:00:03 -0600 (MDT) |
Author: jcorgan
Date: 2007-07-14 11:00:03 -0600 (Sat, 14 Jul 2007)
New Revision: 5963
Modified:
gnuradio/branches/features/pager/gr-pager/src/flex_demod.py
gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py
gnuradio/branches/features/pager/gr-pager/src/usrp_flex_all.py
Log:
Added verbose output and flowgraph logging.
Modified: gnuradio/branches/features/pager/gr-pager/src/flex_demod.py
===================================================================
--- gnuradio/branches/features/pager/gr-pager/src/flex_demod.py 2007-07-14
15:04:54 UTC (rev 5962)
+++ gnuradio/branches/features/pager/gr-pager/src/flex_demod.py 2007-07-14
17:00:03 UTC (rev 5963)
@@ -44,13 +44,13 @@
@type sample_rate: integer
"""
- def __init__(self, fg, queue, freq=0.0):
+ def __init__(self, fg, queue, freq=0.0, verbose=False, log=False):
k = 25000/(2*pi*1600) # 4800 Hz max deviation
QUAD = gr.quadrature_demod_cf(k)
self.INPUT = QUAD
-
+
RSAMP = blks.rational_resampler_fff(fg, 16, 25)
- SLICER = pager_swig.slicer_fb(.001) # Averaging filter constant
+ SLICER = pager_swig.slicer_fb(1e-3) # Averaging filter constant
SYNC = pager_swig.flex_sync(16000)
fg.connect(QUAD, RSAMP, SLICER, SYNC)
@@ -71,3 +71,13 @@
fg.connect((SYNC, 1), DEINTB, PARSEB)
fg.connect((SYNC, 2), DEINTC, PARSEC)
fg.connect((SYNC, 3), DEINTD, PARSED)
+
+ if log:
+ suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat'
+ quad_sink = gr.file_sink(gr.sizeof_float, 'quad'+suffix)
+ rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix)
+ slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer'+suffix)
+ fg.connect(RSAMP, rsamp_sink)
+ fg.connect(QUAD, quad_sink)
+ fg.connect(SLICER, slicer_sink)
+
\ No newline at end of file
Modified: gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py
===================================================================
--- gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py 2007-07-14
15:04:54 UTC (rev 5962)
+++ gnuradio/branches/features/pager/gr-pager/src/usrp_flex.py 2007-07-14
17:00:03 UTC (rev 5963)
@@ -63,15 +63,16 @@
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):
+ 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()
@@ -80,46 +81,69 @@
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)
- # TODO: deal with residual
-
+ 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, args, queue):
+ def __init__(self, options, queue):
gr.flow_graph.__init__(self)
self.options = options
- self.args = args
- 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
- USRP.tune(options.frequency)
+ 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):
+ sys.exit(1)
+
+ if options.log:
+ usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
+ self.connect(USRP, usrp_sink)
+ else:
+ USRP = gr.file_source(gr.sizeof_gr_complex, options.from_file)
+ if options.verbose:
+ print "Reading samples from", options.from_file
- if_rate = USRP.rate()
- channel_rate = 25000
- channel_decim = int(if_rate / channel_rate)
-
CHAN_taps = optfir.low_pass(1.0, # Filter gain
- if_rate, # Sample rate
- 11000, # One sided modulation
bandwidth
- 12500, # One sided channel bandwidth
+ 250e3, # Sample rate
+ 11000, # One-sided modulation
bandwidth
+ 12500, # One-sided channel bandwidth
0.1, # Passband ripple
60) # Stopband attenuation
- CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate
+ 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
- if_rate) # Sample rate
+ 250e3) # Sample rate
- FLEX = pager.flex_demod(self, queue, options.frequency)
+ if options.log:
+ chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat')
+ self.connect(CHAN, chan_sink)
+ FLEX = pager.flex_demod(self, queue, options.frequency,
options.verbose, options.log)
+
self.connect(USRP, CHAN, FLEX.INPUT)
def main():
@@ -132,18 +156,30 @@
help="set frequency offset to Hz", metavar="Hz")
parser.add_option("-g", "--gain", type="int", default=None,
help="set RF gain", metavar="dB")
+ parser.add_option("-l", "--log", action="store_true", default=False,
+ help="log flowgraph to files (LOTS of data)")
+ parser.add_option("-v", "--verbose", action="store_true", default=False,
+ help="display debug output")
+ parser.add_option("-F", "--from-file", default=None,
+ help="read samples from file instead of USRP")
(options, args) = parser.parse_args()
- if len(args) > 0 or options.frequency == None:
+ if len(args) > 0 or (options.frequency == None and options.from_file ==
None):
print "Run 'usrp_flex.py -h' for options."
sys.exit(1)
+ if options.frequency == None:
+ options.frequency = 0.0
+
if options.frequency < 1e6:
options.frequency *= 1e6
+ if options.verbose:
+ print options
+
queue = gr.msg_queue()
- fg = app_flow_graph(options, args, queue)
+ fg = app_flow_graph(options, queue)
try:
fg.start()
while 1:
Modified: gnuradio/branches/features/pager/gr-pager/src/usrp_flex_all.py
===================================================================
--- gnuradio/branches/features/pager/gr-pager/src/usrp_flex_all.py
2007-07-14 15:04:54 UTC (rev 5962)
+++ gnuradio/branches/features/pager/gr-pager/src/usrp_flex_all.py
2007-07-14 17:00:03 UTC (rev 5963)
@@ -12,7 +12,8 @@
if options.from_file is not None:
src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
- print "Reading samples from file", options.from_file
+ if options.verbose:
+ print "Reading samples from file", options.from_file
else:
src = usrp.source_c()
if options.rx_subdev_spec is None:
@@ -21,18 +22,26 @@
src.set_mux(usrp.determine_rx_mux_value(src,
options.rx_subdev_spec))
src.set_decim_rate(20)
result = usrp.tune(src, 0, subdev, 930.5e6+options.calibration)
- print "Using", subdev.name(), " for receiving."
-
+ if options.verbose:
+ print "Using", subdev.name(), " for receiving."
+ print "Tuned USRP to", 930.5e6+options.calibration
+
taps = gr.firdes.low_pass(1.0,
1.0,
1.0/128.0*0.4,
1.0/128.0*0.1,
gr.firdes.WIN_HANN)
- print "Channel filter has", len(taps), "taps"
+ if options.verbose:
+ print "Channel filter has", len(taps), "taps"
+
bank = blks.analysis_filterbank(self, 128, taps)
self.connect(src, bank)
+ if options.log and options.from_file == None:
+ src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
+ self.connect(src, src_sink)
+
for i in range(128):
if i < 64:
freq = 930.5e6+i*25e3
@@ -42,7 +51,10 @@
if ((i < 20) or (i >= 60 and i < 68) or (i >= 108)): # Non-forward
channel frequencies
self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex))
else:
- self.connect((bank, i), pager.flex_demod(self, queue,
freq).INPUT)
+ self.connect((bank, i), pager.flex_demod(self, queue, freq,
+ options.verbose,
options.log).INPUT)
+ if options.log:
+ self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex,
'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
def main():
parser = OptionParser(option_class=eng_option)
@@ -54,8 +66,15 @@
help="set RF gain", metavar="dB")
parser.add_option("-F", "--from-file", default=None,
help="Read from file instead of USRP")
+ parser.add_option("-l", "--log", action="store_true", default=False,
+ help="log flowgraph to files (LOTS of data)")
+ parser.add_option("-v", "--verbose", action="store_true", default=False,
+ help="display debug output")
(options, args) = parser.parse_args()
+ if options.verbose:
+ print options
+
queue = gr.msg_queue()
fg = app_flow_graph(options, queue)
try:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5963 - gnuradio/branches/features/pager/gr-pager/src,
jcorgan <=