Correctly decode DTCs
authorPeter Harris <git@peter.is-a-geek.org>
Fri, 29 Oct 2010 00:20:56 +0000 (20:20 -0400)
committerPeter Harris <git@peter.is-a-geek.org>
Fri, 29 Oct 2010 00:22:43 +0000 (20:22 -0400)
The old algorithm only works with xx00x codes (and/or some other OBD
interface that does some pre-processing on the return value?)

obd_io.py

index 627f5ca..1112ef5 100644 (file)
--- a/obd_io.py
+++ b/obd_io.py
@@ -251,7 +251,7 @@ class OBDPort:
                 if val==0: #skip fill of last packet
                   break
                    
-                DTCStr=dtcLetters[(val&0xC000)>14]+str((val&0x3000)>>12)+str(val&0x0fff) 
+                DTCStr=dtcLetters[(val&0xC000)>14]+str((val&0x3000)>>12)+str((val&0x0f00)>>8)+str((val&0x00f0)>>4)+str(val&0x000f)
                 
                 DTCCodes.append(["Active",DTCStr])
           
@@ -271,7 +271,7 @@ class OBDPort:
               if val==0: #skip fill of last packet
                 break
                    
-              DTCStr=dtcLetters[(val&0xC000)>14]+str((val&0x3000)>>12)+str(val&0x0fff)
+              DTCStr=dtcLetters[(val&0xC000)>14]+str((val&0x3000)>>12)+str((val&0x0f00)>>8)+str((val&0x00f0)>>4)+str(val&0x000f)
               DTCCodes.append(["Passive",DTCStr])
               
           return DTCCodes