Skip to content

Commit 6f754fb

Browse files
committed
fix montor not working after upload
1 parent bf33fa2 commit 6f754fb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/plugins/uploader/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import store from '../../store';
44
// import avrdude from './stk500';
55
import avrdude from './avrgirl';
66

7+
const asyncTimeout = (timeout) => new Promise((resolve) => setTimeout(() => resolve(timeout), timeout));
8+
79
class Uploader extends EventEmitter {
810
install(Vue) {
911
// eslint-disable-next-line no-param-reassign
@@ -23,6 +25,12 @@ class Uploader extends EventEmitter {
2325
return !!get(this.toolMap, toolProt) && get(this.toolMap, tool).isValid(board);
2426
}
2527

28+
async waitForClose(serial, count = 0) {
29+
if (!serial.serial.isOpen || count > 50) return null;
30+
await asyncTimeout(100);
31+
return this.waitForClose(serial, count + 1);
32+
}
33+
2634
async upload(hex, config) {
2735
const serial = this.Vue.$serial;
2836
const existBaud = serial.baud;
@@ -40,6 +48,7 @@ class Uploader extends EventEmitter {
4048
debug: (message) => this.Vue.$compiler.emit('console.log', message),
4149
});
4250

51+
await this.waitForClose(serial);
4352
await serial.setBaud(existBaud);
4453
await serial.connect();
4554
await serial.setMute(false);

0 commit comments

Comments
 (0)