diff options
author | Tom Rondeau | 2012-11-27 11:59:26 -0800 |
---|---|---|
committer | Tom Rondeau | 2012-11-27 11:59:26 -0800 |
commit | 88a9e1f9332d54c1743d062adfaf48aa6d3040ff (patch) | |
tree | cc94dfab112bb5964f0dc968ab4b500ef84eb8af /gr-utils | |
parent | 9dc8f8b18043e71b50b3a254cb52bf355e97e6fa (diff) | |
download | gnuradio-88a9e1f9332d54c1743d062adfaf48aa6d3040ff.tar.gz gnuradio-88a9e1f9332d54c1743d062adfaf48aa6d3040ff.tar.bz2 gnuradio-88a9e1f9332d54c1743d062adfaf48aa6d3040ff.zip |
core: adding ability to handle extra data in headers.
Diffstat (limited to 'gr-utils')
-rw-r--r-- | gr-utils/src/python/gr_read_file_metadata | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gr-utils/src/python/gr_read_file_metadata b/gr-utils/src/python/gr_read_file_metadata index 47109aead..850c29ee7 100644 --- a/gr-utils/src/python/gr_read_file_metadata +++ b/gr-utils/src/python/gr_read_file_metadata @@ -29,6 +29,7 @@ from gnuradio import parse_file_metadata def main(filename): handle = open(filename, "rb") + nheaders = 0 nread = 0 while(True): # read out next header bytes @@ -45,12 +46,27 @@ def main(filename): sys.exit(1) #gr.pmt_print(header) + print "HEADER {0}".format(nheaders) info = parse_file_metadata.parse_header(header, hdr_start, True) - print "\n\n" - nread += info['nbytes'] + parse_file_metadata.HEADER_LENGTH + if(info["extra_len"] > 0): + extra_str = handle.read(info["extra_len"]) + if(len(extra_str) == 0): + break + + try: + extra = gr.pmt_deserialize_str(extra_str) + except RuntimeError: + sys.stderr.write("Could not deserialize extras: invalid or corrupt data file.\n") + sys.exit(1) + print "\nExtra Header:" + extra_info = parse_file_metadata.parse_extra_dict(extra, info, True) + + nheaders += 1 + nread += info['nbytes'] + parse_file_metadata.HEADER_LENGTH + info["extra_len"] + 1 handle.seek(nread, 0) + print "\n\n" if __name__ == "__main__": usage="%prog: [options] filename" |