[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/06: gr-uhd: add option to uhd_rx_cfile t
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/06: gr-uhd: add option to uhd_rx_cfile to write metadata file. |
Date: |
Wed, 29 Jan 2014 00:04:25 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit c236f0cf8e01aec2e282c9cecdd2cdba2bd7e013
Author: Steve Glass <address@hidden>
Date: Tue Oct 29 18:35:34 2013 +1000
gr-uhd: add option to uhd_rx_cfile to write metadata file.
---
gr-uhd/apps/uhd_rx_cfile | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/gr-uhd/apps/uhd_rx_cfile b/gr-uhd/apps/uhd_rx_cfile
old mode 100755
new mode 100644
index d727d87..7d8d5dd
--- a/gr-uhd/apps/uhd_rx_cfile
+++ b/gr-uhd/apps/uhd_rx_cfile
@@ -31,6 +31,7 @@ from gnuradio import blocks
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+import pmt
import sys
n2s = eng_notation.num_to_str
@@ -44,11 +45,9 @@ class rx_cfile_block(gr.top_block):
if options.output_shorts:
self._u = uhd.usrp_source(device_addr=options.args,
stream_args=uhd.stream_args('sc16',
options.wire_format,
args=options.stream_args))
- self._sink = blocks.file_sink(gr.sizeof_short*2, filename)
else:
self._u = uhd.usrp_source(device_addr=options.args,
stream_args=uhd.stream_args('fc32',
options.wire_format,
args=options.stream_args))
- self._sink = blocks.file_sink(gr.sizeof_gr_complex, filename)
# Set the subdevice spec
if(options.spec):
@@ -60,6 +59,7 @@ class rx_cfile_block(gr.top_block):
# Set receiver sample rate
self._u.set_samp_rate(options.samp_rate)
+ samp_rate = self._u.get_samp_rate()
# Set receive daughterboard gain
if options.gain is None:
@@ -67,6 +67,7 @@ class rx_cfile_block(gr.top_block):
options.gain = float(g.start()+g.stop())/2
print "Using mid-point gain of", options.gain, "(", g.start(), "-",
g.stop(), ")"
self._u.set_gain(options.gain)
+ gain = self._u.get_gain()
# Set frequency (tune request takes lo_offset)
if(options.lo_offset is not None):
@@ -77,6 +78,29 @@ class rx_cfile_block(gr.top_block):
if tr == None:
sys.stderr.write('Failed to set center frequency\n')
raise SystemExit, 1
+ freq = self._u.get_center_freq()
+
+ # Create file sink
+ if options.metafile:
+ # store additional metadata
+ extras = pmt.make_dict()
+ extras = pmt.dict_add(extras, pmt.intern("rx_gain"),
pmt.from_double(gain))
+ extras_str = pmt.serialize_str(extras)
+ if options.output_shorts:
+ self._sink = blocks.file_meta_sink(gr.sizeof_short * 2,
filename,
+ samp_rate, 1,
+ blocks.GR_FILE_SHORT, True,
+ 1000000, extras_str, False)
+ else:
+ self._sink = blocks.file_meta_sink(gr.sizeof_gr_complex,
filename,
+ samp_rate, 1,
+ blocks.GR_FILE_FLOAT, True,
+ 1000000, extras_str, False)
+ else:
+ if options.output_shorts:
+ self._sink = blocks.file_sink(gr.sizeof_short*2, filename)
+ else:
+ self._sink = blocks.file_sink(gr.sizeof_gr_complex, filename)
# Create head block if needed and wire it up
if options.nsamples is None:
@@ -89,8 +113,6 @@ class rx_cfile_block(gr.top_block):
self.connect(self._u, self._head, self._sink)
- input_rate = self._u.get_samp_rate()
-
if options.verbose:
try:
info = self._u.get_usrp_info()
@@ -116,10 +138,11 @@ class rx_cfile_block(gr.top_block):
print "Daughterboard: %s (%s, %s, %s)" % (rx_id,
rx_serial, rx_antenna, rx_subdev_spec)
except:
print "Args: ", options.args
+
print "Rx gain:", options.gain
print "Rx baseband frequency:", n2s(tr.actual_rf_freq)
print "Rx DDC frequency:", n2s(tr.actual_dsp_freq)
- print "Rx Sample Rate:", n2s(input_rate)
+ print "Rx Sample Rate:", n2s(samp_rate)
if options.nsamples is None:
print "Receiving samples until Ctrl-C"
else:
@@ -156,6 +179,8 @@ def get_options():
help="set frequency to FREQ", metavar="FREQ")
parser.add_option("-g", "--gain", type="eng_float", default=None,
help="set gain in dB (default is midpoint)")
+ parser.add_option( "-m","--metafile", action="store_true", default=False,
+ help="output metadata to file [default=%default]")
parser.add_option( "-s","--output-shorts", action="store_true",
default=False,
help="output interleaved shorts instead of complex
floats")
parser.add_option("-N", "--nsamples", type="eng_float", default=None,
- [Commit-gnuradio] [gnuradio] branch master updated (300f5fb -> 19d111e), git, 2014/01/28
- [Commit-gnuradio] [gnuradio] 01/06: gr-uhd: add option to uhd_rx_cfile to write metadata file.,
git <=
- [Commit-gnuradio] [gnuradio] 02/06: Merge branch 'maint', git, 2014/01/28
- [Commit-gnuradio] [gnuradio] 06/06: volk: remove unused spu_lib directory from VOLK., git, 2014/01/28
- [Commit-gnuradio] [gnuradio] 05/06: cmake: fixed ICE 3.4 version check for GCC < 4.7., git, 2014/01/28
- [Commit-gnuradio] [gnuradio] 03/06: volk: follow-up to commit cb4142d45 for added volk_get_machine function on master., git, 2014/01/28
- [Commit-gnuradio] [gnuradio] 04/06: Merge remote-tracking branch 'stiabhan/uhd_rx_cfile', git, 2014/01/28