在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
EETOP诚邀模拟IC相关培训讲师 创芯人才网--重磅上线啦!
查看: 4550|回复: 1

MTK中kernel log和mobile_log时间对应问题

[复制链接]
发表于 2015-3-23 21:45:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
mobile_log中的log会有对应时间信息,这点比较好,但是在kernel_log只有从开机到此时经历的秒数,所以出现问题无法对应分析,网上有位大神,做了一个python 脚本,可以解决这个问题,但是只是一个相对值,大家有没有更好的办法,谢谢啦!!!!!!!!!!!!!!!!!!!
 楼主| 发表于 2015-3-24 19:12:05 | 显示全部楼层
看来这个论坛里android驱动的人不多啊,我自己找个python脚本,可以将android_log和kernel_log的时间对应起来



  1. import time
  2. import datetime
  3. import sys
  4. import getopt
  5. import os

  6. a_time = None
  7. s_second = None
  8. s_microsecone = None
  9. abs_time = 0.0
  10. inputfile = None
  11. outputfile = None

  12. def usage():
  13.     print('''Help Information:
  14.              -h, --help:        Show help information
  15.              -i, --inputfile:   input file  to parse
  16.              -o, --outputfile:  output fiel parsed
  17.                         ''')


  18. def calc_delta(stream):
  19.     global s_second
  20.     global s_microsecond
  21.     global a_time
  22.     global outfile
  23.     begin_index = None
  24.     end_index = None
  25.     delta_second = 0
  26.     delta_mircosecond = 0
  27.     delta_time = 0
  28.     d_time = None
  29.     new_line = None
  30.     if a_time ==None:
  31.         print("Can't convert to android time")
  32.         exit(-1)
  33.     for line in stream:
  34.         if line:
  35.             try:
  36.                 begin_index =  line.index('[')
  37.                 end_index = line[begin_index+1:].index(']')+begin_index+1
  38.                 time_string = line[begin_index + 1 :end_index]
  39.                 [d_second,d_microsecond] = time_string.split('.')
  40.                 delta_second = int(int(d_second) - int(s_second))
  41.                 delta_microsecond = int(int(d_microsecond)-int(s_microsecond))
  42.                 delta_time = datetime.timedelta(seconds=delta_second,microseconds=delta_microsecond)
  43.                 d_time = a_time + delta_time
  44.                 new_line = d_time.strftime("%m-%d %H:%M:%S.%f")+' ' + line
  45.                 outputfile.write(new_line)
  46.             except:
  47.                 outputfile.write(line)


  48. def get_atime(stream):
  49.     global s_second
  50.     global s_microsecond
  51.     global a_time
  52.     a_time_op = None
  53.     begin_index = None
  54.     end_index = None
  55.     for line in stream:
  56.         if line:
  57.             a_time_op = line.find('android time')
  58.             if a_time_op>=1:
  59.                 begin_index =  line.index('[')
  60.                 end_index = line[begin_index+1:].index(']')+begin_index+1
  61.                 date_string = line[a_time_op+13:].strip()
  62.                 abs_time = line[begin_index + 1 :end_index]
  63.                 [s_second,s_microsecond] = abs_time.split('.')
  64.                 a_time = datetime.datetime.strptime(date_string, "%Y-%m-%d %H:%M:%S.%f")
  65.                 break

  66. def main(argv):
  67.     global inputfile
  68.     global outputfile
  69.     inputpath = None
  70.     outputpath = None
  71.     try:
  72.         opts, args = getopt.getopt(argv,"hi:o:",["help","inputfile=","outputfile="])
  73.     except getopt.GetoptError:
  74.         usage()
  75.         sys.exit(2)
  76.     for opt, arg in opts:
  77.         if opt in ("-h", "--help"):
  78.             usage()
  79.             sys.exit()
  80.         if opt in ("-i", "--inputfile"):
  81.             inputpath = arg
  82.         if opt in ("-o", "outputfile"):
  83.             outputpath = arg
  84.     if inputpath == None:
  85.         usage()
  86.         sys.exit()
  87.     if outputpath == None:
  88.         outputpath = os.getcwd()+"/out.txt"

  89.     inputfile = open(inputpath, 'r')
  90.     outputfile = open(outputpath, 'w')
  91.     get_atime(inputfile)
  92.     inputfile.seek(0)
  93.     calc_delta(inputfile)
  94.     inputfile.close()
  95.     outputfile.close()
  96. if __name__ == "__main__":
  97.     main(sys.argv[1:])



复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-20 12:44 , Processed in 0.025216 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表