From 6f21db5a0661008c22a17a74d15591e0f83b94c0 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Tue, 19 Jan 2021 21:47:52 +0100 Subject: [PATCH] Check for legacy devices --- src/js/port_handler.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js/port_handler.js b/src/js/port_handler.js index 29c8bf02..6ae190ed 100644 --- a/src/js/port_handler.js +++ b/src/js/port_handler.js @@ -242,12 +242,14 @@ PortHandler.selectPort = function(ports) { for (let i = 0; i < ports.length; i++) { const portName = ports[i].displayName; if (portName) { - if (portName.includes('STM') || portName.includes('CP210')) { - const pathSelect = ports[i].path; - if (OS === 'Windows' || (OS !== 'Windows' && pathSelect.includes('tty'))) { - this.portPickerElement.val(pathSelect); - console.log(`Porthandler detected device ${portName} on port: ${pathSelect}`); - } + const pathSelect = ports[i].path; + const isWindows = (OS === 'Windows'); + const isTty = pathSelect.includes('tty'); + const deviceRecognized = portName.includes('STM') || portName.includes('CP210'); + const legacyDeviceRecognized = portName.includes('usb'); + if (isWindows && deviceRecognized || isTty && (deviceRecognized || legacyDeviceRecognized)) { + this.portPickerElement.val(pathSelect); + console.log(`Porthandler detected device ${portName} on port: ${pathSelect}`); } } }