[UWP] Fix infinite spin when downloading without device plugged (#1500)
* [UWP] Fix infinite spin when downloading without device plugged * Undo format changes * Undo format changes
This commit is contained in:
parent
a7e613c237
commit
52bd7bd146
@ -117,16 +117,18 @@ namespace pxt.editor {
|
||||
|
||||
reconnectAsync(first: boolean) {
|
||||
// configure serial at 115200
|
||||
if (!first)
|
||||
return this.packetIo.reconnectAsync()
|
||||
.then(() => this.allocDAP())
|
||||
let p = Promise.resolve();
|
||||
if (!first) {
|
||||
p = this.packetIo.reconnectAsync()
|
||||
.then(() => this.allocDAP());
|
||||
}
|
||||
|
||||
return p
|
||||
.then(() => this.cortexM.init())
|
||||
.then(() => this.cmsisdap.cmdNums(0x82, [0x00, 0xC2, 0x01, 0x00]))
|
||||
.then(() => { }, err => { this.useSerial = false })
|
||||
else
|
||||
return this.cortexM.init()
|
||||
.then(() => this.cmsisdap.cmdNums(0x82, [0x00, 0xC2, 0x01, 0x00]))
|
||||
.then(() => { }, err => { this.useSerial = false })
|
||||
.then(() => {
|
||||
return this.cmsisdap.cmdNums(0x82, [0x00, 0xC2, 0x01, 0x00])
|
||||
.then(() => { this.useSerial = true }, (err: any) => { this.useSerial = false; });
|
||||
});
|
||||
}
|
||||
|
||||
disconnectAsync() {
|
||||
@ -157,7 +159,8 @@ namespace pxt.editor {
|
||||
let previousDapWrapper: DAPWrapper;
|
||||
function dapAsync() {
|
||||
if (previousDapWrapper)
|
||||
return Promise.resolve(previousDapWrapper)
|
||||
return previousDapWrapper.reconnectAsync(false) // Always fully reconnect to handle device unplugged mid-session
|
||||
.then(() => previousDapWrapper);
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (previousDapWrapper) {
|
||||
|
Loading…
Reference in New Issue
Block a user