summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-12-14 13:57:29 -0500
committerTom Rondeau <trondeau@vt.edu>2012-12-14 13:57:29 -0500
commit3910c6da3c62232e6593e5fcfe53f5ece933a294 (patch)
treed3cc80bae32ced851c83f8393d5fea3b57020464 /gnuradio-core/src/python
parent75b01cc4f55c38dfe5bb329c23df591e43cf4c66 (diff)
core: adding itemsize key to metadata header to allow for vectorized items.
This also simplifies some code in the source since we're told exactly what the items size is and don't have to infer. Also adds an example using vector items.
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r--gnuradio-core/src/python/gnuradio/parse_file_metadata.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/gnuradio-core/src/python/gnuradio/parse_file_metadata.py b/gnuradio-core/src/python/gnuradio/parse_file_metadata.py
index fa54db7465..0cee5a02cc 100644
--- a/gnuradio-core/src/python/gnuradio/parse_file_metadata.py
+++ b/gnuradio-core/src/python/gnuradio/parse_file_metadata.py
@@ -96,6 +96,17 @@ def parse_header(p, VERBOSE=False):
sys.stderr.write("Could not find key 'time': invalid or corrupt data file.\n")
sys.exit(1)
+ # EXTRACT ITEM SIZE
+ if(pmt.pmt_dict_has_key(p, pmt.pmt_string_to_symbol("size"))):
+ r = pmt.pmt_dict_ref(p, pmt.pmt_string_to_symbol("size"), dump)
+ dsize = pmt.pmt_to_long(r)
+ info["size"] = dsize
+ if(VERBOSE):
+ print "Item size: {0}".format(dsize)
+ else:
+ sys.stderr.write("Could not find key 'size': invalid or corrupt data file.\n")
+ sys.exit(1)
+
# EXTRACT DATA TYPE
if(pmt.pmt_dict_has_key(p, pmt.pmt_string_to_symbol("type"))):
r = pmt.pmt_dict_ref(p, pmt.pmt_string_to_symbol("type"), dump)
@@ -135,15 +146,11 @@ def parse_header(p, VERBOSE=False):
sys.exit(1)
# EXTRACT SIZE OF DATA
- if(pmt.pmt_dict_has_key(p, pmt.pmt_string_to_symbol("size"))):
- r = pmt.pmt_dict_ref(p, pmt.pmt_string_to_symbol("size"), dump)
+ if(pmt.pmt_dict_has_key(p, pmt.pmt_string_to_symbol("bytes"))):
+ r = pmt.pmt_dict_ref(p, pmt.pmt_string_to_symbol("bytes"), dump)
nbytes = pmt.pmt_to_uint64(r)
- # Multiply itemsize by 2 if complex
- if(cplx): mult=2
- else: mult=1
-
- nitems = nbytes/(ftype_to_size[dtype]*mult)
+ nitems = nbytes/dsize
info["nitems"] = nitems
info["nbytes"] = nbytes