From 87400d92779e254d0661d4428eb7459286a83d02 Mon Sep 17 00:00:00 2001 From: holgerlembke Date: Mon, 23 Mar 2015 18:16:41 +0100 Subject: [PATCH 1/5] Keep Serial Monitor open during upload Keep Serial Monitor open during upload and don't break existing functions. --- app/src/processing/app/AbstractMonitor.java | 4 +++ app/src/processing/app/Editor.java | 29 ++++++++++++++++++--- app/src/processing/app/SerialMonitor.java | 15 ++++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/AbstractMonitor.java b/app/src/processing/app/AbstractMonitor.java index 146a8c25e20..26defcd55ab 100644 --- a/app/src/processing/app/AbstractMonitor.java +++ b/app/src/processing/app/AbstractMonitor.java @@ -41,6 +41,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener { protected JScrollPane scrollPane; protected JTextField textField; protected JButton sendButton; + protected JCheckBox autoscrollBox; protected JComboBox lineEndings; protected JComboBox serialRates; @@ -228,6 +229,9 @@ public String getAuthorizationKey() { public abstract void close() throws Exception; + public abstract void openSerial() throws Exception; + public abstract void closeSerial() throws Exception; + public synchronized void addToUpdateBuffer(char buff[], int n) { updateBuffer.append(buff, 0, n); } diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 1450878fd92..9869f09b6ab 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -2422,11 +2422,12 @@ synchronized public void handleExport(final boolean usingProgrammer) { // DAM: in Arduino, this is upload class DefaultExportHandler implements Runnable { public void run() { + boolean serialMonitorWasOpen = false; try { if (serialMonitor != null) { - serialMonitor.close(); - serialMonitor.setVisible(false); + serialMonitor.closeSerial(); + serialMonitorWasOpen=true; } uploading = true; @@ -2458,17 +2459,28 @@ public void run() { uploading = false; //toolbar.clear(); toolbar.deactivate(EditorToolbar.EXPORT); + + try { + if ( (serialMonitor != null) && (serialMonitorWasOpen) ){ + serialMonitor.openSerial(); + } + } catch (Exception e) { + // we are in deep trouble.... + e.printStackTrace(); + } + } } // DAM: in Arduino, this is upload (with verbose output) class DefaultExportAppHandler implements Runnable { public void run() { + boolean serialMonitorWasOpen = false; try { if (serialMonitor != null) { - serialMonitor.close(); - serialMonitor.setVisible(false); + serialMonitor.closeSerial(); + serialMonitorWasOpen=true; } uploading = true; @@ -2500,6 +2512,15 @@ public void run() { uploading = false; //toolbar.clear(); toolbar.deactivate(EditorToolbar.EXPORT); + + try { + if ( (serialMonitor != null) && (serialMonitorWasOpen) ){ + serialMonitor.openSerial(); + } + } catch (Exception e) { + // uh, deep trouble.... + e.printStackTrace(); + } } } diff --git a/app/src/processing/app/SerialMonitor.java b/app/src/processing/app/SerialMonitor.java index 122e3323d75..6f1cdc38ee0 100644 --- a/app/src/processing/app/SerialMonitor.java +++ b/app/src/processing/app/SerialMonitor.java @@ -65,6 +65,7 @@ public void actionPerformed(ActionEvent e) { textField.setText(""); } }); + } private void send(String s) { @@ -88,7 +89,7 @@ private void send(String s) { } } - public void open() throws Exception { + public void openSerial() throws Exception { if (serial != null) return; serial = new Serial(port, serialRate) { @@ -98,8 +99,8 @@ protected void message(char buff[], int n) { } }; } - - public void close() throws Exception { + + public void closeSerial() throws Exception { if (serial != null) { int[] location = getPlacement(); String locationStr = PApplet.join(PApplet.str(location), ","); @@ -110,4 +111,12 @@ public void close() throws Exception { } } + public void open() throws Exception { + openSerial(); + } + + public void close() throws Exception { + closeSerial(); + } + } From 4532618ae81ef8bcb4f2fb2d5c4f448e84d7e251 Mon Sep 17 00:00:00 2001 From: holgerlembke Date: Wed, 25 Mar 2015 11:13:16 +0100 Subject: [PATCH 2/5] Send Board Reset from Serial Monitor This introduces two new features: ++ a reset button to the serial monitor. So the board can be reset by a simple button press ++ the "reset board on serial monitor open" has been removed. I think that removed "feature" was a great annoyance: imagine the Arduino is controlling some device. And you forgot to open the monitor. Open it later, Reset, Not nice. --- app/src/processing/app/AbstractMonitor.java | 8 +++++++- app/src/processing/app/SerialMonitor.java | 12 ++++++++++++ arduino-core/src/processing/app/Serial.java | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/AbstractMonitor.java b/app/src/processing/app/AbstractMonitor.java index 26defcd55ab..7834e96e7ae 100644 --- a/app/src/processing/app/AbstractMonitor.java +++ b/app/src/processing/app/AbstractMonitor.java @@ -41,7 +41,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener { protected JScrollPane scrollPane; protected JTextField textField; protected JButton sendButton; - + protected JButton resetButton; protected JCheckBox autoscrollBox; protected JComboBox lineEndings; protected JComboBox serialRates; @@ -102,10 +102,12 @@ public void actionPerformed(ActionEvent event) { textField = new JTextField(40); sendButton = new JButton(_("Send")); + resetButton = new JButton(_("Send Reset")); upperPane.add(textField); upperPane.add(Box.createRigidArea(new Dimension(4, 0))); upperPane.add(sendButton); + upperPane.add(resetButton); getContentPane().add(upperPane, BorderLayout.NORTH); @@ -189,6 +191,10 @@ public void onSendCommand(ActionListener listener) { sendButton.addActionListener(listener); } + public void onResetCommand(ActionListener listener) { + resetButton.addActionListener(listener); + } + protected void setPlacement(int[] location) { setBounds(location[0], location[1], location[2], location[3]); } diff --git a/app/src/processing/app/SerialMonitor.java b/app/src/processing/app/SerialMonitor.java index 6f1cdc38ee0..102ba7175e7 100644 --- a/app/src/processing/app/SerialMonitor.java +++ b/app/src/processing/app/SerialMonitor.java @@ -27,6 +27,7 @@ import static processing.app.I18n._; + @SuppressWarnings("serial") public class SerialMonitor extends AbstractMonitor { @@ -66,6 +67,17 @@ public void actionPerformed(ActionEvent e) { } }); + onResetCommand(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + serial.setDTR(true); + Thread.sleep(207); // Pfffffff. + serial.setDTR(false); + } catch (Exception se) { + se.printStackTrace(); // we are in deep trouble if this happens.... + } + } + }); } private void send(String s) { diff --git a/arduino-core/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java index 53d0601ae7b..65f339f2dd1 100644 --- a/arduino-core/src/processing/app/Serial.java +++ b/arduino-core/src/processing/app/Serial.java @@ -121,7 +121,7 @@ public Serial(String iname, int irate, char iparity, int idatabits, float istopb try { port = new SerialPort(iname); port.openPort(); - port.setParams(rate, databits, stopbits, parity, true, true); + port.setParams(rate, databits, stopbits, parity, true, false); port.addEventListener(this); } catch (Exception e) { throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e); From 16adf827eee5600599b3efc36d4a9bd5811822a3 Mon Sep 17 00:00:00 2001 From: holgerlembke Date: Thu, 26 Mar 2015 16:06:27 +0100 Subject: [PATCH 3/5] Change to keep the Arduinobot compiler happy Mine compiles without it just fine. But... --- app/src/processing/app/AbstractMonitor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/processing/app/AbstractMonitor.java b/app/src/processing/app/AbstractMonitor.java index 7834e96e7ae..0073bf295c1 100644 --- a/app/src/processing/app/AbstractMonitor.java +++ b/app/src/processing/app/AbstractMonitor.java @@ -237,6 +237,7 @@ public String getAuthorizationKey() { public abstract void openSerial() throws Exception; public abstract void closeSerial() throws Exception; + public synchronized void addToUpdateBuffer(char buff[], int n) { updateBuffer.append(buff, 0, n); From f598ae246ecd4153cae5b812de30bff4eff285b8 Mon Sep 17 00:00:00 2001 From: holgerlembke Date: Sat, 28 Mar 2015 14:24:44 +0100 Subject: [PATCH 4/5] Revert "Change to keep the Arduinobot compiler happy" This reverts commit 16adf827eee5600599b3efc36d4a9bd5811822a3. --- app/src/processing/app/AbstractMonitor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/processing/app/AbstractMonitor.java b/app/src/processing/app/AbstractMonitor.java index 0073bf295c1..7834e96e7ae 100644 --- a/app/src/processing/app/AbstractMonitor.java +++ b/app/src/processing/app/AbstractMonitor.java @@ -237,7 +237,6 @@ public String getAuthorizationKey() { public abstract void openSerial() throws Exception; public abstract void closeSerial() throws Exception; - public synchronized void addToUpdateBuffer(char buff[], int n) { updateBuffer.append(buff, 0, n); From 383e812ef4e9360c8834bb3af1606398fe6e6aed Mon Sep 17 00:00:00 2001 From: holgerlembke Date: Sat, 28 Mar 2015 14:27:34 +0100 Subject: [PATCH 5/5] Change to keep the Arduinobot compiler happy Second try, commited the wrong file. I still don't understand why it compiles on Windows her without those lines. I'm synced, the file is compiled (i checked that) and everything, so it should. --- app/src/processing/app/NetworkMonitor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/processing/app/NetworkMonitor.java b/app/src/processing/app/NetworkMonitor.java index 850481ef76e..18927ef4394 100644 --- a/app/src/processing/app/NetworkMonitor.java +++ b/app/src/processing/app/NetworkMonitor.java @@ -121,6 +121,13 @@ public void run() { }); } } + + @Override + public void openSerial() throws Exception {} + + @Override + public void closeSerial() throws Exception {} + @Override public synchronized void message(String s) {