Merge branch 'ss'

This commit is contained in:
Marianpol 2020-03-10 11:56:22 +01:00
commit ff2e0fa5ca
12 changed files with 1494 additions and 24 deletions

View File

@ -189,7 +189,7 @@ class ECU:
flist = []
for root, dirs, files in os.walk("./dumps"):
for f in files:
if (self.ecudata['ecuname']+'.') in f:
if (self.ecudata['ecuname']+'.txt') in f:
flist.append(f)
if len(flist)==0: return
@ -255,7 +255,7 @@ class ECU:
return None
return self.Parameters[name]
def get_id( self, name ):
def get_id( self, name, raw = 0):
if name not in self.Identifications.keys():
for i in self.Identifications.keys():
if name==self.Identifications[i].codeMR:
@ -264,6 +264,8 @@ class ECU:
if name not in self.Identifications.keys():
return 'none','unknown identification'
self.elm.clear_cache()
if raw:
return get_identification( self.Identifications[name], self.Mnemonics, self.Services, self.elm, self.calc, raw)
datastr, help, csvd = get_identification( self.Identifications[name], self.Mnemonics, self.Services, self.elm, self.calc )
return csvd, datastr
@ -424,17 +426,25 @@ class ECU:
print "Press any key to exit"
for dr in datarefs:
datastr = dr.name;
datastr = dr.name
help = dr.type
if dr.type=='State':
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
if self.DataIds and "DTC" in path and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].memDatarefs:
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
else:
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
if dr.type=='Parameter':
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
if self.DataIds and "DTC" in path and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].memDatarefs:
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
else:
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
if dr.type=='Identification':
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
if dr.type=='Command':
datastr = dr.name + " [Command] " + self.Commands[dr.name].label
if dr.type=="Text":
datastr = dr.name
help = ""
if mod_globals.opt_csv and csvf!=0 and (dr.type=='State' or dr.type=='Parameter'):
csvline += ";" + (pyren_encode(csvd) if mod_globals.opt_csv_human else str(csvd))
@ -530,6 +540,8 @@ class ECU:
kb.set_normal_term()
if mod_globals.opt_csv and csvf!=0:
csvf.close()
if "DTC" in path:
mod_globals.ext_cur_DTC = "000000"
return
def add_favourite(self):
@ -704,10 +716,22 @@ class ECU:
index = int(choice[1])-1
dtchex = listkeys[index] if len(listkeys) > index else listkeys[0]
mod_globals.ext_cur_DTC = dtchex
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
cur_dtrf = []
mem_dtrf = []
if self.Defaults[dtchex[:4]].datarefs:
cur_dtrf = [ecu_screen_dataref(0, "\n" + mod_globals.language_dict['300'] + "\n", 'Text')] + self.Defaults[dtchex[:4]].datarefs
if self.Defaults[dtchex[:4]].memDatarefs:
mem_dtrf_txt = mod_globals.language_dict['299'] + " DTC" + mod_globals.ext_cur_DTC + "\n"
mem_dtrf = [ecu_screen_dataref(0, mem_dtrf_txt, 'Text')] + self.Defaults[dtchex[:4]].memDatarefs
self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
tmp_dtrf = mem_dtrf + cur_dtrf
self.show_datarefs(tmp_dtrf, path)
def show_defaults_std_b(self):
while(1):
@ -745,8 +769,20 @@ class ECU:
mod_globals.ext_cur_DTC = dtchex
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
tmp_dtrf = self.Defaults[dtchex[:4]].datarefs + self.ext_de
cur_dtrf = []
mem_dtrf = []
ext_info_dtrf = []
if self.Defaults[dtchex[:4]].datarefs:
cur_dtrf = [ecu_screen_dataref(0, "\n" + mod_globals.language_dict['300'] + "\n", 'Text')] + self.Defaults[dtchex[:4]].datarefs
if self.Defaults[dtchex[:4]].memDatarefs:
mem_dtrf_txt = mod_globals.language_dict['299'] + " DTC" + mod_globals.ext_cur_DTC + "\n"
mem_dtrf = [ecu_screen_dataref(0, mem_dtrf_txt, 'Text')] + self.Defaults[dtchex[:4]].memDatarefs
if self.ext_de:
ext_info_dtrf = [ecu_screen_dataref(0, "\n" + mod_globals.language_dict['1691'] + "\n", 'Text')] + self.ext_de
tmp_dtrf = mem_dtrf + cur_dtrf + ext_info_dtrf
#self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
self.show_datarefs(tmp_dtrf, path)

View File

@ -350,6 +350,7 @@ class ecu_default:
label = ""
status = 0
datarefs = []
memDatarefs = []
helps = []
caracter = {}
interpInfoPeri = ""
@ -384,6 +385,16 @@ class ecu_default:
for dr in DataRef:
dataref = ecu_screen_dataref( dr )
self.datarefs.append( dataref )
self.memDatarefs = []
MemorisedInfo = df.getElementsByTagName("MemorisedInfo")
if MemorisedInfo:
for mi in MemorisedInfo:
DataRef = mi.getElementsByTagName("DataRef")
if DataRef:
for dr in DataRef:
dataref = ecu_screen_dataref( dr )
self.memDatarefs.append( dataref )
self.helps = []
Helps = df.getElementsByTagName("Helps")

View File

@ -7,11 +7,13 @@ from xml.dom.minidom import parseString
import xml.dom.minidom
import mod_globals
def get_identification( id, mn, se, elm, calc ):
def get_identification( id, mn, se, elm, calc, raw = 0 ):
comp = id.computation
comp = comp.replace("&","&")
for m in sorted(id.mnemolist, key=len, reverse=True):
hex_val = get_mnemonic( mn[m], se, elm )
hex_val = get_mnemonic( mn[m], se, elm, raw)
if raw:
return hex_val
comp = comp.replace(m, hex_val)
id.value = calc.calculate(comp)
######

