From 68e1d498081b488a33d60917918d5c70ca285bd3 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Fri, 3 May 2024 13:06:27 +0200 Subject: [PATCH] Rebased --- locales/en/messages.json | 3 + src/js/port_handler.js | 232 +++++++++++--------------------- src/js/serial_backend.js | 123 +++++------------ src/js/tabs/firmware_flasher.js | 21 +-- 4 files changed, 119 insertions(+), 260 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index af923fdb304..a956439b537 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -55,6 +55,9 @@ "portsSelectManual": { "message": "Manual Selection" }, + "portsSelectNone": { + "message": "No connection available" + }, "portsSelectVirtual": { "message": "Virtual Mode (Experimental)", "description": "Configure a Virtual Flight Controller without the need of a physical FC." diff --git a/src/js/port_handler.js b/src/js/port_handler.js index 29b51eefa3d..d61e36bc0af 100644 --- a/src/js/port_handler.js +++ b/src/js/port_handler.js @@ -108,8 +108,8 @@ PortHandler.check_serial_devices = function () { // auto-select port (only during initialization) if (!self.initialPorts) { - self.currentPorts = self.updatePortSelect(self.currentPorts); - self.selectPort(self.currentPorts); + self.updatePortSelect(self.currentPorts); + self.selectActivePort(); self.initialPorts = self.currentPorts; GUI.updateManualPortVisibility(); } else { @@ -121,64 +121,43 @@ PortHandler.check_serial_devices = function () { PortHandler.check_usb_devices = function (callback) { const self = this; - const portSelect = document.querySelector('#port'); chrome.usb.getDevices(usbDevices, function (result) { - const dfuActive = !!portSelect.value.startsWith('DFU'); + const dfuElement = self.portPickerElement.children("[value='DFU']"); if (result.length) { // Found device in DFU mode, add it to the list - if (!dfuActive) { - self.clearOptions(); - - // self.portPickerElement.append($('