Concatenate multiple message lines
authorPaul Robinson <darkraver@gmail.com>
Wed, 7 Nov 2012 22:05:24 +0000 (22:05 +0000)
committerPaul Robinson <darkraver@gmail.com>
Wed, 7 Nov 2012 22:05:24 +0000 (22:05 +0000)
And use the ">" as the end

obd_io.py

index d444d0f..8daece6 100644 (file)
--- a/obd_io.py
+++ b/obd_io.py
@@ -99,6 +99,7 @@ class OBDPort:
          
          try:
             self.send_command("atz")   # initialize
+            time.sleep(1)
          except serial.SerialException:
             self.State = 0
             return None
@@ -170,7 +171,7 @@ class OBDPort:
     
      def get_result(self):
          """Internal use only: not a public interface"""
-         time.sleep(0.1)
+         time.sleep(0.01)
          repeat_count = 0
          if self.port is not None:
              buffer = ""
@@ -182,9 +183,12 @@ class OBDPort:
                     repeat_count = repeat_count + 1
                     continue
                     
-                 if c == '\r' and len(buffer) > 0:
-                     break
-                 
+                 if c == '\r':
+                    continue
+                    
+                 if c == ">":
+                    break;
+                     
                  if buffer != "" or c != ">": #if something is in buffer, add everything
                     buffer = buffer + c