Merge pull request #332 from mikeller/fix_flash_on_connect_lockup

Fixed lockup on failed 'flash on connect' operation. Also removed persisting of 'flash on connect' option since it can lead to accidental flasing.
10.3.x-maintenance
Michael Keller 2016-11-04 10:29:00 +13:00 committed by GitHub
commit 28886f8a56
2 changed files with 52 additions and 53 deletions

View File

@ -748,25 +748,34 @@ STM32_protocol.prototype.upload_procedure = function (step) {
GUI.interval_remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now)
// close connection
serial.disconnect(function (result) {
PortUsage.reset();
if (serial.connectionId) {
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;
}
};
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
var STM32 = new STM32_protocol();

View File

@ -480,46 +480,36 @@ TABS.firmware_flasher.initialize = function (callback) {
$('input.flash_manual_baud_rate').change();
});
chrome.storage.local.get('flash_on_connect', function (result) {
if (result.flash_on_connect) {
$('input.flash_on_connect').prop('checked', true);
$('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 {
$('input.flash_on_connect').prop('checked', false);
PortHandler.flush_callbacks();
}
$('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();
});
}).change();
chrome.storage.local.get('erase_chip', function (result) {
if (result.erase_chip) {