Adding error checking
authorPaul Robinson <darkraver@gmail.com>
Sun, 16 Dec 2012 15:17:42 +0000 (15:17 +0000)
committerPaul Robinson <darkraver@gmail.com>
Sun, 16 Dec 2012 15:17:42 +0000 (15:17 +0000)
obd_recorder.py

index a6e432a..863150c 100755 (executable)
@@ -71,6 +71,11 @@ class OBD_Recorder():
             self.log_file.write(log_string)
             
     def calculate_gear(self, rpm, speed):
+        if speed == "" or speed == 0:
+            return 0
+        if rpm == "" or rpm == 0:
+            return 0
+
         rps = rpm/60
         mps = (speed*1.609*1000)/3600