Fix: 修复electron下arduino在上传后获取代码区串口波特率出错
This commit is contained in:
@@ -335,6 +335,9 @@ class Serial {
|
|||||||
if (this.isOpened()) {
|
if (this.isOpened()) {
|
||||||
await this.close();
|
await this.close();
|
||||||
}
|
}
|
||||||
|
this.#events_ = null;
|
||||||
|
this.#encoder_ = null;
|
||||||
|
this.#decoder_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
bind(type, func) {
|
bind(type, func) {
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ ArduShell.upload = (boardType, port) => {
|
|||||||
statusBarSerial.open()
|
statusBarSerial.open()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const baudRates = code.match(/(?<=Serial.begin[\s]*\([\s]*)[0-9]*(?=[\s]*\))/g);
|
const baudRates = code.match(/(?<=Serial.begin[\s]*\([\s]*)[0-9]*(?=[\s]*\))/g);
|
||||||
if (!baudRates.length) {
|
if (!baudRates?.length) {
|
||||||
statusBarSerial.setBaudRate(9600);
|
statusBarSerial.setBaudRate(9600);
|
||||||
} else {
|
} else {
|
||||||
statusBarSerial.setBaudRate(baudRates[0] - 0);
|
statusBarSerial.setBaudRate(baudRates[0] - 0);
|
||||||
|
|||||||
@@ -258,6 +258,13 @@ class ElectronSerial extends Serial {
|
|||||||
super.onChar(char);
|
super.onChar(char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async dispose() {
|
||||||
|
await super.dispose();
|
||||||
|
this.#parserBytes_ = null;
|
||||||
|
this.#parserLine_ = null;
|
||||||
|
this.#serialport_ = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Electron.Serial = ElectronSerial;
|
Electron.Serial = ElectronSerial;
|
||||||
|
|||||||
Reference in New Issue
Block a user