Erm
authorPaul Robinson <darkraver@gmail.com>
Wed, 7 Nov 2012 22:13:22 +0000 (22:13 +0000)
committerPaul Robinson <darkraver@gmail.com>
Wed, 7 Nov 2012 22:13:22 +0000 (22:13 +0000)
obd_io.py
obd_recorder.py
obd_sensors.py

index 7816e45..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,14 +183,12 @@ class OBDPort:
                     repeat_count = repeat_count + 1
                     continue
                     
-                 if c == '\r' and len(buffer) > 0:
-                     if(buffer == "SEARCHING..."):
-                         buffer = ""
-                         continue
-                     if(buffer == "UNABLE TO CONNECT"):
-                         return None
-                     break
-                 
+                 if c == '\r':
+                    continue
+                    
+                 if c == ">":
+                    break;
+                     
                  if buffer != "" or c != ">": #if something is in buffer, add everything
                     buffer = buffer + c
                     
index 7cae191..76497b3 100755 (executable)
@@ -14,13 +14,14 @@ class OBD_Recorder():
         self.sensorlist = []
         self.logger = logging.getLogger(__name__)
         log_handler = logging.FileHandler(filename)
-        log_formatter = logging.Formatter('%(asctime)s %(message)s')
+        log_formatter = logging.Formatter('%(asctime)s,%(message)s', "%H:%M:%S:%f")
         log_handler.setFormatter(log_formatter)
         self.logger.addHandler(log_handler)
         self.logger.setLevel(logging.INFO)
         
     def connect(self):
         portnames = scanSerial()
+        #portnames = ['COM10']
         print portnames
         for port in portnames:
             self.port = obd_io.OBDPort(port, None, 2, 2)
index 1f8c6d2..ebf323b 100644 (file)
@@ -146,12 +146,12 @@ SENSORS = [
     Sensor("long_term_fuel_trim_2" , "     Long Term Fuel Trim", "0109", fuel_trim_percent,"%"      ),
     Sensor("fuel_pressure"         , "      Fuel Rail Pressure", "010A", cpass            ,""       ),
     Sensor("manifold_pressure"     , "Intake Manifold Pressure", "010B", intake_m_pres    ,"psi"    ),
-    Sensor("rpm"                   , "              Engine RPM", "010C", rpm              ,""       ),
-    Sensor("speed"                 , "           Vehicle Speed", "010D", speed            ,"MPH"    ),
+    Sensor("rpm"                   , "              Engine RPM", "010C1", rpm              ,""       ),
+    Sensor("speed"                 , "           Vehicle Speed", "010D1", speed            ,"MPH"    ),
     Sensor("timing_advance"        , "          Timing Advance", "010E", timing_advance   ,"degrees"),
     Sensor("intake_air_temp"       , "         Intake Air Temp", "010F", temp             ,"C"      ),
     Sensor("maf"                   , "     Air Flow Rate (MAF)", "0110", maf              ,"lb/min" ),
-    Sensor("throttle_pos"          , "       Throttle Position", "0111", throttle_pos     ,"%"      ),
+    Sensor("throttle_pos"          , "       Throttle Position", "01111", throttle_pos     ,"%"      ),
     Sensor("secondary_air_status"  , "    Secondary Air Status", "0112", cpass            ,""       ),
     Sensor("o2_sensor_positions"   , "  Location of O2 sensors", "0113", cpass            ,""       ),
     Sensor("o211"                  , "        O2 Sensor: 1 - 1", "0114", fuel_trim_percent,"%"      ),