9q fix#2
This commit is contained in:
parent
9de92967fc
commit
e2f3715bbb
@ -67,7 +67,7 @@ def prepareECU():
|
|||||||
print "Loading language "
|
print "Loading language "
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
#loading language data
|
#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
|
mod_globals.language_dict = lang.dict
|
||||||
print "Done"
|
print "Done"
|
||||||
|
|
||||||
|
@ -87,22 +87,8 @@ td.row_d {
|
|||||||
mod_globals.os = os.name
|
mod_globals.os = os.name
|
||||||
|
|
||||||
if mod_globals.os == 'nt':
|
if mod_globals.os == 'nt':
|
||||||
import pip
|
import serial
|
||||||
|
import colorama
|
||||||
try:
|
|
||||||
import serial
|
|
||||||
except ImportError:
|
|
||||||
pip.main(['install','pyserial'])
|
|
||||||
|
|
||||||
try:
|
|
||||||
import colorama
|
|
||||||
except ImportError:
|
|
||||||
pip.main(['install','colorama'])
|
|
||||||
try:
|
|
||||||
import colorama
|
|
||||||
except ImportError:
|
|
||||||
print "\n\n\n\t\t\tGive me access to the Internet for download modules\n\n\n"
|
|
||||||
sys.exit()
|
|
||||||
colorama.init()
|
colorama.init()
|
||||||
else:
|
else:
|
||||||
# let's try android
|
# let's try android
|
||||||
@ -771,7 +757,7 @@ def main():
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
#loading language data
|
#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
|
mod_globals.language_dict = lang.dict
|
||||||
print "Done"
|
print "Done"
|
||||||
|
|
||||||
|
@ -122,15 +122,22 @@ def get_file_list_from_clip( pattern ):
|
|||||||
if mod_globals.clip_arc=='':
|
if mod_globals.clip_arc=='':
|
||||||
return glob.glob(os.path.join(mod_globals.cliproot, pattern))
|
return glob.glob(os.path.join(mod_globals.cliproot, pattern))
|
||||||
else:
|
else:
|
||||||
|
if '*' in pattern:
|
||||||
|
pattern = pattern.replace('*', '\d{3}')
|
||||||
file_list = mod_globals.clip_arc.namelist()
|
file_list = mod_globals.clip_arc.namelist()
|
||||||
regex = re.compile(pattern)
|
regex = re.compile(pattern)
|
||||||
return list(filter(regex.search, file_list))
|
return list(filter(regex.search, file_list))
|
||||||
|
|
||||||
def get_file_from_clip( filename ):
|
def get_file_from_clip( filename ):
|
||||||
if mod_globals.clip_arc=='':
|
if filename.lower().endswith('bqm') or '/sg' in filename.lower():
|
||||||
return open(os.path.join(mod_globals.cliproot, filename), 'r')
|
mode = 'rb'
|
||||||
else:
|
else:
|
||||||
return mod_globals.clip_arc.open(filename, 'r')
|
mode = 'r'
|
||||||
|
|
||||||
|
if mod_globals.clip_arc=='':
|
||||||
|
return open(os.path.join(mod_globals.cliproot, filename), mode)
|
||||||
|
else:
|
||||||
|
return mod_globals.clip_arc.open(filename, mode)
|
||||||
|
|
||||||
def file_in_clip( pattern ):
|
def file_in_clip( pattern ):
|
||||||
if mod_globals.clip_arc=='':
|
if mod_globals.clip_arc=='':
|
||||||
|
@ -53,7 +53,7 @@ class class_dfg:
|
|||||||
|
|
||||||
#find TCOM by platform
|
#find TCOM by platform
|
||||||
if platform!='':
|
if platform!='':
|
||||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_*.[Xx]ml')
|
||||||
for file in file_list:
|
for file in file_list:
|
||||||
try:
|
try:
|
||||||
model_n = int(file[17:20])
|
model_n = int(file[17:20])
|
||||||
@ -71,7 +71,7 @@ class class_dfg:
|
|||||||
self.dfgFile = 'Vehicles/DFG/DFG_'+self.tcom+'.xml'
|
self.dfgFile = 'Vehicles/DFG/DFG_'+self.tcom+'.xml'
|
||||||
else:
|
else:
|
||||||
vhcls = []
|
vhcls = []
|
||||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/DFG/DFG_\d{3}.[Xx]ml')
|
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/DFG/DFG_*.[Xx]ml')
|
||||||
for file in file_list:
|
for file in file_list:
|
||||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||||
vh = DOMTree.documentElement
|
vh = DOMTree.documentElement
|
||||||
|
@ -972,8 +972,9 @@ def main():
|
|||||||
|
|
||||||
print "Loading optimyzer"
|
print "Loading optimyzer"
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
opt_file = optfile(mod_db_manager.get_file_from_clip(sgfile))
|
#opt_file = optfile(mod_db_manager.get_file_from_clip(sgfile))
|
||||||
|
opt_file = optfile(sgfile)
|
||||||
|
|
||||||
print "Loading defaults"
|
print "Loading defaults"
|
||||||
df_class = ecu_defaults ( Defaults, mdoc, opt_file.dict, lang.dict )
|
df_class = ecu_defaults ( Defaults, mdoc, opt_file.dict, lang.dict )
|
||||||
print "Loading parameters"
|
print "Loading parameters"
|
||||||
|
@ -35,28 +35,29 @@ class optfile:
|
|||||||
return
|
return
|
||||||
|
|
||||||
lf = mod_db_manager.get_file_from_clip( filename )
|
lf = mod_db_manager.get_file_from_clip( filename )
|
||||||
|
|
||||||
if lf:
|
if lf:
|
||||||
self.get_dict( lf, progress )
|
self.get_dict( lf, progress )
|
||||||
if cache:
|
if cache:
|
||||||
pickle.dump( self.dict, open( cachename, "wb" ) )
|
pickle.dump( self.dict, open( cachename, "wb" ) )
|
||||||
|
|
||||||
def get_string(self,lf,len):
|
def get_string(self, lf, len):
|
||||||
|
|
||||||
i = lf.tell()
|
i = lf.tell()
|
||||||
bytes = lf.read(2*len)
|
bytes = lf.read(2 * len)
|
||||||
|
|
||||||
st = ''
|
st = ''
|
||||||
j = 0
|
j = 0
|
||||||
len = len*2
|
len = len * 2
|
||||||
while j<len:
|
while j < len:
|
||||||
x = struct.unpack('<H', bytes[j:j+2])[0]
|
x = struct.unpack('<H', bytes[j:j + 2])[0]
|
||||||
if self.obf: x=x^(i&0xFFFF)^0x5555
|
if self.obf: x = x ^ (i & 0xFFFF) ^ 0x5555
|
||||||
j += 2
|
j += 2
|
||||||
i += 2
|
i += 2
|
||||||
st += unichr(x)
|
st += unichr(x)
|
||||||
|
|
||||||
return st
|
return st
|
||||||
|
|
||||||
def get_2_bytes(self,lf):
|
def get_2_bytes(self,lf):
|
||||||
|
|
||||||
i = lf.tell()
|
i = lf.tell()
|
||||||
@ -101,9 +102,9 @@ class optfile:
|
|||||||
strl = self.get_4_bytes(lf)
|
strl = self.get_4_bytes(lf)
|
||||||
keyl = self.get_4_bytes(lf)
|
keyl = self.get_4_bytes(lf)
|
||||||
n = n + 1
|
n = n + 1
|
||||||
|
|
||||||
key = self.get_string(lf,keyl)
|
key = self.get_string(lf,keyl)
|
||||||
|
|
||||||
lf.seek(addr)
|
lf.seek(addr)
|
||||||
line = self.get_string(lf,strl)
|
line = self.get_string(lf,strl)
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -74,7 +74,7 @@ class ScanEcus:
|
|||||||
####### Get list car models from vehicles directory #######
|
####### Get list car models from vehicles directory #######
|
||||||
self.vhcls = []
|
self.vhcls = []
|
||||||
|
|
||||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_*.[Xx]ml')
|
||||||
for file in file_list:
|
for file in file_list:
|
||||||
try:
|
try:
|
||||||
model_n = int(file[-7:-4])
|
model_n = int(file[-7:-4])
|
||||||
@ -976,7 +976,7 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
ecuvhc = {}
|
ecuvhc = {}
|
||||||
vehicle = ''
|
vehicle = ''
|
||||||
print 'Read models'
|
print 'Read models'
|
||||||
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_\d{3}.[Xx]ml')
|
file_list = mod_db_manager.get_file_list_from_clip('Vehicles/TCOM_*.[Xx]ml')
|
||||||
for file in file_list:
|
for file in file_list:
|
||||||
vehicle = ''
|
vehicle = ''
|
||||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||||
|
@ -12,7 +12,7 @@ import pickle
|
|||||||
|
|
||||||
if mod_globals.os == 'nt':
|
if mod_globals.os == 'nt':
|
||||||
import pip
|
import pip
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import serial
|
import serial
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user