All Classes Namespaces Files Functions Variables Enumerations Enumerator
programs/UrgViewer/print_timestamp.py
00001 #!/usr/bin/env python
00002 #
00003 # print SCIP timestamp value
00004 #
00005 # usage:
00006 # python print_timestamp.py data_file
00007 
00008 import sys
00009 
00010 def decode(string):
00011     value = 0
00012 
00013     for ch in string:
00014         value <<= 6
00015         value &= ~0x3f
00016         value |= ord(ch) - 0x30
00017 
00018     return value
00019 
00020 
00021 file = sys.argv[1]
00022 pre_line = ''
00023 pre_timestamp = -1
00024 for line in open(file):
00025     if pre_line == '99b':
00026         timestamp_string = line[:-2] # ignore checksum
00027         timestamp = decode(timestamp_string)
00028         print str(timestamp) + "(" + str(timestamp - pre_timestamp) + ")"
00029         pre_timestamp = timestamp
00030 
00031     pre_line = line[:-1]