acf insert addr and sesion based on TCOMs
This commit is contained in:
parent
82d4a0a19a
commit
951742363a
@ -6,6 +6,7 @@ import mod_db_manager
|
|||||||
import mod_utils
|
import mod_utils
|
||||||
from mod_optfile import *
|
from mod_optfile import *
|
||||||
from mod_scan_ecus import families as families
|
from mod_scan_ecus import families as families
|
||||||
|
from mod_scan_ecus import findTCOM as findTCOM
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ def main():
|
|||||||
mod_utils.chkDirTree()
|
mod_utils.chkDirTree()
|
||||||
mod_db_manager.find_DBs()
|
mod_db_manager.find_DBs()
|
||||||
|
|
||||||
'''Check direcories'''
|
'''Check directories'''
|
||||||
if not os.path.exists('../BVMEXTRACTION'):
|
if not os.path.exists('../BVMEXTRACTION'):
|
||||||
print("Can't find MTC database. (../BVMEXTRACTION)")
|
print("Can't find MTC database. (../BVMEXTRACTION)")
|
||||||
exit()
|
exit()
|
||||||
@ -214,8 +215,6 @@ def main():
|
|||||||
if mod_globals.opt_speed<mod_globals.opt_rate and not mod_globals.opt_demo:
|
if mod_globals.opt_speed<mod_globals.opt_rate and not mod_globals.opt_demo:
|
||||||
elm.port.soft_boudrate( mod_globals.opt_rate )
|
elm.port.soft_boudrate( mod_globals.opt_rate )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print("Loading language ")
|
print("Loading language ")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
#loading language data
|
#loading language data
|
||||||
@ -230,6 +229,13 @@ def main():
|
|||||||
if mod_globals.opt_can2:
|
if mod_globals.opt_can2:
|
||||||
SEFname = "savedEcus2.p"
|
SEFname = "savedEcus2.p"
|
||||||
|
|
||||||
|
pl_id_cache = './cache/pl_id_attr.p'
|
||||||
|
if os.path.isfile(pl_id_cache): #if cache exists
|
||||||
|
pl_id = pickle.load( open( pl_id_cache, "rb" ) ) #load it
|
||||||
|
else: #else
|
||||||
|
findTCOM('', '', '', True) #make cache
|
||||||
|
pl_id = pickle.load( open( pl_id_cache, "rb" ) ) #load it
|
||||||
|
|
||||||
if mod_globals.opt_demo and len(mod_globals.opt_ecuid)>0:
|
if mod_globals.opt_demo and len(mod_globals.opt_ecuid)>0:
|
||||||
# demo mode with predefined ecu list
|
# demo mode with predefined ecu list
|
||||||
se.read_Uces_file( all = True )
|
se.read_Uces_file( all = True )
|
||||||
@ -297,7 +303,10 @@ def main():
|
|||||||
if 'mo' in list(m.keys()) and m['mo']!='':
|
if 'mo' in list(m.keys()) and m['mo']!='':
|
||||||
print("%2s : %s : %s" % (m['idf'],m['sref'],m['mo'].NOM))
|
print("%2s : %s : %s" % (m['idf'],m['sref'],m['mo'].NOM))
|
||||||
|
|
||||||
acf_MTC_generateDefaults( m, mtc )
|
attr = []
|
||||||
|
if platform in pl_id.keys() and m['idf'] in pl_id[platform].keys():
|
||||||
|
attr = pl_id[platform][m['idf']]
|
||||||
|
acf_MTC_generateDefaults( m, mtc, attr )
|
||||||
#acf_MTC_findDiff( m, mtc, elm )
|
#acf_MTC_findDiff( m, mtc, elm )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -6,6 +6,7 @@ import time
|
|||||||
import mod_globals
|
import mod_globals
|
||||||
import mod_elm
|
import mod_elm
|
||||||
import shutil
|
import shutil
|
||||||
|
import pickle
|
||||||
|
|
||||||
from mod_mtc import acf_MTC_finde
|
from mod_mtc import acf_MTC_finde
|
||||||
from mod_mtc import acf_MTC_and
|
from mod_mtc import acf_MTC_and
|
||||||
@ -68,7 +69,7 @@ def acf_form_commands( m, cu, op ):
|
|||||||
m['acf_wc'][cu.RW] = acf_pack_command( True, ace.req[cu.RW], cu.DW, m['acf_wc'][cu.RW], op.TW, op.MW)
|
m['acf_wc'][cu.RW] = acf_pack_command( True, ace.req[cu.RW], cu.DW, m['acf_wc'][cu.RW], op.TW, op.MW)
|
||||||
ace.req[cu.RW].SentDI[cu.DW].val = op.VW + ' #[' + cu.TE + ' : ' + op.TEX + '](' + op.MTC + ')'
|
ace.req[cu.RW].SentDI[cu.DW].val = op.VW + ' #[' + cu.TE + ' : ' + op.TEX + '](' + op.MTC + ')'
|
||||||
|
|
||||||
def acf_MTC_generateDefaults( m, mtc ):
|
def acf_MTC_generateDefaults( m, mtc, attr ):
|
||||||
""" m - module definition map """
|
""" m - module definition map """
|
||||||
''' mtc - list of options '''
|
''' mtc - list of options '''
|
||||||
''' this function generates default values'''
|
''' this function generates default values'''
|
||||||
@ -136,14 +137,26 @@ def acf_MTC_generateDefaults( m, mtc ):
|
|||||||
sf = open(scriptn,'wt')
|
sf = open(scriptn,'wt')
|
||||||
|
|
||||||
#print "--------------- Write Commands --------------------"
|
#print "--------------- Write Commands --------------------"
|
||||||
|
attr = list(attr)
|
||||||
|
attr_dst = ''
|
||||||
|
attr_ses = ''
|
||||||
|
if len(attr)>0:
|
||||||
|
attr_dst, attr_ses = attr[0].split('#')
|
||||||
|
if len(attr)>1:
|
||||||
|
attr_dst = attr_dst + ' #'
|
||||||
|
attr_ses = attr_ses + ' #'
|
||||||
|
for a in attr[1:]:
|
||||||
|
dst,ses = a.split('#')
|
||||||
|
attr_dst = attr_dst + ' ' + dst
|
||||||
|
attr_ses = attr_ses + ' ' + ses
|
||||||
|
|
||||||
# write preamble
|
# write preamble
|
||||||
sf.write('# ' + mod_globals.vin + '\n\n')
|
sf.write('# ' + mod_globals.vin + '\n\n')
|
||||||
sf.write('$addr = ' + m['dst'] +'\n\n')
|
sf.write('$addr = ' + attr_dst +'\n\n')
|
||||||
sf.write('can500 # init can macro\n\n')
|
sf.write('can500 # init can macro\n\n')
|
||||||
sf.write('delay 1\n\n')
|
sf.write('delay 1\n\n')
|
||||||
sf.write('# open session\n')
|
sf.write('# open session\n')
|
||||||
sf.write('session ' + m['startDiagReq'] + '\n\n')
|
sf.write('session ' + attr_ses + '\n\n')
|
||||||
sf.write('# configuration\n')
|
sf.write('# configuration\n')
|
||||||
|
|
||||||
# save write commands
|
# save write commands
|
||||||
|
@ -68,14 +68,20 @@ def acf_buildFull( platf ):
|
|||||||
return
|
return
|
||||||
|
|
||||||
mtc = {}
|
mtc = {}
|
||||||
mtcf = open(plDIR+'/MTC.dat', 'rt')
|
mtc_name = 'MTC.dat'
|
||||||
|
for fn in os.listdir(plDIR):
|
||||||
|
if fn.upper()=='MTC.DAT': mtc_name = fn
|
||||||
|
mtcf = open(plDIR + '/' + mtc_name, 'rt')
|
||||||
mtc_list = csv.reader(mtcf, delimiter=';')
|
mtc_list = csv.reader(mtcf, delimiter=';')
|
||||||
for i in mtc_list:
|
for i in mtc_list:
|
||||||
if i:
|
if i:
|
||||||
mtc[int(i[0][:-4])] = i[1:]
|
mtc[int(i[0][:-4])] = i[1:]
|
||||||
|
|
||||||
ref = {}
|
ref = {}
|
||||||
reff = open(plDIR+'/REF.dat', 'rt')
|
ref_name = 'REF.dat'
|
||||||
|
for fn in os.listdir(plDIR):
|
||||||
|
if fn.upper()=='REF.DAT': ref_name = fn
|
||||||
|
reff = open(plDIR + '/' + ref_name, 'rt')
|
||||||
ref_list = csv.reader(reff, delimiter=';')
|
ref_list = csv.reader(reff, delimiter=';')
|
||||||
for i in ref_list:
|
for i in ref_list:
|
||||||
if i:
|
if i:
|
||||||
@ -205,7 +211,10 @@ def acf_getMTC( VIN, preferFile=False ):
|
|||||||
|
|
||||||
#check if there is an mtc file
|
#check if there is an mtc file
|
||||||
|
|
||||||
mz = open(vindir+'MTC.dat','r')
|
mtc_name = 'MTC.dat'
|
||||||
|
for fn in os.listdir(vindir):
|
||||||
|
if fn.upper()=='MTC.DAT': mtc_name = fn
|
||||||
|
mz = open(vindir+mtc_name,'r')
|
||||||
mtclist = mz.read().split('\n')
|
mtclist = mz.read().split('\n')
|
||||||
mz.close()
|
mz.close()
|
||||||
for l in mtclist:
|
for l in mtclist:
|
||||||
@ -213,7 +222,10 @@ def acf_getMTC( VIN, preferFile=False ):
|
|||||||
mtcdata = l
|
mtcdata = l
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rz = open(vindir+'REF.dat','r')
|
ref_name = 'REF.dat'
|
||||||
|
for fn in os.listdir(vindir):
|
||||||
|
if fn.upper()=='REF.DAT': ref_name = fn
|
||||||
|
rz = open(vindir+ref_name,'r')
|
||||||
reflist = rz.read().split('\n')
|
reflist = rz.read().split('\n')
|
||||||
rz.close()
|
rz.close()
|
||||||
for l in reflist:
|
for l in reflist:
|
||||||
|
@ -999,8 +999,9 @@ def readECUIds( elm ):
|
|||||||
return StartSession, DiagVersion, Supplier, Version, Soft, Std, VIN
|
return StartSession, DiagVersion, Supplier, Version, Soft, Std, VIN
|
||||||
|
|
||||||
|
|
||||||
def findTCOM( addr, cmd, rsp ):
|
def findTCOM( addr, cmd, rsp, pl_id = False ):
|
||||||
ecuvhc = {}
|
ecuvhc = {}
|
||||||
|
pl_id = {}
|
||||||
vehicle = ''
|
vehicle = ''
|
||||||
print('Read models')
|
print('Read models')
|
||||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_*.[Xx]ml')
|
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_*.[Xx]ml')
|
||||||
@ -1013,7 +1014,7 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
vehTypeCode = vh.getAttribute("vehTypeCode")
|
vehTypeCode = vh.getAttribute("vehTypeCode")
|
||||||
vehTCOM = vh.getAttribute("TCOM")
|
vehTCOM = vh.getAttribute("TCOM")
|
||||||
vehicle = vehiclename+'#'+vehTCOM;
|
vehicle = vehiclename+'#'+vehTCOM;
|
||||||
|
pl_id[vehTypeCode] = {}
|
||||||
#print vehicle
|
#print vehicle
|
||||||
|
|
||||||
connector = vh.getElementsByTagName("Connector")
|
connector = vh.getElementsByTagName("Connector")
|
||||||
@ -1024,9 +1025,13 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
if eculist:
|
if eculist:
|
||||||
ecukind = eculist.item(0).getElementsByTagName("EcuKind")
|
ecukind = eculist.item(0).getElementsByTagName("EcuKind")
|
||||||
for ek in ecukind:
|
for ek in ecukind:
|
||||||
|
id = ek.getAttribute("idFamily")
|
||||||
|
pl_id[vehTypeCode][id] = {}
|
||||||
|
pl_id[vehTypeCode][id]['refs'] = []
|
||||||
ecuref = ek.getElementsByTagName("EcuRef")
|
ecuref = ek.getElementsByTagName("EcuRef")
|
||||||
for er in ecuref:
|
for er in ecuref:
|
||||||
ecuname = er.getAttribute("name")
|
ecuname = er.getAttribute("name")
|
||||||
|
pl_id[vehTypeCode][id]['refs'].append(ecuname)
|
||||||
if ecuname in list(ecuvhc.keys()):
|
if ecuname in list(ecuvhc.keys()):
|
||||||
ecuvhc[ecuname].append(vehicle)
|
ecuvhc[ecuname].append(vehicle)
|
||||||
else:
|
else:
|
||||||
@ -1036,9 +1041,14 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
if eculist:
|
if eculist:
|
||||||
ecukind = eculist.item(0).getElementsByTagName("EcuKind")
|
ecukind = eculist.item(0).getElementsByTagName("EcuKind")
|
||||||
for ek in ecukind:
|
for ek in ecukind:
|
||||||
|
id = ek.getAttribute("idFamily")
|
||||||
|
if id not in pl_id[vehTypeCode].keys():
|
||||||
|
pl_id[vehTypeCode][id] = {}
|
||||||
|
pl_id[vehTypeCode][id]['refs'] = []
|
||||||
ecuref = ek.getElementsByTagName("EcuRef")
|
ecuref = ek.getElementsByTagName("EcuRef")
|
||||||
for er in ecuref:
|
for er in ecuref:
|
||||||
ecuname = er.getAttribute("name")
|
ecuname = er.getAttribute("name")
|
||||||
|
pl_id[vehTypeCode][id]['refs'].append(ecuname)
|
||||||
if ecuname in list(ecuvhc.keys()):
|
if ecuname in list(ecuvhc.keys()):
|
||||||
ecuvhc[ecuname].append(vehicle)
|
ecuvhc[ecuname].append(vehicle)
|
||||||
else:
|
else:
|
||||||
@ -1047,7 +1057,23 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
se = ScanEcus( None )
|
se = ScanEcus( None )
|
||||||
print('Loading Uces.xml')
|
print('Loading Uces.xml')
|
||||||
se.read_Uces_file(True)
|
se.read_Uces_file(True)
|
||||||
#print ecuvhc
|
|
||||||
|
if pl_id:
|
||||||
|
#save pl_id
|
||||||
|
for pl in pl_id.keys():
|
||||||
|
for id in pl_id[pl].keys():
|
||||||
|
attr = set()
|
||||||
|
for r in pl_id[pl][id]['refs']:
|
||||||
|
if r in se.allecus.keys():
|
||||||
|
#attr.add(se.allecus[r]['stdType']+"#"+se.allecus[r]['dst']+"#"+se.allecus[r]['startDiagReq'])
|
||||||
|
attr.add(se.allecus[r]['dst']+"#"+se.allecus[r]['startDiagReq'])
|
||||||
|
#else:
|
||||||
|
# print(r)
|
||||||
|
del pl_id[pl][id]['refs']
|
||||||
|
pl_id[pl][id] = attr
|
||||||
|
pickle.dump( pl_id, open( './cache/pl_id_attr.p', "wb" ) )
|
||||||
|
else:
|
||||||
|
#print found ecus
|
||||||
for r in list(se.allecus.keys()):
|
for r in list(se.allecus.keys()):
|
||||||
if se.allecus[r]['dst']!=addr: continue
|
if se.allecus[r]['dst']!=addr: continue
|
||||||
if se.allecus[r]['ids'][0]!=cmd: continue
|
if se.allecus[r]['ids'][0]!=cmd: continue
|
||||||
@ -1056,6 +1082,9 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
print(r, se.allecus[r]['doc'], se.allecus[r]['ids'], ecuvhc[r])
|
print(r, se.allecus[r]['doc'], se.allecus[r]['ids'], ecuvhc[r])
|
||||||
except:
|
except:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generateSavedEcus( eculist, fileName ):
|
def generateSavedEcus( eculist, fileName ):
|
||||||
se = ScanEcus( 0 )
|
se = ScanEcus( 0 )
|
||||||
se.read_Uces_file( all = True )
|
se.read_Uces_file( all = True )
|
||||||
@ -1078,6 +1107,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
mod_db_manager.find_DBs()
|
mod_db_manager.find_DBs()
|
||||||
|
|
||||||
|
#findTCOM( '', '', '', pl_id=True)
|
||||||
|
|
||||||
# 10016,10074 savedEcus.p_gen
|
# 10016,10074 savedEcus.p_gen
|
||||||
if len(sys.argv)==3: generateSavedEcus( sys.argv[1], sys.argv[2] )
|
if len(sys.argv)==3: generateSavedEcus( sys.argv[1], sys.argv[2] )
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user