From b37c492930f023ff58b5617cb60a7bdc3a3ceec1 Mon Sep 17 00:00:00 2001 From: linyimin <18316471919@139.com> Date: Tue, 30 Dec 2025 15:49:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=204g=E6=A8=A1=E5=9D=97=E6=8C=89=E8=A1=8C?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 4cb9503..729b974 100644 --- a/main.py +++ b/main.py @@ -335,7 +335,7 @@ class ATClient: # OTA 升级地址与本地路径 # url = "https://static.shelingxingqiu.com/shoot/202511031031/main.py" local_filename = "/maixapp/apps/t11/main_tmp.py" -app_version = '1.0.0' +app_version = '1.0.2' # OTA 下发参数(由后端指令写入) OTA_URL = None OTA_MODE = None # "4g" / "wifi" / None @@ -1017,7 +1017,7 @@ def connect_server(): return True return False - +raw_line_data = [] def tcp_main(): """TCP 主通信循环:登录、心跳、处理指令、发送数据""" global tcp_connected, high_send_queue, normal_send_queue, queue_lock, laser_calibration_active, laser_calibration_result, laser_calibration_lock, update_thread_started @@ -1089,6 +1089,21 @@ def tcp_main(): last_heartbeat_ack_time = time.ticks_ms() print("✅ 收到心跳确认") + elif logged_in and msg_type == 40: + if isinstance(body, dict): + t = body.get('t', 0) + v = body.get('v') + raw_line_data.append(body) + if len(raw_line_data) >= int(t): + print(f"下载完成") + stock_array = list(map(lambda x: x.get('d'), raw_line_data)) + with open(local_filename, 'w', encoding='utf-8') as file: + file.write("\n".join(stock_array)) + apply_ota_and_reboot() + else: + safe_enqueue({'data':{'l': len(raw_line_data), 'v': v}, 'cmd': 41}) + print(f"已下载{len(raw_line_data)} 全部:{t} 版本:{v}") + # 处理业务指令 elif logged_in and isinstance(body, dict): # 重要:每个包都要重新解析 inner_cmd,避免上一次的 cmd “粘住”导致反复执行 @@ -1831,6 +1846,6 @@ if __name__ == "__main__": # print("has lock") # finally: # pass - import config - print("env: ", config.get_env()) + # import config + # print("env: ", config.get_env()) cmd_str() \ No newline at end of file