mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
Merge branch 'master' into new-extension
This commit is contained in:
@ -41,9 +41,9 @@ import processing.core.*;
|
||||
* files and images, etc) that comes from that.
|
||||
*/
|
||||
public class Base {
|
||||
public static final int REVISION = 21;
|
||||
public static final int REVISION = 22;
|
||||
/** This might be replaced by main() if there's a lib/version.txt file. */
|
||||
static String VERSION_NAME = "0021";
|
||||
static String VERSION_NAME = "0022";
|
||||
/** Set true if this a proper release rather than a numbered revision. */
|
||||
static public boolean RELEASE = false;
|
||||
|
||||
|
@ -898,23 +898,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
//public SerialMenuListener() { }
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(serialMenu == null) {
|
||||
System.out.println("serialMenu is null");
|
||||
return;
|
||||
}
|
||||
int count = serialMenu.getItemCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
((JCheckBoxMenuItem)serialMenu.getItem(i)).setState(false);
|
||||
}
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource();
|
||||
item.setState(true);
|
||||
String name = item.getText();
|
||||
//System.out.println(item.getLabel());
|
||||
Preferences.set("serial.port", name);
|
||||
serialMonitor.closeSerialPort();
|
||||
serialMonitor.setVisible(false);
|
||||
serialMonitor = new SerialMonitor(Preferences.get("serial.port"));
|
||||
//System.out.println("set to " + get("serial.port"));
|
||||
selectSerialPort(((JCheckBoxMenuItem)e.getSource()).getText());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -929,7 +913,35 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
protected void selectSerialPort(String name) {
|
||||
if(serialMenu == null) {
|
||||
System.out.println("serialMenu is null");
|
||||
return;
|
||||
}
|
||||
if (name == null) {
|
||||
System.out.println("name is null");
|
||||
return;
|
||||
}
|
||||
JCheckBoxMenuItem selection = null;
|
||||
for (int i = 0; i < serialMenu.getItemCount(); i++) {
|
||||
JCheckBoxMenuItem item = ((JCheckBoxMenuItem)serialMenu.getItem(i));
|
||||
if (item == null) {
|
||||
System.out.println("name is null");
|
||||
continue;
|
||||
}
|
||||
item.setState(false);
|
||||
if (name.equals(item.getText())) selection = item;
|
||||
}
|
||||
if (selection != null) selection.setState(true);
|
||||
//System.out.println(item.getLabel());
|
||||
Preferences.set("serial.port", name);
|
||||
serialMonitor.closeSerialPort();
|
||||
serialMonitor.setVisible(false);
|
||||
serialMonitor = new SerialMonitor(Preferences.get("serial.port"));
|
||||
//System.out.println("set to " + get("serial.port"));
|
||||
}
|
||||
|
||||
|
||||
protected void populateSerialMenu() {
|
||||
// getting list of ports
|
||||
|
||||
@ -2269,6 +2281,31 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean serialPrompt() {
|
||||
populateSerialMenu();
|
||||
int count = serialMenu.getItemCount();
|
||||
Object[] names = new Object[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
names[i] = ((JCheckBoxMenuItem)serialMenu.getItem(i)).getText();
|
||||
}
|
||||
|
||||
String result = (String)
|
||||
JOptionPane.showInputDialog(this,
|
||||
"Serial port " +
|
||||
Preferences.get("serial.port") +
|
||||
" not found.\n" +
|
||||
"Retry the upload with another serial port?",
|
||||
"Serial port not found",
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
null,
|
||||
names,
|
||||
0);
|
||||
if (result == null) return false;
|
||||
selectSerialPort(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -2311,6 +2348,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} else {
|
||||
// error message will already be visible
|
||||
}
|
||||
} catch (SerialNotFoundException e) {
|
||||
if (serialPrompt()) run();
|
||||
else statusNotice("Upload canceled.");
|
||||
} catch (RunnerException e) {
|
||||
//statusError("Error during upload.");
|
||||
//e.printStackTrace();
|
||||
|
@ -150,7 +150,7 @@ public class Serial implements SerialPortEventListener {
|
||||
}
|
||||
|
||||
if (port == null) {
|
||||
throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?");
|
||||
throw new SerialNotFoundException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?");
|
||||
}
|
||||
}
|
||||
|
||||
|
39
app/src/processing/app/SerialNotFoundException.java
Normal file
39
app/src/processing/app/SerialNotFoundException.java
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
public class SerialNotFoundException extends SerialException {
|
||||
public SerialNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SerialNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SerialNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public SerialNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1518,8 +1518,8 @@ public class Sketch {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected boolean exportApplet(boolean verbose) throws Exception {
|
||||
return exportApplet(tempBuildFolder.getAbsolutePath(), verbose);
|
||||
}
|
||||
@ -1529,7 +1529,7 @@ public class Sketch {
|
||||
* Handle export to applet.
|
||||
*/
|
||||
public boolean exportApplet(String appletPath, boolean verbose)
|
||||
throws RunnerException, IOException {
|
||||
throws RunnerException, IOException, SerialException {
|
||||
|
||||
// Make sure the user didn't hide the sketch folder
|
||||
ensureExistence();
|
||||
@ -1566,7 +1566,7 @@ public class Sketch {
|
||||
// }
|
||||
|
||||
upload(appletFolder.getPath(), foundName, verbose);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1593,7 +1593,7 @@ public class Sketch {
|
||||
|
||||
|
||||
protected String upload(String buildPath, String suggestedClassName, boolean verbose)
|
||||
throws RunnerException {
|
||||
throws RunnerException, SerialException {
|
||||
|
||||
Uploader uploader;
|
||||
|
||||
|
@ -29,6 +29,7 @@ package processing.app.debug;
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Serial;
|
||||
import processing.app.SerialException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@ -43,7 +44,7 @@ public class AvrdudeUploader extends Uploader {
|
||||
|
||||
// XXX: add support for uploading sketches using a programmer
|
||||
public boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
|
||||
throws RunnerException {
|
||||
throws RunnerException, SerialException {
|
||||
this.verbose = verbose;
|
||||
Map<String, String> boardPreferences = Base.getBoardPreferences();
|
||||
String uploadUsing = boardPreferences.get("upload.using");
|
||||
@ -71,7 +72,7 @@ public class AvrdudeUploader extends Uploader {
|
||||
}
|
||||
|
||||
private boolean uploadViaBootloader(String buildPath, String className)
|
||||
throws RunnerException {
|
||||
throws RunnerException, SerialException {
|
||||
Map<String, String> boardPreferences = Base.getBoardPreferences();
|
||||
List commandDownloader = new ArrayList();
|
||||
String protocol = boardPreferences.get("upload.protocol");
|
||||
|
@ -93,72 +93,72 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
List<File> objectFiles = new ArrayList<File>();
|
||||
|
||||
List includePaths = new ArrayList();
|
||||
includePaths.add(corePath);
|
||||
|
||||
String runtimeLibraryName = buildPath + File.separator + "core.a";
|
||||
// 0. include paths for core + all libraries
|
||||
|
||||
// 1. compile the core, outputting .o files to <buildPath> and then
|
||||
// collecting them into the core.a library file.
|
||||
|
||||
List<File> coreObjectFiles =
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(corePath, "S", true),
|
||||
findFilesInPath(corePath, "c", true),
|
||||
findFilesInPath(corePath, "cpp", true),
|
||||
boardPreferences);
|
||||
|
||||
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
|
||||
avrBasePath + "avr-ar",
|
||||
"rcs",
|
||||
runtimeLibraryName
|
||||
}));
|
||||
List includePaths = new ArrayList();
|
||||
includePaths.add(corePath);
|
||||
for (File file : sketch.getImportedLibraries()) {
|
||||
includePaths.add(file.getPath());
|
||||
}
|
||||
|
||||
for(File file : coreObjectFiles) {
|
||||
List commandAR = new ArrayList(baseCommandAR);
|
||||
commandAR.add(file.getAbsolutePath());
|
||||
execAsynchronously(commandAR);
|
||||
}
|
||||
// 1. compile the sketch (already in the buildPath)
|
||||
|
||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(buildPath, "S", false),
|
||||
findFilesInPath(buildPath, "c", false),
|
||||
findFilesInPath(buildPath, "cpp", false),
|
||||
boardPreferences));
|
||||
|
||||
// use library directories as include paths for all libraries
|
||||
for (File file : sketch.getImportedLibraries()) {
|
||||
includePaths.add(file.getPath());
|
||||
}
|
||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||
|
||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||
File utilityFolder = new File(libraryFolder, "utility");
|
||||
createFolder(outputFolder);
|
||||
// this library can use includes in its utility/ folder
|
||||
includePaths.add(utilityFolder.getAbsolutePath());
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||
findFilesInFolder(libraryFolder, "S", false),
|
||||
findFilesInFolder(libraryFolder, "c", false),
|
||||
findFilesInFolder(libraryFolder, "cpp", false),
|
||||
boardPreferences));
|
||||
outputFolder = new File(outputFolder, "utility");
|
||||
createFolder(outputFolder);
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||
findFilesInFolder(utilityFolder, "S", false),
|
||||
findFilesInFolder(utilityFolder, "c", false),
|
||||
findFilesInFolder(utilityFolder, "cpp", false),
|
||||
boardPreferences));
|
||||
// other libraries should not see this library's utility/ folder
|
||||
includePaths.remove(includePaths.size() - 1);
|
||||
}
|
||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||
File utilityFolder = new File(libraryFolder, "utility");
|
||||
createFolder(outputFolder);
|
||||
// this library can use includes in its utility/ folder
|
||||
includePaths.add(utilityFolder.getAbsolutePath());
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||
findFilesInFolder(libraryFolder, "S", false),
|
||||
findFilesInFolder(libraryFolder, "c", false),
|
||||
findFilesInFolder(libraryFolder, "cpp", false),
|
||||
boardPreferences));
|
||||
outputFolder = new File(outputFolder, "utility");
|
||||
createFolder(outputFolder);
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||
findFilesInFolder(utilityFolder, "S", false),
|
||||
findFilesInFolder(utilityFolder, "c", false),
|
||||
findFilesInFolder(utilityFolder, "cpp", false),
|
||||
boardPreferences));
|
||||
// other libraries should not see this library's utility/ folder
|
||||
includePaths.remove(includePaths.size() - 1);
|
||||
}
|
||||
|
||||
// 3. compile the sketch (already in the buildPath)
|
||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||
// collecting them into the core.a library file.
|
||||
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(buildPath, "S", false),
|
||||
findFilesInPath(buildPath, "c", false),
|
||||
findFilesInPath(buildPath, "cpp", false),
|
||||
boardPreferences));
|
||||
includePaths.clear();
|
||||
includePaths.add(corePath); // include path for core only
|
||||
List<File> coreObjectFiles =
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(corePath, "S", true),
|
||||
findFilesInPath(corePath, "c", true),
|
||||
findFilesInPath(corePath, "cpp", true),
|
||||
boardPreferences);
|
||||
|
||||
String runtimeLibraryName = buildPath + File.separator + "core.a";
|
||||
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
|
||||
avrBasePath + "avr-ar",
|
||||
"rcs",
|
||||
runtimeLibraryName
|
||||
}));
|
||||
for(File file : coreObjectFiles) {
|
||||
List commandAR = new ArrayList(baseCommandAR);
|
||||
commandAR.add(file.getAbsolutePath());
|
||||
execAsynchronously(commandAR);
|
||||
}
|
||||
|
||||
// 4. link it all together into the .elf file
|
||||
|
||||
|
@ -29,6 +29,8 @@ package processing.app.debug;
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Serial;
|
||||
import processing.app.SerialException;
|
||||
import processing.app.SerialNotFoundException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@ -63,11 +65,11 @@ public abstract class Uploader implements MessageConsumer {
|
||||
}
|
||||
|
||||
public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
|
||||
throws RunnerException;
|
||||
throws RunnerException, SerialException;
|
||||
|
||||
public abstract boolean burnBootloader(String target, String programmer) throws RunnerException;
|
||||
|
||||
protected void flushSerialBuffer() throws RunnerException {
|
||||
protected void flushSerialBuffer() throws RunnerException, SerialException {
|
||||
// Cleanup the serial buffer
|
||||
try {
|
||||
Serial serialPort = new Serial();
|
||||
@ -90,6 +92,8 @@ public abstract class Uploader implements MessageConsumer {
|
||||
serialPort.setRTS(true);
|
||||
|
||||
serialPort.dispose();
|
||||
} catch (SerialNotFoundException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RunnerException(e.getMessage());
|
||||
|
@ -114,6 +114,26 @@ public class DiscourseFormat {
|
||||
" has been copied to the clipboard.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a char to a stringbuffer while escaping for proper display in HTML.
|
||||
* @param c input char to escape
|
||||
* @param buffer StringBuffer to append html-safe version of c to.
|
||||
*/
|
||||
private void appendToHTML(char c, StringBuffer buffer) {
|
||||
if (!html) {
|
||||
buffer.append(c);
|
||||
} else if (c == '<') {
|
||||
buffer.append("<");
|
||||
} else if (c == '>') {
|
||||
buffer.append(">");
|
||||
} else if (c == '&') {
|
||||
buffer.append("&");
|
||||
} else if (c > 127) {
|
||||
buffer.append("&#" + ((int) c) + ";"); // use unicode entity
|
||||
} else {
|
||||
buffer.append(c); // normal character
|
||||
}
|
||||
}
|
||||
|
||||
// A terrible headache...
|
||||
public void appendFormattedLine(StringBuffer cf, int line) {
|
||||
@ -138,7 +158,7 @@ public class DiscourseFormat {
|
||||
if (tokenMarker == null) {
|
||||
for (int j = 0; j < segmentCount; j++) {
|
||||
char c = segmentArray[j + segmentOffset];
|
||||
cf = cf.append(c);
|
||||
appendToHTML(c, cf);
|
||||
// int charWidth;
|
||||
// if (c == '\t') {
|
||||
// charWidth = (int) painter.nextTabStop(width, j) - width;
|
||||
@ -171,7 +191,7 @@ public class DiscourseFormat {
|
||||
if (id == Token.END) {
|
||||
char c = segmentArray[segmentOffset + offset];
|
||||
if (segmentOffset + offset < limit) {
|
||||
cf.append(c);
|
||||
appendToHTML(c, cf);
|
||||
} else {
|
||||
cf.append('\n');
|
||||
}
|
||||
@ -203,7 +223,7 @@ public class DiscourseFormat {
|
||||
// cf.append(' ');
|
||||
// }
|
||||
} else {
|
||||
cf.append(c);
|
||||
appendToHTML(c, cf);
|
||||
}
|
||||
// Place close tags [/]
|
||||
if (j == (length - 1) && id != Token.NULL && styles[id].isBold())
|
||||
@ -225,4 +245,4 @@ public class DiscourseFormat {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user