From 06f583ff754a0813171e789451cb95f7f6bb497e Mon Sep 17 00:00:00 2001 From: James Cotton Date: Thu, 10 Mar 2011 21:36:09 -0600 Subject: [PATCH] Fixed some timer issues. Got connection with this. --- .../src/org/openpilot/uavtalk/Telemetry.java | 9 ++++++++- .../org/openpilot/uavtalk/TelemetryMonitor.java | 3 --- .../src/org/openpilot/uavtalk/UAVTalk.java | 16 +++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/androidgcs/src/org/openpilot/uavtalk/Telemetry.java b/androidgcs/src/org/openpilot/uavtalk/Telemetry.java index d2f82459b..7f04e344b 100644 --- a/androidgcs/src/org/openpilot/uavtalk/Telemetry.java +++ b/androidgcs/src/org/openpilot/uavtalk/Telemetry.java @@ -101,7 +101,14 @@ public class Telemetry { } synchronized void transTimerSetPeriod(int periodMs) { - transTimer = new Timer(); + if(transTimerTask != null) + transTimerTask.cancel(); + + if(transTimer != null) + transTimer.purge(); + + transTimer = new Timer(); + transTimerTask = new TimerTask() { @Override public void run() { diff --git a/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java b/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java index bc0bfd6eb..eb406923d 100644 --- a/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java +++ b/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java @@ -164,7 +164,6 @@ public class TelemetryMonitor { gcsStatsObj = objMngr.getObject("GCSTelemetryStats"); flightStatsObj = objMngr.getObject("FlightTelemetryStats"); - System.out.println(flightStatsObj.toString()); if ( ((String) gcsStatsObj.getField("Status").getValue()).compareTo("Connected") != 0 || ((String) flightStatsObj.getField("Status").getValue()).compareTo("Connected") == 0 ) { @@ -250,8 +249,6 @@ public class TelemetryMonitor { boolean gcsConnected = ((String) statusField.getValue()).compareTo("Connected") == 0; boolean gcsDisconnected = ((String) statusField.getValue()).compareTo("Disconnected") == 0; - if(gcsConnected) - System.out.println("Detected here"); if ( gcsStatusChanged || ((String) flightStatsObj.getField("Status").getValue()).compareTo("Disconnected") != 0 ) { diff --git a/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java b/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java index d656aa707..825f9d9fe 100644 --- a/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java +++ b/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java @@ -180,7 +180,7 @@ public class UAVTalk extends Observable{ break; } - System.out.println("Received byte " + val + " in state + " + rxState); + //System.out.println("Received byte " + val + " in state + " + rxState); processInputByte(val); } } @@ -423,7 +423,6 @@ public class UAVTalk extends Observable{ // Update CRC rxCS = updateCRC(rxCS, rxbyte); - //System.out.println(rxCount + "/" + rxLength); rxBuffer.put(rxCount++, (byte) (rxbyte & 0xff)); if (rxCount < rxLength) break; @@ -491,7 +490,7 @@ public class UAVTalk extends Observable{ // All instances, not allowed for OBJ messages if (!allInstances) { - System.out.println("Received object: " + objId + " " + objMngr.getObject(objId).getName()); + System.out.println("Received object: " + objMngr.getObject(objId).getName()); // Get object and update its data obj = updateObject(objId, instId, data); // Check if an ack is pending @@ -513,7 +512,7 @@ public class UAVTalk extends Observable{ // All instances, not allowed for OBJ_ACK messages if (!allInstances) { - System.out.println("Received object ack: " + objId + " " + objMngr.getObject(objId).getName()); +// System.out.println("Received object ack: " + objId + " " + objMngr.getObject(objId).getName()); // Get object and update its data obj = updateObject(objId, instId, data); // Transmit ACK @@ -533,7 +532,7 @@ public class UAVTalk extends Observable{ break; case TYPE_OBJ_REQ: // Get object, if all instances are requested get instance 0 of the object - System.out.println("Received object request: " + objId + " " + objMngr.getObject(objId).getName()); +// System.out.println("Received object request: " + objId + " " + objMngr.getObject(objId).getName()); if (allInstances) { obj = objMngr.getObject(objId); @@ -556,7 +555,7 @@ public class UAVTalk extends Observable{ // All instances, not allowed for ACK messages if (!allInstances) { - System.out.println("Received ack: " + objId + " " + objMngr.getObject(objId).getName()); +// System.out.println("Received ack: " + objId + " " + objMngr.getObject(objId).getName()); // Get object obj = objMngr.getObject(objId, instId); // Check if an ack is pending @@ -617,14 +616,14 @@ public class UAVTalk extends Observable{ // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("Unpacking new object"); +// System.out.println("Unpacking new object"); instobj.unpack(data); return instobj; } else { // Unpack data into object instance - System.out.println("Unpacking existing object: " + data.position() + " / " + data.capacity() ); +// System.out.println("Unpacking existing object: " + data.position() + " / " + data.capacity() ); obj.unpack(data); return obj; } @@ -772,7 +771,6 @@ public class UAVTalk extends Observable{ bbuf.position(0); byte [] dst = new byte[packlen]; bbuf.get(dst,0,packlen); - System.out.println("Outputting: " + dst.length); outStream.write(dst); } catch (IOException e) { // TODO Auto-generated catch block