添加提取bin文件中log的功能

This commit is contained in:
ranchuan
2025-05-30 14:35:09 +08:00
parent e1fbee6ef1
commit 285f9a516e
2 changed files with 122 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ from bin.bin_to_hex import check_bin_type
from bin.base import bin_path
from bin.factory_mode import ftm_handle
from bin.crc import CRC16
from bin.get_log import print_log
def init_send(s_port:serial.Serial, send_str:str):
@@ -379,6 +380,7 @@ def global_def():
global layout_index
global log_file
global skip_ram
global extract_log
args = parser.parse_args()
init_str="WQKL"
@@ -389,6 +391,7 @@ def global_def():
log_timeout=args.timeout
layout_index=args.layout_index
skip_ram=args.skip_ram
extract_log=args.extract_log
# 上传或者下载flash镜像
@@ -464,6 +467,7 @@ def parser_init():
parser.add_argument('--ftm',action='store_true',default=False,help='进入工厂模式')
parser.add_argument('--list',action='store_true',default=False,help='列出所有.bin文件')
parser.add_argument('--skip_ram',action='store_true',default=False,help='下载flash文件时是否跳过下载ram.bin的步骤默认否')
parser.add_argument('--extract_log',action='store_true',default=False,help='是否提取bin中的log信息默认否')
@@ -481,7 +485,7 @@ if __name__ == '__main__':
function_type=None # 功能类型 "download" 下载,"upload" 上传,"ram" 下载ram"convert"" 转换bin
time_stamp_start, time_stamp_end = 0, 0
init_str, serial_com, b_rate, nb_rate, ram_file, iot_flash_file, ser = None, None, None, None, None, None, None
upload_key, parser, layout_index, log_file=None, None, None, None
upload_key, parser, layout_index, log_file, extract_log=None, None, None, None, False
user_log=False
log_timeout=0
skip_ram=False
@@ -494,6 +498,8 @@ if __name__ == '__main__':
log_init(calc_log_file_name())
if(function_type=='convert'):
bin_to_hex_file(iot_flash_file,calc_hex_name(),layout_index)
if(extract_log):
print_log(iot_flash_file)
sys.exit(0)
if(function_type=="list"):
l=list_bin_file()
@@ -526,6 +532,8 @@ if __name__ == '__main__':
if(function_type=='upload'):
upload_fun()
if(extract_log):
print_log(calc_upload_name())
elif(function_type=='download'):
burn_fun()
clear_tmp()