Updated to run without serial connection

This commit is contained in:
nifi 2010-10-28 14:17:10 +00:00
parent 2682536bf7
commit 571519db97
1 changed files with 13 additions and 9 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: CollectServer.java,v 1.31 2010/10/24 21:40:54 nifi Exp $ * $Id: CollectServer.java,v 1.32 2010/10/28 14:17:10 nifi Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
@ -34,8 +34,8 @@
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 3 jul 2008 * Created : 3 jul 2008
* Updated : $Date: 2010/10/24 21:40:54 $ * Updated : $Date: 2010/10/28 14:17:10 $
* $Revision: 1.31 $ * $Revision: 1.32 $
*/ */
package se.sics.contiki.collect; package se.sics.contiki.collect;
@ -782,7 +782,7 @@ public class CollectServer implements SerialConnectionListener {
} }
protected void connectToSerial() { protected void connectToSerial() {
if (!serialConnection.isOpen()) { if (serialConnection != null && !serialConnection.isOpen()) {
String comPort = serialConnection.getComPort(); String comPort = serialConnection.getComPort();
if (comPort == null && serialConnection.isMultiplePortsSupported()) { if (comPort == null && serialConnection.isMultiplePortsSupported()) {
comPort = MoteFinder.selectComPort(window); comPort = MoteFinder.selectComPort(window);
@ -1057,7 +1057,7 @@ public class CollectServer implements SerialConnectionListener {
return false; return false;
} }
protected void parseIncomingLine(long systemTime, String line) { public void handleIncomingData(long systemTime, String line) {
if (line.length() == 0 || line.charAt(0) == '#') { if (line.length() == 0 || line.charAt(0) == '#') {
// Ignore empty lines, comments, and annotations. // Ignore empty lines, comments, and annotations.
return; return;
@ -1237,11 +1237,15 @@ public class CollectServer implements SerialConnectionListener {
public void run() { public void run() {
try { try {
if (serialConnection != null && serialConnection.isOpen()) { if (serialConnection != null) {
if (serialConnection.isOpen()) {
serialConnection.close(); serialConnection.close();
} else { } else {
connectToSerial(); connectToSerial();
} }
} else {
JOptionPane.showMessageDialog(window, "No serial connection configured", "Error", JOptionPane.ERROR_MESSAGE);
}
} finally { } finally {
isRunning = false; isRunning = false;
} }
@ -1311,7 +1315,7 @@ public class CollectServer implements SerialConnectionListener {
@Override @Override
public void serialData(SerialConnection connection, String line) { public void serialData(SerialConnection connection, String line) {
parseIncomingLine(System.currentTimeMillis(), line); handleIncomingData(System.currentTimeMillis(), line);
} }
@Override @Override