miao zhicheng / Mbed 2 deprecated DragonflyMQTT

Dependencies:   MQTT mbed mtsas

Revision:
6:4a25f3b9caef
Parent:
5:ded8fe5991a2
--- a/TripDataReader.cpp	Tue Sep 05 15:00:17 2017 +0000
+++ b/TripDataReader.cpp	Fri Sep 08 07:35:33 2017 +0000
@@ -130,9 +130,9 @@
     uint8_t obdData[16];
     TripData d;
 
-    d.averageSpeed = (float)tripDataHistory.speed*0.62137119f/(float)tripDataHistory.speedSamples;
+    d.averageSpeed = tripDataHistory.speedSamples ? (float)tripDataHistory.speed*0.62137119f/(float)tripDataHistory.speedSamples : 0;
     d.minimumThrottle = (float)tripDataHistory.minT*0.39215686f;
-    d.averageThrottle = (float)tripDataHistory.avgT*0.39215686f/(float)tripDataHistory.throttleSamples;
+    d.averageThrottle = tripDataHistory.throttleSamples ? (float)tripDataHistory.avgT*0.39215686f/(float)tripDataHistory.throttleSamples : 0;
     d.maximumThrottle = (float)tripDataHistory.maxT*0.39215686f;
     d.hardBrakeCount = tripDataHistory.hardBrakeCount;