View File

@ -33,7 +33,16 @@ def get_mnemonicDTC( m, resp ):
return hexval
def get_mnemonic( m, se, elm ):
def get_mnemonic( m, se, elm, raw = 0 ):
if not m.serviceID and mod_globals.ext_cur_DTC != "000000":
for sid in se.keys():
if se[sid].startReq == "120004"+ mod_globals.ext_cur_DTC[:4]:
m.startByte = se[sid].responces[se[sid].responces.keys()[0]].mnemolocations[m.name].startByte
m.startBit = se[sid].responces[se[sid].responces.keys()[0]].mnemolocations[m.name].startBit
m.request = se[sid].startReq
m.positive = se[sid].simpleRsp
m.delay = '100' #don't know how much it should be
#get responce
if len(m.sids)>0:
@ -48,14 +57,59 @@ def get_mnemonic( m, se, elm ):
if not all(c in string.hexdigits for c in resp): resp = ''
resp = ' '.join(a+b for a,b in zip(resp[::2], resp[1::2]))
if len(m.startByte)==0: m.startByte = u'01'
hexval = getHexVal(m, m.startByte, m.startBit, resp, raw)
return hexval
def get_SnapShotMnemonic(m, se, elm, dataids):
snapshotService = ""
posInResp = 0
for sid in se:
if len(se[sid].params) > 1:
if se[sid].params[1]['type'] == 'Snapshot':
snapshotService = se[sid]
resp = executeService( snapshotService, elm, [], "", True )
if mod_globals.opt_demo and not resp or not resp.startswith(snapshotService.simpleRsp):
return "00"
resp = resp.strip().replace(' ','')
if not all(c in string.hexdigits for c in resp): resp = ''
resp = ' '.join(a+b for a,b in zip(resp[::2], resp[1::2]))
numberOfIdentifiers = int("0x" + resp[7*3:8*3-1],16)
resp = resp[8*3:]
didDict = {}
for x in range(numberOfIdentifiers):
dataId = resp[posInResp:posInResp + 2*3].replace(" ", "")
posInResp += 2*3
if dataId not in dataids.keys():
continue
didDataLength = int(dataids[dataId].dataBitLength)/8
didData = resp[posInResp: posInResp + didDataLength*3]
posInResp += didDataLength*3
didDict[dataId] = didData
startByte = ""
startBit = ""
dataId = ""
for did in dataids.keys():
for mn in dataids[did].mnemolocations.keys():
if mn == m.name:
dataId = did
startByte = dataids[dataId].mnemolocations[m.name].startByte
startBit = dataids[dataId].mnemolocations[m.name].startBit
hexval = getHexVal(m, startByte, startBit, didDict[dataId])
return hexval
def getHexVal(m, startByte, startBit, resp, raw = 0):
#prepare local variables
sb = int(m.startByte) - 1
sb = int(startByte) - 1
bits = int(m.bitsLength)
sbit = int(m.startBit)
sbit = int(startBit)
bytes = (bits+sbit-1)/8+1
rshift = ((bytes+1)*8 - (bits+sbit))%8
#check length of responce
if (sb*3+bytes*3-1)>(len(resp)):
return '00'
@ -64,6 +118,12 @@ def get_mnemonic( m, se, elm ):
hexval = resp[sb*3:(sb+bytes)*3-1]
hexval = hexval.replace(" ","")
if raw:
if resp.startswith(m.positive):
return hexval
else:
return 'ERROR'
#shift and mask
val = (int(hexval,16)>>rshift)&(2**bits-1)

View File

@ -7,7 +7,7 @@ from xml.dom.minidom import parseString
import xml.dom.minidom
import mod_globals
def get_parameter( pr, mn, se, elm, calc ):
def get_parameter( pr, mn, se, elm, calc, dataids = {} ):
comp = pr.computation
comp = comp.replace("&","&")
@ -15,7 +15,10 @@ def get_parameter( pr, mn, se, elm, calc ):
for m in sorted(pr.mnemolist, key=len, reverse=True):
val = get_mnemonic( mn[m], se, elm )
if dataids:
val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
else:
val = get_mnemonic( mn[m], se, elm )
if mn[m].type=="SNUM8" and int(val,16)>0x7f:
val = str(int(val,16)-0x100)
elif mn[m].type=="SNUM16" and int(val,16)>0x7fff:

View File

@ -26,7 +26,10 @@ def playScenario(command, ecu, elm):
if os.path.isfile('./'+scenarioName+'.py'):
scen = __import__( scenarioName )
scen.run( elm, ecu, command, '../'+path+scenarioData )
if mod_globals.clip_arc:
scen.run( elm, ecu, command, '../'+path+scenarioData )
else:
scen.run( elm, ecu, command, './'+path+scenarioData )
return
print "\nThere is scenarium. I do not support them!!!\n"

View File

@ -7,11 +7,14 @@ from xml.dom.minidom import parseString
import xml.dom.minidom
import mod_globals
def get_state( st, mn, se, elm, calc ):
def get_state( st, mn, se, elm, calc, dataids = {} ):
comp = st.computation
comp = comp.replace("&","&")
for m in sorted(st.mnemolist, key=len, reverse=True):
hex_val = get_mnemonic( mn[m], se, elm )
if dataids:
hex_val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
else:
hex_val = get_mnemonic( mn[m], se, elm )
comp = comp.replace(m, "0x"+hex_val)
tmp_val = calc.calculate(comp)

