From b779c04ceb0e825cf03be757b398d4662da19ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Fri, 30 Aug 2024 00:17:57 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8Dweb=E4=B8=8B=E6=9D=BF?= =?UTF-8?q?=E5=8D=A1=E7=83=A7=E5=BD=95=E5=9B=BA=E4=BB=B6=E5=90=8E=E4=B8=8D?= =?UTF-8?q?=E5=A4=8D=E4=BD=8D=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8ampy?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/deps.json | 1 + common/modules/mixly-modules/web/ampy.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/modules/mixly-modules/deps.json b/common/modules/mixly-modules/deps.json index 7c58c146..4bbd0646 100644 --- a/common/modules/mixly-modules/deps.json +++ b/common/modules/mixly-modules/deps.json @@ -1531,6 +1531,7 @@ "Mixly.Env", "Mixly.Msg", "Mixly.Ampy", + "Mixly.Config", "Mixly.Web" ], "provide": [ diff --git a/common/modules/mixly-modules/web/ampy.js b/common/modules/mixly-modules/web/ampy.js index ae86f7cd..93c06602 100644 --- a/common/modules/mixly-modules/web/ampy.js +++ b/common/modules/mixly-modules/web/ampy.js @@ -5,6 +5,7 @@ goog.require('Mustache'); goog.require('Mixly.Env'); goog.require('Mixly.Msg'); goog.require('Mixly.Ampy'); +goog.require('Mixly.Config'); goog.require('Mixly.Web'); goog.provide('Mixly.Web.Ampy'); @@ -12,6 +13,7 @@ const { Env, Msg, Ampy, + Config, Web } = Mixly; @@ -54,7 +56,7 @@ class AmpyExt extends Ampy { return this.#active_; } - async readUntil(ending, withEnding = true, timeout = 1000) { + async readUntil(ending, withEnding = true, timeout = 5000) { const startTime = Number(new Date()); let nowTime = startTime; let readStr = ''; @@ -152,8 +154,17 @@ class AmpyExt extends Ampy { if (this.isActive()) { return; } + this.#active_ = true; await this.#device_.open(115200); - await this.#device_.sleep(1000); + await this.#device_.sleep(500); + const { SELECTED_BOARD } = Config; + if (SELECTED_BOARD?.serial + && SELECTED_BOARD.serial?.dtr !== undefined + && SELECTED_BOARD.serial?.rts !== undefined) { + const { dtr, rts } = SELECTED_BOARD.serial; + await this.#device_.setDTRAndRTS(dtr, rts); + } + await this.#device_.sleep(500); await this.#device_.sendBuffer([2]); if (!await this.interrupt()) { throw new Error(Msg.Lang['ampy.interruptFailed']); @@ -161,7 +172,6 @@ class AmpyExt extends Ampy { if (!await this.enterRawREPL()) { throw new Error(Msg.Lang['ampy.enterRawREPLFailed']); } - this.#active_ = true; } async exit() {