[mod_term] Use ELM init commands from ELM class
This commit is contained in:
parent
c1820285e8
commit
fdbe0eae16
@ -1,85 +0,0 @@
|
|||||||
#
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
# Day running light off
|
# Day running light off
|
||||||
$addr = 26
|
$addr = 26
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
10C0
|
10C0
|
||||||
3BA01800
|
3BA01800
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Car wipers manual control, not managed by rain sensor
|
# Car wipers manual control, not managed by rain sensor
|
||||||
$addr = 26
|
$addr = 26
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
10C0
|
10C0
|
||||||
3BA01200
|
3BA01200
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#Accoustics for R2_08_v3_81
|
#Accoustics for R2_08_v3_81
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
delay 2
|
delay 2
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# QR25 Idle speed correction
|
# QR25 Idle speed correction
|
||||||
$addr = 7A
|
$addr = 7A
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
# check ECU
|
# check ECU
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Repair script for rlink2 black screen
|
# Repair script for rlink2 black screen
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Repair script for rlink2 black screen
|
# Repair script for rlink2 black screen
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Repair script for rlink2 black screen
|
# Repair script for rlink2 black screen
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Repair script for rlink2 black screen
|
# Repair script for rlink2 black screen
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Enable AndroidAuto and CarPlay on R-Link2
|
# Enable AndroidAuto and CarPlay on R-Link2
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Rotate R-Link2 screen
|
# Rotate R-Link2 screen
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
1003
|
1003
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Phone_acoustic and SPVR for RadNav 3.3 and 7.0
|
# Phone_acoustic and SPVR for RadNav 3.3 and 7.0
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
delay 2
|
delay 2
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Phone_acoustic and SPVR for RadNav 8.0
|
# Phone_acoustic and SPVR for RadNav 8.0
|
||||||
$addr = 13
|
$addr = 13
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
delay 2
|
delay 2
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
# terminal
|
# terminal
|
||||||
$addr = 7A
|
$addr = 7A
|
||||||
|
|
||||||
can500 # init can macro
|
init_can_500 # init can macro
|
||||||
|
|
||||||
session 10C0
|
session 10C0
|
||||||
|
@ -2006,11 +2006,11 @@ class ELM:
|
|||||||
if self.currentprotocol == "can" and self.currentaddress == addr:
|
if self.currentprotocol == "can" and self.currentaddress == addr:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len (ecu['idTx']): dnat[addr] = ecu['idTx']
|
if len(ecu.get('idTx', '')): dnat[addr] = ecu['idTx']
|
||||||
if len (ecu['idRx']): snat[addr] = ecu['idRx']
|
if len(ecu.get('idRx', '')): snat[addr] = ecu['idRx']
|
||||||
|
|
||||||
if self.lf != 0:
|
if self.lf != 0:
|
||||||
self.lf.write ('#' * 60 + "\n#connect to: " + ecu['ecuname'] + " Addr:" + addr + "\n" + '#' * 60 + "\n")
|
self.lf.write ('#' * 60 + "\n#connect to: " + ecu.get('ecuname', '') + " Addr:" + addr + "\n" + '#' * 60 + "\n")
|
||||||
self.lf.flush ()
|
self.lf.flush ()
|
||||||
|
|
||||||
self.currentprotocol = "can"
|
self.currentprotocol = "can"
|
||||||
@ -2096,19 +2096,19 @@ class ELM:
|
|||||||
self.notSupportedCommands = {}
|
self.notSupportedCommands = {}
|
||||||
self.tmpNotSupportedCommands = {}
|
self.tmpNotSupportedCommands = {}
|
||||||
|
|
||||||
if self.currentprotocol == "iso" and self.currentaddress == addr and self.currentsubprotocol == ecu['protocol']:
|
if self.currentprotocol == "iso" and self.currentaddress == addr and self.currentsubprotocol == ecu.get('protocol', ''):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.lf != 0:
|
if self.lf != 0:
|
||||||
self.lf.write ('#' * 60 + "\n#connect to: " + ecu['ecuname'] + " Addr:" + addr + " Protocol:" + ecu[
|
self.lf.write ('#' * 60 + "\n#connect to: " + ecu.get('ecuname', '') + " Addr:" + addr + " Protocol:" +
|
||||||
'protocol'] + "\n" + '#' * 60 + "\n")
|
ecu.get('protocol', '') + "\n" + '#' * 60 + "\n")
|
||||||
self.lf.flush ()
|
self.lf.flush ()
|
||||||
|
|
||||||
if self.currentprotocol == "iso":
|
if self.currentprotocol == "iso":
|
||||||
self.check_answer(self.cmd("82")) # close previous session
|
self.check_answer(self.cmd("82")) # close previous session
|
||||||
|
|
||||||
self.currentprotocol = "iso"
|
self.currentprotocol = "iso"
|
||||||
self.currentsubprotocol = ecu['protocol']
|
self.currentsubprotocol = ecu.get('protocol', '')
|
||||||
self.currentaddress = addr
|
self.currentaddress = addr
|
||||||
self.startSession = ""
|
self.startSession = ""
|
||||||
self.lastCMDtime = 0
|
self.lastCMDtime = 0
|
||||||
@ -2123,13 +2123,13 @@ class ELM:
|
|||||||
self.check_answer (self.cmd ("at st ff")) # set timeout to 1 second
|
self.check_answer (self.cmd ("at st ff")) # set timeout to 1 second
|
||||||
self.check_answer (self.cmd ("at at 0")) # disable adaptive timing
|
self.check_answer (self.cmd ("at at 0")) # disable adaptive timing
|
||||||
|
|
||||||
if 'PRNA2000' in ecu['protocol'].upper () or mod_globals.opt_si:
|
if 'PRNA2000' in ecu.get('protocol', '').upper () or mod_globals.opt_si:
|
||||||
self.cmd ("at sp 4") # slow init mode 4
|
self.cmd ("at sp 4") # slow init mode 4
|
||||||
if len (ecu['slowInit']) > 0:
|
if len (ecu.get('slowInit', '')) > 0:
|
||||||
self.cmd ("at iia " + ecu['slowInit']) # address for slow init
|
self.cmd ("at iia " + ecu['slowInit']) # address for slow init
|
||||||
rsp = self.lastinitrsp = self.cmd ("at si") # for slow init mode 4
|
rsp = self.lastinitrsp = self.cmd ("at si") # for slow init mode 4
|
||||||
# rsp = self.cmd("81")
|
# rsp = self.cmd("81")
|
||||||
if 'ERROR' in rsp and len (ecu['fastInit']) > 0:
|
if 'ERROR' in rsp and len (ecu.get('fastInit', '')) > 0:
|
||||||
ecu['protocol'] = ''
|
ecu['protocol'] = ''
|
||||||
if self.lf != 0:
|
if self.lf != 0:
|
||||||
self.lf.write ('### Try fast init\n')
|
self.lf.write ('### Try fast init\n')
|
||||||
|
@ -100,6 +100,7 @@ def pars_macro( file ):
|
|||||||
l = l.strip()
|
l = l.strip()
|
||||||
if l == '': continue
|
if l == '': continue
|
||||||
if '{' in l:
|
if '{' in l:
|
||||||
|
print("line { :", l)
|
||||||
if macroname=='':
|
if macroname=='':
|
||||||
literals = l.split('{')
|
literals = l.split('{')
|
||||||
macroname = literals[0].strip()
|
macroname = literals[0].strip()
|
||||||
@ -114,6 +115,7 @@ def pars_macro( file ):
|
|||||||
var = {}
|
var = {}
|
||||||
return
|
return
|
||||||
if '}' in l:
|
if '}' in l:
|
||||||
|
print("line } :", l)
|
||||||
if macroname!='':
|
if macroname!='':
|
||||||
literals = l.split('}')
|
literals = l.split('}')
|
||||||
cmd = literals[0].strip()
|
cmd = literals[0].strip()
|
||||||
@ -224,6 +226,12 @@ def optParser():
|
|||||||
default=False,
|
default=False,
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
|
||||||
|
parser.add_argument("--caf",
|
||||||
|
help="turn on CAN Auto Formatting. Available only for OBDLink",
|
||||||
|
dest="caf",
|
||||||
|
default=False,
|
||||||
|
action="store_true")
|
||||||
|
|
||||||
parser.add_argument("--n1c",
|
parser.add_argument("--n1c",
|
||||||
help="turn off L1 cache",
|
help="turn off L1 cache",
|
||||||
dest="n1c",
|
dest="n1c",
|
||||||
@ -274,6 +282,7 @@ def optParser():
|
|||||||
mod_globals.opt_demo = options.demo
|
mod_globals.opt_demo = options.demo
|
||||||
mod_globals.opt_si = options.si
|
mod_globals.opt_si = options.si
|
||||||
mod_globals.opt_cfc0 = options.cfc
|
mod_globals.opt_cfc0 = options.cfc
|
||||||
|
mod_globals.opt_caf = options.caf
|
||||||
mod_globals.opt_n1c = options.n1c
|
mod_globals.opt_n1c = options.n1c
|
||||||
mod_globals.opt_minordtc = options.minordtc
|
mod_globals.opt_minordtc = options.minordtc
|
||||||
auto_dia = options.dia
|
auto_dia = options.dia
|
||||||
@ -428,21 +437,21 @@ def play_macro(mname, elm):
|
|||||||
global var
|
global var
|
||||||
global stack
|
global stack
|
||||||
|
|
||||||
if mname in stack:
|
def run_init_function(mname, elm):
|
||||||
print 'Error: recursion prohibited:', mname
|
global var
|
||||||
return
|
|
||||||
else:
|
|
||||||
stack.append(mname)
|
|
||||||
|
|
||||||
for l in macro[mname]:
|
if mname in ["init_can_250", "init_can_500"]:
|
||||||
|
elm.init_can()
|
||||||
if l in macro.keys():
|
if mname == "init_can_250":
|
||||||
play_macro(l, elm)
|
elm.set_can_addr(var['$addr'], {'brp': '1'})
|
||||||
continue
|
else:
|
||||||
|
elm.set_can_addr(var['$addr'], {})
|
||||||
proc_line( l, elm )
|
elif mname in ["init_iso_slow", "init_iso_fast"]:
|
||||||
|
elm.init_iso()
|
||||||
stack.remove(mname)
|
if mname == "init_iso_slow":
|
||||||
|
elm.set_iso_addr(var['$addr'], {'protocol': 'PRNA2000'})
|
||||||
|
else:
|
||||||
|
elm.set_iso_addr(var['$addr'], {})
|
||||||
|
|
||||||
def term_cmd( c, elm ):
|
def term_cmd( c, elm ):
|
||||||
global var
|
global var
|
||||||
@ -682,8 +691,8 @@ def proc_line( l, elm ):
|
|||||||
mod_utils.clearScreen()
|
mod_utils.clearScreen()
|
||||||
return
|
return
|
||||||
|
|
||||||
if l in macro.keys():
|
if l.startswith("init"):
|
||||||
play_macro(l, elm)
|
run_init_function(l, elm)
|
||||||
return
|
return
|
||||||
|
|
||||||
m = re.search('\$\S+\s*=\s*\S+', l)
|
m = re.search('\$\S+\s*=\s*\S+', l)
|
||||||
@ -713,7 +722,7 @@ def proc_line( l, elm ):
|
|||||||
l_parts = l.split()
|
l_parts = l.split()
|
||||||
if len(l_parts) > 0 and l_parts[0] in ['wait', 'sleep']:
|
if len(l_parts) > 0 and l_parts[0] in ['wait', 'sleep']:
|
||||||
try:
|
try:
|
||||||
wait_kb(int(l_parts[1]))
|
wait_kb(float(l_parts[1]))
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -726,7 +735,7 @@ def proc_line( l, elm ):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if len(l_parts) > 0 and l_parts[0] in ['delay']:
|
if len(l_parts) > 0 and l_parts[0] in ['delay']:
|
||||||
cmd_delay = int(l_parts[1])
|
cmd_delay = float(l_parts[1])
|
||||||
return
|
return
|
||||||
|
|
||||||
if l.lower().startswith('set_bits'):
|
if l.lower().startswith('set_bits'):
|
||||||
@ -797,9 +806,6 @@ def main():
|
|||||||
load_macro()
|
load_macro()
|
||||||
|
|
||||||
optParser()
|
optParser()
|
||||||
|
|
||||||
# disable auto flow control
|
|
||||||
mod_globals.opt_cfc0 = True
|
|
||||||
|
|
||||||
print 'Opening ELM'
|
print 'Opening ELM'
|
||||||
elm = mod_elm.ELM( mod_globals.opt_port, mod_globals.opt_speed, True )
|
elm = mod_elm.ELM( mod_globals.opt_port, mod_globals.opt_speed, True )
|
||||||
@ -835,8 +841,8 @@ def main():
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if auto_macro != '':
|
if auto_macro != '':
|
||||||
if auto_macro in macro.keys():
|
if auto_macro.startswith("init"):
|
||||||
play_macro( auto_macro, elm )
|
run_init_function(auto_macro, elm)
|
||||||
else:
|
else:
|
||||||
print 'Error: unknown macro name:', auto_macro
|
print 'Error: unknown macro name:', auto_macro
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user