From f94f1875280de435316086310f4518921aca2bab Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 14 Oct 2012 19:43:58 -0500 Subject: [PATCH] AndroidGCS: Remove an unnecessary check that was triggering false positive telemetry errors --- .../openpilot/uavtalk/TelemetryMonitor.java | 18 +++++++++++------- .../src/org/openpilot/uavtalk/UAVTalk.java | 19 +++++-------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java b/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java index b1313b578..053c2a227 100644 --- a/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java +++ b/androidgcs/src/org/openpilot/uavtalk/TelemetryMonitor.java @@ -50,7 +50,7 @@ public class TelemetryMonitor extends Observable { static final int STATS_CONNECT_PERIOD_MS = 1000; static final int CONNECTION_TIMEOUT_MS = 8000; - private final boolean HANDSHAKE_IS_CONNECTED = false; + private final boolean HANDSHAKE_IS_CONNECTED = true; private final UAVObjectManager objMngr; private final Telemetry tel; @@ -77,7 +77,8 @@ public class TelemetryMonitor extends Observable { return objects_updated; }; - public TelemetryMonitor(UAVObjectManager objMngr, Telemetry tel, OPTelemetryService s) { + public TelemetryMonitor(UAVObjectManager objMngr, Telemetry tel, + OPTelemetryService s) { this(objMngr, tel); telemService = s; } @@ -373,7 +374,9 @@ public class TelemetryMonitor extends Observable { startRetrievingObjects(); else firmwareIapObj.updateRequested(); - if (HANDSHAKE_IS_CONNECTED) setChanged(); // Enabling this line makes the opConnected signal occur whenever we get a handshake + if (HANDSHAKE_IS_CONNECTED) + setChanged(); // Enabling this line makes the opConnected signal + // occur whenever we get a handshake } if (gcsDisconnected && gcsStatusChanged) { if (DEBUG) @@ -423,16 +426,17 @@ public class TelemetryMonitor extends Observable { if (DEBUG) Log.d(TAG, "Received firmware IAP Updated message"); UAVObjectField description = firmwareIapObj.getField("Description"); - if(description == null || description.getNumElements() < 100) { + if (description == null || description.getNumElements() < 100) { telemService.toastMessage("Failed to determine UAVO set"); } else { final int HASH_SIZE_USED = 8; String jarName = new String(); - for(int i = 0; i < HASH_SIZE_USED; i++) - jarName += Integer.toHexString((int) description.getDouble(i+60)); + for (int i = 0; i < HASH_SIZE_USED; i++) + jarName += Integer.toHexString((int) description + .getDouble(i + 60)); jarName += ".jar"; if (DEBUG) Log.d(TAG, "Attempting to load: " + jarName); - if (telemService.loadUavobjects(jarName, objMngr) ) { + if (telemService.loadUavobjects(jarName, objMngr)) { telemService.toastMessage("Loaded appropriate UAVO set"); objectsRegistered = true; try { diff --git a/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java b/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java index da27f4dc0..fae619714 100644 --- a/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java +++ b/androidgcs/src/org/openpilot/uavtalk/UAVTalk.java @@ -418,7 +418,7 @@ public class UAVTalk { { UAVObject rxObj = objMngr.getObject(rxObjId); if (rxObj == null) { - if (DEBUG) Log.d(TAG, "Unknown ID: " + rxObjId); + if (WARN) Log.w(TAG, "Unknown ID: " + rxObjId); stats.rxErrors++; rxState = RxStateType.STATE_SYNC; break; @@ -432,17 +432,7 @@ public class UAVTalk { // Check length and determine next state if (rxLength >= MAX_PAYLOAD_LENGTH) { - stats.rxErrors++; - rxState = RxStateType.STATE_SYNC; - break; - } - - // Check the lengths match - if ((rxPacketLength + rxLength) != packetSize) { // packet error - // - - // mismatched - // packet - // size + if (WARN) Log.w(TAG, "Greater than max payload length"); stats.rxErrors++; rxState = RxStateType.STATE_SYNC; break; @@ -506,7 +496,7 @@ public class UAVTalk { rxCSPacket = rxbyte; if (rxCS != rxCSPacket) { // packet error - faulty CRC - if (DEBUG) Log.d(TAG,"Bad crc"); + if (WARN) Log.w(TAG,"Bad crc"); stats.rxErrors++; rxState = RxStateType.STATE_SYNC; break; @@ -515,7 +505,7 @@ public class UAVTalk { if (rxPacketLength != (packetSize + 1)) { // packet error - // mismatched packet // size - if (DEBUG) Log.d(TAG,"Bad size"); + if (WARN) Log.w(TAG,"Bad size"); stats.rxErrors++; rxState = RxStateType.STATE_SYNC; break; @@ -532,6 +522,7 @@ public class UAVTalk { break; default: + if (WARN) Log.w(TAG, "Bad state"); rxState = RxStateType.STATE_SYNC; stats.rxErrors++; }