View File

@ -33,7 +33,7 @@ if mod_globals.os != 'android':
DevList = ['27', '28', '2E', '30', '31', '32', '34', '35', '36', '37', '3B', '3D']
# List of commands allowed in any mode
AllowedList = ['12', '1A', '21', '22', '23']
AllowedList = ['12', '19', '1A', '21', '22', '23']
# Max frame burst for Flow Control
MaxBurst = 0x7
@ -1834,7 +1834,7 @@ class ELM:
def set_can_500(self, addr='XXX'):
if mod_globals.opt_can2 and mod_globals.opt_stn:
tmp = self.cmd("STPBR 500000")
tmp = self.cmd("STP 33")
if '?' not in tmp: return
if len(addr)==3:
self.cmd("at sp 6")
@ -1843,7 +1843,7 @@ class ELM:
def set_can_250(self, addr='XXX'):
if mod_globals.opt_can2 and mod_globals.opt_stn:
tmp = self.cmd("STPBR 250000")
tmp = self.cmd("STP 35")
if '?' not in tmp: return
if len(addr)==3:
self.cmd("at sp 8")

View File

@ -358,7 +358,7 @@ def loadDumpToELM( ecuname, elm ):
flist = []
for root, dirs, files in os.walk("./dumps"):
for f in files:
if (ecuname+'.') in f:
if (ecuname+'.txt') in f:
flist.append(f)
if len(flist)==0: return

116
pyren/scen_ecri_counter2.py Normal file
View File

@ -0,0 +1,116 @@
#!/usr/bin/env python
import os
import sys
import re
import time
import string
import mod_globals
import mod_utils
import mod_ecu
import mod_db_manager
from mod_utils import clearScreen
from mod_utils import pyren_encode
from mod_utils import KBHit
import mod_ecu_mnemonic
import xml.dom.minidom
def run( elm, ecu, command, data ):
clearScreen()
header = '['+command.codeMR+'] '+command.label
ScmSet = {}
ScmParam = {}
def get_message( msg ):
if msg in ScmParam.keys():
value = ScmParam[msg]
else:
value = msg
if value.isdigit() and value in mod_globals.language_dict.keys():
value = pyren_encode( mod_globals.language_dict[value] )
return value
def get_message_by_id( id ):
if id.isdigit() and id in mod_globals.language_dict.keys():
value = pyren_encode( mod_globals.language_dict[id] )
return value
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
ScmRoom = DOMTree.documentElement
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmParam[name] = value
ScmSets = ScmRoom.getElementsByTagName("ScmSet")
for Set in ScmSets:
setname = pyren_encode(Set.getAttribute("name"))
ScmParams = Set.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmSet[setname]= value
ScmParam[name] = value
kb = KBHit()
confirm = get_message_by_id('19800')
title = get_message("Title")
messageInfo = get_message("Message1")
succesMessage = get_message("CommandFinished")
failMessage = get_message("CommandImpossible")
mnemonics = ecu.get_ref_id(ScmParam["default"]).mnemolist
if mnemonics[0][-2:] > mnemonics[1][-2:]:
mnemo1 = mnemonics[1]
mnemo2 = mnemonics[0]
else:
mnemo1 = mnemonics[0]
mnemo2 = mnemonics[1]
byteFrom = int(mnemo1[-2:])
byteTo = int(re.findall("\d+", mnemo2)[1])
byteCount = byteTo - byteFrom - 1
resetBytes = byteCount * "00"
mnemo1Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo1], ecu.Services, elm, 1)
mnemo2Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo2], ecu.Services, elm, 1)
paramsToSend = mnemo1Data + resetBytes + mnemo2Data
print title
print '*'*80
print messageInfo
print '*'*80
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
response = ecu.run_cmd(ScmParam['Cmde1'], paramsToSend)
print
if "NR" in response:
print failMessage
else:
print succesMessage
print
ch = raw_input('Press ENTER to exit')
return

View File

