9q
This commit is contained in:
parent
ebcad26ad6
commit
65f6205c1e
@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
import os
|
||||
import zipfile
|
||||
import shutil
|
||||
from os import listdir
|
||||
from os.path import isdir
|
||||
@ -80,7 +79,6 @@ if osname == 'android':
|
||||
print "Error while using jnius"
|
||||
sys.exit()
|
||||
|
||||
|
||||
def update_from_gitlab():
|
||||
try:
|
||||
import os
|
||||
@ -146,10 +144,10 @@ def getPathList():
|
||||
|
||||
|
||||
def getLangList():
|
||||
if not os.path.exists('./Location'):
|
||||
return []
|
||||
return [f[10:-4] for f in listdir('./Location') if f.lower().startswith('diagoncan_')]
|
||||
|
||||
#if not os.path.exists('./Location'):
|
||||
# return []
|
||||
#return [f[10:-4] for f in listdir('./Location') if f.lower().startswith('diagoncan_')]
|
||||
return ['AL','CNT','CO','CR','CZ','DK','EL','FI','FR','GB','HG','IT','JP','NG','NL','PL','PO','RO','RU','SD','SL','SP','TR']
|
||||
|
||||
def getPortList():
|
||||
ret = []
|
||||
|
@ -67,7 +67,7 @@ def prepareECU():
|
||||
print "Loading language "
|
||||
sys.stdout.flush()
|
||||
#loading language data
|
||||
lang = optfile("../Location/DiagOnCan_"+mod_globals.opt_lang+".bqm",True)
|
||||
lang = optfile("../Location/DiagOnCAN_"+mod_globals.opt_lang+".bqm",True)
|
||||
mod_globals.language_dict = lang.dict
|
||||
print "Done"
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
import sys, os
|
||||
import time
|
||||
import mod_utils
|
||||
import mod_db_manager
|
||||
|
||||
import mod_globals
|
||||
import mod_ecu
|
||||
@ -42,6 +44,9 @@ def prepareECUs():
|
||||
|
||||
pyren.optParser()
|
||||
|
||||
mod_utils.chkDirTree()
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
if len(mod_globals.opt_log)==0:
|
||||
mod_globals.opt_log = 'commander_log.txt'
|
||||
|
||||
@ -61,7 +66,7 @@ def prepareECUs():
|
||||
print "Loading language "
|
||||
sys.stdout.flush()
|
||||
#loading language data
|
||||
lang = optfile("../Location/DiagOnCan_"+mod_globals.opt_lang+".bqm",True)
|
||||
lang = optfile("Location/DiagOnCAN_"+mod_globals.opt_lang+".bqm",True)
|
||||
mod_globals.language_dict = lang.dict
|
||||
print "Done"
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
import sys, os, glob, copy
|
||||
import mod_globals
|
||||
import mod_utils
|
||||
import mod_db_manager
|
||||
from mod_optfile import *
|
||||
from mod_scan_ecus import families as families
|
||||
from mod_dfg import class_dfg
|
||||
@ -379,6 +381,20 @@ def convertXML(root, h_t, fns, ff, lid):
|
||||
ni = et.SubElement(h_t, 'td', attrib={'class':'row_d'})
|
||||
convertXML( e, ni, fns, ff, lid )
|
||||
|
||||
def saveToSeparateFile(nel, dtc ):
|
||||
|
||||
t_doc = et.Element('html')
|
||||
t_h_h = et.SubElement(t_doc, 'head')
|
||||
t_h_b = et.SubElement(t_doc, 'body')
|
||||
|
||||
et.SubElement(t_h_h, 'meta', charset="utf-8")
|
||||
et.SubElement(t_h_h, 'style').text = style
|
||||
|
||||
t_h_b.append(nel)
|
||||
|
||||
tree = et.ElementTree(t_doc)
|
||||
tree.write('./doc/' + dtc + '.htm', encoding='UTF-8', xml_declaration=True, default_namespace=None, method='html')
|
||||
|
||||
def processXML( path, l, ff ):
|
||||
|
||||
tree = et.parse(path+l)
|
||||
@ -412,6 +428,10 @@ def processXML( path, l, ff ):
|
||||
if fns[4]!='000000' and fns[5]=='104':
|
||||
dtcId = fns[4]
|
||||
|
||||
dtcId_106 = ''
|
||||
if fns[4]!='000000' and fns[5]=='106':
|
||||
dtcId_106 = fns[4]
|
||||
|
||||
#add line to bookmark
|
||||
#cop = et.SubElement(h_o, 'p')
|
||||
#coa = et.SubElement(cop, 'a', href='#'+l[:-4]).text = title
|
||||
@ -426,6 +446,9 @@ def processXML( path, l, ff ):
|
||||
|
||||
convertXML( root, nel, fns, ff, lid )
|
||||
|
||||
if dtcId_106 != '' and mod_globals.opt_sd:
|
||||
saveToSeparateFile(nel, dtcId_106)
|
||||
|
||||
return nel, lid, title
|
||||
|
||||
def f_symptom( dfg_fet, ff, of, pref, fetname, path ):
|
||||
@ -665,6 +688,11 @@ def optParser():
|
||||
dest="lang",
|
||||
default="RU")
|
||||
|
||||
parser.add_argument("--sd",
|
||||
help="separate doc files",
|
||||
dest="sd",
|
||||
default=False)
|
||||
|
||||
parser.add_argument("--cfc",
|
||||
help="turn off automatic FC and do it by script",
|
||||
dest="cfc",
|
||||
@ -714,6 +742,7 @@ def optParser():
|
||||
mod_globals.opt_scan = options.scan
|
||||
mod_globals.opt_si = options.si
|
||||
mod_globals.opt_cfc0 = options.cfc
|
||||
mod_globals.opt_sd = options.sd
|
||||
vin_opt = options.vinnum
|
||||
|
||||
def main():
|
||||
@ -731,11 +760,8 @@ def main():
|
||||
|
||||
optParser()
|
||||
|
||||
'''Check direcories'''
|
||||
if not os.path.exists('./cache'):
|
||||
os.makedirs('./cache')
|
||||
if not os.path.exists('../MTCSAVE'):
|
||||
os.makedirs('../MTCSAVE')
|
||||
mod_utils.chkDirTree()
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
'''If MTC database does not exists then demo mode'''
|
||||
if not os.path.exists('../BVMEXTRACTION'):
|
||||
|
@ -5,9 +5,12 @@ import sys, os
|
||||
import operator
|
||||
import ast
|
||||
import gc
|
||||
import time
|
||||
|
||||
import mod_ddt_utils
|
||||
import mod_utils
|
||||
import mod_db_manager
|
||||
|
||||
from shutil import copyfile
|
||||
|
||||
|
||||
@ -141,14 +144,14 @@ class DDT():
|
||||
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 mod_db_manager.file_in_ddt(self.decu.ecufname):
|
||||
print "No such file: ", self.decu.ecufname
|
||||
return None
|
||||
|
||||
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
|
||||
'ns1': 'http://www-diag.renault.com/2002/screens'}
|
||||
|
||||
tree = et.parse(self.decu.ecufname)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(self.decu.ecufname))
|
||||
xdoc = tree.getroot()
|
||||
|
||||
# Show screen
|
||||
@ -173,7 +176,7 @@ def optParser():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
# usage = "%prog -p <port> [options]",
|
||||
version="mod_ddt Version 0.9.p",
|
||||
version="mod_ddt Version 0.9.q",
|
||||
description="mod_ddt - python program for diagnostic Renault cars"
|
||||
)
|
||||
|
||||
@ -290,6 +293,7 @@ class DDTLauncher():
|
||||
self.var_dump = tk.BooleanVar()
|
||||
self.var_log = tk.BooleanVar()
|
||||
self.var_cfc = tk.BooleanVar()
|
||||
self.var_can2 = tk.BooleanVar()
|
||||
|
||||
self.var_portList = []
|
||||
self.var_speedList = []
|
||||
@ -462,6 +466,12 @@ class DDTLauncher():
|
||||
|
||||
self.dumpChk = tk.Checkbutton(self.set_fr, variable=self.var_dump, background="#d9d9d9")
|
||||
self.dumpChk.grid(row=2, column=1, **optsGrid_w)
|
||||
|
||||
self.can2_lbl = tk.Label(self.set_fr, text='CAN2:', background="#d9d9d9")
|
||||
self.can2_lbl.grid(row=2, column=1, **optsGrid_e)
|
||||
|
||||
self.can2Chk = tk.Checkbutton(self.set_fr, variable=self.var_can2, background="#d9d9d9")
|
||||
self.can2Chk.grid(row=2, column=2, **optsGrid_w)
|
||||
####################################################################################
|
||||
|
||||
self.btn_connect = tk.Button(self.mf, text="Connect selected ECU (ON-line)", command=self.ConnectBtnClick, **btn_style)
|
||||
@ -873,7 +883,7 @@ class DDTLauncher():
|
||||
decu = pickle.load(open(decucashfile, "rb")) # load it
|
||||
else: # else
|
||||
decu = DDTECU(None) # init class
|
||||
decu.loadXml(mod_globals.ddtroot+'/ecus/'+ce['xml'])
|
||||
decu.loadXml('ecus/'+ce['xml'])
|
||||
if len(decu.ecufname) > 0:
|
||||
pickle.dump(decu, open(decucashfile, "wb")) # and save cache
|
||||
|
||||
@ -914,14 +924,14 @@ class DDTLauncher():
|
||||
self.SaveBtnClick()
|
||||
|
||||
# Load XML
|
||||
if not os.path.isfile(decu.ecufname):
|
||||
if not mod_db_manager.file_in_ddt(decu.ecufname):
|
||||
print "No such file: ", decu.ecufname
|
||||
return None
|
||||
|
||||
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
|
||||
'ns1': 'http://www-diag.renault.com/2002/screens'}
|
||||
|
||||
tree = et.parse(decu.ecufname)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(decu.ecufname))
|
||||
xdoc = tree.getroot()
|
||||
|
||||
# Show screen
|
||||
@ -1219,7 +1229,7 @@ class DDTLauncher():
|
||||
c_pro.grid(row=7, column=1, **optsGrid)
|
||||
|
||||
self.getXmlListByProj()
|
||||
l_xml = tk.Label(self.ecudlg, text='XML:', background="#d9d9d9")
|
||||
l_xml = tk.Label(self.ecudlg, text='Recommended XML:', background="#d9d9d9")
|
||||
l_xml.grid(row=8, column=0, **optsGrid_e)
|
||||
self.dv_xml = tk.StringVar()
|
||||
self.dv_xml.set(ecu['xml'])
|
||||
@ -1228,27 +1238,39 @@ class DDTLauncher():
|
||||
c_xml.configure(textvariable=self.dv_xml)
|
||||
c_xml.configure(takefocus="")
|
||||
c_xml.grid(row=8, column=1, **optsGrid_w)
|
||||
b_xml = tk.Button(self.ecudlg, text="XML file", command=self.xmlBtnClick, **btn_style)
|
||||
b_xml.grid(row=8, column=2, **optsGrid)
|
||||
#b_xml = tk.Button(self.ecudlg, text="XML file", command=self.xmlBtnClick, **btn_style)
|
||||
#b_xml.grid(row=8, column=2, **optsGrid)
|
||||
|
||||
allxmllist = []
|
||||
for l in sorted(mod_db_manager.get_file_list_from_ddt('^ecus/*')):
|
||||
allxmllist.append( l[5:] )
|
||||
l2_xml = tk.Label(self.ecudlg, text='ALL XML:', background="#d9d9d9")
|
||||
l2_xml.grid(row=9, column=0, **optsGrid_e)
|
||||
a_xml = ttk.Combobox(self.ecudlg, width=30)
|
||||
a_xml.configure(values=allxmllist)
|
||||
a_xml.configure(textvariable=self.dv_xml)
|
||||
a_xml.configure(takefocus="")
|
||||
a_xml.grid(row=9, column=1, **optsGrid_w)
|
||||
|
||||
|
||||
self.getDumpListByXml()
|
||||
l_dump = tk.Label(self.ecudlg, text='Dump:', background="#d9d9d9")
|
||||
l_dump.grid(row=9, column=0, **optsGrid_e)
|
||||
l_dump.grid(row=10, column=0, **optsGrid_e)
|
||||
self.dv_dump = tk.StringVar()
|
||||
self.dv_dump.set(ecu['dump'])
|
||||
c_dump = ttk.Combobox(self.ecudlg, width=30)
|
||||
c_dump.configure(values=self.v_dumpList)
|
||||
c_dump.configure(textvariable=self.dv_dump)
|
||||
c_dump.configure(takefocus="")
|
||||
c_dump.grid(row=9, column=1, **optsGrid_w)
|
||||
c_dump.grid(row=10, column=1, **optsGrid_w)
|
||||
b_dump = tk.Button(self.ecudlg, text="Dump file", command=self.dumpBtnClick, **btn_style)
|
||||
b_dump.grid(row=9, column=2, **optsGrid)
|
||||
b_dump.grid(row=10, column=2, **optsGrid)
|
||||
|
||||
b_save = tk.Button(self.ecudlg, text="Save", command=self.ecuSaveBtnClick, **btn_style)
|
||||
b_save.grid(row=10, column=1, **optsGrid)
|
||||
b_save.grid(row=11, column=1, **optsGrid)
|
||||
|
||||
b_canc = tk.Button(self.ecudlg, text="Cancel", command=self.ecuCancelBtnClick, **btn_style)
|
||||
b_canc.grid(row=10, column=2, **optsGrid)
|
||||
b_canc.grid(row=11, column=2, **optsGrid)
|
||||
|
||||
def renewEcuList(self):
|
||||
self.ecutree.delete(*self.ecutree.get_children())
|
||||
@ -1264,6 +1286,7 @@ class DDTLauncher():
|
||||
def applySettings(self):
|
||||
mod_globals.opt_port = self.var_port.get().split(';')[0]
|
||||
mod_globals.opt_rate = int(self.var_speed.get())
|
||||
mod_globals.opt_can2 = self.var_can2.get()
|
||||
if self.var_log.get():
|
||||
mod_globals.opt_log = self.var_logName.get()
|
||||
else:
|
||||
@ -1374,8 +1397,8 @@ class DDTLauncher():
|
||||
def main():
|
||||
'''Main function'''
|
||||
|
||||
mod_ddt_utils.searchddtroot()
|
||||
mod_utils.chkDirTree()
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
lau = DDTLauncher()
|
||||
|
||||
|
@ -18,6 +18,7 @@ def trim( st ):
|
||||
|
||||
import mod_globals
|
||||
import mod_ddt_utils
|
||||
import mod_db_manager
|
||||
from mod_ddt_request import *
|
||||
from mod_ddt_data import *
|
||||
from mod_utils import *
|
||||
@ -319,12 +320,12 @@ class DDTECU():
|
||||
if len(xmlfile):
|
||||
self.ecufname = xmlfile
|
||||
|
||||
if not os.path.isfile(self.ecufname):
|
||||
if not mod_db_manager.file_in_ddt(self.ecufname):
|
||||
print "No such file:", self.ecufname
|
||||
return
|
||||
|
||||
#Load XML
|
||||
tree = et.parse (self.ecufname)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(self.ecufname))
|
||||
root = tree.getroot ()
|
||||
|
||||
ns = {'ns0':'http://www-diag.renault.com/2002/ECU',
|
||||
|
@ -7,6 +7,7 @@ import copy
|
||||
import time
|
||||
|
||||
from mod_utils import *
|
||||
import mod_db_manager
|
||||
|
||||
# import traceback
|
||||
|
||||
@ -1317,7 +1318,7 @@ class DDTScreen (tk.Frame):
|
||||
xfItalic = xFont.attrib["Italic"]
|
||||
xfColor = xFont.attrib["Color"]
|
||||
|
||||
if '::pic:' not in xText or not os.path.exists ('../graphics/'):
|
||||
if '::pic:' not in xText or not mod_db_manager.path_in_ddt('graphics'):
|
||||
self.ddt.create_rectangle (xrLeft, xrTop, xrLeft + xrWidth, xrTop + xrHeight,
|
||||
fill=self.ddtColor (xColor), outline=self.ddtColor (xColor))
|
||||
|
||||
@ -1352,9 +1353,10 @@ class DDTScreen (tk.Frame):
|
||||
id = self.ddt.create_text (xrLeft, xrTop, text=xText, font=lFont, width=xrWidth, anchor=xAlignment,
|
||||
fill=self.ddtColor (xfColor))
|
||||
else:
|
||||
gifname = xText.replace ('::pic:', mod_globals.ddtroot+'/graphics/') + '.gif'
|
||||
gifname = xText.replace ('::pic:', 'graphics/') + '.gif'
|
||||
gifname = gifname.replace ('\\', '/')
|
||||
if os.path.isfile (gifname):
|
||||
gifname = mod_db_manager.extract_from_ddt_to_cache(gifname)
|
||||
if gifname:
|
||||
self.images.append (tk.PhotoImage (file=gifname))
|
||||
x1 = self.images[-1].width ()
|
||||
y1 = self.images[-1].height ()
|
||||
@ -1610,9 +1612,10 @@ class DDTScreen (tk.Frame):
|
||||
obj = tk.Button (frame, text=xText, font=lFont, relief=tk.GROOVE,
|
||||
command=lambda key=str (slist), btn=xText: self.buttonPressed (btn, key))
|
||||
else:
|
||||
gifname = '../graphics/' + xText.split ('|')[1] + '.gif'
|
||||
gifname = 'graphics/' + xText.split ('|')[1] + '.gif'
|
||||
gifname = gifname.replace ('\\', '/')
|
||||
if os.path.isfile (gifname):
|
||||
gifname = mod_db_manager.extract_from_ddt_to_cache(gifname)
|
||||
if gifname:
|
||||
self.images.append (tk.PhotoImage (file=gifname))
|
||||
x1 = self.images[-1].width ()
|
||||
y1 = self.images[-1].height ()
|
||||
|
@ -3,6 +3,8 @@
|
||||
import os
|
||||
import xml.etree.ElementTree as et
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
|
||||
from operator import itemgetter
|
||||
from copy import deepcopy
|
||||
|
||||
@ -83,22 +85,23 @@ def loadECUlist():
|
||||
|
||||
# make or load eculist
|
||||
print "Loading eculist"
|
||||
eculistcache = "./cache/ddt_eculist.p"
|
||||
eculistcache = os.path.join(mod_globals.cache_dir, "ddt_eculist.p")
|
||||
|
||||
if os.path.isfile(eculistcache): # if cache exists
|
||||
eculist = pickle.load(open(eculistcache, "rb")) # load it #dbaccess
|
||||
else:
|
||||
|
||||
# open xml
|
||||
eculistfilename = mod_globals.ddtroot+'/ecus/eculist.xml'
|
||||
if not os.path.isfile(eculistfilename):
|
||||
eculistfilename = 'ecus/eculist.xml'
|
||||
#if not os.path.isfile(eculistfilename):
|
||||
if not mod_db_manager.file_in_ddt(eculistfilename):
|
||||
print "No such file: "+eculistfilename
|
||||
return None
|
||||
|
||||
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
|
||||
'ns1': 'http://www-diag.renault.com/2002/screens'}
|
||||
|
||||
tree = et.parse(eculistfilename)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(eculistfilename))
|
||||
root = tree.getroot()
|
||||
|
||||
eculist = {}
|
||||
@ -142,14 +145,14 @@ def loadECUlist():
|
||||
|
||||
class ddtProjects():
|
||||
def __init__(self):
|
||||
self.proj_path = mod_globals.ddtroot + '/vehicles/projects.xml'
|
||||
self.proj_path = 'vehicles/projects.xml'
|
||||
|
||||
self.plist = []
|
||||
|
||||
if not os.path.exists(self.proj_path):
|
||||
if not mod_db_manager.file_in_ddt(self.proj_path):
|
||||
return
|
||||
|
||||
tree = et.parse(self.proj_path)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(self.proj_path))
|
||||
root = tree.getroot()
|
||||
|
||||
DefaultAddressing = root.findall('DefaultAddressing')
|
||||
@ -201,14 +204,14 @@ class ddtProjects():
|
||||
|
||||
class ddtAddressing():
|
||||
def __init__(self, filename ):
|
||||
self.addr_path = mod_globals.ddtroot + '/vehicles/' + filename
|
||||
self.addr_path = 'vehicles/' + filename
|
||||
|
||||
self.alist = []
|
||||
|
||||
if not os.path.exists(self.addr_path):
|
||||
if not mod_db_manager.file_in_ddt(self.addr_path):
|
||||
return
|
||||
|
||||
tree = et.parse(self.addr_path)
|
||||
tree = et.parse(mod_db_manager.get_file_from_ddt(self.addr_path))
|
||||
root = tree.getroot()
|
||||
|
||||
ns = {'ns0': 'DiagnosticAddressingSchema.xml',
|
||||
|
@ -11,6 +11,7 @@ from mod_utils import ChoiceFromDict
|
||||
from mod_utils import pyren_encode
|
||||
from mod_utils import clearScreen
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
import sys
|
||||
import glob
|
||||
import os
|
||||
@ -52,13 +53,14 @@ class class_dfg:
|
||||
|
||||
#find TCOM by platform
|
||||
if platform!='':
|
||||
for file in glob.glob("../Vehicles/TCOM_*.[Xx]ml"):
|
||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
||||
for file in file_list:
|
||||
try:
|
||||
model_n = int(file[17:20])
|
||||
if model_n<86: continue
|
||||
except ValueError:
|
||||
pass
|
||||
DOMTree = xml.dom.minidom.parse(file)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||
vh = DOMTree.documentElement
|
||||
if vh.hasAttribute("defaultText"):
|
||||
TCOM = vh.getAttribute("TCOM")
|
||||
@ -66,11 +68,12 @@ class class_dfg:
|
||||
if vehTypeCode.upper()==platform.upper():
|
||||
self.tcom = TCOM
|
||||
break
|
||||
self.dfgFile = '../Vehicles/DFG/DFG_'+self.tcom+'.Xml'
|
||||
self.dfgFile = 'Vehicles/DFG/DFG_'+self.tcom+'.xml'
|
||||
else:
|
||||
vhcls = []
|
||||
for file in glob.glob("../Vehicles/DFG/DFG_*.[Xx]ml"):
|
||||
DOMTree = xml.dom.minidom.parse(file)
|
||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/DFG/DFG_\d{3}.[Xx]ml')
|
||||
for file in file_list:
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||
vh = DOMTree.documentElement
|
||||
if vh.hasAttribute("defaultText"):
|
||||
TCOM = vh.getAttribute("TCOM")
|
||||
@ -93,7 +96,7 @@ class class_dfg:
|
||||
|
||||
def loadDFG( self ):
|
||||
try:
|
||||
DOMTree = xml.dom.minidom.parse(self.dfgFile)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(self.dfgFile))
|
||||
except:
|
||||
print "ERROR loading dfg-file"
|
||||
#if 'DFG_135' in self.dfgFile:
|
||||
|
@ -20,13 +20,14 @@ if mod_globals.os != 'android':
|
||||
from mod_ddt import DDT
|
||||
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
|
||||
from xml.dom.minidom import parse
|
||||
from datetime import datetime
|
||||
from mod_utils import show_doc
|
||||
import xml.dom.minidom
|
||||
import xml.etree.ElementTree as et
|
||||
import struct
|
||||
#import xml.etree.ElementTree as et
|
||||
#import struct
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
@ -53,7 +54,7 @@ class ECU:
|
||||
'''Contains data for one specific ECU
|
||||
implement menu for ecu'''
|
||||
|
||||
path = "../EcuRenault/Sessions/"
|
||||
path = "EcuRenault/Sessions/"
|
||||
|
||||
getDTCmnemo = ""
|
||||
resetDTCcommand = ""
|
||||
@ -95,7 +96,7 @@ class ECU:
|
||||
|
||||
print "ECU type: ", cecu['stdType']
|
||||
|
||||
mdom = xml.dom.minidom.parse(self.path+self.ecudata['ModelId'].strip())
|
||||
mdom = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(self.path+self.ecudata['ModelId'].strip()[:-3]+'xml'))
|
||||
mdoc = mdom.documentElement
|
||||
|
||||
print "Loading screens "
|
||||
@ -104,7 +105,7 @@ class ECU:
|
||||
|
||||
print "Loading optimyzer"
|
||||
self.defaults = []
|
||||
opt_file = optfile(self.path+self.ecudata['OptimizerId'].strip())
|
||||
opt_file = optfile(self.path+self.ecudata['OptimizerId'].strip()[:-3]+'xml')
|
||||
|
||||
print "Loading defaults"
|
||||
df_class = ecu_defaults ( self.Defaults, mdoc, opt_file.dict, tran )
|
||||
@ -127,7 +128,7 @@ class ECU:
|
||||
xmlstr = opt_file.dict["DataIds"]
|
||||
ddom = xml.dom.minidom.parseString( xmlstr.encode( "utf-8" ) )
|
||||
ddoc = ddom.documentElement
|
||||
di_class = ecu_dataids ( self.DataIds, ddoc, opt_file.dict, tran )
|
||||
di_class = ecu_dataids( self.DataIds, ddoc, opt_file.dict, tran )
|
||||
|
||||
def initELM(self, elm):
|
||||
|
||||
@ -465,7 +466,7 @@ class ECU:
|
||||
newScreen = newScreen + pyren_encode( l ) + ' \n'
|
||||
|
||||
if pages>0:
|
||||
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] N for page number H for help or any other to exit"
|
||||
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] <N> for page number H for help or any other to exit"
|
||||
else:
|
||||
newScreen = newScreen+'\n'+"Press H for help or any key to exit"
|
||||
|
||||
@ -865,7 +866,7 @@ def find_real_ecuid( eid ):
|
||||
candst = ''
|
||||
startDiagReq = '10C0'
|
||||
|
||||
DOMTree = xml.dom.minidom.parse("../EcuRenault/Uces.Xml")
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip("EcuRenault/Uces.xml"))
|
||||
Ecus = DOMTree.documentElement
|
||||
EcuDatas = Ecus.getElementsByTagName("EcuData")
|
||||
|
||||
@ -943,6 +944,8 @@ def main():
|
||||
ecuid = sys.argv[1]
|
||||
lanid = sys.argv[2]
|
||||
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
if len(ecuid)==5:
|
||||
ecuid, fastinit, slowinit, protocol, candst, startDiagReq = find_real_ecuid(ecuid)
|
||||
sys.argv[1] = ecuid
|
||||
@ -957,19 +960,19 @@ def main():
|
||||
|
||||
print "Loading language "
|
||||
sys.stdout.flush()
|
||||
lang = optfile("../Location/DiagOnCan_"+lanid+".bqm",True)
|
||||
lang = optfile("Location/DiagOnCAN_"+lanid+".bqm",True)
|
||||
print "Done"
|
||||
sys.stdout.flush()
|
||||
|
||||
fgfile = "../EcuRenault/Sessions/FG"+ecuid+".xml"
|
||||
sgfile = "../EcuRenault/Sessions/SG"+ecuid+".xml"
|
||||
fgfile = "EcuRenault/Sessions/FG"+ecuid+".xml"
|
||||
sgfile = "EcuRenault/Sessions/SG"+ecuid+".xml"
|
||||
|
||||
mdom = xml.dom.minidom.parse(fgfile)
|
||||
mdom = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(fgfile))
|
||||
mdoc = mdom.documentElement
|
||||
|
||||
print "Loading optimyzer"
|
||||
sys.stdout.flush()
|
||||
opt_file = optfile(sgfile)
|
||||
opt_file = optfile(mod_db_manager.get_file_from_clip(sgfile))
|
||||
|
||||
print "Loading defaults"
|
||||
df_class = ecu_defaults ( Defaults, mdoc, opt_file.dict, lang.dict )
|
||||
|
@ -4,6 +4,7 @@ import os
|
||||
import re
|
||||
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
import mod_utils
|
||||
import mod_ecu
|
||||
|
||||
@ -13,9 +14,11 @@ def playScenario(command, ecu, elm):
|
||||
|
||||
services = ecu.Services
|
||||
|
||||
path = "../EcuRenault/Scenarios/"
|
||||
path = "EcuRenault/Scenarios/"
|
||||
scenarioName,scenarioData = command.scenario.split('#')
|
||||
|
||||
scenarioData = scenarioData.upper()[:-4]+'.xml'
|
||||
|
||||
showable = False
|
||||
if scenarioName.lower().startswith('scm'):
|
||||
showable = True
|
||||
@ -23,7 +26,7 @@ def playScenario(command, ecu, elm):
|
||||
|
||||
if os.path.isfile('./'+scenarioName+'.py'):
|
||||
scen = __import__( scenarioName )
|
||||
scen.run( elm, ecu, command, path+scenarioData )
|
||||
scen.run( elm, ecu, command, '../'+path+scenarioData )
|
||||
return
|
||||
|
||||
print "\nThere is scenarium. I do not support them!!!\n"
|
||||
@ -35,10 +38,10 @@ def playScenario(command, ecu, elm):
|
||||
if 'show' not in ch.lower():
|
||||
return
|
||||
|
||||
if not os.path.isfile(path+scenarioData):
|
||||
if not mod_db_manager.file_in_clip(os.path.join(path,scenarioData)):
|
||||
return
|
||||
|
||||
lines = [line.rstrip('\n') for line in open(path+scenarioData)]
|
||||
lines = [line.rstrip('\n') for line in mod_db_manager.get_file_from_clip(os.path.join(path,scenarioData))]
|
||||
|
||||
for l in lines:
|
||||
pa = re.compile(r'name=\"(\w+)\"\s+value=\"(\w+)\"')
|
||||
|
@ -1005,7 +1005,7 @@ class ELM:
|
||||
|
||||
# Ensure time gap between commands
|
||||
# dl = self.busLoad + self.srvsDelay - tb + self.lastCMDtime
|
||||
if ((tb - self.lastCMDtime) < (self.busLoad + self.srvsDelay)) and "AT" not in command.upper ():
|
||||
if ((tb - self.lastCMDtime) < (self.busLoad + self.srvsDelay)) and command.upper()[:2] in ['AT','ST']:
|
||||
time.sleep (self.busLoad + self.srvsDelay - tb + self.lastCMDtime)
|
||||
|
||||
tb = time.time () # renew start time
|
||||
@ -1127,7 +1127,7 @@ class ELM:
|
||||
if mod_globals.opt_rate < 50000 and len (command) == 6 and command[:4] == '1902':
|
||||
command = '1902AF'
|
||||
|
||||
if "AT" in command.upper () or self.currentprotocol != "can":
|
||||
if command.upper()[:2] in ["AT","ST"] or self.currentprotocol != "can":
|
||||
return self.send_raw (command)
|
||||
|
||||
if self.ATCFC0:
|
||||
@ -1780,7 +1780,19 @@ class ELM:
|
||||
tmstr = datetime.now ().strftime ("%x %H:%M:%S.%f")[:-3]
|
||||
self.lf.write('#' * 60 + "\n#[" + tmstr + "] Init CAN\n" + '#' * 60 + "\n")
|
||||
self.lf.flush()
|
||||
self.check_answer(self.cmd("at ws"))
|
||||
|
||||
# reset ELM
|
||||
elm_ver = self.cmd("at ws")
|
||||
if 'v1.3a' in elm_ver:
|
||||
mod_globals.opt_stn = True
|
||||
self.check_answer(elm_ver)
|
||||
|
||||
# check STN
|
||||
if mod_globals.opt_can2 and mod_globals.opt_stn:
|
||||
tmp = self.cmd("STP 53")
|
||||
if 'OK' not in tmp:
|
||||
mod_globals.opt_stn = False
|
||||
|
||||
self.check_answer(self.cmd("at e1"))
|
||||
self.check_answer(self.cmd("at s0"))
|
||||
self.check_answer(self.cmd("at h0"))
|
||||
@ -1799,6 +1811,18 @@ class ELM:
|
||||
# self.cmd("at at 1")
|
||||
self.lastCMDtime = 0
|
||||
|
||||
def set_can_500(self):
|
||||
if mod_globals.opt_can2 and mod_globals.opt_stn:
|
||||
tmp = self.cmd("STPBR 500000")
|
||||
if '?' not in tmp: return
|
||||
self.cmd("at sp 6")
|
||||
|
||||
def set_can_250(self):
|
||||
if mod_globals.opt_can2 and mod_globals.opt_stn:
|
||||
tmp = self.cmd("STPBR 250000")
|
||||
if '?' not in tmp: return
|
||||
self.cmd("at sp 8")
|
||||
|
||||
def set_can_addr(self, addr, ecu):
|
||||
|
||||
self.notSupportedCommands = {}
|
||||
@ -1843,18 +1867,18 @@ class ELM:
|
||||
if self.lf != 0:
|
||||
self.lf.write ('#' * 60 + "\n# Double BRP, try CAN250 and then CAN500\n" + '#' * 60 + "\n")
|
||||
self.lf.flush ()
|
||||
self.cmd ("at sp 8") # set 250
|
||||
self.set_can_250()
|
||||
tmprsp = self.send_raw ("0210C0") # send any command
|
||||
if 'CAN ERROR' in tmprsp: # not 250!
|
||||
ecu['brp'] = '0' # brp = 0
|
||||
self.cmd ("at sp 6") # set 500
|
||||
self.set_can_500()
|
||||
else: # 250!
|
||||
ecu['brp'] = '1' # brp = 1
|
||||
else: # not double brp
|
||||
if 'brp' in ecu.keys () and '1' in ecu['brp']:
|
||||
self.cmd ("at sp 8")
|
||||
self.set_can_250()
|
||||
else:
|
||||
self.cmd ("at sp 6")
|
||||
self.set_can_500()
|
||||
|
||||
self.check_answer (self.cmd ("at at 1")) # reset adaptive timing step 3
|
||||
|
||||
|
@ -30,6 +30,8 @@ opt_exp = False #allow to use buttons in ddt
|
||||
opt_dump = False #dump responces from all 21xx and 22xxxx requests
|
||||
opt_can2 = False #can connected to pins 13 and 12
|
||||
opt_ddtxml = ""
|
||||
opt_stn = False
|
||||
opt_sd = False #separate doc files
|
||||
|
||||
dumpName = ""
|
||||
|
||||
@ -42,8 +44,14 @@ ext_cur_DTC = "000000"
|
||||
none_val = "None"
|
||||
|
||||
mtcdir = "../MTCSAVE/VIN"
|
||||
|
||||
user_data_dir = "./"
|
||||
cache_dir = "./cache/"
|
||||
log_dir = "./logs/"
|
||||
dumps_dir = "./dumps/"
|
||||
ddt_arc = ""
|
||||
ddtroot = ".." # parent folder for backward compatibility. for 9n and up use ../DDT2000data
|
||||
clip_arc = ""
|
||||
cliproot = ".."
|
||||
|
||||
os = ""
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
import struct
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
@ -21,16 +23,22 @@ class optfile:
|
||||
|
||||
self.dict = {}
|
||||
|
||||
fn = filename
|
||||
pn = './cache/'+os.path.basename(fn)+'.p'
|
||||
# check in cache folder
|
||||
cachename = mod_globals.cache_dir+os.path.basename(filename)[:-4]+'.p'
|
||||
if os.path.isfile(cachename):
|
||||
self.dict = pickle.load( open( cachename, "rb" ) )
|
||||
return
|
||||
|
||||
if os.path.isfile(pn):
|
||||
self.dict = pickle.load( open( pn, "rb" ) )
|
||||
elif os.path.isfile(fn):
|
||||
lf = open( fn, "rb" )
|
||||
if mod_globals.clip_arc!='' and mod_db_manager.file_in_clip(filename[:-4]+'.p'):
|
||||
mod_db_manager.extract_from_clip_to_cache(filename[:-4]+'.p')
|
||||
self.dict = pickle.load( open( cachename, "rb" ) )
|
||||
return
|
||||
|
||||
lf = mod_db_manager.get_file_from_clip( filename )
|
||||
if lf:
|
||||
self.get_dict( lf, progress )
|
||||
if cache:
|
||||
pickle.dump( self.dict, open( pn, "wb" ) )
|
||||
pickle.dump( self.dict, open( cachename, "wb" ) )
|
||||
|
||||
def get_string(self,lf,len):
|
||||
|
||||
|
@ -31,7 +31,8 @@ from mod_utils import Choice
|
||||
from mod_utils import ChoiceLong
|
||||
from mod_utils import pyren_encode
|
||||
from mod_utils import DBG
|
||||
from mod_elm import ELM
|
||||
#from mod_elm import ELM
|
||||
import mod_db_manager
|
||||
import mod_elm as m_elm
|
||||
import mod_globals
|
||||
import sys
|
||||
@ -72,13 +73,15 @@ class ScanEcus:
|
||||
|
||||
####### Get list car models from vehicles directory #######
|
||||
self.vhcls = []
|
||||
for file in glob.glob("../Vehicles/TCOM_*.[Xx]ml"):
|
||||
|
||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
||||
for file in file_list:
|
||||
try:
|
||||
model_n = int(file[17:20])
|
||||
model_n = int(file[-7:-4])
|
||||
if model_n<86: continue
|
||||
except ValueError:
|
||||
pass
|
||||
DOMTree = xml.dom.minidom.parse(file)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||
vh = DOMTree.documentElement
|
||||
if vh.hasAttribute("defaultText"):
|
||||
vehiclename = vh.getAttribute("defaultText").strip()
|
||||
@ -328,7 +331,7 @@ class ScanEcus:
|
||||
|
||||
ecuname = ''
|
||||
|
||||
DOMTree = xml.dom.minidom.parse(file)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||
vh = DOMTree.documentElement
|
||||
|
||||
if vh.hasAttribute ("vehTypeCode"):
|
||||
@ -404,8 +407,7 @@ class ScanEcus:
|
||||
def read_Uces_file( self, all = False ):
|
||||
|
||||
# Finding them in Uces.xml and loading
|
||||
#print 'Reading Uces file'
|
||||
DOMTree = xml.dom.minidom.parse("../EcuRenault/Uces.Xml")
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip("EcuRenault/Uces.xml"))
|
||||
Ecus = DOMTree.documentElement
|
||||
EcuDatas = Ecus.getElementsByTagName("EcuData")
|
||||
if EcuDatas:
|
||||
@ -618,7 +620,8 @@ class ScanEcus:
|
||||
self.elm.lf.write("#load: "+model+' '+tcomfilename+"\n")
|
||||
self.elm.lf.flush()
|
||||
|
||||
self.load_model_ECUs( "../Vehicles/"+tcomfilename )
|
||||
#self.load_model_ECUs( "../Vehicles/"+tcomfilename )
|
||||
self.load_model_ECUs( tcomfilename )
|
||||
print " - "+str(len(self.allecus))+" ecus loaded"
|
||||
|
||||
def compare_ecu( self, row, rrsp, req ):
|
||||
@ -973,9 +976,10 @@ def findTCOM( addr, cmd, rsp ):
|
||||
ecuvhc = {}
|
||||
vehicle = ''
|
||||
print 'Read models'
|
||||
for file in glob.glob("../Vehicles/TCOM_*.xml"):
|
||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
||||
for file in file_list:
|
||||
vehicle = ''
|
||||
DOMTree = xml.dom.minidom.parse(file)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||
vh = DOMTree.documentElement
|
||||
if vh.hasAttribute("defaultText"):
|
||||
vehiclename = vh.getAttribute("defaultText")
|
||||
@ -1045,6 +1049,8 @@ def generateSavedEcus( eculist, fileName ):
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
# 10016,10074 savedEcus.p_gen
|
||||
if len(sys.argv)==3: generateSavedEcus( sys.argv[1], sys.argv[2] )
|
||||
|
||||
|
@ -388,7 +388,8 @@ def chkDirTree():
|
||||
os.makedirs('./macro')
|
||||
if not os.path.exists('./doc'):
|
||||
os.makedirs('./doc')
|
||||
|
||||
if not os.path.exists('../MTCSAVE'):
|
||||
os.makedirs('../MTCSAVE')
|
||||
|
||||
def getVIN( de, elm, getFirst = False ):
|
||||
''' getting VINs from every ECU '''
|
||||
@ -476,9 +477,11 @@ def show_doc( addr, id ):
|
||||
mod_globals.doc_server_proc = subprocess.Popen(["python", "-m", "SimpleHTTPServer", "59152"])
|
||||
atexit.register(kill_server)
|
||||
|
||||
if mod_globals.opt_sd:
|
||||
url = 'http://localhost:59152/doc/' + id[1:] + '.htm'
|
||||
else:
|
||||
url = 'http://localhost:59152/doc/'+mod_globals.vin+'.htm'+id
|
||||
webbrowser.open(url, new=0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import sys, os
|
||||
import mod_globals
|
||||
import mod_db_manager
|
||||
|
||||
mod_globals.os = os.name
|
||||
|
||||
@ -67,7 +68,7 @@ def optParser():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
#usage = "%prog -p <port> [options]",
|
||||
version="pyRen Version 0.9.p",
|
||||
version="pyRen Version 0.9.q",
|
||||
description = "pyRen - python program for diagnostic Renault cars"
|
||||
)
|
||||
|
||||
@ -91,6 +92,11 @@ def optParser():
|
||||
dest="lang",
|
||||
default="RU")
|
||||
|
||||
parser.add_argument("--sd",
|
||||
help="separate doc files",
|
||||
dest="sd",
|
||||
default=False)
|
||||
|
||||
parser.add_argument("-m",
|
||||
help="number of car model",
|
||||
dest="car",
|
||||
@ -223,6 +229,7 @@ def optParser():
|
||||
mod_globals.opt_exp = options.exp
|
||||
mod_globals.opt_dump = options.dump
|
||||
mod_globals.opt_can2 = options.can2
|
||||
mod_globals.opt_sd = options.sd
|
||||
if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10':
|
||||
mod_globals.opt_dev = False
|
||||
mod_globals.opt_devses = '1086'
|
||||
@ -237,6 +244,7 @@ def main():
|
||||
optParser()
|
||||
|
||||
mod_utils.chkDirTree()
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
print 'Opening ELM'
|
||||
elm = ELM( mod_globals.opt_port, mod_globals.opt_speed, mod_globals.opt_log )
|
||||
@ -276,28 +284,15 @@ def main():
|
||||
|
||||
print "Loading language "
|
||||
sys.stdout.flush()
|
||||
#loading language data
|
||||
lang = optfile("../Location/DiagOnCan_"+mod_globals.opt_lang+".bqm",True)
|
||||
# loading language data
|
||||
lang = optfile("Location/DiagOnCAN_" + mod_globals.opt_lang + ".bqm", True)
|
||||
mod_globals.language_dict = lang.dict
|
||||
print "Done"
|
||||
|
||||
#check cache version
|
||||
if not os.path.isfile("./cache/version09k.txt"):
|
||||
#if the cache has old version then we should clear it
|
||||
for root, dirs, files in os.walk("./cache"):
|
||||
for sfile in files:
|
||||
if sfile.startswith("ver") or sfile.startswith("FG") or sfile.startswith("ddt"):
|
||||
full_path = os.path.join("./cache", sfile)
|
||||
os.remove(full_path)
|
||||
#create new version file
|
||||
verfile = open( "./cache/version09k.txt", "wb" )
|
||||
verfile.write("Do not remove me if you have v0.9.k or above.\n")
|
||||
verfile.close()
|
||||
|
||||
mod_ddt_utils.searchddtroot()
|
||||
|
||||
#check if DDT present
|
||||
if os.path.exists(mod_globals.ddtroot+'/ecus') and mod_globals.os != 'android':
|
||||
if os.path.exists(os.path.join(mod_globals.ddtroot, '/ecus')) and mod_globals.os != 'android':
|
||||
mod_globals.opt_ddt = True
|
||||
|
||||
while( 1 ):
|
||||
|
Loading…
x
Reference in New Issue
Block a user