1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

ugly fix for outstanding call error

This commit is contained in:
cTn 2014-06-09 17:55:21 +02:00
parent 7bdd43fd1c
commit 623c049b5e

View file

@ -349,6 +349,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
var delay = data[1] | (data[2] << 8) | (data[3] << 16); var delay = data[1] | (data[2] << 8) | (data[3] << 16);
setTimeout(function() { setTimeout(function() {
if (data[4] != self.state.dfuUPLOAD_IDLE) {
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x21, address, (address >> 8), (address >> 16), (address >> 24)], function(result) { // problem on this call !! self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x21, address, (address >> 8), (address >> 16), (address >> 24)], function(result) { // problem on this call !!
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) { self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
if (data[4] == self.state.dfuDNBUSY) { if (data[4] == self.state.dfuDNBUSY) {
@ -370,15 +371,24 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
} }
}); });
}); });
} else {
clear_status(function() {
load_read_address();
});
}
}, delay); }, delay);
}); });
} }
function clear_status() { function clear_status(callback) {
self.controlTransfer('out', self.request.CLRSTATUS, 0, 0, 0, 0, function() { self.controlTransfer('out', self.request.CLRSTATUS, 0, 0, 0, 0, function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) { self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
if (data[4] == self.state.dfuIDLE) { if (data[4] == self.state.dfuIDLE) {
if (callback) {
callback();
} else {
read(); read();
}
} else { } else {
clear_status(); clear_status();
} }