9p fix#1 ddtroot
This commit is contained in:
parent
3c02d8e84b
commit
c278eb8adf
@ -26,6 +26,7 @@ This mode allows you:
|
|||||||
Getting started video
|
Getting started video
|
||||||
https://www.youtube.com/watch?v=DazsvlnLCoA
|
https://www.youtube.com/watch?v=DazsvlnLCoA
|
||||||
|
|
||||||
|
|
||||||
## Included tools
|
## Included tools
|
||||||
* **doc_maker.py** - build diagnostic documentation for your car (require BVMEXTRACTION folder and extracted DocDB_xx.7ze)
|
* **doc_maker.py** - build diagnostic documentation for your car (require BVMEXTRACTION folder and extracted DocDB_xx.7ze)
|
||||||
* **bus_monitor.py** - catch, parse and shows the content of system frames on your CAN bus.
|
* **bus_monitor.py** - catch, parse and shows the content of system frames on your CAN bus.
|
||||||
|
@ -7,6 +7,7 @@ import pickle
|
|||||||
import codecs
|
import codecs
|
||||||
import string
|
import string
|
||||||
import threading
|
import threading
|
||||||
|
import mod_ddt_utils
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||||
|
|
||||||
@ -88,6 +89,8 @@ class DDT_MON():
|
|||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
print "Starting DDT process"
|
print "Starting DDT process"
|
||||||
|
|
||||||
|
mod_ddt_utils.searchddtroot()
|
||||||
|
|
||||||
#make or load ddt ecu
|
#make or load ddt ecu
|
||||||
decucashfile = "./cache/ddt_"+xmlfile+".p"
|
decucashfile = "./cache/ddt_"+xmlfile+".p"
|
||||||
@ -97,7 +100,7 @@ class DDT_MON():
|
|||||||
else: #else
|
else: #else
|
||||||
self.decu = DDTECU( None ) #init class
|
self.decu = DDTECU( None ) #init class
|
||||||
self.decu.setELM(self.elm) #define ELM for it
|
self.decu.setELM(self.elm) #define ELM for it
|
||||||
self.decu.loadXml( '../ecus/'+xmlfile ) #loading original data for chosen ECU
|
self.decu.loadXml( mod_globals.ddtroot+'/ecus/'+xmlfile )#loading original data for chosen ECU
|
||||||
self.decu.setELM( None ) #clear elm before serialization
|
self.decu.setELM( None ) #clear elm before serialization
|
||||||
if len(self.decu.ecufname)>0:
|
if len(self.decu.ecufname)>0:
|
||||||
pickle.dump( self.decu, open( decucashfile, "wb" ) ) #and save cache
|
pickle.dump( self.decu, open( decucashfile, "wb" ) ) #and save cache
|
||||||
|
129
pyren/mod_ddt.py
129
pyren/mod_ddt.py
@ -136,6 +136,10 @@ class DDT():
|
|||||||
self.decu.saveDump()
|
self.decu.saveDump()
|
||||||
|
|
||||||
# Load XML
|
# Load XML
|
||||||
|
if not self.decu.ecufname.startswith(mod_globals.ddtroot):
|
||||||
|
tmp_f_name = self.decu.ecufname.split('/')[-1]
|
||||||
|
self.decu.ecufname = mod_globals.ddtroot+'/ecus/'+tmp_f_name
|
||||||
|
|
||||||
if not os.path.isfile(self.decu.ecufname):
|
if not os.path.isfile(self.decu.ecufname):
|
||||||
print "No such file: ", self.decu.ecufname
|
print "No such file: ", self.decu.ecufname
|
||||||
return None
|
return None
|
||||||
@ -270,131 +274,6 @@ def optParser():
|
|||||||
else:
|
else:
|
||||||
mod_globals.opt_protocol = '500'
|
mod_globals.opt_protocol = '500'
|
||||||
|
|
||||||
|
|
||||||
def get_addr_from_xml(xmlfile):
|
|
||||||
if '/ecus/' not in xmlfile:
|
|
||||||
xmlfile = '../ecus/' + xmlfile
|
|
||||||
|
|
||||||
# Load XML
|
|
||||||
xdom = xml.dom.minidom.parse(xmlfile)
|
|
||||||
xdoc = xdom.documentElement
|
|
||||||
if not xdoc:
|
|
||||||
print "No such file:", xmlfile
|
|
||||||
return
|
|
||||||
|
|
||||||
faddr = ''
|
|
||||||
cans = xdoc.getElementsByTagName("CAN")
|
|
||||||
if cans:
|
|
||||||
for can in cans:
|
|
||||||
sendid = can.getElementsByTagName("SendId")
|
|
||||||
if sendid:
|
|
||||||
for sid in sendid:
|
|
||||||
canid = sid.getElementsByTagName("CANId")
|
|
||||||
if canid:
|
|
||||||
for cid in canid:
|
|
||||||
send_can_addr = cid.getAttribute("Value")
|
|
||||||
if len(send_can_addr) > 0:
|
|
||||||
sca = hex(int(send_can_addr))[2:].upper().zfill(3)
|
|
||||||
for k in mod_elm.dnat.keys():
|
|
||||||
if sca == mod_elm.dnat[k]:
|
|
||||||
faddr = k
|
|
||||||
|
|
||||||
# if faddr=='':
|
|
||||||
# faddr = raw_input('Please define functional address : ')
|
|
||||||
|
|
||||||
return faddr
|
|
||||||
|
|
||||||
|
|
||||||
def main_old():
|
|
||||||
'''Main function'''
|
|
||||||
|
|
||||||
import mod_ecu
|
|
||||||
|
|
||||||
optParser()
|
|
||||||
|
|
||||||
print 'Opening ELM'
|
|
||||||
elm = ELM(mod_globals.opt_port, mod_globals.opt_speed, mod_globals.opt_log)
|
|
||||||
|
|
||||||
# change serial port baud rate
|
|
||||||
if mod_globals.opt_speed < mod_globals.opt_rate and not mod_globals.opt_demo:
|
|
||||||
elm.port.soft_boudrate(mod_globals.opt_rate)
|
|
||||||
|
|
||||||
print "Loading language "
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
# loading language data
|
|
||||||
lang = optfile("../Location/DiagOnCan_" + mod_globals.opt_lang + ".bqm", True)
|
|
||||||
mod_globals.language_dict = lang.dict
|
|
||||||
print "Done"
|
|
||||||
|
|
||||||
# check if address or xml defined
|
|
||||||
|
|
||||||
if mod_globals.opt_ecuAddr == '' and mod_globals.opt_ddtxml != '':
|
|
||||||
mod_globals.opt_ecuAddr = get_addr_from_xml(mod_globals.opt_ddtxml)
|
|
||||||
|
|
||||||
# if mod_globals.opt_ddtxml=='' and (mod_globals.opt_ecuAddr=='' or mod_globals.opt_ecuAddr not in mod_ecu.F2A.values()):
|
|
||||||
if mod_globals.opt_ecuAddr == '' or mod_globals.opt_ecuAddr not in mod_ecu.F2A.values():
|
|
||||||
# ask to choose famile
|
|
||||||
fmls = []
|
|
||||||
for f in sorted(mod_ecu.F2A.keys()):
|
|
||||||
f = str(int(f))
|
|
||||||
if mod_scan_ecus.families[f] in mod_globals.language_dict.keys():
|
|
||||||
x = f
|
|
||||||
if len(x) == 1: x = '0' + x
|
|
||||||
if x in mod_ecu.F2A.keys() and mod_ecu.F2A[x] in mod_elm.dnat.keys():
|
|
||||||
fmls.append(f + ":" + mod_globals.language_dict[mod_scan_ecus.families[f]])
|
|
||||||
ch = ChoiceLong(fmls, "Choose ECU type :")
|
|
||||||
family = ch[0].split(':')[0]
|
|
||||||
if len(family) == 1: family = '0' + family
|
|
||||||
if family in mod_ecu.F2A.keys():
|
|
||||||
mod_globals.opt_ecuAddr = mod_ecu.F2A[family]
|
|
||||||
else:
|
|
||||||
print "ERROR : Unknown family!!!!"
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
addr = mod_globals.opt_ecuAddr
|
|
||||||
# if addr=='' and mod_globals.opt_ddtxml!='':
|
|
||||||
# addr = get_addr_from_xml( mod_globals.opt_ddtxml )
|
|
||||||
|
|
||||||
if 'S' in mod_globals.opt_protocol:
|
|
||||||
# SlowInit KWP
|
|
||||||
ecudata = {'pin': 'iso', 'slowInit': addr, 'fastInit': addr, 'ecuname': 'ddt_unknown', 'idTx': '', 'idRx': '',
|
|
||||||
'ModelId': addr, 'protocol': 'KWP_Slow'}
|
|
||||||
mod_globals.opt_si = True
|
|
||||||
elm.init_iso()
|
|
||||||
elm.set_iso_addr(addr, ecudata)
|
|
||||||
elif 'F' in mod_globals.opt_protocol:
|
|
||||||
# FastInitKWP
|
|
||||||
ecudata = {'pin': 'iso', 'slowInit': addr, 'fastInit': addr, 'ecuname': 'ddt_unknown', 'idTx': '', 'idRx': '',
|
|
||||||
'ModelId': addr, 'protocol': 'KWP_Fast'}
|
|
||||||
mod_globals.opt_si = False
|
|
||||||
elm.init_iso()
|
|
||||||
elm.set_iso_addr(addr, ecudata)
|
|
||||||
elif '250' in mod_globals.opt_protocol:
|
|
||||||
# CAN 250
|
|
||||||
ecudata = {'pin': 'can', 'slowInit': '', 'fastInit': '', 'brp': '1', 'ecuname': 'ddt_unknown', 'idTx': '',
|
|
||||||
'idRx': '', 'ModelId': addr, 'protocol': 'CAN_250'}
|
|
||||||
elm.init_can()
|
|
||||||
elm.set_can_addr(addr, ecudata)
|
|
||||||
elif '500' in mod_globals.opt_protocol:
|
|
||||||
# CAN 500
|
|
||||||
ecudata = {'pin': 'can', 'slowInit': '', 'fastInit': '', 'brp': '0', 'ecuname': 'ddt_unknown', 'idTx': '',
|
|
||||||
'idRx': '', 'ModelId': addr, 'protocol': 'CAN_500'}
|
|
||||||
elm.init_can()
|
|
||||||
elm.set_can_addr(addr, ecudata)
|
|
||||||
else:
|
|
||||||
print "ERROR : Unknown protocol!!!!"
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
ecudata['dst'] = addr
|
|
||||||
|
|
||||||
elm.start_session('10C0')
|
|
||||||
|
|
||||||
ddt = DDT(elm, ecudata)
|
|
||||||
|
|
||||||
print "Done"
|
|
||||||
|
|
||||||
|
|
||||||
class DDTLauncher():
|
class DDTLauncher():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
|
@ -294,10 +294,12 @@ class DDTECU():
|
|||||||
# eculist = mod_ddt_utils.loadECUlist() #loading original data
|
# eculist = mod_ddt_utils.loadECUlist() #loading original data
|
||||||
# if eculist == None: return #return if no eculist file
|
# if eculist == None: return #return if no eculist file
|
||||||
# pickle.dump( eculist, open( eculistcache, "wb" ) ) #and save cache
|
# pickle.dump( eculist, open( eculistcache, "wb" ) ) #and save cache
|
||||||
|
|
||||||
|
mod_ddt_utils.searchddtroot()
|
||||||
|
|
||||||
if len(mod_globals.opt_ddtxml)>0:
|
if len(mod_globals.opt_ddtxml)>0:
|
||||||
fname = mod_globals.opt_ddtxml
|
fname = mod_globals.opt_ddtxml
|
||||||
self.ecufname = '../ecus/'+fname
|
self.ecufname = mod_globals.ddtroot+'/ecus/'+fname
|
||||||
else:
|
else:
|
||||||
problist = ecuSearch(vehTypeCode, Address, DiagVersion, Supplier, Soft, Version, eculist)
|
problist = ecuSearch(vehTypeCode, Address, DiagVersion, Supplier, Soft, Version, eculist)
|
||||||
|
|
||||||
@ -312,7 +314,7 @@ class DDTECU():
|
|||||||
|
|
||||||
fname = fname.strip()
|
fname = fname.strip()
|
||||||
if len(fname):
|
if len(fname):
|
||||||
self.ecufname = '../ecus/'+fname
|
self.ecufname = mod_globals.ddtroot+'/ecus/'+fname
|
||||||
if os.path.isfile(self.ecufname):
|
if os.path.isfile(self.ecufname):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import sys, os
|
import sys, os
|
||||||
import mod_globals
|
import mod_globals
|
||||||
import mod_utils
|
import mod_utils
|
||||||
|
import mod_ddt_utils
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||||
|
|
||||||
@ -290,9 +291,11 @@ def main():
|
|||||||
verfile = open( "./cache/version09k.txt", "wb" )
|
verfile = open( "./cache/version09k.txt", "wb" )
|
||||||
verfile.write("Do not remove me if you have v0.9.k or above.\n")
|
verfile.write("Do not remove me if you have v0.9.k or above.\n")
|
||||||
verfile.close()
|
verfile.close()
|
||||||
|
|
||||||
|
mod_ddt_utils.searchddtroot()
|
||||||
|
|
||||||
#check if DDT present
|
#check if DDT present
|
||||||
if os.path.exists('../ecus') and mod_globals.os != 'android':
|
if os.path.exists(mod_globals.ddtroot+'/ecus') and mod_globals.os != 'android':
|
||||||
mod_globals.opt_ddt = True
|
mod_globals.opt_ddt = True
|
||||||
|
|
||||||
while( 1 ):
|
while( 1 ):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user