@ -0,0 +1,650 @@
#!/usr/bin/env python
'''
Scenarium usage example
Name of this script should be exactly the same as in scenaruim URL but with '.py' extension
URL - scm:scen_ecri_calinj1#scen_ecri_calinj1_xxxxx.xml
'run' procedure will be executed by pyren script
'''
import os
import sys
import re
import time
import string
import mod_globals
import mod_utils
import mod_ecu
import mod_db_manager
from mod_utils import pyren_encode
from mod_utils import clearScreen
from mod_utils import ASCIITOHEX
from mod_utils import StringToIntToHex
from mod_utils import Choice
from collections import OrderedDict
import xml.dom.minidom
import xml.etree.cElementTree as et
class ecus:
vdiag = ""
buttons = {}
ncalib = ""
def __init__(self, vd, nc, bt):
self.vdiag = vd
self.ncalib = nc
self.buttons = bt
def run( elm, ecu, command, data ):
'''
MAIN function of scenarium
Parameters:
elm - refernce to adapter class
ecu - reference to ecu class
command - refernce to the command this scenarium belongs to
data - name of xml file with parameters from scenarium URL
'''
clearScreen()
header = '['+command.codeMR+'] '+command.label
ScmSet = {}
ScmParam = OrderedDict()
ecusList = []
correctEcu = ''
vdiagExists = False
ncalibExists = False
def get_message( msg, encode = 1 ):
if msg in ScmParam.keys():
value = ScmParam[msg]
else:
value = msg
if value.isdigit() and value in mod_globals.language_dict.keys():
if encode:
value = pyren_encode(mod_globals.language_dict[value])
else:
value = mod_globals.language_dict[value]
return value
def get_message_by_id( id, encode = 1 ):
if id.isdigit() and id in mod_globals.language_dict.keys():
if encode:
value = pyren_encode(mod_globals.language_dict[id])
else:
value = mod_globals.language_dict[id]
return value
#
# Data file parsing
#
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
ScmRoom = DOMTree.documentElement
root = et.parse(mod_db_manager.get_file_from_clip(data)).getroot()
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmParam[name] = value
ScmSets = ScmRoom.getElementsByTagName("ScmSet")
for Set in ScmSets:
if len(Set.attributes) != 1:
setname = pyren_encode(mod_globals.language_dict[Set.getAttribute("name")])
ScmParams = Set.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmSet[setname]= value
ScmParam[name] = value
if "VDiag" in ScmParam.keys():
vdiagExists = True
if "Ncalib" in ScmParam.keys():
ncalibExists = True
# Get nested buttons with VDiag and Ncalib
for vDiag in root:
if vDiag.attrib["name"] == "VDiag":
if len(vDiag.keys()) == 1:
for vDiagName in vDiag:
if vDiagName:
for vDiagButtons in vDiagName:
buttons = OrderedDict()
if vDiagButtons.attrib["name"] == "Ncalib":
for ncalibName in vDiagButtons:
for ncalibButtons in ncalibName:
if ncalibButtons.attrib["name"] == "Buttons":
for ncalibButton in ncalibButtons:
buttons[ncalibButton.attrib["name"]] = ncalibButton.attrib["value"]
ecusList.append(ecus(vDiagName.attrib["name"],ncalibName.attrib["name"], buttons))
buttons = OrderedDict()
else:
if vDiagButtons.attrib["name"] == "Buttons":
for vDiagButton in vDiagButtons:
buttons[vDiagButton.attrib["name"]] = vDiagButton.attrib["value"]
ecusList.append(ecus(vDiagName.attrib["name"], '', buttons))
# Get plain buttons with VDiag
if vdiagExists:
if not ncalibExists:
vdiag = ''
buttons = OrderedDict()
for name in ScmParam.keys():
if name.startswith("InjectorsButton"):
if buttons:
ecusList.append(ecus(vdiag, '', buttons))
buttons = OrderedDict()
vdiag = name[-2:]
buttons[name[:-2]] = ScmParam[name]
if vdiag:
if name.endswith("Button" + vdiag):
buttons[name[:-2]] = ScmParam[name]
ecusList.append(ecus(vdiag, '', buttons))
else: #Get buttons without VDiag
buttons = OrderedDict()
found = False
for name in ScmParam.keys():
if name == "InjectorsButton":
buttons[name] = ScmParam[name]
found = True
if found:
if name.endswith("Button"):
buttons[name] = ScmParam[name]
else:
found = False
break
ecusList.append(ecus('', '', buttons))
# Get correct buttons set
if vdiagExists:
value1, datastr1 = ecu.get_id(ScmParam['VDiag'])
for ecuSet in ecusList:
if ecuSet.vdiag == value1.upper():
if ncalibExists:
if ecuSet.ncalib:
value2, datastr2 = ecu.get_id(ScmParam['Ncalib'])
if ecuSet.ncalib == value2.upper():
correctEcu = ecuSet
break
elif ecuSet.ncalib == "Other":
correctEcu = ecuSet
break
else:
correctEcu = ecuSet
break
else:
correctEcu = ecuSet
break
else:
correctEcu = ecusList[0]
if not correctEcu and mod_globals.opt_demo:
correctEcu = ecusList[0]
if vdiagExists:
if not correctEcu:
print '*'*80
ch = raw_input('Unknown diagnostic version. Press ENTER to exit')
return
#Prepare buttons
buttons = OrderedDict()
for bt in correctEcu.buttons.keys():
if bt == 'InjectorsButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[1] = get_message("Injectors", 0)
if bt == 'EGRValveButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[2] = get_message("EGR_VALVE", 0)
if bt == 'InletFlapButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[3] = get_message("INLET_FLAP", 0)
if bt.startswith("Button"):
if str(correctEcu.buttons[bt]) == 'true':
buttons[int(bt.strip('Button'))] = get_message(bt[:-6] + "Text", 0)
buttons["loadDump"] = get_message_by_id('19802', 0)
buttons["exit"] = '<exit>'
#Get commands
commands = {}
for child in root:
if child.attrib["name"] == "Commands":
if len(child.keys()) == 1:
for param in child:
serviceIDs = ecu.get_ref_cmd(param.attrib["value"]).serviceID
startReq = ""
for sid in serviceIDs:
if ecu.Services[sid].params:
startReq = ecu.Services[sid].startReq
break
commands[param.attrib["name"]] = {"command": param.attrib["value"], "startReq": startReq}
#Get identifications
identsList = OrderedDict()
identsRangeKeys = OrderedDict()
for param in ScmParam.keys():
if param.startswith('Idents') and param.endswith('Begin'):
key = param[6:-5]
begin = int(ScmParam['Idents'+key+'Begin'])
end = int(ScmParam['Idents'+key+'End'])
try:
ecu.get_ref_id(ScmParam['Ident' + str(begin)]).mnemolist[0] #10529 ID114 doesn't exist
except:
continue
else:
for idnum in range(begin ,end + 1):
identsList['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
frame = ecu.Mnemonics[ecu.get_ref_id(identsList['D'+str(begin)]).mnemolist[0]].request
identsRangeKeys[key] = {"begin": begin, "end": end, "frame": frame}
def getValuesToChange(resetItem):
params = {}
for child in root:
if child.attrib["name"] == resetItem:
if len(child.keys()) == 1:
for param in child:
params[param.attrib["name"].replace("D0", "D")] = param.attrib["value"]
return params
def takesParams(request):
for cmd in commands.values():
if cmd['startReq'] == request:
commandToRun = cmd['command']
return commandToRun
def getValuesFromEcu(params):
paramToSend = ""
commandToRun = ""
requestToFindInCommandsRequests = ""
backupDict = {}
try:
idKeyToFindInRange = int((params.keys()[0]).replace("D",""))
except:
return commandToRun, paramToSend
else:
for rangeK in identsRangeKeys.keys():
if identsRangeKeys[rangeK]['begin'] <= idKeyToFindInRange <= identsRangeKeys[rangeK]['end']:
requestToFindInCommandsRequests = "3B" + identsRangeKeys[rangeK]['frame'][-2:]
isTakingParams = takesParams(requestToFindInCommandsRequests)
if isTakingParams:
for k,v in params.iteritems():
backupDict[k] = ecu.get_id(identsList[k], 1)
if v in identsList.keys():
identsList[k] = ecu.get_id(identsList[v], 1)
else:
identsList[k] = v
for idKey in range(identsRangeKeys[rangeK]['begin'], identsRangeKeys[rangeK]['end'] + 1):
if identsList["D" + str(idKey)].startswith("ID"):
identsList["D" + str(idKey)] = ecu.get_id(identsList["D" + str(idKey)], 1)
backupDict["D" + str(idKey)] = identsList["D" + str(idKey)]
paramToSend += identsList["D" + str(idKey)]
commandToRun = isTakingParams
break
makeDump(commandToRun, backupDict)
return commandToRun, paramToSend
confirm = get_message_by_id('19800')
successMessage = get_message('Message32')
failMessage = get_message('MessageNACK')
mainText = get_message('Title')
inProgressMessage = get_message('CommandInProgressMessage')
def resetInjetorsData(button, injectorsList):
injectorsInfoMessage = get_message('Message21')
response = ""
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print injectorsInfoMessage
print '*'*80
print
choice = Choice(injectorsList.keys(), "Choose :")
if choice[0]=='<exit>': return
clearScreen()
print
response = ecu.run_cmd(injectorsList[choice[0]])
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def afterEcuChange(title, button):
params = getValuesToChange(title)
infoMessage = get_message("Message262")
mileageText = get_message_by_id('2110')
mileageUnit = get_message_by_id('16521')
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print infoMessage
print '*'*80
print get_message("MessageBox2")
print
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ')
while not (mileage.isdigit() and 2 <= len(mileage) <= 6 and int(mileage) >= 10):
print get_message("MessageBox1")
print
mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ')
clearScreen()
print mileageText + ': ' + mileage + ' ' + mileageUnit
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
print inProgressMessage
mileage = int(mileage)
for paramkey in params.keys():
if params[paramkey] == "Mileage":
mnemonics = ecu.get_ref_id(identsList[paramkey]).mnemolist[0]
identValue = ecu.get_id(identsList[paramkey], 1)
if identValue == 'ERROR':
identValue = '00000000'
hexval = "{0:0{1}X}".format(mileage,len(identValue))
if ecu.Mnemonics[mnemonics].littleEndian == '1':
a = hexval
b = ''
if not len(a) % 2:
for i in range(0,len(a),2):
b = a[i:i+2]+b
hexval = b
params[paramkey] = hexval
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
response = ecu.run_cmd(command,paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def setGlowPlugsType(title, button):
params = getValuesToChange(title)
currentType = ecu.get_id(identsList[params["IdentToBeDisplayed"].replace("Ident", "D")], 1)
slowTypeValue = get_message('ValueSlowParam')
fastTypeValue = get_message('ValueFastParam')
currentMessage = get_message_by_id('52676')
slowMessage = get_message('Slow')
fastMessage = get_message('Fast')
notDefinedMessage = get_message('NotDefined')
message2 = get_message('Message282')
typesButtons = OrderedDict()
typesButtons[get_message('Slow', 0)] = slowTypeValue
typesButtons[get_message('Fast', 0)] = fastTypeValue
typesButtons['<exit>'] = ""
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print message2
print '*'*80
print
if currentType == slowTypeValue:
print currentMessage + ': ' + slowMessage
elif currentType == fastTypeValue:
print currentMessage + ': ' + fastMessage
else:
print currentMessage + ': ' + notDefinedMessage
print
choice = Choice(typesButtons.keys(), "Choose :")
if choice[0]=='<exit>': return
clearScreen()
print
print inProgressMessage
params[params["IdentToBeDisplayed"].replace("Ident", "D")] = typesButtons[choice[0]]
params.pop("IdentToBeDisplayed")
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
response = ecu.run_cmd(command,paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def resetValues(title, button, defaultCommand):
paramToSend = ""
commandTakesParams = True
params = getValuesToChange(title)
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
if button == 4:
print get_message_by_id('55662')
print '*'*80
if button == 5:
print get_message_by_id('55663')
print '*'*80
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
print inProgressMessage
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
if command:
response = ecu.run_cmd(command,paramToSend)
else:
response = ecu.run_cmd(defaultCommand)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def makeDump(cmd, idents):
fileRoot = et.Element("ScmRoot")
fileRoot.text = "\n "
cmdElement = et.Element("ScmParam", name="Command", value=cmd)
cmdElement.tail = "\n "
fileRoot.insert(1,cmdElement)
for k in idents:
el = et.Element("ScmParam", name='D'+ '{:0>2}'.format(k[1:]), value=idents[k])
el.tail = "\n "
fileRoot.insert(1,el)
tree = et.ElementTree(fileRoot)
tree.write(mod_globals.dumps_dir + ScmParam['FileName'])
def loadDump():
clearScreen()
paramToSend = ""
dumpScmParam = {}
try:
dumpData = open(mod_globals.dumps_dir + ScmParam['FileName'], 'r')
except:
print get_message_by_id('2194')
raw_input()
return
dumpDOMTree = xml.dom.minidom.parse(dumpData)
dumpScmRoot = dumpDOMTree.documentElement
dumpScmParams = dumpScmRoot.getElementsByTagName("ScmParam")
for Param in dumpScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
dumpScmParam[name] = value
for k in sorted(dumpScmParam):
if k != "Command":
paramToSend += dumpScmParam[k]
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
print '*'*80
print get_message_by_id('19802')
print '*'*80
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
response = ecu.run_cmd(dumpScmParam['Command'],paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
functions = OrderedDict()
for cmdKey in commands.keys():
if cmdKey == 'Cmd1':
injectorsDict = OrderedDict()
injectorsDict[get_message('Cylinder1', 0)] = commands['Cmd1']['command']
injectorsDict[get_message('Cylinder2', 0)] = commands['Cmd2']['command']
injectorsDict[get_message('Cylinder3', 0)] = commands['Cmd3']['command']
injectorsDict[get_message('Cylinder4', 0)] = commands['Cmd4']['command']
injectorsDict['<exit>'] = ""
functions[1] = [1, injectorsDict]
if cmdKey == 'Cmd5':
functions[2] = ["EGR_VALVE", 2, commands['Cmd5']['command']]
if cmdKey == 'Cmd6':
functions[3] = ["INLET_FLAP", 3, commands['Cmd6']['command']]
if cmdKey == 'Cmd7':
functions[4] = ["PARTICLE_FILTER", 4, commands['Cmd7']['command']]
functions[5] = ["Button5ChangeData", 5, commands['Cmd7']['command']]
functions[6] = ["Button6ChangeData", 6, commands['Cmd7']['command']]
if cmdKey == 'Cmd9':
functions[8] = ["Button8DisplayData", 8]
infoMessage = get_message('Message1')
print mainText
print
print infoMessage
print
notSupported = [7]
choice = Choice(buttons.values(), "Choose :")
for key, value in buttons.iteritems():
if choice[0] =='<exit>': return
if value == choice[0]:
if key in notSupported:
ch = raw_input("\nNot Supported yet. Press ENTER to exit")
elif key == 'loadDump':
loadDump()
elif key == 1:
resetInjetorsData(functions[key][0],functions[key][1])
elif key == 6:
afterEcuChange(functions[key][0],functions[key][1])
elif key == 8:
setGlowPlugsType(functions[key][0],functions[key][1])
else:
resetValues(functions[key][0],functions[key][1],functions[key][2])
return

View File

@ -0,0 +1,586 @@
#!/usr/bin/env python
'''
Scenarium usage example
Name of this script should be exactly the same as in scenaruim URL but with '.py' extension
URL - scm:scen_ecri_calinj1#scen_ecri_calinj1_xxxxx.xml
'run' procedure will be executed by pyren script
'''
import os
import sys
import re
import time
import string
import mod_globals
import mod_utils
import mod_ecu
import mod_db_manager
from mod_utils import pyren_encode
from mod_utils import clearScreen
from mod_utils import ASCIITOHEX
from mod_utils import StringToIntToHex
from mod_utils import Choice
from collections import OrderedDict
import xml.dom.minidom
import xml.etree.cElementTree as et
class ecus:
vdiag = ""
buttons = {}
ncalib = ""
def __init__(self, vd, nc, bt):
self.vdiag = vd
self.ncalib = nc
self.buttons = bt
def run( elm, ecu, command, data ):
'''
MAIN function of scenarium
Parameters:
elm - refernce to adapter class
ecu - reference to ecu class
command - refernce to the command this scenarium belongs to
data - name of xml file with parameters from scenarium URL
'''
clearScreen()
header = '['+command.codeMR+'] '+command.label
ScmSet = {}
ScmParam = OrderedDict()
ecusList = []
correctEcu = ''
vdiagExists = False
def get_message( msg, encode = 1 ):
if msg in ScmParam.keys():
value = ScmParam[msg]
else:
value = msg
if value.isdigit() and value in mod_globals.language_dict.keys():
if encode:
value = pyren_encode(mod_globals.language_dict[value])
else:
value = mod_globals.language_dict[value]
return value
def get_message_by_id( id, encode = 1 ):
if id.isdigit() and id in mod_globals.language_dict.keys():
if encode:
value = pyren_encode(mod_globals.language_dict[id])
else:
value = mod_globals.language_dict[id]
return value
#
# Data file parsing
#
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
ScmRoom = DOMTree.documentElement
root = et.parse(mod_db_manager.get_file_from_clip(data)).getroot()
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmParam[name] = value
ScmSets = ScmRoom.getElementsByTagName("ScmSet")
for Set in ScmSets:
if len(Set.attributes) != 1:
setname = pyren_encode(mod_globals.language_dict[Set.getAttribute("name")])
ScmParams = Set.getElementsByTagName("ScmParam")
for Param in ScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
ScmSet[setname]= value
ScmParam[name] = value
if "IdentVdiag" in ScmParam.keys():
vdiagExists = True
# Get nested buttons with VDiag
for vDiag in root:
if vDiag.attrib["name"] == "ListVdiag":
if len(vDiag.keys()) == 1:
for vDiagName in vDiag:
buttons = OrderedDict()
if vDiagName:
for vDiagButton in vDiagName:
buttons[vDiagButton.attrib["name"]] = vDiagButton.attrib["value"]
ecusList.append(ecus(vDiagName.attrib["name"], '', buttons))
# Get correct buttons set
if vdiagExists:
value1, datastr1 = ecu.get_id(ScmParam['IdentVdiag'])
for ecuSet in ecusList:
if ecuSet.vdiag == value1.upper():
correctEcu = ecuSet
break
else:
correctEcu = ecusList[0]
if not correctEcu and mod_globals.opt_demo:
correctEcu = ecusList[0]
if vdiagExists:
if not correctEcu:
print '*'*80
ch = raw_input('Unknown diagnostic version. Press ENTER to exit')
return
#Prepare buttons
buttons = OrderedDict()
for bt in correctEcu.buttons.keys():
if bt == 'InjectorsButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[1] = get_message("Injectors",0)
if bt == 'EGRValveButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[2] = get_message("EGR_VALVE",0)
if bt == 'InletFlapButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[3] = get_message("INLET_FLAP",0)
if bt == 'ParticleFilterButton':
if str(correctEcu.buttons[bt]) == 'true':
buttons[4] = get_message("PARTICLES_FILTER",0)
if bt.startswith("Button"):
if str(correctEcu.buttons[bt]) == 'true':
buttons[int(bt.strip('Button'))] = get_message(bt[:-6] + "Text", 0)
buttons["loadDump"] = get_message_by_id('19802', 0)
buttons["exit"] = '<exit>'
#Get commands
commands = {}
for child in root:
if child.attrib["name"] == "Commands":
if len(child.keys()) == 1:
for param in child:
serviceIDs = ecu.get_ref_cmd(param.attrib["value"]).serviceID
startReq = ""
for sid in serviceIDs:
if ecu.Services[sid].params:
startReq = ecu.Services[sid].startReq
break
commands[param.attrib["name"]] = {"command": param.attrib["value"], "startReq": startReq}
#Get identifications
identsList = OrderedDict()
identsRangeKeys = OrderedDict()
for param in ScmParam.keys():
if param.startswith('Idents') and param.endswith('Begin'):
key = param[6:-5]
begin = int(ScmParam['Idents'+key+'Begin'])
end = int(ScmParam['Idents'+key+'End'])
try: #10099 trap
ecu.get_ref_id(ScmParam['Ident' + str(begin)]).mnemolist[0]
except:
continue
else:
for idnum in range(begin ,end + 1):
identsList['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
frame = ecu.Mnemonics[ecu.get_ref_id(identsList['D'+str(begin)]).mnemolist[0]].request
identsRangeKeys[key] = {"begin": begin, "end": end, "frame": frame}
def getValuesToChange(resetItem):
params = {}
for child in root:
if child.attrib["name"] == resetItem:
if len(child.keys()) == 1:
for param in child:
params[param.attrib["name"].replace("D0", "D")] = param.attrib["value"]
return params
def takesParams(request):
for cmd in commands.values():
if cmd['startReq'] == request:
commandToRun = cmd['command']
return commandToRun
def getValuesFromEcu(params):
paramToSend = ""
commandToRun = ""
requestToFindInCommandsRequests = ""
backupDict = {}
try:
idKeyToFindInRange = int((params.keys()[0]).replace("D",""))
except:
return commandToRun, paramToSend
else:
for rangeK in identsRangeKeys.keys():
if identsRangeKeys[rangeK]['begin'] <= idKeyToFindInRange <= identsRangeKeys[rangeK]['end']:
requestToFindInCommandsRequests = "3B" + identsRangeKeys[rangeK]['frame'][-2:]
isTakingParams = takesParams(requestToFindInCommandsRequests)
if isTakingParams:
for k,v in params.iteritems():
backupDict[k] = ecu.get_id(identsList[k], 1)
if v in identsList.keys():
identsList[k] = ecu.get_id(identsList[v], 1)
else:
identsList[k] = v
for idKey in range(identsRangeKeys[rangeK]['begin'], identsRangeKeys[rangeK]['end'] + 1):
if identsList["D" + str(idKey)].startswith("ID"):
identsList["D" + str(idKey)] = ecu.get_id(identsList["D" + str(idKey)], 1)
backupDict["D" + str(idKey)] = identsList["D" + str(idKey)]
paramToSend += identsList["D" + str(idKey)]
commandToRun = isTakingParams
break
makeDump(commandToRun, backupDict)
return commandToRun, paramToSend
confirm = get_message_by_id('19800')
successMessage = get_message('Message32')
failMessage = get_message('MessageNACK')
mainText = get_message('Title')
inProgressMessage = get_message('CommandInProgressMessage')
def resetInjetorsData(button, injectorsList):
injectorsInfoMessage = get_message('Message21')
response = ""
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print injectorsInfoMessage
print '*'*80
print
choice = Choice(injectorsList.keys(), "Choose :")
if choice[0]=='<exit>': return
clearScreen()
print
response = ecu.run_cmd(injectorsList[choice[0]])
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def afterEcuChange(title, button):
params = getValuesToChange(title)
infoMessage = get_message("Message262")
mileageText = get_message_by_id('2110')
mileageUnit = get_message_by_id('16521')
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print infoMessage
print '*'*80
print get_message("MessageBox2")
print
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ')
while not (mileage.isdigit() and 2 <= len(mileage) <= 6 and int(mileage) >= 10):
print get_message("MessageBox1")
print
mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ')
clearScreen()
print mileageText + ': ' + mileage + ' ' + mileageUnit
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
print inProgressMessage
mileage = int(mileage)
for paramkey in params.keys():
if params[paramkey] == "Mileage":
mnemonics = ecu.get_ref_id(identsList[paramkey]).mnemolist[0]
identValue = ecu.get_id(identsList[paramkey], 1)
if identValue == 'ERROR':
identValue = '00000000'
hexval = "{0:0{1}X}".format(mileage,len(identValue))
if ecu.Mnemonics[mnemonics].littleEndian == '1':
a = hexval
b = ''
if not len(a) % 2:
for i in range(0,len(a),2):
b = a[i:i+2]+b
hexval = b
params[paramkey] = hexval
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
response = ecu.run_cmd(command,paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def setGlowPlugsType(title, button):
params = getValuesToChange(title)
value, datastr = ecu.get_st(ScmParam['State1'])
message = get_message('Message29')
currentTypeMessage = get_message_by_id('52676')
typesButtons = OrderedDict()
typesButtons[get_message_by_id('54031',0)] = ScmParam['54031']
typesButtons[get_message_by_id('54030',0)] = ScmParam['54030']
typesButtons[get_message_by_id('54032',0)] = ScmParam['54032']
typesButtons['<exit>'] = ""
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
print message
print '*'*80
print
print currentTypeMessage + ':'
print
print datastr
print
choice = Choice(typesButtons.keys(), "Choose :")
if choice[0]=='<exit>': return
clearScreen()
print
print inProgressMessage
glowPlugType = "{0:0{1}X}".format((int(ScmParam['Mask1']) + int(typesButtons[choice[0]])),2)
params[params.keys()[0]] = glowPlugType
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
response = ecu.run_cmd(command,paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def resetValues(title, button, defaultCommand):
paramToSend = ""
commandTakesParams = True
params = getValuesToChange(title)
clearScreen()
print mainText
print '*'*80
print buttons[button]
print '*'*80
if button == 4:
print get_message_by_id('55662')
print '*'*80
if button == 5:
print get_message_by_id('55663')
print '*'*80
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
print inProgressMessage
command, paramToSend = getValuesFromEcu(params)
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
clearScreen()
print
if command:
response = ecu.run_cmd(command,paramToSend)
else:
response = ecu.run_cmd(defaultCommand)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
def makeDump(cmd, idents):
fileRoot = et.Element("ScmRoot")
fileRoot.text = "\n "
cmdElement = et.Element("ScmParam", name="Command", value=cmd)
cmdElement.tail = "\n "
fileRoot.insert(1,cmdElement)
for k in idents:
el = et.Element("ScmParam", name='D'+ '{:0>2}'.format(k[1:]), value=idents[k])
el.tail = "\n "
fileRoot.insert(1,el)
tree = et.ElementTree(fileRoot)
tree.write(mod_globals.dumps_dir + ScmParam['FileName'])
def loadDump():
clearScreen()
paramToSend = ""
dumpScmParam = {}
try:
dumpData = open(mod_globals.dumps_dir + ScmParam['FileName'], 'r')
except:
print get_message_by_id('2194')
raw_input()
return
dumpDOMTree = xml.dom.minidom.parse(dumpData)
dumpScmRoot = dumpDOMTree.documentElement
dumpScmParams = dumpScmRoot.getElementsByTagName("ScmParam")
for Param in dumpScmParams:
name = pyren_encode( Param.getAttribute("name") )
value = pyren_encode( Param.getAttribute("value") )
dumpScmParam[name] = value
for k in sorted(dumpScmParam):
if k != "Command":
paramToSend += dumpScmParam[k]
if "ERROR" in paramToSend:
raw_input("Data downloading went wrong. Aborting.")
return
print '*'*80
print get_message_by_id('19802')
print '*'*80
print
ch = raw_input(confirm + ' <YES/NO>: ')
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':
return
clearScreen()
print
response = ecu.run_cmd(dumpScmParam['Command'],paramToSend)
print
if "NR" in response:
print failMessage
else:
print successMessage
print
ch = raw_input('Press ENTER to exit')
functions = OrderedDict()
for cmdKey in commands.keys():
if cmdKey == 'Cmd1' and "Cmd5" in commands.keys():
injectorsDict = OrderedDict()
injectorsDict[get_message('Cylinder1', 0)] = commands['Cmd1']['command']
injectorsDict[get_message('Cylinder2', 0)] = commands['Cmd2']['command']
injectorsDict[get_message('Cylinder3', 0)] = commands['Cmd3']['command']
injectorsDict[get_message('Cylinder4', 0)] = commands['Cmd4']['command']
injectorsDict['<exit>'] = ""
functions[1] = [1, injectorsDict]
if cmdKey == 'Cmd5':
functions[2] = ["EGR_VALVE", 2, commands['Cmd5']['command']]
if cmdKey == 'Cmd6':
functions[3] = ["INLET_FLAP", 3, commands['Cmd6']['command']]
if cmdKey == 'Cmd7':
functions[4] = ["PARTICLE_FILTER", 4, commands['Cmd7']['command']]
functions[5] = ["Button5ChangeData", 5, commands['Cmd7']['command']]
functions[6] = ["Button6ChangeData", 6, commands['Cmd7']['command']]
if len(commands) == 1 and cmdKey == 'Cmd1':
functions[7] = ["Button7ChangeData", 7]
infoMessage = get_message('Message1')
print mainText
print
print infoMessage
print
choice = Choice(buttons.values(), "Choose :")
for key, value in buttons.iteritems():
if choice[0]=='<exit>': return
if value == choice[0]:
if key == 'loadDump':
loadDump()
elif key == 1:
resetInjetorsData(functions[key][0],functions[key][1])
elif key == 6:
afterEcuChange(functions[key][0],functions[key][1])
elif key == 7:
setGlowPlugsType(functions[key][0],functions[key][1])
else:
resetValues(functions[key][0],functions[key][1],functions[key][2])
return