Skip to content

Commit 0088188

Browse files
committed
Merge branch 'ide-1.5.x' into dev-ide-1.5.x-discovery
Conflicts: app/src/cc/arduino/packages/uploaders/SerialUploader.java app/src/processing/app/Editor.java app/src/processing/app/Sketch.java app/src/processing/app/debug/Uploader.java
2 parents de095c0 + 65c36f2 commit 0088188

File tree

11 files changed

+80
-35
lines changed

11 files changed

+80
-35
lines changed

app/src/cc/arduino/packages/Uploader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ protected Uploader() {
7272
this.notFoundError = false;
7373
}
7474

75-
public abstract boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws RunnerException;
75+
public abstract boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception;
7676

77-
public abstract boolean burnBootloader() throws RunnerException;
77+
public abstract boolean burnBootloader() throws Exception;
7878

7979
public boolean requiresAuthorization() {
8080
return false;
@@ -84,11 +84,11 @@ public String getAuthorizationKey() {
8484
return null;
8585
}
8686

87-
protected boolean executeUploadCommand(Collection<String> command) throws RunnerException {
87+
protected boolean executeUploadCommand(Collection<String> command) throws Exception {
8888
return executeUploadCommand(command.toArray(new String[command.size()]));
8989
}
9090

91-
protected boolean executeUploadCommand(String command[]) throws RunnerException {
91+
protected boolean executeUploadCommand(String command[]) throws Exception {
9292
notFoundError = false;
9393
int result = -1;
9494

app/src/cc/arduino/packages/uploaders/SerialUploader.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import processing.app.debug.RunnerException;
3434
import processing.app.debug.TargetPlatform;
3535
import processing.app.helpers.PreferencesMap;
36+
import processing.app.helpers.PreferencesMapException;
3637
import processing.app.helpers.StringReplacer;
3738

3839
import java.io.File;
@@ -43,12 +44,12 @@
4344

4445
public class SerialUploader extends Uploader {
4546

46-
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws RunnerException {
47+
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
4748
// FIXME: Preferences should be reorganized
4849
TargetPlatform targetPlatform = Base.getTargetPlatform();
4950
PreferencesMap prefs = Preferences.getMap();
5051
prefs.putAll(Base.getBoardPreferences());
51-
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
52+
prefs.putAll(targetPlatform.getTool(prefs.getOrExcept("upload.tool")));
5253

5354
// if no protocol is specified for this board, assume it lacks a
5455
// bootloader and upload using the selected programmer.
@@ -69,7 +70,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
6970
boolean waitForUploadPort = (t != null) && t.equals("true");
7071

7172
if (doTouch) {
72-
String uploadPort = prefs.get("serial.port");
73+
String uploadPort = prefs.getOrExcept("serial.port");
7374
try {
7475
// Toggle 1200 bps on selected serial port to force board reset.
7576
List<String> before = Serial.list();
@@ -105,9 +106,9 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
105106
prefs.put("build.path", buildPath);
106107
prefs.put("build.project_name", className);
107108
if (verbose)
108-
prefs.put("upload.verbose", prefs.get("upload.params.verbose"));
109+
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
109110
else
110-
prefs.put("upload.verbose", prefs.get("upload.params.quiet"));
111+
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
111112

112113
boolean uploadResult;
113114
try {
@@ -116,7 +117,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
116117
// flushSerialBuffer();
117118
// }
118119

119-
String pattern = prefs.get("upload.pattern");
120+
String pattern = prefs.getOrExcept("upload.pattern");
120121
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
121122
uploadResult = executeUploadCommand(cmd);
122123
} catch (Exception e) {
@@ -207,7 +208,7 @@ private String waitForUploadPort(String uploadPort, List<String> before) throws
207208
throw new RunnerException(_("Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload."));
208209
}
209210

210-
public boolean uploadUsingProgrammer(String buildPath, String className) throws RunnerException {
211+
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
211212

212213
TargetPlatform targetPlatform = Base.getTargetPlatform();
213214
String programmer = Preferences.get("programmer");
@@ -220,15 +221,15 @@ public boolean uploadUsingProgrammer(String buildPath, String className) throws
220221
PreferencesMap prefs = Preferences.getMap();
221222
prefs.putAll(Base.getBoardPreferences());
222223
prefs.putAll(targetPlatform.getProgrammer(programmer));
223-
prefs.putAll(targetPlatform.getTool(prefs.get("program.tool")));
224+
prefs.putAll(targetPlatform.getTool(prefs.getOrExcept("program.tool")));
224225

225226
prefs.put("build.path", buildPath);
226227
prefs.put("build.project_name", className);
227228

228229
if (verbose)
229-
prefs.put("program.verbose", prefs.get("program.params.verbose"));
230+
prefs.put("program.verbose", prefs.getOrExcept("program.params.verbose"));
230231
else
231-
prefs.put("program.verbose", prefs.get("program.params.quiet"));
232+
prefs.put("program.verbose", prefs.getOrExcept("program.params.quiet"));
232233

233234
try {
234235
// if (prefs.get("program.disable_flushing") == null
@@ -237,15 +238,15 @@ public boolean uploadUsingProgrammer(String buildPath, String className) throws
237238
// flushSerialBuffer();
238239
// }
239240

240-
String pattern = prefs.get("program.pattern");
241+
String pattern = prefs.getOrExcept("program.pattern");
241242
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
242243
return executeUploadCommand(cmd);
243244
} catch (Exception e) {
244245
throw new RunnerException(e);
245246
}
246247
}
247248

248-
public boolean burnBootloader() throws RunnerException {
249+
public boolean burnBootloader() throws Exception {
249250
TargetPlatform targetPlatform = Base.getTargetPlatform();
250251

251252
// Find preferences for the selected programmer
@@ -267,7 +268,7 @@ public boolean burnBootloader() throws RunnerException {
267268

268269
// Create configuration for bootloader tool
269270
PreferencesMap toolPrefs = new PreferencesMap();
270-
String tool = prefs.get("bootloader.tool");
271+
String tool = prefs.getOrExcept("bootloader.tool");
271272
if (tool.contains(":")) {
272273
String[] split = tool.split(":", 2);
273274
TargetPlatform platform = Base.getCurrentTargetPlatformFromPackage(split[0]);
@@ -283,20 +284,20 @@ public boolean burnBootloader() throws RunnerException {
283284
// Merge tool with global configuration
284285
prefs.putAll(toolPrefs);
285286
if (verbose) {
286-
prefs.put("erase.verbose", prefs.get("erase.params.verbose"));
287-
prefs.put("bootloader.verbose", prefs.get("bootloader.params.verbose"));
287+
prefs.put("erase.verbose", prefs.getOrExcept("erase.params.verbose"));
288+
prefs.put("bootloader.verbose", prefs.getOrExcept("bootloader.params.verbose"));
288289
} else {
289-
prefs.put("erase.verbose", prefs.get("erase.params.quiet"));
290-
prefs.put("bootloader.verbose", prefs.get("bootloader.params.quiet"));
290+
prefs.put("erase.verbose", prefs.getOrExcept("erase.params.quiet"));
291+
prefs.put("bootloader.verbose", prefs.getOrExcept("bootloader.params.quiet"));
291292
}
292293

293294
try {
294-
String pattern = prefs.get("erase.pattern");
295+
String pattern = prefs.getOrExcept("erase.pattern");
295296
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
296297
if (!executeUploadCommand(cmd))
297298
return false;
298299

299-
pattern = prefs.get("bootloader.pattern");
300+
pattern = prefs.getOrExcept("bootloader.pattern");
300301
cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
301302
return executeUploadCommand(cmd);
302303
} catch (Exception e) {

app/src/processing/app/Base.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,10 +1195,15 @@ public LibraryList scanLibraries(File folder) throws IOException {
11951195
continue;
11961196
}
11971197

1198-
Library lib = Library.create(subfolder);
1199-
// (also replace previously found libs with the same name)
1200-
if (lib != null)
1201-
res.addOrReplace(lib);
1198+
try {
1199+
Library lib = Library.create(subfolder);
1200+
// (also replace previously found libs with the same name)
1201+
if (lib != null)
1202+
res.addOrReplace(lib);
1203+
} catch (IOException e) {
1204+
System.out.println(I18n.format(_("Invalid library found in {0}: {1}"),
1205+
subfolder, e.getMessage()));
1206+
}
12021207
}
12031208
return res;
12041209
}

app/src/processing/app/Editor.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.jcraft.jsch.JSchException;
2727
import processing.app.debug.*;
2828
import processing.app.forms.PasswordAuthorizationDialog;
29+
import processing.app.helpers.PreferencesMapException;
2930
import processing.app.syntax.*;
3031
import processing.app.tools.*;
3132
import processing.core.*;
@@ -2403,6 +2404,10 @@ public void run() {
24032404
if (serialMenu.getItemCount() == 0) statusError(e);
24042405
else if (serialPrompt()) run();
24052406
else statusNotice(_("Upload canceled."));
2407+
} catch (PreferencesMapException e) {
2408+
statusError(I18n.format(
2409+
_("Error while uploading: missing '{0}' configuration parameter"),
2410+
e.getMessage()));
24062411
} catch (RunnerException e) {
24072412
//statusError("Error during upload.");
24082413
//e.printStackTrace();
@@ -2439,6 +2444,10 @@ public void run() {
24392444
if (serialMenu.getItemCount() == 0) statusError(e);
24402445
else if (serialPrompt()) run();
24412446
else statusNotice(_("Upload canceled."));
2447+
} catch (PreferencesMapException e) {
2448+
statusError(I18n.format(
2449+
_("Error while uploading: missing '{0}' configuration parameter"),
2450+
e.getMessage()));
24422451
} catch (RunnerException e) {
24432452
//statusError("Error during upload.");
24442453
//e.printStackTrace();
@@ -2541,9 +2550,10 @@ public void run() {
25412550
statusError(_("Error while burning bootloader."));
25422551
// error message will already be visible
25432552
}
2544-
} catch (RunnerException e) {
2545-
statusError(_("Error while burning bootloader."));
2546-
e.printStackTrace();
2553+
} catch (PreferencesMapException e) {
2554+
statusError(I18n.format(
2555+
_("Error while burning bootloader: missing '{0}' configuration parameter"),
2556+
e.getMessage()));
25472557
//statusError(e);
25482558
} catch (Exception e) {
25492559
statusError(_("Error while burning bootloader."));

app/src/processing/app/Sketch.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package processing.app;
2525

2626
import cc.arduino.packages.UploaderAndMonitorFactory;
27-
import org.apache.commons.codec.digest.DigestUtils;
2827

2928
import cc.arduino.packages.Uploader;
3029
import processing.app.debug.*;
@@ -1583,7 +1582,7 @@ protected boolean exportApplet(boolean usingProgrammer) throws Exception {
15831582
* Handle export to applet.
15841583
*/
15851584
public boolean exportApplet(String appletPath, boolean usingProgrammer)
1586-
throws RunnerException, IOException {
1585+
throws Exception {
15871586

15881587
prepare();
15891588

@@ -1661,7 +1660,7 @@ protected void size(PreferencesMap prefs) throws RunnerException {
16611660
System.out.println(_("Low memory available, stability problems may occur"));
16621661
}
16631662

1664-
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws RunnerException {
1663+
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
16651664

16661665
TargetPlatform target = Base.getTargetPlatform();
16671666
String board = Preferences.get("board");

app/src/processing/app/helpers/PreferencesMap.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,22 @@ public String toString(String indent) {
245245
return res;
246246
}
247247

248+
/**
249+
* Returns the value to which the specified key is mapped, or throws a
250+
* PreferencesMapException if not found
251+
*
252+
* @param k
253+
* the key whose associated value is to be returned
254+
* @return the value to which the specified key is mapped
255+
* @throws PreferencesMapException
256+
*/
257+
public String getOrExcept(String k) throws PreferencesMapException {
258+
String r = get(k);
259+
if (r == null)
260+
throw new PreferencesMapException(k);
261+
return r;
262+
}
263+
248264
@Override
249265
public String toString() {
250266
return toString("");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package processing.app.helpers;
2+
3+
@SuppressWarnings("serial")
4+
public class PreferencesMapException extends Exception {
5+
6+
public PreferencesMapException(String message) {
7+
super(message);
8+
}
9+
10+
}

build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plays a pitch that changes based on a changing analog input
55
66
circuit:
7-
* 8-ohm speaker on digital pin 8
7+
* 8-ohm speaker on digital pin 9
88
* photoresistor on analog 0 to 5V
99
* 4.7K resistor on analog 0 to ground
1010

build/shared/revisions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ARDUINO 1.5.3 BETA
1717
* avr: Added support for Flash strings on String class (Jantje)
1818
* Added support for floating point numbers in String class (Tevin Zhang, SebiTimeWaster)
1919
* sam: Fixed String buffer overflows (Paul Stoffregen)
20+
* avr: Added recipe for assembly files (C. A. Church)
2021

2122
[libraries]
2223
* sam: Added CAN library (still in early stage of development) (Palliser)

hardware/arduino/avr/libraries/SoftwareSerial/keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#######################################
22
# Syntax Coloring Map for SoftwareSerial
3-
# (formely NewSoftSerial)
3+
# (formerly NewSoftSerial)
44
#######################################
55

66
#######################################

0 commit comments

Comments
 (0)