def test_001_t(self): fftlen = 128 cell_id = 124 taps = filter.optfir.low_pass(1, fftlen * 15e3, 472.5e3, 900e3, 0.2, 40) samples = t.get_mod_frame(cell_id, 6, 1, fftlen) samps = np.tile(samples[0], 5) src = blocks.vector_source_c(samps, repeat=False, vlen=1) fir = filter.fir_filter_ccc(fftlen / 64, taps) sync = lte.mimo_pss_coarse_sync(4, 1) dbg0 = blocks.message_debug() dbg1 = blocks.message_debug() dbg2 = blocks.message_debug() self.tb.connect(src, fir, sync) self.tb.msg_connect((sync, 'control'), (dbg0, 'store')) self.tb.msg_connect((sync, 'N_id_2'), (dbg1, 'store')) self.tb.msg_connect((sync, 'coarse_pos'), (dbg2, 'store')) # set up fg self.tb.run() # check data self.assertEqual(pmt.to_long(dbg1.get_message(0)), int(cell_id % 3)) ctrl_res = pmt.to_bool(dbg0.get_message(0)) assert ctrl_res offset = 10 + 5 * 9 + 6 * fftlen print(offset) # print() pos = pmt.to_long(dbg2.get_message(0)) print(pos) print(pos * 2 - (len(taps) // 2))
def test_001(self): src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) src = blocks.vector_source_i(src_data) trg = blocks.vector_source_s(trg_data) op = blocks.burst_tagger(gr.sizeof_int) snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA") self.tb.connect(src, (op,0)) self.tb.connect(trg, (op,1)) self.tb.connect(op, snk) self.tb.run() x = snk.current_tags() self.assertEqual(2, x[0].offset) self.assertEqual(4, x[1].offset) self.assertEqual(6, x[2].offset) self.assertEqual(8, x[3].offset) self.assertEqual(True, pmt.to_bool(x[0].value)) self.assertEqual(False, pmt.to_bool(x[1].value)) self.assertEqual(True, pmt.to_bool(x[2].value)) self.assertEqual(False, pmt.to_bool(x[3].value))
def test_001(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) src = blocks.vector_source_i(src_data) trg = blocks.vector_source_s(trg_data) op = blocks.burst_tagger(gr.sizeof_int) snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA") self.tb.connect(src, (op, 0)) self.tb.connect(trg, (op, 1)) self.tb.connect(op, snk) self.tb.run() x = snk.current_tags() self.assertEqual(2, x[0].offset) self.assertEqual(4, x[1].offset) self.assertEqual(6, x[2].offset) self.assertEqual(8, x[3].offset) self.assertEqual(True, pmt.to_bool(x[0].value)) self.assertEqual(False, pmt.to_bool(x[1].value)) self.assertEqual(True, pmt.to_bool(x[2].value)) self.assertEqual(False, pmt.to_bool(x[3].value))
def test_001_t(self): fftlen = 128 cell_id = 124 taps = filter.optfir.low_pass(1, fftlen*15e3, 472.5e3, 900e3, 0.2, 40) samples = t.get_mod_frame(cell_id, 6, 1, fftlen) samps = np.tile(samples[0], 5) src = blocks.vector_source_c(samps, repeat=False, vlen=1) fir = filter.fir_filter_ccc(fftlen/64, taps) sync = lte.mimo_pss_coarse_sync(4, 1) dbg0 = blocks.message_debug() dbg1 = blocks.message_debug() dbg2 = blocks.message_debug() self.tb.connect(src, fir, sync) self.tb.msg_connect((sync, 'control'), (dbg0, 'store')) self.tb.msg_connect((sync, 'N_id_2'), (dbg1, 'store')) self.tb.msg_connect((sync, 'coarse_pos'), (dbg2, 'store')) # set up fg self.tb.run() # check data self.assertEqual(pmt.to_long(dbg1.get_message(0)), int(cell_id % 3)) ctrl_res = pmt.to_bool(dbg0.get_message(0)) assert ctrl_res offset = 10 + 5 * 9 + 6 * fftlen print(offset) # print() pos = pmt.to_long(dbg2.get_message(0)) print(pos) print(pos * 2 - (len(taps) // 2)) import matplotlib.pyplot as plt plt.plot(np.abs(samps)) plt.show()
def parse_header(p, VERBOSE=False): dump = pmt.PMT_NIL info = dict() if (pmt.is_dict(p) is False): sys.stderr.write( "Header is not a PMT dictionary: invalid or corrupt data file.\n") sys.exit(1) # GET FILE FORMAT VERSION NUMBER if (pmt.dict_has_key(p, pmt.string_to_symbol("version"))): r = pmt.dict_ref(p, pmt.string_to_symbol("version"), dump) version = pmt.to_long(r) if (VERBOSE): print("Version Number: {0}".format(version)) else: sys.stderr.write( "Could not find key 'version': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SAMPLE RATE if (pmt.dict_has_key(p, pmt.string_to_symbol("rx_rate"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_rate"), dump) samp_rate = pmt.to_double(r) info["rx_rate"] = samp_rate if (VERBOSE): print("Sample Rate: {0:.2f} sps".format(samp_rate)) else: sys.stderr.write( "Could not find key 'sr': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT TIME STAMP if (pmt.dict_has_key(p, pmt.string_to_symbol("rx_time"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_time"), dump) secs = pmt.tuple_ref(r, 0) fracs = pmt.tuple_ref(r, 1) secs = float(pmt.to_uint64(secs)) fracs = pmt.to_double(fracs) t = secs + fracs info["rx_time"] = t if (VERBOSE): print("Seconds: {0:.6f}".format(t)) else: sys.stderr.write( "Could not find key 'time': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT ITEM SIZE if (pmt.dict_has_key(p, pmt.string_to_symbol("size"))): r = pmt.dict_ref(p, pmt.string_to_symbol("size"), dump) dsize = 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.dict_has_key(p, pmt.string_to_symbol("type"))): r = pmt.dict_ref(p, pmt.string_to_symbol("type"), dump) dtype = pmt.to_long(r) stype = ftype_to_string[dtype] info["type"] = stype if (VERBOSE): print("Data Type: {0} ({1})".format(stype, dtype)) else: sys.stderr.write( "Could not find key 'type': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT COMPLEX if (pmt.dict_has_key(p, pmt.string_to_symbol("cplx"))): r = pmt.dict_ref(p, pmt.string_to_symbol("cplx"), dump) cplx = pmt.to_bool(r) info["cplx"] = cplx if (VERBOSE): print("Complex? {0}".format(cplx)) else: sys.stderr.write( "Could not find key 'cplx': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT WHERE CURRENT SEGMENT STARTS if (pmt.dict_has_key(p, pmt.string_to_symbol("strt"))): r = pmt.dict_ref(p, pmt.string_to_symbol("strt"), dump) seg_start = pmt.to_uint64(r) info["hdr_len"] = seg_start info["extra_len"] = seg_start - HEADER_LENGTH info["has_extra"] = info["extra_len"] > 0 if (VERBOSE): print("Header Length: {0} bytes".format(info["hdr_len"])) print("Extra Length: {0}".format((info["extra_len"]))) print("Extra Header? {0}".format(info["has_extra"])) else: sys.stderr.write( "Could not find key 'strt': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SIZE OF DATA if (pmt.dict_has_key(p, pmt.string_to_symbol("bytes"))): r = pmt.dict_ref(p, pmt.string_to_symbol("bytes"), dump) nbytes = pmt.to_uint64(r) nitems = nbytes / dsize info["nitems"] = nitems info["nbytes"] = nbytes if (VERBOSE): print("Size of Data: {0} bytes".format(nbytes)) print(" {0} items".format(nitems)) else: sys.stderr.write( "Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) return info
def parse_header(p, VERBOSE=False): dump = pmt.PMT_NIL info = dict() if(pmt.is_dict(p) is False): sys.stderr.write("Header is not a PMT dictionary: invalid or corrupt data file.\n") sys.exit(1) # GET FILE FORMAT VERSION NUMBER if(pmt.dict_has_key(p, pmt.string_to_symbol("version"))): r = pmt.dict_ref(p, pmt.string_to_symbol("version"), dump) version = pmt.to_long(r) if(VERBOSE): print("Version Number: {0}".format(version)) else: sys.stderr.write("Could not find key 'version': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SAMPLE RATE if(pmt.dict_has_key(p, pmt.string_to_symbol("rx_rate"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_rate"), dump) samp_rate = pmt.to_double(r) info["rx_rate"] = samp_rate if(VERBOSE): print("Sample Rate: {0:.2f} sps".format(samp_rate)) else: sys.stderr.write("Could not find key 'sr': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT TIME STAMP if(pmt.dict_has_key(p, pmt.string_to_symbol("rx_time"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_time"), dump) secs = pmt.tuple_ref(r, 0) fracs = pmt.tuple_ref(r, 1) secs = float(pmt.to_uint64(secs)) fracs = pmt.to_double(fracs) t = secs + fracs info["rx_time"] = t if(VERBOSE): print("Seconds: {0:.6f}".format(t)) else: sys.stderr.write("Could not find key 'time': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT ITEM SIZE if(pmt.dict_has_key(p, pmt.string_to_symbol("size"))): r = pmt.dict_ref(p, pmt.string_to_symbol("size"), dump) dsize = 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.dict_has_key(p, pmt.string_to_symbol("type"))): r = pmt.dict_ref(p, pmt.string_to_symbol("type"), dump) dtype = pmt.to_long(r) stype = ftype_to_string[dtype] info["type"] = stype if(VERBOSE): print("Data Type: {0} ({1})".format(stype, dtype)) else: sys.stderr.write("Could not find key 'type': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT COMPLEX if(pmt.dict_has_key(p, pmt.string_to_symbol("cplx"))): r = pmt.dict_ref(p, pmt.string_to_symbol("cplx"), dump) cplx = pmt.to_bool(r) info["cplx"] = cplx if(VERBOSE): print("Complex? {0}".format(cplx)) else: sys.stderr.write("Could not find key 'cplx': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT WHERE CURRENT SEGMENT STARTS if(pmt.dict_has_key(p, pmt.string_to_symbol("strt"))): r = pmt.dict_ref(p, pmt.string_to_symbol("strt"), dump) seg_start = pmt.to_uint64(r) info["hdr_len"] = seg_start info["extra_len"] = seg_start - HEADER_LENGTH info["has_extra"] = info["extra_len"] > 0 if(VERBOSE): print("Header Length: {0} bytes".format(info["hdr_len"])) print("Extra Length: {0}".format((info["extra_len"]))) print("Extra Header? {0}".format(info["has_extra"])) else: sys.stderr.write("Could not find key 'strt': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SIZE OF DATA if(pmt.dict_has_key(p, pmt.string_to_symbol("bytes"))): r = pmt.dict_ref(p, pmt.string_to_symbol("bytes"), dump) nbytes = pmt.to_uint64(r) nitems = nbytes / dsize info["nitems"] = nitems info["nbytes"] = nbytes if(VERBOSE): print("Size of Data: {0} bytes".format(nbytes)) print(" {0} items".format(nitems)) else: sys.stderr.write("Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) return info
def parse_header(p, VERBOSE=False): dump = pmt.PMT_NIL info = dict() if (pmt.is_dict(p) is False): sys.stderr.write( "Header is not a PMT dictionary: invalid or corrupt data file.\n") sys.exit(1) # GET FILE FORMAT VERSION NUMBER if (pmt.dict_has_key(p, pmt.string_to_symbol("version"))): r = pmt.dict_ref(p, pmt.string_to_symbol("version"), dump) version = pmt.to_long(r) if (VERBOSE): print "Version Number: {0}".format(version) else: sys.stderr.write( "Could not find key 'version': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SAMPLE RATE if (pmt.dict_has_key(p, pmt.string_to_symbol("rx_rate"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_rate"), dump) samp_rate = pmt.to_double(r) info["rx_rate"] = samp_rate if (VERBOSE): print "Sample Rate: " + eng_notation.num_to_str(samp_rate) + "SPS" else: sys.stderr.write( "Could not find key 'sr': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT TIME STAMP if (pmt.dict_has_key(p, pmt.string_to_symbol("rx_time"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_time"), dump) secs = pmt.tuple_ref(r, 0) fracs = pmt.tuple_ref(r, 1) secs = float(pmt.to_uint64(secs)) fracs = pmt.to_double(fracs) t = secs + fracs info["rx_time"] = t if (VERBOSE): time = datetime.fromtimestamp(t).strftime('%m/%d/%Y %H:%M:%S') print "Timestamp (Unix Epoch): " + time print "Integer Seconds: " + repr(secs) print "Fractional Seconds: " + repr(fracs) #print "Linux Epoch: {0:.6f}".format(t) + " Seconds" else: sys.stderr.write( "Could not find key 'time': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT ITEM SIZE if (pmt.dict_has_key(p, pmt.string_to_symbol("size"))): r = pmt.dict_ref(p, pmt.string_to_symbol("size"), dump) dsize = pmt.to_long(r) info["size"] = dsize if (VERBOSE): print "Item Size: " + eng_notation.num_to_str(dsize) + " Bytes" else: sys.stderr.write( "Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT DATA TYPE if (pmt.dict_has_key(p, pmt.string_to_symbol("type"))): r = pmt.dict_ref(p, pmt.string_to_symbol("type"), dump) dtype = pmt.to_long(r) stype = ftype_to_string[dtype] info["type"] = stype if (VERBOSE): print "Data Type: {0} ({1})".format(stype, dtype) else: sys.stderr.write( "Could not find key 'type': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT COMPLEX if (pmt.dict_has_key(p, pmt.string_to_symbol("cplx"))): r = pmt.dict_ref(p, pmt.string_to_symbol("cplx"), dump) #global cplx cplx = pmt.to_bool(r) info["cplx"] = cplx if (VERBOSE): print "Complex? {0}".format(cplx) global vecchk global tsize #print cplx #print dtype #print dsize if (cplx == False): if (dtype == 0): tsize = 1 elif (dtype == 1): tsize = 4 elif (dtype == 2): tsize = 4 elif (dtype == 3): tsize = 4 elif (dtype == 5): tsize = 4 elif (dtype == 6): tsize = 8 else: tsize = 64 #print tsize vecchk = dsize / tsize #print vecchk if (vecchk > 1): print "The data is a vector containing {0} elements.".format( vecchk) else: print "The data is not a vector." '''else: sys.stderr.write("Could not find key 'cplx': invalid or corrupt data file.\n") sys.exit(1) ''' # EXTRACT WHERE CURRENT SEGMENT STARTS if (pmt.dict_has_key(p, pmt.string_to_symbol("strt"))): r = pmt.dict_ref(p, pmt.string_to_symbol("strt"), dump) seg_start = pmt.to_uint64(r) info["hdr_len"] = seg_start info["extra_len"] = seg_start - HEADER_LENGTH info["has_extra"] = info["extra_len"] > 0 if (VERBOSE): print "Header Length: {0} bytes".format(info["hdr_len"]) print "Extra Length: {0}".format((info["extra_len"])) print "Extra Header? {0}".format(info["has_extra"]) else: sys.stderr.write( "Could not find key 'strt': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SIZE OF DATA if (pmt.dict_has_key(p, pmt.string_to_symbol("bytes"))): r = pmt.dict_ref(p, pmt.string_to_symbol("bytes"), dump) nbytes = pmt.to_uint64(r) nitems = nbytes / dsize info["nitems"] = nitems info["nbytes"] = nbytes #info["types"] = types if (VERBOSE): #print "Size of Data: {0:2.1e} bytes".format(nbytes) print "Segment Size (bytes): " + eng_notation.num_to_str(nbytes) #print " {0:2.1e} items".format(nitems) print "Segment Size (items): " + eng_notation.num_to_str(nitems) else: sys.stderr.write( "Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) return info
def key(self, msg): if pmt.is_pair(msg) and pmt.car(msg) == pmt.intern('key'): self.keyed = pmt.to_bool(pmt.cdr(msg))
def __init__(self, fname='', add_metadata=False, metadata_format='', data_type='uint8', precision=0): gr.sync_block.__init__(self, name="csv_writer", in_sig=None, out_sig=None) self.fname = fname self.add_metadata = add_metadata self.metadata_format = metadata_format self.data_type = data_type self.precision = precision self.fid = None # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() if logger_name in gr.logger_get_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') # metadata field mappings self.metadata_mappings = { 'string': lambda x: pmt.symbol_to_string(x), 'bool': lambda x: pmt.to_bool(x), 'long': lambda x: pmt.to_long(x), 'uint64': lambda x: pmt.to_uint64(x), 'float': lambda x: pmt.to_float(x), 'double': lambda x: pmt.to_double(x), 'complex': lambda x: pmt.to_complex(x), 'time': lambda x: float(pmt.to_uint64(pmt.car(x))) + pmt.to_double( pmt.cdr(x)), 'time_tuple': lambda x: float(pmt.to_uint64(pmt.tuple_ref(x, 0))) + pmt. to_double(pmt.tuple_ref(x, 1)) } # data type parsers self.data_type_mappings = { 'uint8': lambda x: pmt.u8vector_elements(x), 'int8': lambda x: pmt.s8vector_elements(x), 'uint16': lambda x: pmt.u16vector_elements(x), 'int16': lambda x: pmt.s16vector_elements(x), 'uint32': lambda x: pmt.u32vector_elements(x), 'int32': lambda x: pmt.s32vector_elements(x), 'float': lambda x: pmt.f32vector_elements(x), 'complex float': lambda x: pmt.c32vector_elements(x), 'double': lambda x: pmt.f64vector_elements(x), 'complex double': lambda x: pmt.c64vector_elements(x) } # check data type if data_type not in self.data_type_mappings.keys(): raise ValueError('Invalid data type') self.find_metadata = False self.header = [] if self.add_metadata: if self.metadata_format == '': # set flag to load metadata on first message received self.find_metadata = True else: self.parse_header_format() # register message handler self.message_port_name = pmt.intern('in') self.message_port_register_in(self.message_port_name) self.set_msg_handler(self.message_port_name, self.message_handler)
def receive_message(self, message): self.drop = pmt.to_bool(pmt.cdr(message))
def parse_header(p, VERBOSE=False): dump = pmt.PMT_NIL info = dict() if(pmt.is_dict(p) is False): sys.stderr.write("Header is not a PMT dictionary: invalid or corrupt data file.\n") sys.exit(1) # GET FILE FORMAT VERSION NUMBER if(pmt.dict_has_key(p, pmt.string_to_symbol("version"))): r = pmt.dict_ref(p, pmt.string_to_symbol("version"), dump) version = pmt.to_long(r) if(VERBOSE): print "Version Number: {0}".format(version) else: sys.stderr.write("Could not find key 'version': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SAMPLE RATE if(pmt.dict_has_key(p, pmt.string_to_symbol("rx_rate"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_rate"), dump) samp_rate = pmt.to_double(r) info["rx_rate"] = samp_rate if(VERBOSE): print "Sample Rate: " + eng_notation.num_to_str(samp_rate) + "SPS" else: sys.stderr.write("Could not find key 'sr': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT TIME STAMP if(pmt.dict_has_key(p, pmt.string_to_symbol("rx_time"))): r = pmt.dict_ref(p, pmt.string_to_symbol("rx_time"), dump) secs = pmt.tuple_ref(r, 0) fracs = pmt.tuple_ref(r, 1) secs = float(pmt.to_uint64(secs)) fracs = pmt.to_double(fracs) t = secs + fracs info["rx_time"] = t if(VERBOSE): time = datetime.fromtimestamp(t).strftime('%m/%d/%Y %H:%M:%S') print "Timestamp (Unix Epoch): " + time print "Integer Seconds: " + repr(secs) print "Fractional Seconds: " + repr(fracs) #print "Linux Epoch: {0:.6f}".format(t) + " Seconds" else: sys.stderr.write("Could not find key 'time': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT ITEM SIZE if(pmt.dict_has_key(p, pmt.string_to_symbol("size"))): r = pmt.dict_ref(p, pmt.string_to_symbol("size"), dump) dsize = pmt.to_long(r) info["size"] = dsize if(VERBOSE): print "Item Size: " + eng_notation.num_to_str(dsize) + " Bytes" else: sys.stderr.write("Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT DATA TYPE if(pmt.dict_has_key(p, pmt.string_to_symbol("type"))): r = pmt.dict_ref(p, pmt.string_to_symbol("type"), dump) dtype = pmt.to_long(r) stype = ftype_to_string[dtype] info["type"] = stype if(VERBOSE): print "Data Type: {0} ({1})".format(stype, dtype) else: sys.stderr.write("Could not find key 'type': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT COMPLEX if(pmt.dict_has_key(p, pmt.string_to_symbol("cplx"))): r = pmt.dict_ref(p, pmt.string_to_symbol("cplx"), dump) #global cplx cplx = pmt.to_bool(r) info["cplx"] = cplx if(VERBOSE): print "Complex? {0}".format(cplx) global vecchk global tsize #print cplx #print dtype #print dsize if(cplx==False): if(dtype==0): tsize=1 elif(dtype==1): tsize=4 elif(dtype==2): tsize=4 elif(dtype==3): tsize=4 elif(dtype==5): tsize=4 elif(dtype==6): tsize=8 else: tsize=64 #print tsize vecchk = dsize/tsize #print vecchk if(vecchk>1): print "The data is a vector containing {0} elements.".format(vecchk) else: print "The data is not a vector." '''else: sys.stderr.write("Could not find key 'cplx': invalid or corrupt data file.\n") sys.exit(1) ''' # EXTRACT WHERE CURRENT SEGMENT STARTS if(pmt.dict_has_key(p, pmt.string_to_symbol("strt"))): r = pmt.dict_ref(p, pmt.string_to_symbol("strt"), dump) seg_start = pmt.to_uint64(r) info["hdr_len"] = seg_start info["extra_len"] = seg_start - HEADER_LENGTH info["has_extra"] = info["extra_len"] > 0 if(VERBOSE): print "Header Length: {0} bytes".format(info["hdr_len"]) print "Extra Length: {0}".format((info["extra_len"])) print "Extra Header? {0}".format(info["has_extra"]) else: sys.stderr.write("Could not find key 'strt': invalid or corrupt data file.\n") sys.exit(1) # EXTRACT SIZE OF DATA if(pmt.dict_has_key(p, pmt.string_to_symbol("bytes"))): r = pmt.dict_ref(p, pmt.string_to_symbol("bytes"), dump) nbytes = pmt.to_uint64(r) nitems = nbytes/dsize info["nitems"] = nitems info["nbytes"] = nbytes #info["types"] = types if(VERBOSE): #print "Size of Data: {0:2.1e} bytes".format(nbytes) print "Segment Size (bytes): " + eng_notation.num_to_str(nbytes) #print " {0:2.1e} items".format(nitems) print "Segment Size (items): " + eng_notation.num_to_str(nitems) else: sys.stderr.write("Could not find key 'size': invalid or corrupt data file.\n") sys.exit(1) return info