[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:
Guillaume Jenkins 2018-10-23 12:40:24 -04:00 committed by GitHub
parent a7e613c237
commit 52bd7bd146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,16 +117,18 @@ namespace pxt.editor {
reconnectAsync(first: boolean) {
// configure serial at 115200
if (!first)
return this.packetIo.reconnectAsync()
.then(() => this.allocDAP())
.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 })
let p = Promise.resolve();
if (!first) {
p = this.packetIo.reconnectAsync()
.then(() => this.allocDAP());
}
return p
.then(() => this.cortexM.init())
.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) {
@ -648,7 +651,7 @@ namespace pxt.editor {
converts to
<block type="radio_on_number" x="196" y="208">
<block type="radio_on_number" x="196" y="208">
<field name="HANDLER_receivedNumber" id="DCy(W;1)*jLWQUpoy4Mm" variabletype="">receivedNumber</field>
</block>
<block type="radio_on_value" x="134" y="408">