From dd03bef0d75067007c63ef2510561268e1688b02 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Fri, 31 Aug 2018 03:52:51 -0700 Subject: [PATCH 1/3] Show a helpful message when no Port is selected --- app/src/processing/app/SketchController.java | 4 ++++ arduino-core/src/cc/arduino/UploaderUtils.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/SketchController.java b/app/src/processing/app/SketchController.java index 89f1a35167f..392422c5923 100644 --- a/app/src/processing/app/SketchController.java +++ b/app/src/processing/app/SketchController.java @@ -709,6 +709,10 @@ private boolean upload(String suggestedClassName, boolean usingProgrammer) throw UploaderUtils uploaderInstance = new UploaderUtils(); Uploader uploader = uploaderInstance.getUploaderByPreferences(false); + if (uploader == null) { + editor.statusError(tr("Please select a Port before Upload")); + return false; + } EditorConsole.setCurrentEditorConsole(editor.console); diff --git a/arduino-core/src/cc/arduino/UploaderUtils.java b/arduino-core/src/cc/arduino/UploaderUtils.java index ec27b496148..c98928ded25 100644 --- a/arduino-core/src/cc/arduino/UploaderUtils.java +++ b/arduino-core/src/cc/arduino/UploaderUtils.java @@ -50,7 +50,16 @@ public Uploader getUploaderByPreferences(boolean noUploadPort) { BoardPort boardPort = null; if (!noUploadPort) { - boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port")); + String port = PreferencesData.get("serial.port"); + if (port == null || port.isEmpty()) { + return null; + } + boardPort = BaseNoGui.getDiscoveryManager().find(port); + //if (boardPort == null) { + // Is there ever a reason to attempt upload when + // the Port is not found by DiscoveryManager? + //return null; + //} } return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort); From 73875458c16f61285cba11111e40551f26b31296 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Fri, 31 Aug 2018 03:53:27 -0700 Subject: [PATCH 2/3] Change default Port from COM1 to nothing selected --- build/shared/lib/preferences.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index e777627af3d..7e7fd7c381c 100644 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -267,7 +267,8 @@ programmer = arduino:avrispmkii upload.using = bootloader upload.verify = true -serial.port=COM1 +#default port is empty to prevent running AVRDUDE before Port selected (issue #7943) +serial.port= serial.databits=8 serial.stopbits=1 serial.parity=N From 7cd579150f923df552c52de1eba8c3923aeb39ed Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Fri, 31 Aug 2018 04:28:16 -0700 Subject: [PATCH 3/3] Delete leftover comments & question --- arduino-core/src/cc/arduino/UploaderUtils.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arduino-core/src/cc/arduino/UploaderUtils.java b/arduino-core/src/cc/arduino/UploaderUtils.java index c98928ded25..108d7c137b3 100644 --- a/arduino-core/src/cc/arduino/UploaderUtils.java +++ b/arduino-core/src/cc/arduino/UploaderUtils.java @@ -55,11 +55,6 @@ public Uploader getUploaderByPreferences(boolean noUploadPort) { return null; } boardPort = BaseNoGui.getDiscoveryManager().find(port); - //if (boardPort == null) { - // Is there ever a reason to attempt upload when - // the Port is not found by DiscoveryManager? - //return null; - //} } return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);