添加ftm选项 未实现

This commit is contained in:
ranchuan
2024-12-18 15:39:02 +08:00
parent 0b491bde89
commit 5133fcb0fd
3 changed files with 194 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ from bin.bin_to_hex import bin_file_decrypt
from bin.bin_to_hex import clear_tmp
from bin.bin_to_hex import load_flash_info
from bin.base import bin_path
from bin.factory_mode import ftm_handle
def init_send(s_port:serial.Serial, send_str:str):
@@ -182,6 +183,16 @@ def upload_bin(x_modem:xmodem.XMODEM, w_file):
myprint (f"Receiving {w_file} result: {xmodem_send}, consuming time: {(time_stamp_end-time_stamp_start)} s ")
def recv_ser_data_ftm(s_port:serial.Serial,timeout:float=1):
recv_data=bytearray()
while timeout>0:
time.sleep(0.1)
timeout-=0.1
bytes2read = s_port.in_waiting
if(bytes2read>0):
tmp = s_port.read(bytes2read)
recv_data+=tmp
ftm_handle(recv_data)
def getc(size, timeout=1):
@@ -342,6 +353,8 @@ def global_def():
elif(args.console is not None):
iot_flash_file=args.console
function_type='console'
elif(args.ftm):
function_type='ftm'
@@ -362,6 +375,7 @@ def parser_init():
parser.add_argument('-i','--layout_index',action='store',type=int,help='解析接收到的flash文件或转换bin文件时使用的layout不指定则不解析')
parser.add_argument('--b_rate',action='store',type=int,default=115200,help='下载ram程序 上传flash数据 控制台 接收log等 使用的串口波特率')
parser.add_argument('--nb_rate',action='store',type=int,default=1500000,help='下载flash程序使用的串口波特率')
parser.add_argument('--ftm',action='store_true',type=bool,default=False,help='进入工厂模式')
@@ -412,6 +426,9 @@ if __name__ == '__main__':
recv_ser_data(ser)
read_input(ser)
sys.exit(0)
if(function_type=="ftm"):
myprint("此功能尚未实现")
sys.exit(0)
modem = xmodem.XMODEM(getc, putc, mode='xmodem1k')
# 发送启动字符让设备进入xmodem模式