成功提取oem数据并解析
This commit is contained in:
45
kunlun.py
45
kunlun.py
@@ -236,17 +236,30 @@ def global_def():
|
||||
global time_stamp_start
|
||||
global time_stamp_end
|
||||
global upload
|
||||
global encrypt
|
||||
init_str="WQKL"
|
||||
serial_com=sys.argv[1]
|
||||
b_rate=115200
|
||||
nb_rate=1500000
|
||||
|
||||
arg_num=len(sys.argv)
|
||||
|
||||
if(sys.argv[3]=='upload'):
|
||||
upload=True
|
||||
elif(sys.argv[3]=='download'):
|
||||
upload=False
|
||||
else:
|
||||
if(arg_num==2):
|
||||
if(sys.argv[1].endswith('.bin')):
|
||||
iot_flash_file=sys.argv[1]
|
||||
return
|
||||
elif(arg_num==3):
|
||||
if(sys.argv[1].endswith('.bin')):
|
||||
iot_flash_file=sys.argv[1]
|
||||
encrypt=1
|
||||
return
|
||||
elif(arg_num==5):
|
||||
if(sys.argv[3]=='upload'):
|
||||
upload=True
|
||||
elif(sys.argv[3]=='download'):
|
||||
upload=False
|
||||
iot_flash_file=sys.argv[4]
|
||||
elif(arg_num==4):
|
||||
if(sys.argv[3].endswith('.bin')):
|
||||
if(os.path.exists(sys.argv[3])):
|
||||
# 存在这个文件 是下载
|
||||
@@ -257,12 +270,12 @@ def global_def():
|
||||
else:
|
||||
print("param err.")
|
||||
sys.exit(-1)
|
||||
iot_flash_file=sys.argv[3]
|
||||
if(upload):
|
||||
ram_file=f'bootram_{sys.argv[2]}.bin'
|
||||
else:
|
||||
ram_file=f'{sys.argv[2]}_ram_build.bin'
|
||||
ram_file=os.path.join(bin_path(),ram_file)
|
||||
iot_flash_file=sys.argv[-1]
|
||||
|
||||
|
||||
def print_help():
|
||||
@@ -281,23 +294,19 @@ def print_help():
|
||||
# kunlun.py [com] [kl1/kl3] [upload/download] [upload.bin/download.bin]
|
||||
# kunlun.py [file.bin] <enc>
|
||||
if __name__ == '__main__':
|
||||
if(len(sys.argv)<4):
|
||||
if(len(sys.argv)>=2):
|
||||
if(sys.argv[1].endswith('.bin')):
|
||||
if(len(sys.argv)>=3):
|
||||
enc=1
|
||||
else:
|
||||
enc=0
|
||||
bin_to_hex_file(sys.argv[1],"work/"+sys.argv[1]+".txt",enc)
|
||||
sys.exit(0)
|
||||
print("param too less")
|
||||
print_help()
|
||||
sys.exit(-1)
|
||||
upload=None
|
||||
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
|
||||
encrypt=0
|
||||
global_def()
|
||||
if(iot_flash_file is None):
|
||||
print("param err.")
|
||||
print_help()
|
||||
sys.exit(-1)
|
||||
log_init(calc_log_file_name())
|
||||
if(ram_file is None):
|
||||
bin_to_hex_file(iot_flash_file,calc_hex_name(),encrypt)
|
||||
sys.exit(0)
|
||||
try:
|
||||
ser = serial.Serial(port=serial_com, baudrate=b_rate, timeout=0.3)
|
||||
except Exception:
|
||||
|
Reference in New Issue
Block a user