mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Now have uploading working with the Boards menu. Improved serial port error messages.
This commit is contained in:
parent
1f35dce6a8
commit
c78c1efe18
@ -44,19 +44,19 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
// 0x000000); force it to continue uploading anyway
|
// 0x000000); force it to continue uploading anyway
|
||||||
commandDownloader.add("-F");
|
commandDownloader.add("-F");
|
||||||
|
|
||||||
String programmer = Preferences.get("upload.programmer");
|
String protocol = Preferences.get("boards." + Preferences.get("board") + ".upload.protocol");
|
||||||
|
|
||||||
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
// avrdude wants "stk500v1" to distinguish it from stk500v2
|
||||||
if (programmer.equals("stk500"))
|
if (protocol.equals("stk500"))
|
||||||
programmer = "stk500v1";
|
protocol = "stk500v1";
|
||||||
commandDownloader.add("-c" + programmer);
|
commandDownloader.add("-c" + protocol);
|
||||||
if (Preferences.get("upload.programmer").equals("dapa")) {
|
if (protocol.equals("dapa")) {
|
||||||
// avrdude doesn't need to be told the address of the parallel port
|
// avrdude doesn't need to be told the address of the parallel port
|
||||||
//commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
//commandDownloader.add("-dlpt=" + Preferences.get("parallel.port"));
|
||||||
} else {
|
} else {
|
||||||
commandDownloader.add("-P" + Preferences.get("serial.port"));
|
commandDownloader.add("-P" + Preferences.get("serial.port"));
|
||||||
commandDownloader.add(
|
commandDownloader.add(
|
||||||
"-b" + Preferences.getInteger("serial.download_rate"));
|
"-b" + Preferences.getInteger("boards." + Preferences.get("board") + ".upload.speed"));
|
||||||
}
|
}
|
||||||
if (Preferences.getBoolean("upload.erase"))
|
if (Preferences.getBoolean("upload.erase"))
|
||||||
commandDownloader.add("-e");
|
commandDownloader.add("-e");
|
||||||
@ -151,7 +151,8 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
}
|
}
|
||||||
// XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168",
|
// XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168",
|
||||||
// then shove an "m" at the beginning. won't work for attiny's, etc.
|
// then shove an "m" at the beginning. won't work for attiny's, etc.
|
||||||
commandDownloader.add("-pm" + Preferences.get("build.mcu").substring(6));
|
commandDownloader.add("-pm" +
|
||||||
|
Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6));
|
||||||
commandDownloader.addAll(params);
|
commandDownloader.addAll(params);
|
||||||
|
|
||||||
return executeUploadCommand(commandDownloader);
|
return executeUploadCommand(commandDownloader);
|
||||||
|
@ -104,8 +104,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
"-Os", // optimize for size
|
"-Os", // optimize for size
|
||||||
"-I" + target.getPath(),
|
"-I" + target.getPath(),
|
||||||
"-w", // surpress all warnings
|
"-w", // surpress all warnings
|
||||||
"-mmcu=" + Preferences.get("build.mcu"),
|
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
|
||||||
"-DF_CPU=" + Preferences.get("build.f_cpu"),
|
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// use lib directories as include paths
|
// use lib directories as include paths
|
||||||
@ -130,8 +130,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
"-I" + target.getPath(),
|
"-I" + target.getPath(),
|
||||||
"-w", // surpress all warnings
|
"-w", // surpress all warnings
|
||||||
"-fno-exceptions",
|
"-fno-exceptions",
|
||||||
"-mmcu=" + Preferences.get("build.mcu"),
|
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
|
||||||
"-DF_CPU=" + Preferences.get("build.f_cpu"),
|
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// use lib directories as include paths
|
// use lib directories as include paths
|
||||||
@ -145,7 +145,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
String preCommandLinker[] = new String[] {
|
String preCommandLinker[] = new String[] {
|
||||||
avrBasePath + "avr-gcc",
|
avrBasePath + "avr-gcc",
|
||||||
" ",
|
" ",
|
||||||
"-mmcu=" + Preferences.get("build.mcu"),
|
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
|
||||||
"-o",
|
"-o",
|
||||||
" ",
|
" ",
|
||||||
};
|
};
|
||||||
|
@ -783,23 +783,18 @@ public class Editor extends JFrame
|
|||||||
*/
|
*/
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
mcuMenu = new JMenu("Microcontroller (MCU)");
|
JMenu boardsMenu = new JMenu("Board");
|
||||||
String curr_mcu = Preferences.get("build.mcu");
|
ButtonGroup boardGroup = new ButtonGroup();
|
||||||
ButtonGroup mcuGroup = new ButtonGroup();
|
for (Iterator i = Preferences.getSubKeys("boards"); i.hasNext(); ) {
|
||||||
McuMenuListener mml = new McuMenuListener();
|
String board = (String) i.next();
|
||||||
|
Action action = new BoardMenuAction(board);
|
||||||
item = new JCheckBoxMenuItem("atmega8", "atmega8".equals(curr_mcu));
|
item = new JRadioButtonMenuItem(action);
|
||||||
item.addActionListener(mml);
|
if (board.equals(Preferences.get("board")))
|
||||||
mcuGroup.add(item);
|
item.setSelected(true);
|
||||||
mcuMenu.add(item);
|
boardGroup.add(item);
|
||||||
|
boardsMenu.add(item);
|
||||||
item = new JCheckBoxMenuItem("atmega168", "atmega168".equals(curr_mcu));
|
}
|
||||||
item.addActionListener(mml);
|
menu.add(boardsMenu);
|
||||||
mcuGroup.add(item);
|
|
||||||
mcuMenu.add(item);
|
|
||||||
|
|
||||||
|
|
||||||
menu.add(mcuMenu);
|
|
||||||
|
|
||||||
serialMenu = new JMenu("Serial Port");
|
serialMenu = new JMenu("Serial Port");
|
||||||
populateSerialMenu();
|
populateSerialMenu();
|
||||||
@ -913,7 +908,7 @@ public class Editor extends JFrame
|
|||||||
|
|
||||||
protected void showBootloaderMenuItemsForCurrentMCU() {
|
protected void showBootloaderMenuItemsForCurrentMCU() {
|
||||||
boolean onATmega8 =
|
boolean onATmega8 =
|
||||||
Preferences.get("build.mcu").equals("atmega8");
|
Preferences.get("boards." + Preferences.get("board") + ".build.mcu").equals("atmega8");
|
||||||
|
|
||||||
burnBootloader8Item.setVisible(onATmega8);
|
burnBootloader8Item.setVisible(onATmega8);
|
||||||
if (burnBootloader8ParallelItem != null)
|
if (burnBootloader8ParallelItem != null)
|
||||||
@ -927,20 +922,15 @@ public class Editor extends JFrame
|
|||||||
burnBootloader168NGParallelItem.setVisible(!onATmega8);
|
burnBootloader168NGParallelItem.setVisible(!onATmega8);
|
||||||
}
|
}
|
||||||
|
|
||||||
class McuMenuListener implements ActionListener {
|
class BoardMenuAction extends AbstractAction {
|
||||||
McuMenuListener() {}
|
private String board;
|
||||||
|
public BoardMenuAction(String board) {
|
||||||
|
super(Preferences.get("boards." + board + ".name"));
|
||||||
|
this.board = board;
|
||||||
|
}
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
for (int i = 0; i < mcuMenu.getItemCount(); i++)
|
//System.out.println("Switching to " + board);
|
||||||
if (mcuMenu.getItem(i) instanceof JCheckBoxMenuItem)
|
Preferences.set("board", board);
|
||||||
((JCheckBoxMenuItem) mcuMenu.getItem(i)).setState(false);
|
|
||||||
|
|
||||||
((JCheckBoxMenuItem) actionevent.getSource()).setState(true);
|
|
||||||
Preferences.set("build.mcu",
|
|
||||||
((JCheckBoxMenuItem) actionevent.getSource()).getLabel());
|
|
||||||
|
|
||||||
showBootloaderMenuItemsForCurrentMCU();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LibraryManager libraryManager = new LibraryManager();
|
LibraryManager libraryManager = new LibraryManager();
|
||||||
libraryManager.rebuildAllBuilt();
|
libraryManager.rebuildAllBuilt();
|
||||||
@ -1448,7 +1438,8 @@ public class Editor extends JFrame
|
|||||||
try {
|
try {
|
||||||
if (!sketch.handleRun(new Target(
|
if (!sketch.handleRun(new Target(
|
||||||
System.getProperty("user.dir") + File.separator + "hardware" +
|
System.getProperty("user.dir") + File.separator + "hardware" +
|
||||||
File.separator + "cores", Preferences.get("build.target"))))
|
File.separator + "cores",
|
||||||
|
Preferences.get("boards." + Preferences.get("board") + ".build.core"))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//runtime = new Runner(sketch, Editor.this);
|
//runtime = new Runner(sketch, Editor.this);
|
||||||
@ -1539,11 +1530,15 @@ public class Editor extends JFrame
|
|||||||
|
|
||||||
public void handleSerial() {
|
public void handleSerial() {
|
||||||
if (!debugging) {
|
if (!debugging) {
|
||||||
|
try {
|
||||||
|
serialPort = new Serial(true);
|
||||||
console.clear();
|
console.clear();
|
||||||
buttons.activate(EditorButtons.SERIAL);
|
buttons.activate(EditorButtons.SERIAL);
|
||||||
serialPort = new Serial(true);
|
|
||||||
debugging = true;
|
debugging = true;
|
||||||
status.serial();
|
status.serial();
|
||||||
|
} catch(SerialException e) {
|
||||||
|
error(e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
doStop();
|
doStop();
|
||||||
}
|
}
|
||||||
@ -2057,7 +2052,8 @@ public class Editor extends JFrame
|
|||||||
//sketch.exportLibrary() : sketch.exportApplet();
|
//sketch.exportLibrary() : sketch.exportApplet();
|
||||||
boolean success = sketch.exportApplet(new Target(
|
boolean success = sketch.exportApplet(new Target(
|
||||||
System.getProperty("user.dir") + File.separator + "hardware" +
|
System.getProperty("user.dir") + File.separator + "hardware" +
|
||||||
File.separator + "cores", Preferences.get("build.target")));
|
File.separator + "cores",
|
||||||
|
Preferences.get("boards." + Preferences.get("board") + ".build.core")));
|
||||||
if (success) {
|
if (success) {
|
||||||
message("Done uploading.");
|
message("Done uploading.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -526,7 +526,11 @@ public class EditorStatus extends JPanel implements ActionListener {
|
|||||||
int rate = Integer.parseInt(rateString);
|
int rate = Integer.parseInt(rateString);
|
||||||
Preferences.set("serial.debug_rate", rateString);
|
Preferences.set("serial.debug_rate", rateString);
|
||||||
editor.serialPort.dispose();
|
editor.serialPort.dispose();
|
||||||
|
try {
|
||||||
editor.serialPort = new Serial(true);
|
editor.serialPort = new Serial(true);
|
||||||
|
} catch (SerialException err) {
|
||||||
|
editor.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,8 @@ public class Library implements MessageConsumer{
|
|||||||
"-g",
|
"-g",
|
||||||
"-Os",
|
"-Os",
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-mmcu=" + Preferences.get("build.mcu"),
|
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
|
||||||
"-DF_CPU=" + Preferences.get("build.f_cpu"),
|
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
|
||||||
"-I" + libManager.getTarget().getPath(),
|
"-I" + libManager.getTarget().getPath(),
|
||||||
"-I" + getFolder(),
|
"-I" + getFolder(),
|
||||||
};
|
};
|
||||||
@ -348,8 +348,8 @@ public class Library implements MessageConsumer{
|
|||||||
"-Os",
|
"-Os",
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-fno-exceptions",
|
"-fno-exceptions",
|
||||||
"-mmcu=" + Preferences.get("build.mcu"),
|
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
|
||||||
"-DF_CPU=" + Preferences.get("build.f_cpu"),
|
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
|
||||||
"-I" + libManager.getTarget().getPath(),
|
"-I" + libManager.getTarget().getPath(),
|
||||||
"-I" + getFolder(),
|
"-I" + getFolder(),
|
||||||
};
|
};
|
||||||
|
@ -49,7 +49,8 @@ public class LibraryManager {
|
|||||||
"libraries");
|
"libraries");
|
||||||
target = new Target(
|
target = new Target(
|
||||||
System.getProperty("user.dir") + File.separator + "hardware" +
|
System.getProperty("user.dir") + File.separator + "hardware" +
|
||||||
File.separator + "cores", Preferences.get("build.target"));
|
File.separator + "cores",
|
||||||
|
Preferences.get("boards." + Preferences.get("board") + ".build.core"));
|
||||||
refreshLibraries();
|
refreshLibraries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +139,13 @@ public class Preferences {
|
|||||||
|
|
||||||
|
|
||||||
// data model
|
// data model
|
||||||
|
// we have multiple preference files, one main one and a few subsidiary
|
||||||
static Hashtable table = new Hashtable();;
|
// ones with prefixes. the preferences from the main file go in table
|
||||||
|
// and are saved back to the main file. the preferences from the
|
||||||
|
// subsidiary files are stored in prefixes (which maps a prefix string to
|
||||||
|
// a Hashtable mapping unprefixed keys to values) and are not saved.
|
||||||
|
static Hashtable table = new Hashtable();
|
||||||
|
static Hashtable prefixes = new Hashtable();
|
||||||
static File preferencesFile;
|
static File preferencesFile;
|
||||||
|
|
||||||
|
|
||||||
@ -203,6 +208,18 @@ public class Preferences {
|
|||||||
" and restart Arduino.", ex);
|
" and restart Arduino.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
load(new FileInputStream(new File(
|
||||||
|
System.getProperty("user.dir") +
|
||||||
|
File.separator + "hardware" +
|
||||||
|
File.separator + "boards.txt")),
|
||||||
|
"boards");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Base.showError("Error reading board definitions",
|
||||||
|
"Error reading the board definitions file. " +
|
||||||
|
"Please re-download or re-unzip Arduino.\n", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -521,10 +538,19 @@ public class Preferences {
|
|||||||
|
|
||||||
// .................................................................
|
// .................................................................
|
||||||
|
|
||||||
|
|
||||||
static public void load(InputStream input) throws IOException {
|
static public void load(InputStream input) throws IOException {
|
||||||
|
load(input, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void load(InputStream input, String prefix) throws IOException {
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
new BufferedReader(new InputStreamReader(input));
|
new BufferedReader(new InputStreamReader(input));
|
||||||
|
Hashtable table = Preferences.table;
|
||||||
|
|
||||||
|
if (prefix != null) {
|
||||||
|
table = new Hashtable();
|
||||||
|
prefixes.put(prefix, table);
|
||||||
|
}
|
||||||
|
|
||||||
//table = new Hashtable();
|
//table = new Hashtable();
|
||||||
String line = null;
|
String line = null;
|
||||||
@ -633,6 +659,18 @@ public class Preferences {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
static public String get(String attribute /*, String defaultValue */) {
|
static public String get(String attribute /*, String defaultValue */) {
|
||||||
|
// if the attribute starts with a prefix used by one of our subsidiary
|
||||||
|
// preference files, look up the attribute in that file's Hashtable
|
||||||
|
// (don't override with or fallback to the main file). otherwise,
|
||||||
|
// look up the attribute in the main file's Hashtable.
|
||||||
|
Hashtable table = Preferences.table;
|
||||||
|
if (attribute.indexOf('.') != -1) {
|
||||||
|
String prefix = attribute.substring(0, attribute.indexOf('.'));
|
||||||
|
if (prefixes.containsKey(prefix)) {
|
||||||
|
table = (Hashtable) prefixes.get(prefix);
|
||||||
|
attribute = attribute.substring(attribute.indexOf('.') + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return (String) table.get(attribute);
|
return (String) table.get(attribute);
|
||||||
/*
|
/*
|
||||||
//String value = (properties != null) ?
|
//String value = (properties != null) ?
|
||||||
@ -644,6 +682,27 @@ public class Preferences {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the top-level key prefixes defined in the subsidiary file loaded with
|
||||||
|
* the given prefix. For example, if the file contains:
|
||||||
|
* foo.count=1
|
||||||
|
* bar.count=2
|
||||||
|
* baz.count=3
|
||||||
|
* this will return { "foo", "bar", "baz" }.
|
||||||
|
*/
|
||||||
|
static public Iterator getSubKeys(String prefix) {
|
||||||
|
if (!prefixes.containsKey(prefix))
|
||||||
|
return null;
|
||||||
|
Set subkeys = new HashSet();
|
||||||
|
for (Enumeration e = ((Hashtable) prefixes.get(prefix)).keys(); e.hasMoreElements(); ) {
|
||||||
|
String subkey = (String) e.nextElement();
|
||||||
|
if (subkey.indexOf('.') != -1)
|
||||||
|
subkey = subkey.substring(0, subkey.indexOf('.'));
|
||||||
|
subkeys.add(subkey);
|
||||||
|
}
|
||||||
|
return subkeys.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static public void set(String attribute, String value) {
|
static public void set(String attribute, String value) {
|
||||||
//preferences.put(attribute, value);
|
//preferences.put(attribute, value);
|
||||||
|
@ -59,7 +59,7 @@ public class Serial implements SerialPortEventListener {
|
|||||||
int bufferIndex;
|
int bufferIndex;
|
||||||
int bufferLast;
|
int bufferLast;
|
||||||
|
|
||||||
public Serial(boolean monitor) {
|
public Serial(boolean monitor) throws SerialException {
|
||||||
this(Preferences.get("serial.port"),
|
this(Preferences.get("serial.port"),
|
||||||
Preferences.getInteger("serial.debug_rate"),
|
Preferences.getInteger("serial.debug_rate"),
|
||||||
Preferences.get("serial.parity").charAt(0),
|
Preferences.get("serial.parity").charAt(0),
|
||||||
@ -68,7 +68,7 @@ public class Serial implements SerialPortEventListener {
|
|||||||
this.monitor = monitor;
|
this.monitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serial() {
|
public Serial() throws SerialException {
|
||||||
this(Preferences.get("serial.port"),
|
this(Preferences.get("serial.port"),
|
||||||
Preferences.getInteger("serial.debug_rate"),
|
Preferences.getInteger("serial.debug_rate"),
|
||||||
Preferences.get("serial.parity").charAt(0),
|
Preferences.get("serial.parity").charAt(0),
|
||||||
@ -76,20 +76,20 @@ public class Serial implements SerialPortEventListener {
|
|||||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serial(int irate) {
|
public Serial(int irate) throws SerialException {
|
||||||
this(Preferences.get("serial.port"), irate,
|
this(Preferences.get("serial.port"), irate,
|
||||||
Preferences.get("serial.parity").charAt(0),
|
Preferences.get("serial.parity").charAt(0),
|
||||||
Preferences.getInteger("serial.databits"),
|
Preferences.getInteger("serial.databits"),
|
||||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serial(String iname, int irate) {
|
public Serial(String iname, int irate) throws SerialException {
|
||||||
this(iname, irate, Preferences.get("serial.parity").charAt(0),
|
this(iname, irate, Preferences.get("serial.parity").charAt(0),
|
||||||
Preferences.getInteger("serial.databits"),
|
Preferences.getInteger("serial.databits"),
|
||||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serial(String iname) {
|
public Serial(String iname) throws SerialException {
|
||||||
this(iname, Preferences.getInteger("serial.debug_rate"),
|
this(iname, Preferences.getInteger("serial.debug_rate"),
|
||||||
Preferences.get("serial.parity").charAt(0),
|
Preferences.get("serial.parity").charAt(0),
|
||||||
Preferences.getInteger("serial.databits"),
|
Preferences.getInteger("serial.databits"),
|
||||||
@ -97,7 +97,8 @@ public class Serial implements SerialPortEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Serial(String iname, int irate,
|
public Serial(String iname, int irate,
|
||||||
char iparity, int idatabits, float istopbits) {
|
char iparity, int idatabits, float istopbits)
|
||||||
|
throws SerialException {
|
||||||
//if (port != null) port.close();
|
//if (port != null) port.close();
|
||||||
//this.parent = parent;
|
//this.parent = parent;
|
||||||
//parent.attach(this);
|
//parent.attach(this);
|
||||||
@ -115,6 +116,7 @@ public class Serial implements SerialPortEventListener {
|
|||||||
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
|
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
port = null;
|
||||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
||||||
while (portList.hasMoreElements()) {
|
while (portList.hasMoreElements()) {
|
||||||
CommPortIdentifier portId =
|
CommPortIdentifier portId =
|
||||||
@ -134,14 +136,17 @@ public class Serial implements SerialPortEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (PortInUseException e) {
|
||||||
|
throw new SerialException("Serial port '" + iname + "' already in use. Try quiting any programs that may be using it.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorMessage("<init>", e);
|
throw new SerialException("Error opening serial port '" + iname + "'.", e);
|
||||||
//exception = e;
|
// //errorMessage("<init>", e);
|
||||||
//e.printStackTrace();
|
// //exception = e;
|
||||||
port = null;
|
// //e.printStackTrace();
|
||||||
input = null;
|
}
|
||||||
output = null;
|
|
||||||
|
if (port == null) {
|
||||||
|
throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
app/SerialException.java
Normal file
39
app/SerialException.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 SerialException extends Exception {
|
||||||
|
public SerialException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerialException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerialException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerialException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -1592,9 +1592,7 @@ public class Sketch {
|
|||||||
protected void size(String buildPath, String suggestedClassName)
|
protected void size(String buildPath, String suggestedClassName)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
long size = 0;
|
long size = 0;
|
||||||
long maxsize = Preferences.getInteger("upload.maximum_size");
|
long maxsize = Preferences.getInteger("boards." + Preferences.get("board") + ".upload.maximum_size");
|
||||||
if (Preferences.get("build.mcu").equals("atmega168"))
|
|
||||||
maxsize *= 2;
|
|
||||||
Sizer sizer = new Sizer(buildPath, suggestedClassName);
|
Sizer sizer = new Sizer(buildPath, suggestedClassName);
|
||||||
try {
|
try {
|
||||||
size = sizer.computeSize();
|
size = sizer.computeSize();
|
||||||
@ -1606,8 +1604,7 @@ public class Sketch {
|
|||||||
|
|
||||||
if (size > maxsize)
|
if (size > maxsize)
|
||||||
throw new RunnerException(
|
throw new RunnerException(
|
||||||
"Sketch too big; try deleting code, removing floats, or see " +
|
"Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.");
|
||||||
"http://www.arduino.cc/en/Main/FAQ for more advice.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String upload(String buildPath, String suggestedClassName)
|
protected String upload(String buildPath, String suggestedClassName)
|
||||||
@ -1617,11 +1614,7 @@ public class Sketch {
|
|||||||
|
|
||||||
// download the program
|
// download the program
|
||||||
//
|
//
|
||||||
if ("uisp".equals(Preferences.get("upload.application"))) {
|
|
||||||
uploader = new UispUploader();
|
|
||||||
} else {
|
|
||||||
uploader = new AvrdudeUploader();
|
uploader = new AvrdudeUploader();
|
||||||
}
|
|
||||||
// macos9 now officially broken.. see PdeCompilerJavac
|
// macos9 now officially broken.. see PdeCompilerJavac
|
||||||
//PdeCompiler compiler =
|
//PdeCompiler compiler =
|
||||||
// ((PdeBase.platform == PdeBase.MACOS9) ?
|
// ((PdeBase.platform == PdeBase.MACOS9) ?
|
||||||
@ -1691,6 +1684,8 @@ public class Sketch {
|
|||||||
if (Preferences.getBoolean("editor.external")) {
|
if (Preferences.getBoolean("editor.external")) {
|
||||||
// nuke previous files and settings
|
// nuke previous files and settings
|
||||||
load();
|
load();
|
||||||
|
} else {
|
||||||
|
current.program = editor.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFileContents = new Hashtable();
|
zipFileContents = new Hashtable();
|
||||||
|
@ -62,8 +62,9 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
|
|
||||||
public abstract boolean burnBootloaderParallel(String target) throws RunnerException;
|
public abstract boolean burnBootloaderParallel(String target) throws RunnerException;
|
||||||
|
|
||||||
protected void flushSerialBuffer() {
|
protected void flushSerialBuffer() throws RunnerException {
|
||||||
// Cleanup the serial buffer
|
// Cleanup the serial buffer
|
||||||
|
try {
|
||||||
Serial serialPort = new Serial();
|
Serial serialPort = new Serial();
|
||||||
byte[] readBuffer;
|
byte[] readBuffer;
|
||||||
while(serialPort.available() > 0) {
|
while(serialPort.available() > 0) {
|
||||||
@ -82,6 +83,10 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
serialPort.setDTR(true);
|
serialPort.setDTR(true);
|
||||||
|
|
||||||
serialPort.dispose();
|
serialPort.dispose();
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RunnerException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean executeUploadCommand(Collection commandDownloader)
|
protected boolean executeUploadCommand(Collection commandDownloader)
|
||||||
|
@ -78,7 +78,8 @@ public class ExportFolder {
|
|||||||
// success may not be that useful, usually an ex is thrown
|
// success may not be that useful, usually an ex is thrown
|
||||||
success = editor.sketch.exportApplet(new Target(
|
success = editor.sketch.exportApplet(new Target(
|
||||||
System.getProperty("user.dir") + File.separator + "hardware" +
|
System.getProperty("user.dir") + File.separator + "hardware" +
|
||||||
File.separator + "cores", Preferences.get("build.target")));
|
File.separator + "cores",
|
||||||
|
Preferences.get("boards." + Preferences.get("board") + ".build.core")));
|
||||||
if (!success) break;
|
if (!success) break;
|
||||||
//System.out.println("success was " + success);
|
//System.out.println("success was " + success);
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,7 @@
|
|||||||
/* End PBXApplicationTarget section */
|
/* End PBXApplicationTarget section */
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
33055EFF0CB8187700824CD9 /* SerialException.java in Sources */ = {isa = PBXBuildFile; fileRef = 33055EFE0CB8187600824CD9 /* SerialException.java */; };
|
||||||
332D4DB609CF147F00BF81F6 /* Sizer.java in Sources */ = {isa = PBXBuildFile; fileRef = 332D4DB509CF147F00BF81F6 /* Sizer.java */; };
|
332D4DB609CF147F00BF81F6 /* Sizer.java in Sources */ = {isa = PBXBuildFile; fileRef = 332D4DB509CF147F00BF81F6 /* Sizer.java */; };
|
||||||
335A28F50C8CCB0A00D8A7F4 /* quaqua.jar in CopyFiles */ = {isa = PBXBuildFile; fileRef = 335A28F30C8CCAF700D8A7F4 /* quaqua.jar */; };
|
335A28F50C8CCB0A00D8A7F4 /* quaqua.jar in CopyFiles */ = {isa = PBXBuildFile; fileRef = 335A28F30C8CCAF700D8A7F4 /* quaqua.jar */; };
|
||||||
335A28FE0C8CCB4000D8A7F4 /* libquaqua.jnilib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 335A28F20C8CCAF700D8A7F4 /* libquaqua.jnilib */; };
|
335A28FE0C8CCB4000D8A7F4 /* libquaqua.jnilib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 335A28F20C8CCAF700D8A7F4 /* libquaqua.jnilib */; };
|
||||||
@ -441,6 +442,7 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
33055EFE0CB8187600824CD9 /* SerialException.java */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.java; path = SerialException.java; sourceTree = "<group>"; };
|
||||||
332D4DB509CF147F00BF81F6 /* Sizer.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = Sizer.java; sourceTree = "<group>"; };
|
332D4DB509CF147F00BF81F6 /* Sizer.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = Sizer.java; sourceTree = "<group>"; };
|
||||||
335A28F20C8CCAF700D8A7F4 /* libquaqua.jnilib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libquaqua.jnilib; sourceTree = "<group>"; };
|
335A28F20C8CCAF700D8A7F4 /* libquaqua.jnilib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libquaqua.jnilib; sourceTree = "<group>"; };
|
||||||
335A28F30C8CCAF700D8A7F4 /* quaqua.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; path = quaqua.jar; sourceTree = "<group>"; };
|
335A28F30C8CCAF700D8A7F4 /* quaqua.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; path = quaqua.jar; sourceTree = "<group>"; };
|
||||||
@ -702,6 +704,7 @@
|
|||||||
33FFFE220965BD100016AC38 /* app */ = {
|
33FFFE220965BD100016AC38 /* app */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
33055EFE0CB8187600824CD9 /* SerialException.java */,
|
||||||
33F944E00C2B33560093EB9C /* AvrdudeUploader.java */,
|
33F944E00C2B33560093EB9C /* AvrdudeUploader.java */,
|
||||||
33F9446B0C2B2F6F0093EB9C /* UispUploader.java */,
|
33F9446B0C2B2F6F0093EB9C /* UispUploader.java */,
|
||||||
33BEE0CD09D7446100430D5B /* Library.java */,
|
33BEE0CD09D7446100430D5B /* Library.java */,
|
||||||
@ -739,6 +742,7 @@
|
|||||||
33FFFE740965BD110016AC38 /* Uploader.java */,
|
33FFFE740965BD110016AC38 /* Uploader.java */,
|
||||||
332D4DB509CF147F00BF81F6 /* Sizer.java */,
|
332D4DB509CF147F00BF81F6 /* Sizer.java */,
|
||||||
);
|
);
|
||||||
|
includeInIndex = 0;
|
||||||
name = app;
|
name = app;
|
||||||
path = ../../app;
|
path = ../../app;
|
||||||
sourceTree = SOURCE_ROOT;
|
sourceTree = SOURCE_ROOT;
|
||||||
@ -1097,6 +1101,7 @@
|
|||||||
335A291F0C8CCC0900D8A7F4 /* PShape.java in Sources */,
|
335A291F0C8CCC0900D8A7F4 /* PShape.java in Sources */,
|
||||||
335A29200C8CCC0900D8A7F4 /* PTriangle.java in Sources */,
|
335A29200C8CCC0900D8A7F4 /* PTriangle.java in Sources */,
|
||||||
335A29240C8CCC5E00D8A7F4 /* DiscourseFormat.java in Sources */,
|
335A29240C8CCC5E00D8A7F4 /* DiscourseFormat.java in Sources */,
|
||||||
|
33055EFF0CB8187700824CD9 /* SerialException.java in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -271,53 +271,18 @@ linestatus.height = 20
|
|||||||
upload.verbose=false
|
upload.verbose=false
|
||||||
upload.erase=false
|
upload.erase=false
|
||||||
upload.verify=false
|
upload.verify=false
|
||||||
upload.programmer=stk500
|
|
||||||
upload.maximum_size=7168
|
|
||||||
|
|
||||||
# set the parallel port defaults (used if upload.programmer=dapa)
|
# set the parallel port defaults (used if upload.programmer=dapa)
|
||||||
parallel.port=0x378
|
parallel.port=0x378
|
||||||
|
|
||||||
# set the serial port defaults
|
# set the serial port defaults
|
||||||
|
serial.port=COM1
|
||||||
serial.databits=8
|
serial.databits=8
|
||||||
serial.stopbits=1
|
serial.stopbits=1
|
||||||
serial.parity=N
|
serial.parity=N
|
||||||
serial.port=COM1
|
|
||||||
serial.download_rate=19200
|
|
||||||
serial.debug_rate=9600
|
serial.debug_rate=9600
|
||||||
serial.burn_rate=115200
|
serial.burn_rate=115200
|
||||||
|
|
||||||
bootloader.atmega8.low_fuses=0xdf
|
|
||||||
bootloader.atmega8.high_fuses=0xca
|
|
||||||
bootloader.atmega8.path=bootloader
|
|
||||||
bootloader.atmega8.file=ATmegaBOOT.hex
|
|
||||||
bootloader.atmega8.unlock_bits=0xFF
|
|
||||||
bootloader.atmega8.lock_bits=0xCF
|
|
||||||
bootloader.atmega8.programmer=stk500
|
|
||||||
bootloader.atmega8.communication=serial
|
|
||||||
|
|
||||||
bootloader.atmega168-ng.low_fuses=0xff
|
|
||||||
bootloader.atmega168-ng.high_fuses=0xdd
|
|
||||||
bootloader.atmega168-ng.extended_fuses=0x00
|
|
||||||
bootloader.atmega168-ng.path=bootloader168
|
|
||||||
bootloader.atmega168-ng.file=ATmegaBOOT_168_ng.hex
|
|
||||||
bootloader.atmega168-ng.unlock_bits=0x3F
|
|
||||||
bootloader.atmega168-ng.lock_bits=0x0F
|
|
||||||
bootloader.atmega168-ng.programmer=avrispmkii
|
|
||||||
bootloader.atmega168-ng.communication=usb
|
|
||||||
|
|
||||||
bootloader.atmega168-diecimila.low_fuses=0xff
|
|
||||||
bootloader.atmega168-diecimila.high_fuses=0xdd
|
|
||||||
bootloader.atmega168-diecimila.extended_fuses=0x00
|
|
||||||
bootloader.atmega168-diecimila.path=bootloader168
|
|
||||||
bootloader.atmega168-diecimila.file=ATmegaBOOT_168_diecimila.hex
|
|
||||||
bootloader.atmega168-diecimila.unlock_bits=0x3F
|
|
||||||
bootloader.atmega168-diecimila.lock_bits=0x0F
|
|
||||||
bootloader.atmega168-diecimila.programmer=avrispmkii
|
|
||||||
bootloader.atmega168-diecimila.communication=usb
|
|
||||||
|
|
||||||
# set the build defaults
|
|
||||||
build.mcu=atmega168
|
|
||||||
build.f_cpu=16000000L
|
|
||||||
build.extension=c
|
|
||||||
build.target=arduino
|
|
||||||
build.verbose=false
|
build.verbose=false
|
||||||
|
|
||||||
|
board=diecimila
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
atmega8.name=Arduino NG or older w/ ATmega8
|
atmega8.name=Arduino NG or older w/ ATmega8
|
||||||
|
|
||||||
atmega8.upload.programmer=stk500
|
atmega8.upload.protocol=stk500
|
||||||
atmega8.upload.maximum_size=7168
|
atmega8.upload.maximum_size=7168
|
||||||
|
atmega8.upload.speed=19200
|
||||||
|
|
||||||
atmega8.bootloader.low_fuses=0xdf
|
atmega8.bootloader.low_fuses=0xdf
|
||||||
atmega8.bootloader.high_fuses=0xca
|
atmega8.bootloader.high_fuses=0xca
|
||||||
@ -20,8 +21,9 @@ atmega8.build.core=arduino
|
|||||||
|
|
||||||
atmega168.name=Arduino Mini or NG w/ ATmega168
|
atmega168.name=Arduino Mini or NG w/ ATmega168
|
||||||
|
|
||||||
atmega168.upload.programmer=stk500
|
atmega168.upload.protocol=stk500
|
||||||
atmega168.upload.maximum_size=14336
|
atmega168.upload.maximum_size=14336
|
||||||
|
atmega168.upload.speed=19200
|
||||||
|
|
||||||
atmega168.bootloader.low_fuses=0xff
|
atmega168.bootloader.low_fuses=0xff
|
||||||
atmega168.bootloader.high_fuses=0xdd
|
atmega168.bootloader.high_fuses=0xdd
|
||||||
@ -39,8 +41,9 @@ atmega168.build.core=arduino
|
|||||||
|
|
||||||
diecimila.name=Arduino Diecimila
|
diecimila.name=Arduino Diecimila
|
||||||
|
|
||||||
diecimila.upload.programmer=stk500
|
diecimila.upload.protocol=stk500
|
||||||
diecimila.upload.maximum_size=14336
|
diecimila.upload.maximum_size=14336
|
||||||
|
diecimila.upload.speed=19200
|
||||||
|
|
||||||
diecimila.bootloader.low_fuses=0xff
|
diecimila.bootloader.low_fuses=0xff
|
||||||
diecimila.bootloader.high_fuses=0xdd
|
diecimila.bootloader.high_fuses=0xdd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user