mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-07 01:54:26 +01:00
Revert "close SerialMonitor when port goes away suddenly (as when user presses Leonardo reset button)"
This reverts commit e9a00eb38f3988a1fe28206bdfca618384bbda0f.
This commit is contained in:
parent
202bb102a0
commit
f66b83dd35
@ -28,10 +28,8 @@ import javax.swing.*;
|
|||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
import gnu.io.CommPortIdentifier;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
public class SerialMonitor extends JFrame implements MessageConsumer, Runnable {
|
public class SerialMonitor extends JFrame implements MessageConsumer {
|
||||||
private Serial serial;
|
private Serial serial;
|
||||||
private String port;
|
private String port;
|
||||||
private JTextArea textArea;
|
private JTextArea textArea;
|
||||||
@ -173,9 +171,6 @@ public class SerialMonitor extends JFrame implements MessageConsumer, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread thread = new Thread(this);
|
|
||||||
thread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setPlacement(int[] location) {
|
protected void setPlacement(int[] location) {
|
||||||
@ -233,26 +228,4 @@ public class SerialMonitor extends JFrame implements MessageConsumer, Runnable {
|
|||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
|
||||||
while (!Thread.interrupted()) {
|
|
||||||
if (serial != null) {
|
|
||||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
|
||||||
boolean portStillHere = false;
|
|
||||||
while (portList.hasMoreElements()) {
|
|
||||||
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
|
|
||||||
if (portId.getName().equals(port)) {
|
|
||||||
portStillHere = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!portStillHere) {
|
|
||||||
closeSerialPort();
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException ex) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user