mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 14:25:14 +03:00
Fixed lockup on failed 'flash on connect' operation. Also removed persisting of 'flash on connect' option since it can lead to accidental flasing.
This commit is contained in:
parent
6a282565ed
commit
b9b0ae542d
2 changed files with 52 additions and 53 deletions
|
@ -748,25 +748,34 @@ STM32_protocol.prototype.upload_procedure = function (step) {
|
||||||
GUI.interval_remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now)
|
GUI.interval_remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now)
|
||||||
|
|
||||||
// close connection
|
// close connection
|
||||||
serial.disconnect(function (result) {
|
if (serial.connectionId) {
|
||||||
PortUsage.reset();
|
serial.disconnect(self.cleanup);
|
||||||
|
} else {
|
||||||
|
self.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
// unlocking connect button
|
|
||||||
GUI.connect_lock = false;
|
|
||||||
|
|
||||||
// unlock some UI elements TODO needs rework
|
|
||||||
$('select[name="release"]').prop('disabled', false);
|
|
||||||
|
|
||||||
// handle timing
|
|
||||||
var timeSpent = new Date().getTime() - self.upload_time_start;
|
|
||||||
|
|
||||||
console.log('Script finished after: ' + (timeSpent / 1000) + ' seconds');
|
|
||||||
|
|
||||||
if (self.callback) self.callback();
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
STM32_protocol.prototype.cleanup = function () {
|
||||||
|
PortUsage.reset();
|
||||||
|
|
||||||
|
// unlocking connect button
|
||||||
|
GUI.connect_lock = false;
|
||||||
|
|
||||||
|
// unlock some UI elements TODO needs rework
|
||||||
|
$('select[name="release"]').prop('disabled', false);
|
||||||
|
|
||||||
|
// handle timing
|
||||||
|
var timeSpent = new Date().getTime() - self.upload_time_start;
|
||||||
|
|
||||||
|
console.log('Script finished after: ' + (timeSpent / 1000) + ' seconds');
|
||||||
|
|
||||||
|
if (self.callback) {
|
||||||
|
self.callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// initialize object
|
// initialize object
|
||||||
var STM32 = new STM32_protocol();
|
var STM32 = new STM32_protocol();
|
||||||
|
|
|
@ -480,46 +480,36 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$('input.flash_manual_baud_rate').change();
|
$('input.flash_manual_baud_rate').change();
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('flash_on_connect', function (result) {
|
$('input.flash_on_connect').change(function () {
|
||||||
if (result.flash_on_connect) {
|
var status = $(this).is(':checked');
|
||||||
$('input.flash_on_connect').prop('checked', true);
|
|
||||||
|
if (status) {
|
||||||
|
var catch_new_port = function () {
|
||||||
|
PortHandler.port_detected('flash_detected_device', function (result) {
|
||||||
|
var port = result[0];
|
||||||
|
|
||||||
|
if (!GUI.connect_lock) {
|
||||||
|
GUI.log('Detected: <strong>' + port + '</strong> - triggering flash on connect');
|
||||||
|
console.log('Detected: ' + port + ' - triggering flash on connect');
|
||||||
|
|
||||||
|
// Trigger regular Flashing sequence
|
||||||
|
GUI.timeout_add('initialization_timeout', function () {
|
||||||
|
$('a.flash_firmware').click();
|
||||||
|
}, 100); // timeout so bus have time to initialize after being detected by the system
|
||||||
|
} else {
|
||||||
|
GUI.log('Detected <strong>' + port + '</strong> - previous device still flashing, please replug to try again');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since current port_detected request was consumed, create new one
|
||||||
|
catch_new_port();
|
||||||
|
}, false, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
catch_new_port();
|
||||||
} else {
|
} else {
|
||||||
$('input.flash_on_connect').prop('checked', false);
|
PortHandler.flush_callbacks();
|
||||||
}
|
}
|
||||||
|
}).change();
|
||||||
$('input.flash_on_connect').change(function () {
|
|
||||||
var status = $(this).is(':checked');
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
var catch_new_port = function () {
|
|
||||||
PortHandler.port_detected('flash_detected_device', function (result) {
|
|
||||||
var port = result[0];
|
|
||||||
|
|
||||||
if (!GUI.connect_lock) {
|
|
||||||
GUI.log('Detected: <strong>' + port + '</strong> - triggering flash on connect');
|
|
||||||
console.log('Detected: ' + port + ' - triggering flash on connect');
|
|
||||||
|
|
||||||
// Trigger regular Flashing sequence
|
|
||||||
GUI.timeout_add('initialization_timeout', function () {
|
|
||||||
$('a.flash_firmware').click();
|
|
||||||
}, 100); // timeout so bus have time to initialize after being detected by the system
|
|
||||||
} else {
|
|
||||||
GUI.log('Detected <strong>' + port + '</strong> - previous device still flashing, please replug to try again');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Since current port_detected request was consumed, create new one
|
|
||||||
catch_new_port();
|
|
||||||
}, false, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
catch_new_port();
|
|
||||||
} else {
|
|
||||||
PortHandler.flush_callbacks();
|
|
||||||
}
|
|
||||||
|
|
||||||
chrome.storage.local.set({'flash_on_connect': status});
|
|
||||||
}).change();
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.storage.local.get('erase_chip', function (result) {
|
chrome.storage.local.get('erase_chip', function (result) {
|
||||||
if (result.erase_chip) {
|
if (result.erase_chip) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue