9p doc improvements

This commit is contained in:
shrlnm 2019-10-09 11:50:51 +03:00
parent 0b71166a9e
commit 2b44dba967
8 changed files with 105 additions and 98 deletions

View File

@ -29,6 +29,7 @@ if __name__ == "__main__":
fbsessionfiles += glob.glob (os.path.join (ecudir, "Sessions", "FG*.xml")) fbsessionfiles += glob.glob (os.path.join (ecudir, "Sessions", "FG*.xml"))
fgsessionfiles = glob.glob (os.path.join (ecudir, "Sessions", "SG*.xml")) fgsessionfiles = glob.glob (os.path.join (ecudir, "Sessions", "SG*.xml"))
vehiclesfiles = glob.glob (os.path.join (vehicledir, "*.xml")) vehiclesfiles = glob.glob (os.path.join (vehicledir, "*.xml"))
dfgfiles = glob.glob (os.path.join (vehicledir, "DFG", "*.xml"))
locationsfiles = glob.glob (os.path.join (locationdir, "*.bqm")) locationsfiles = glob.glob (os.path.join (locationdir, "*.bqm"))
scnerariosfiles = glob.glob (os.path.join (ecudir, "Scenarios", "*.xml")) scnerariosfiles = glob.glob (os.path.join (ecudir, "Scenarios", "*.xml"))
@ -44,7 +45,13 @@ if __name__ == "__main__":
f = open (vf, "r") f = open (vf, "r")
data = f.read () data = f.read ()
zf.writestr (os.path.join ("Vehicles", os.path.basename (vf)), str (data)) zf.writestr (os.path.join ("Vehicles", os.path.basename (vf)), str (data))
for vf in dfgfiles:
print "Processing file ", vf
f = open(vf, "r")
data = f.read()
zf.writestr(os.path.join("Vehicles", "DFG", os.path.basename(vf)), str(data))
for vf in ecufiles: for vf in ecufiles:
print "Processing file ", vf print "Processing file ", vf
f = open (vf, "r") f = open (vf, "r")

View File

@ -388,9 +388,16 @@ def processXML( path, l, ff ):
#ma = acf_MTC_compare_doc( sieconfigid, mtc ) #ma = acf_MTC_compare_doc( sieconfigid, mtc )
#if ma: #document complines to MTC filter #if ma: #document complines to MTC filter
title = root.find('title').text.strip() try:
if title=='': #check id documents refers to another title = root.find('title').text.strip()
root,title = getTitleAndRef( path, ff, root, title, l ) except:
title = ''
try:
if title=='': #check id documents refers to another
root,title = getTitleAndRef( path, ff, root, title, l )
except:
pass
lid = l[:-4] lid = l[:-4]
@ -400,13 +407,23 @@ def processXML( path, l, ff ):
if fns[4]!='000000': if fns[4]!='000000':
title = 'DTC'+fns[4]+' '+title title = 'DTC'+fns[4]+' '+title
dtcId = ''
if fns[4]!='000000' and fns[5]=='104':
dtcId = fns[4]
#add line to bookmark #add line to bookmark
#cop = et.SubElement(h_o, 'p') #cop = et.SubElement(h_o, 'p')
#coa = et.SubElement(cop, 'a', href='#'+l[:-4]).text = title #coa = et.SubElement(cop, 'a', href='#'+l[:-4]).text = title
nel = et.Element('div') nel = et.Element('div')
et.SubElement(nel, 'hr', attrib={'id':lid}) et.SubElement(nel, 'hr', attrib={'id':lid})
et.SubElement(nel, 'a', attrib={'href':'#home'}).text = "Up"
if dtcId!='':
et.SubElement(nel, 'a', attrib={'href':'#home','id':dtcId}).text = "Up"
else:
et.SubElement(nel, 'a', attrib={'href':'#home'}).text = "Up"
convertXML( root, nel, fns, ff, lid ) convertXML( root, nel, fns, ff, lid )
return nel, lid, title return nel, lid, title
@ -480,6 +497,7 @@ def f_functions( dfg_dom, ff, of, pref, domname, path ):
of.remove( l ) of.remove( l )
cop = et.SubElement(dom_dtc_o, 'p') cop = et.SubElement(dom_dtc_o, 'p')
et.SubElement(cop, 'a', href='#'+lid).text = title et.SubElement(cop, 'a', href='#'+lid).text = title
print lid,';',title
dom_t.append(nel) dom_t.append(nel)
cop = et.SubElement(dom_o, 'p') cop = et.SubElement(dom_o, 'p')
@ -604,7 +622,7 @@ def generateHTML(path, mtc, vin, dfg, date_madc ):
h_o.append(oth_o) h_o.append(oth_o)
tree = et.ElementTree(doc) tree = et.ElementTree(doc)
tree.write('./'+vin+'.htm', encoding='UTF-8', xml_declaration=True, default_namespace=None, method='html') tree.write('./doc/'+vin+'.htm', encoding='UTF-8', xml_declaration=True, default_namespace=None, method='html')
print '\r\tDone:100%' print '\r\tDone:100%'
vin_opt = '' vin_opt = ''

View File

@ -284,17 +284,6 @@ class DDTECU():
eculist = mod_ddt_utils.loadECUlist() eculist = mod_ddt_utils.loadECUlist()
##make or load eculist
#print "Loading eculist"
#eculistcache = "./cache/ddt_eculist.p"
#
#if os.path.isfile(eculistcache): #if cache exists
# eculist = pickle.load( open( eculistcache, "rb" ) ) #load it
#else: #else
# eculist = mod_ddt_utils.loadECUlist() #loading original data
# if eculist == None: return #return if no eculist file
# pickle.dump( eculist, open( eculistcache, "wb" ) ) #and save cache
mod_ddt_utils.searchddtroot() mod_ddt_utils.searchddtroot()
if len(mod_globals.opt_ddtxml)>0: if len(mod_globals.opt_ddtxml)>0:
@ -363,62 +352,6 @@ class DDTECU():
if di.Name not in self.cmd4data.keys(): if di.Name not in self.cmd4data.keys():
self.cmd4data[di.Name] = r.Name self.cmd4data[di.Name] = r.Name
'''
def loadECUlist(self):
global eculist
#open xml
if not os.path.isfile('../ecus/eculist.xml'):
print "No such file: ../ecus/eculist.xml"
return None
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
'ns1': 'http://www-diag.renault.com/2002/screens'}
tree = et.parse ('../ecus/eculist.xml')
root = tree.getroot ()
eculist = {}
#print et.dump(root)
functions = root.findall("Function")
if len(functions):
for function in functions:
Address = hex(int(function.attrib["Address"])).replace("0x","").zfill(2).upper()
eculist[Address] = {}
FuncName = function.attrib["Name"]
targets = function.findall("Target")
eculist[Address]["FuncName"] = FuncName
eculist[Address]["targets"] = {}
if len(targets):
for target in targets:
href = target.attrib["href"]
eculist[Address]["targets"][href] = {}
pjc = target.findall("Projects")
if len(pjc)>0:
pjcl = [elem.tag.upper() for elem in pjc[0].iter()][1:]
else:
pjcl = []
eculist[Address]["targets"][href]['Projects'] = pjcl
ail = []
ais = target.findall("AutoIdents")
if len(ais):
for ai in ais:
AutoIdents = ai.findall("AutoIdent")
if len(AutoIdents):
for AutoIdent in AutoIdents:
air = {}
air['DiagVersion'] = AutoIdent.attrib["DiagVersion"].strip()
air['Supplier'] = AutoIdent.attrib["Supplier"].strip()
air['Soft'] = AutoIdent.attrib["Soft"].strip()
air['Version'] = AutoIdent.attrib["Version"].strip()
#if len(DiagVersion)==1 : DiagVersion = '0'+DiagVersion
#hash = Address+DiagVersion+Supplier+Soft+Version
#eculist[hash] = href
ail.append(air)
eculist[Address]["targets"][href]['AutoIdents'] = ail
'''
def saveDump( self ): def saveDump( self ):
''' save responces from all 21xx, 22xxxx commands ''' ''' save responces from all 21xx, 22xxxx commands '''

View File

@ -86,7 +86,7 @@ def loadECUlist():
eculistcache = "./cache/ddt_eculist.p" eculistcache = "./cache/ddt_eculist.p"
if os.path.isfile(eculistcache): # if cache exists if os.path.isfile(eculistcache): # if cache exists
eculist = pickle.load(open(eculistcache, "rb")) # load it eculist = pickle.load(open(eculistcache, "rb")) # load it #dbaccess
else: else:
# open xml # open xml
@ -135,7 +135,7 @@ def loadECUlist():
air['Version'] = AutoIdent.attrib["Version"].strip() air['Version'] = AutoIdent.attrib["Version"].strip()
ail.append(air) ail.append(air)
eculist[Address]["targets"][href]['AutoIdents'] = ail eculist[Address]["targets"][href]['AutoIdents'] = ail
pickle.dump(eculist, open(eculistcache, "wb")) # and save cache pickle.dump(eculist, open(eculistcache, "wb")) # and save cache #dbaccess
return eculist return eculist

View File

@ -23,6 +23,7 @@ import mod_globals
from xml.dom.minidom import parse from xml.dom.minidom import parse
from datetime import datetime from datetime import datetime
from mod_utils import show_doc
import xml.dom.minidom import xml.dom.minidom
import xml.etree.ElementTree as et import xml.etree.ElementTree as et
import struct import struct
@ -375,13 +376,22 @@ class ECU:
#if mod_globals.os == 'android': #if mod_globals.os == 'android':
# csv_filename = csv_filename.encode("ascii","ignore") # csv_filename = csv_filename.encode("ascii","ignore")
csvf = open("./csv/"+pyren_encode(csv_filename), "wt") csvf = open("./csv/"+pyren_encode(csv_filename), "wt")
DTCpos = path.find('DTC')
if DTCpos > 0:
IDstr = '#' + path[DTCpos+3:DTCpos + 9]
else:
IDstr = ''
#debug
#show_doc(self.ecudata['dst'], IDstr)
kb = KBHit() kb = KBHit()
tb = time.time() #time of begining tb = time.time() #time of begining
if len(datarefs)==0 and 'DE' not in path: return if len(datarefs)==0 and 'DE' not in path: return
page = 0 page = 0
while(True): while(True):
@ -455,9 +465,9 @@ class ECU:
newScreen = newScreen + pyren_encode( l ) + ' \n' newScreen = newScreen + pyren_encode( l ) + ' \n'
if pages>0: if pages>0:
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] Press page number to switch 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: else:
newScreen = newScreen+'\n'+"Press any key to exit" newScreen = newScreen+'\n'+"Press H for help or any key to exit"
print newScreen, print newScreen,
sys.stdout.flush () sys.stdout.flush ()
@ -479,6 +489,9 @@ class ECU:
page = n-1 page = n-1
clearScreen() clearScreen()
continue continue
if c in ['h','H']:
show_doc(self.ecudata['dst'], IDstr)
continue
if mod_globals.opt_csv and (c in mod_globals.opt_usrkey): if mod_globals.opt_csv and (c in mod_globals.opt_usrkey):
csvline += ";" + c csvline += ";" + c
continue continue
@ -579,7 +592,7 @@ class ECU:
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n' path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path) self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
def show_defaults_std_b(self): def show_defaults_std_b(self):
while(1): while(1):

View File

@ -39,13 +39,16 @@ currentDDTscreen = None
ext_cur_DTC = "000000" ext_cur_DTC = "000000"
none_val = 'None' none_val = "None"
mtcdir = '../MTCSAVE/VIN' mtcdir = "../MTCSAVE/VIN"
ddtroot = '..' # parent folder for backward compatibility. for 9n and up use ../DDT2000data ddtroot = ".." # parent folder for backward compatibility. for 9n and up use ../DDT2000data
os = "" os = ""
language_dict = {} language_dict = {}
vin = ""
doc_server_proc = None

View File

@ -14,7 +14,14 @@ GNU General Public License for more details.
import sys import sys
import os import os
import signal
import atexit
import subprocess
import mod_globals import mod_globals
try:
import webbrowser
except:
pass
# Snippet from http://home.wlu.edu/~levys/software/kbhit.py # Snippet from http://home.wlu.edu/~levys/software/kbhit.py
@ -25,9 +32,9 @@ if os.name == 'nt':
# Posix (Linux, OS X) # Posix (Linux, OS X)
else: else:
import termios import termios
import atexit #import atexit
from select import select from select import select
from decimal import * #from decimal import *
class KBHit: class KBHit:
@ -379,14 +386,16 @@ def chkDirTree():
os.makedirs('./dumps') os.makedirs('./dumps')
if not os.path.exists('./macro'): if not os.path.exists('./macro'):
os.makedirs('./macro') os.makedirs('./macro')
if not os.path.exists('./doc'):
os.makedirs('./doc')
def getVIN( de, elm ): def getVIN( de, elm, getFirst = False ):
''' getting VINs from every ECU ''' ''' getting VINs from every ECU '''
''' de - list of detected ECUs ''' ''' de - list of detected ECUs '''
''' elm - reference to ELM class ''' ''' elm - reference to ELM class '''
m_vin = {} m_vin = set([])
for e in de: for e in de:
# init elm # init elm
@ -406,19 +415,21 @@ def getVIN( de, elm ):
rsp = elm.request( req = '22F190', positive = '62', cache = False )[9:59] rsp = elm.request( req = '22F190', positive = '62', cache = False )[9:59]
else: else:
rsp = elm.request( req = '2181', positive = '61', cache = False )[6:56] rsp = elm.request( req = '2181', positive = '61', cache = False )[6:56]
try: try:
vin = rsp.replace(' ','').decode('HEX') vin = rsp.replace(' ','').decode('HEX')
except: except:
continue continue
#debug #debug
print e['dst'],' : ', vin #print e['dst'],' : ', vin
if len(vin)==17: if len(vin)==17:
m_vin[vin] = '' m_vin.add(vin)
if getFirst:
return vin
l_vin = m_vin.keys() l_vin = m_vin
if os.path.exists('savedVIN.txt'): if os.path.exists('savedVIN.txt'):
with open('savedVIN.txt') as vinfile: with open('savedVIN.txt') as vinfile:
@ -427,14 +438,14 @@ def getVIN( de, elm ):
l = l.strip() l = l.strip()
if '#' in l: continue if '#' in l: continue
if len(l)==17: if len(l)==17:
l_vin.append(l.upper()) l_vin.add(l.upper())
if len(l_vin)==0: if len(l_vin)==0 and not getFirst:
print "ERROR!!! Can't find any VIN. Check connection" print "ERROR!!! Can't find any VIN. Check connection"
exit() exit()
if len(l_vin)<2: if len(l_vin)<2:
return l_vin[0] return next(iter(l_vin))
print "\nFound ",len(l_vin), " VINs\n" print "\nFound ",len(l_vin), " VINs\n"
@ -446,3 +457,24 @@ def DBG( tag, s ):
if mod_globals.opt_debug and mod_globals.debug_file!=None: if mod_globals.opt_debug and mod_globals.debug_file!=None:
mod_globals.debug_file.write( '### ' + tag + '\n') mod_globals.debug_file.write( '### ' + tag + '\n')
mod_globals.debug_file.write( '"' + s + '"\n') mod_globals.debug_file.write( '"' + s + '"\n')
def kill_server():
if mod_globals.doc_server_proc is None:
pass
else:
os.kill(mod_globals.doc_server_proc.pid, signal.SIGTERM)
def show_doc( addr, id ):
if mod_globals.vin == '':
return
if mod_globals.doc_server_proc == None:
mod_globals.doc_server_proc = subprocess.Popen(["python", "-m", "SimpleHTTPServer", "59152"])
atexit.register(kill_server)
url = 'http://localhost:59152/doc/'+mod_globals.vin+'.htm'+id
webbrowser.open(url, new=0)

View File

@ -247,8 +247,8 @@ def main():
print 'Loading ECUs list' print 'Loading ECUs list'
se = ScanEcus(elm) #Prepare list of all ecus se = ScanEcus(elm) #Prepare list of all ecus
SEFname = "savedEcus.p" SEFname = "savedEcus.p"
if mod_globals.opt_can2: if mod_globals.opt_can2:
SEFname = "savedEcus2.p" SEFname = "savedEcus2.p"
@ -272,7 +272,8 @@ def main():
# Do this check every time # Do this check every time
se.scanAllEcus() #First scan of all ecus se.scanAllEcus() #First scan of all ecus
mod_globals.vin = getVIN(se.detectedEcus, elm, getFirst=True)
print "Loading language " print "Loading language "
sys.stdout.flush() sys.stdout.flush()
#loading language data #loading language data