commit
6093e7aa71
|
@ -23,6 +23,9 @@ PortHandler.initialize = function () {
|
|||
this.selectList = document.querySelector(portPickerElementSelector);
|
||||
this.initialWidth = this.selectList.offsetWidth + 12;
|
||||
|
||||
this.showVirtualMode = ConfigStorage.get('showVirtualMode').showVirtualMode;
|
||||
this.showAllSerialDevices = ConfigStorage.get('showAllSerialDevices').showAllSerialDevices;
|
||||
|
||||
// fill dropdown with version numbers
|
||||
generateVirtualApiVersions();
|
||||
|
||||
|
@ -32,17 +35,14 @@ PortHandler.initialize = function () {
|
|||
|
||||
PortHandler.check = function () {
|
||||
const self = this;
|
||||
let result;
|
||||
|
||||
result = ConfigStorage.get('showVirtualMode');
|
||||
self.showVirtualMode = result.showVirtualMode;
|
||||
result = ConfigStorage.get('showAllSerialDevices');
|
||||
self.showAllSerialDevices = result.showAllSerialDevices;
|
||||
if (!self.port_available) {
|
||||
self.check_usb_devices();
|
||||
}
|
||||
|
||||
self.check_usb_devices();
|
||||
self.check_serial_devices();
|
||||
|
||||
GUI.updateManualPortVisibility();
|
||||
if (!self.dfu_available) {
|
||||
self.check_serial_devices();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
self.check();
|
||||
|
@ -87,14 +87,6 @@ PortHandler.check_usb_devices = function (callback) {
|
|||
data: {isDFU: true},
|
||||
}));
|
||||
|
||||
if (self.showVirtualMode) {
|
||||
self.portPickerElement.append($('<option/>', {
|
||||
value: 'virtual',
|
||||
text: i18n.getMessage('portsSelectVirtual'),
|
||||
data: {isVirtual: true},
|
||||
}));
|
||||
}
|
||||
|
||||
self.portPickerElement.append($('<option/>', {
|
||||
value: 'manual',
|
||||
text: i18n.getMessage('portsSelectManual'),
|
||||
|
@ -112,14 +104,16 @@ PortHandler.check_usb_devices = function (callback) {
|
|||
}
|
||||
self.dfu_available = false;
|
||||
}
|
||||
if(callback) {
|
||||
if (callback) {
|
||||
callback(self.dfu_available);
|
||||
}
|
||||
if (!$('option:selected', self.portPickerElement).data().isDFU) {
|
||||
if (!(GUI.connected_to || GUI.connect_lock)) {
|
||||
FC.resetState();
|
||||
}
|
||||
self.portPickerElement.trigger('change');
|
||||
if (self.dfu_available) {
|
||||
self.portPickerElement.trigger('change');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -159,6 +153,7 @@ PortHandler.removePort = function(currentPorts) {
|
|||
self.initialPorts.splice(self.initialPorts.indexOf(removePorts[i]), 1);
|
||||
}
|
||||
self.updatePortSelect(self.initialPorts);
|
||||
self.portPickerElement.trigger('change');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -188,6 +183,8 @@ PortHandler.detectPort = function(currentPorts) {
|
|||
TABS.firmware_flasher.boardNeedsVerification = true;
|
||||
}
|
||||
|
||||
self.portPickerElement.trigger('change');
|
||||
|
||||
// auto-connect if enabled
|
||||
if (GUI.auto_connect && !GUI.connecting_to && !GUI.connected_to) {
|
||||
// start connect procedure. We need firmware flasher protection over here
|
||||
|
@ -269,7 +266,7 @@ PortHandler.selectPort = function(ports) {
|
|||
const pathSelect = ports[i].path;
|
||||
const isWindows = (OS === 'Windows');
|
||||
const isTty = pathSelect.includes('tty');
|
||||
const deviceRecognized = portName.includes('STM') || portName.includes('CP210');
|
||||
const deviceRecognized = portName.includes('STM') || portName.includes('CP210') || portName.startsWith('SPR');
|
||||
const legacyDeviceRecognized = portName.includes('usb');
|
||||
if (isWindows && deviceRecognized || isTty && (deviceRecognized || legacyDeviceRecognized)) {
|
||||
this.portPickerElement.val(pathSelect);
|
||||
|
@ -295,7 +292,7 @@ PortHandler.setPortsInputWidth = function() {
|
|||
return max;
|
||||
}
|
||||
|
||||
const correction = 24; // account for up/down button and spacing
|
||||
const correction = 32; // account for up/down button and spacing
|
||||
let width = findMaxLengthOption(this.selectList) + correction;
|
||||
|
||||
width = (width > this.initialWidth) ? width : this.initialWidth;
|
||||
|
|
|
@ -5,7 +5,7 @@ let connectionTimestamp;
|
|||
let clicks = false;
|
||||
|
||||
function initializeSerialBackend() {
|
||||
GUI.updateManualPortVisibility = function(){
|
||||
GUI.updateManualPortVisibility = function() {
|
||||
const selected_port = $('div#port-picker #port option:selected');
|
||||
if (selected_port.data().isManual) {
|
||||
$('#port-override-option').show();
|
||||
|
@ -19,12 +19,8 @@ function initializeSerialBackend() {
|
|||
else {
|
||||
$('#firmware-virtual-option').hide();
|
||||
}
|
||||
if (selected_port.data().isDFU) {
|
||||
$('select#baud').hide();
|
||||
}
|
||||
else {
|
||||
$('select#baud').show();
|
||||
}
|
||||
|
||||
$('#auto-connect-and-baud').toggle(!selected_port.data().isDFU);
|
||||
};
|
||||
|
||||
GUI.updateManualPortVisibility();
|
||||
|
|
|
@ -847,15 +847,24 @@ firmware_flasher.initialize = function (callback) {
|
|||
if (String(portPickerElement.val()) !== '0') {
|
||||
const port = String(portPickerElement.val());
|
||||
let baud = 115200;
|
||||
|
||||
if ($('input.flash_manual_baud').is(':checked')) {
|
||||
baud = parseInt($('#flash_manual_baud_rate').val());
|
||||
}
|
||||
|
||||
GUI.log(i18n.getMessage('firmwareFlasherDetectBoardQuery'));
|
||||
if (!(serial.connected || serial.connectionId)) {
|
||||
serial.connect(port, {bitrate: baud}, onConnect);
|
||||
|
||||
const isLoaded = self.releases ? Object.keys(self.releases).length > 0 : false;
|
||||
|
||||
if (isLoaded) {
|
||||
if (!(serial.connected || serial.connectionId)) {
|
||||
serial.connect(port, {bitrate: baud}, onConnect);
|
||||
} else {
|
||||
console.warn('Attempting to connect while there still is a connection', serial.connected, serial.connectionId);
|
||||
serial.disconnect();
|
||||
}
|
||||
} else {
|
||||
console.warn('Attempting to connect while there still is a connection', serial.connected, serial.connectionId);
|
||||
serial.disconnect();
|
||||
console.log('Releases not loaded yet');
|
||||
}
|
||||
} else {
|
||||
GUI.log(i18n.getMessage('firmwareFlasherNoValidPort'));
|
||||
|
@ -864,32 +873,24 @@ firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
|
||||
const detectBoardElement = $('a.detect-board');
|
||||
let isClickable = true;
|
||||
|
||||
detectBoardElement.on('click', () => {
|
||||
detectBoardElement.addClass('disabled');
|
||||
|
||||
if (isClickable) {
|
||||
isClickable = false;
|
||||
verifyBoard();
|
||||
setTimeout(() => isClickable = true, 1000);
|
||||
}
|
||||
verifyBoard();
|
||||
|
||||
setTimeout(() => detectBoardElement.removeClass('disabled'), 1000);
|
||||
});
|
||||
|
||||
function updateDetectBoardButton() {
|
||||
const isDfu = portPickerElement.val().includes('DFU');
|
||||
const isDfu = PortHandler.dfu_available;
|
||||
const isBusy = GUI.connect_lock;
|
||||
const isLoaded = self.releases ? Object.keys(self.releases).length > 0 : false;
|
||||
const isAvailable = PortHandler.port_available || false;
|
||||
const isButtonDisabled = isDfu || isBusy || !isLoaded || !isAvailable;
|
||||
const isAvailable = PortHandler.port_available;
|
||||
const isButtonDisabled = isDfu || isBusy || !isAvailable;
|
||||
|
||||
detectBoardElement.toggleClass('disabled', isButtonDisabled);
|
||||
}
|
||||
|
||||
document.querySelector('select[name="build_type"]').addEventListener('change', updateDetectBoardButton);
|
||||
document.querySelector('select[name="board"]').addEventListener('change', updateDetectBoardButton);
|
||||
document.querySelector('select[name="firmware_version"]').addEventListener('change', updateDetectBoardButton);
|
||||
|
||||
let result = ConfigStorage.get('erase_chip');
|
||||
if (result.erase_chip) {
|
||||
$('input.erase_chip').prop('checked', true);
|
||||
|
@ -1114,11 +1115,14 @@ firmware_flasher.initialize = function (callback) {
|
|||
});
|
||||
|
||||
const exitDfuElement = $('a.exit_dfu');
|
||||
|
||||
exitDfuElement.click(function () {
|
||||
if (!$(this).hasClass('disabled')) {
|
||||
if (!exitDfuElement.hasClass('disabled')) {
|
||||
exitDfuElement.addClass("disabled");
|
||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLASHING, 'ExitDfu', null);
|
||||
try {
|
||||
console.log('Closing DFU');
|
||||
STM32DFU.connect(usbDevices, self.parsed_hex, { exitDfu: true });
|
||||
} catch (e) {
|
||||
console.log(`Exiting DFU failed: ${e.message}`);
|
||||
|
@ -1127,25 +1131,27 @@ firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
portPickerElement.change(function () {
|
||||
if (!GUI.connect_lock) {
|
||||
if ($('option:selected', this).data().isDFU) {
|
||||
exitDfuElement.removeClass('disabled');
|
||||
} else {
|
||||
// Porthandler resets board on port detect
|
||||
if (self.boardNeedsVerification) {
|
||||
// reset to prevent multiple calls
|
||||
self.boardNeedsVerification = false;
|
||||
verifyBoard();
|
||||
}
|
||||
portPickerElement.on('change', function () {
|
||||
if (GUI.active_tab === 'firmware_flasher') {
|
||||
if (!GUI.connect_lock) {
|
||||
if ($('option:selected', this).data().isDFU) {
|
||||
exitDfuElement.removeClass('disabled');
|
||||
} else {
|
||||
// Porthandler resets board on port detect
|
||||
if (self.boardNeedsVerification) {
|
||||
// reset to prevent multiple calls
|
||||
self.boardNeedsVerification = false;
|
||||
verifyBoard();
|
||||
}
|
||||
|
||||
$("a.load_remote_file").removeClass('disabled');
|
||||
$("a.load_file").removeClass('disabled');
|
||||
exitDfuElement.addClass('disabled');
|
||||
$("a.load_remote_file").removeClass('disabled');
|
||||
$("a.load_file").removeClass('disabled');
|
||||
exitDfuElement.addClass('disabled');
|
||||
}
|
||||
}
|
||||
updateDetectBoardButton();
|
||||
}
|
||||
updateDetectBoardButton();
|
||||
}).change();
|
||||
}).trigger('change');
|
||||
|
||||
$('a.flash_firmware').click(function () {
|
||||
if (!$(this).hasClass('disabled')) {
|
||||
|
@ -1214,6 +1220,7 @@ firmware_flasher.initialize = function (callback) {
|
|||
|
||||
function startFlashing() {
|
||||
exitDfuElement.addClass('disabled');
|
||||
$('a.flash_firmware').addClass('disabled');
|
||||
$("a.load_remote_file").addClass('disabled');
|
||||
$("a.load_file").addClass('disabled');
|
||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||
|
|
Loading…
Reference in New Issue