feat(core): micropython下串口开启后先等待interrupt结束后再read
This commit is contained in:
@@ -85,6 +85,7 @@ class StatusBarSerial extends PageBase {
|
||||
#$hex_ = null;
|
||||
#opened_ = false;
|
||||
#valueTemp_ = '';
|
||||
#receiveTemp_ = '';
|
||||
#manager_ = null;
|
||||
#output_ = null;
|
||||
#chart_ = null;
|
||||
@@ -253,6 +254,7 @@ class StatusBarSerial extends PageBase {
|
||||
+ `==${Msg.Lang['statusbar.serial.port']} ${portName} ${Msg.Lang['statusbar.serial.close']}==`;
|
||||
this.setValue(output);
|
||||
this.#valueTemp_ = '';
|
||||
this.#receiveTemp_ = '';
|
||||
this.#$sendInput_.val('');
|
||||
this.#$sendInput_.attr('disabled', true);
|
||||
this.#chart_.stop();
|
||||
@@ -274,6 +276,9 @@ class StatusBarSerial extends PageBase {
|
||||
});
|
||||
|
||||
this.#serial_.bind('onChar', (char) => {
|
||||
if (!this.#reading_) {
|
||||
this.#receiveTemp_ += char;
|
||||
}
|
||||
if (!this.#reading_ || this.#output_.hexChecked()) {
|
||||
return;
|
||||
}
|
||||
@@ -453,12 +458,21 @@ class StatusBarSerial extends PageBase {
|
||||
async open() {
|
||||
await this.#serial_.open(this.#config_.baud);
|
||||
if (SELECTED_BOARD?.serial?.ctrlCBtn) {
|
||||
await this.#serial_.sleep(500);
|
||||
await this.#serial_.sleep(1000);
|
||||
await this.#serial_.interrupt();
|
||||
await this.#serial_.sleep(200);
|
||||
const startTime = Number(new Date());
|
||||
let endTime = startTime;
|
||||
while (endTime - startTime < 2000) {
|
||||
await this.#serial_.sleep(50);
|
||||
if (this.#receiveTemp_.indexOf('>>>') !== -1) {
|
||||
break;
|
||||
}
|
||||
endTime = Number(new Date());
|
||||
}
|
||||
this.#valueTemp_ = '';
|
||||
this.empty();
|
||||
this.startRead();
|
||||
this.#receiveTemp_ = '';
|
||||
await this.#serial_.reset();
|
||||
} else {
|
||||
this.startRead();
|
||||
|
||||
Reference in New Issue
Block a user