feat(tools): flash_run 内置守候循环
This commit is contained in:
1 parent
31571b54ef
commit
14cd3277de
2 files changed
+19
-8
No files matched your search
+18
-8
@@ -82,14 +82,24 @@ async def main():
|
||||
if msg["block"] % 20 == 0 or msg["block"] == msg["total"]:
|
||||
print(f"[{el:6.1f}s] 块确认(2) {msg['block']}/{msg['total']}", flush=True)
|
||||
|
||||
async with BridgeTransport(address=DEVICE, timeout=45, subscribe=False,
|
||||
host=HOST, port=PORT) as t:
|
||||
print("已连接(净连接),开始全量烧录...", flush=True)
|
||||
log({"kind": "connected", "device": DEVICE})
|
||||
# BridgeTransport.run_ota 不支持 gpio_map 参数,直接发 RPC
|
||||
result = await ota_with_gpio(HOST, PORT, image, GPIO, prog)
|
||||
print(f"[{time.time() - t0:6.1f}s] 最终结果: {result}", flush=True)
|
||||
log({"kind": "run_end", "result": result, "stats": stats})
|
||||
# 守候清醒窗口(设备无唤醒按钮、自动周期醒)
|
||||
for attempt in range(20):
|
||||
try:
|
||||
async with BridgeTransport(address=DEVICE, timeout=30, subscribe=False,
|
||||
host=HOST, port=PORT) as t:
|
||||
print(f"已连接(第 {attempt + 1} 次尝试),开始全量烧录...", flush=True)
|
||||
log({"kind": "connected", "device": DEVICE, "attempt": attempt + 1})
|
||||
result = await ota_with_gpio(HOST, PORT, image, GPIO, prog)
|
||||
print(f"[{time.time() - t0:6.1f}s] 最终结果: {result}", flush=True)
|
||||
log({"kind": "run_end", "result": result, "stats": stats})
|
||||
break
|
||||
except Exception as e:
|
||||
print(f" 等待设备唤醒...({attempt + 1}/20) {type(e).__name__}", flush=True)
|
||||
await asyncio.sleep(15)
|
||||
else:
|
||||
print("设备持续未醒,放弃", flush=True)
|
||||
log({"kind": "run_abort", "reason": "device_never_awake"})
|
||||
return
|
||||
print(f"=== 状态统计: {stats} ===", flush=True)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user