diff --git a/pyren/macro/init.txt b/pyren/macro/init.txt new file mode 100644 index 0000000..b47e970 --- /dev/null +++ b/pyren/macro/init.txt @@ -0,0 +1,86 @@ +# +# +# Initialisation macros for mod_term +# +# + +$addr = 7A +$txa = 7E0 +$rxa = 7E8 + +# reset elm +reset_elm { + at ws + $prompt = ELM +} + +# general CAN init +init_can { + reset_elm #macro + at e1 + at s0 + at h0 + at l0 + at al + at caf0 + at cfc0 + at sh $txa + at cra $rxa + at fc sh $txa + at fc sd 30 00 00 + at fc sm 1 + $prompt = CAN +} + +# CAN 250 init +can250 { + init_can + at st ff + at at 0 + at sp 8 + at at 1 + $prompt = CAN250 +} + +# CAN 500 init +can500 { + init_can + at st ff + at at 0 + at sp 6 + at at 1 + $prompt = CAN500 +} + +# general ISO init +init_iso { + reset_elm #macro + at e1 + at l1 + at d1 + at sh 81 $addr f1 + at sw 96 + at wm 81 $addr f1 3E + #at wm 82 $addr f1 3E01 + at ib10 + at st ff + at at 0 + $prompt = KL +} + +# K-Line slow init +slow { + init_iso + at sp 4 + at at 1 + $prompt = SLOW +} + +# K-Line fast init +fast { + init_iso + at sp 5 + at at 1 + $prompt = FAST +} + diff --git a/pyren/mod_elm.py b/pyren/mod_elm.py index d6f349f..9f4815c 100644 --- a/pyren/mod_elm.py +++ b/pyren/mod_elm.py @@ -465,7 +465,7 @@ class Port: continue self.buff += byte tc = time.time () - if 'ELM' or 'STN' in self.buff: + if ('ELM' in self.buff) or ('STN' in self.buff): break if (tc - tb) > 1: print "ERROR - rate not supported. Let's go back." diff --git a/pyren/mod_scan_ecus.py b/pyren/mod_scan_ecus.py index 429932c..91b43ec 100644 --- a/pyren/mod_scan_ecus.py +++ b/pyren/mod_scan_ecus.py @@ -645,7 +645,7 @@ class ScanEcus: ttrrsp = rrsp.replace(' ','') if not all(c in string.hexdigits for c in ttrrsp): return False - while base+6<=len(row) and (int(row[base+3])*3+2)<=len(rrsp): + while base+6<=len(row): if row[base]!=req: req = row[base] rrsp = self.elm.cmd(req)[3:] @@ -654,7 +654,10 @@ class ScanEcus: if not all(c in string.hexdigits for c in ttrrsp): return False if len( req )/2==3: rrsp = rrsp[3:] - + + if int(row[base+3])*3+2 > len(rrsp): + return False + byte = int(rrsp[int(row[base+3])*3:int(row[base+3])*3+2],16) mask = int(row[base+4],16) val = int(row[base+5],16) @@ -691,8 +694,8 @@ class ScanEcus: if row['stdType']=='UDS': rerr = self.elm.cmd('1902AF') #get errors UDS - if len(row['stopDiagReq'])>0: - self.elm.cmd(row['stopDiagReq']) #close session + #if len(row['stopDiagReq'])>0: + # self.elm.cmd(row['stopDiagReq']) #close session self.elm.cmd("at at 1") #enable adaptive timing