Compare commits

...

2 Commits

Author SHA1 Message Date
yczpf2019
9bcc49059e fix(ampy): 启用 exitREPL 软复位让设备执行上传的代码 2026-01-24 20:30:25 +08:00
yczpf2019
0c6199d8e4 fix(ampy): 添加 dispose 方法 null 检查防止重复调用报错 2026-01-24 20:28:38 +08:00

View File

@@ -228,9 +228,10 @@ class AmpyExt extends Ampy {
if (!await this.exitRawREPL()) { if (!await this.exitRawREPL()) {
throw new Error(Msg.Lang['ampy.exitRawREPLFailed']); throw new Error(Msg.Lang['ampy.exitRawREPLFailed']);
} }
/*if (!await this.exitREPL()) { // 发送 Ctrl+D 触发软复位,让设备执行上传的 main.py
if (!await this.exitREPL()) {
throw new Error(Msg.Lang['ampy.exitREPLFailed']); throw new Error(Msg.Lang['ampy.exitREPLFailed']);
}*/ }
await this.#device_.close(); await this.#device_.close();
this.#active_ = false; this.#active_ = false;
} }
@@ -417,12 +418,16 @@ class AmpyExt extends Ampy {
async dispose() { async dispose() {
this.#active_ = false; this.#active_ = false;
if (this.#device_) {
await this.#device_.dispose(); await this.#device_.dispose();
this.#device_ = null; this.#device_ = null;
}
if (this.#events_) {
this.#events_.reset(); this.#events_.reset();
this.#events_ = null; this.#events_ = null;
} }
} }
}
Web.Ampy = AmpyExt; Web.Ampy = AmpyExt;