fix acf and ddt

This commit is contained in:
shrlnm 2022-08-24 21:02:50 +03:00
parent ae788e6b92
commit 848b2ebe1e
2 changed files with 15 additions and 10 deletions

12
pyren3/mod_ddt_ecu.py Executable file → Normal file
View File

@ -96,8 +96,6 @@ class DDTECU():
self.Multipoint = '1' self.Multipoint = '1'
def __del__(self): def __del__(self):
#debug
#print 'DDTECU __del__'
try: try:
del(self.elm) del(self.elm)
del(self.cecu) del(self.cecu)
@ -116,6 +114,7 @@ class DDTECU():
del(self.rotaryResultsQueue) del(self.rotaryResultsQueue)
del(self.elmAccess) del(self.elmAccess)
except: except:
print('Exception in DDTECU __del__')
pass pass
def initRotary(self): def initRotary(self):
@ -259,6 +258,9 @@ class DDTECU():
print("Getting ID from 22xx") print("Getting ID from 22xx")
self.clearELMcache () self.clearELMcache ()
rule = 'replace'
#rule = 'ignore' may be a bit better in some cases
#DiagVersion F1A0 #DiagVersion F1A0
IdRsp_F1A0 = self.elm.request( req = '22F1A0', positive = '62', cache = False ) IdRsp_F1A0 = self.elm.request( req = '22F1A0', positive = '62', cache = False )
if len(IdRsp_F1A0)>8 and 'NR' not in IdRsp_F1A0: if len(IdRsp_F1A0)>8 and 'NR' not in IdRsp_F1A0:
@ -269,19 +271,19 @@ class DDTECU():
IdRsp_F18A = self.elm.request( req = '22F18A', positive = '62', cache = False ) IdRsp_F18A = self.elm.request( req = '22F18A', positive = '62', cache = False )
if len(IdRsp_F18A)>8 and 'NR' not in IdRsp_F18A: if len(IdRsp_F18A)>8 and 'NR' not in IdRsp_F18A:
Supplier = trim(IdRsp_F18A[9:].replace(' ','')) Supplier = trim(IdRsp_F18A[9:].replace(' ',''))
Supplier = bytes.fromhex(Supplier).decode('utf-8') Supplier = bytes.fromhex(Supplier).decode('utf-8',rule)
#Soft F194 #Soft F194
IdRsp_F194 = self.elm.request( req = '22F194', positive = '62', cache = False ) IdRsp_F194 = self.elm.request( req = '22F194', positive = '62', cache = False )
if len(IdRsp_F194)>8 and 'NR' not in IdRsp_F194: if len(IdRsp_F194)>8 and 'NR' not in IdRsp_F194:
Soft = trim(IdRsp_F194[9:].replace(' ','')) Soft = trim(IdRsp_F194[9:].replace(' ',''))
Soft = bytes.fromhex(Soft).decode('utf-8') Soft = bytes.fromhex(Soft).decode('utf-8',rule)
#Version F195 #Version F195
IdRsp_F195 = self.elm.request( req = '22F195', positive = '62', cache = False ) IdRsp_F195 = self.elm.request( req = '22F195', positive = '62', cache = False )
if len(IdRsp_F195)>8 and 'NR' not in IdRsp_F195: if len(IdRsp_F195)>8 and 'NR' not in IdRsp_F195:
Version = trim(IdRsp_F195[9:].replace(' ','')) Version = trim(IdRsp_F195[9:].replace(' ',''))
Version = bytes.fromhex(Version).decode('utf-8','replace') Version = bytes.fromhex(Version).decode('utf-8',rule)
hash = Address+DiagVersion+Supplier+Soft+Version hash = Address+DiagVersion+Supplier+Soft+Version

13
pyren3/mod_mtc.py Executable file → Normal file
View File

@ -13,15 +13,15 @@ from mod_utils import Choice
def acf_saveMTCtoFile( folder, vindata, mtcdata, refdata, platform ): def acf_saveMTCtoFile( folder, vindata, mtcdata, refdata, platform ):
f = open( folder+'/vindata.txt', 'wt' ) f = open( folder+'/vindata.txt', 'wt' )
f.write(vindata) f.write(str(vindata))
f.close() f.close()
f = open( folder+'/refdata.txt', 'wt' ) f = open( folder+'/refdata.txt', 'wt' )
f.write(refdata) f.write(str(refdata))
f.close() f.close()
f = open( folder+'/platform.txt', 'wt' ) f = open( folder+'/platform.txt', 'wt' )
f.write(platform) f.write(str(platform))
f.close() f.close()
f = open( folder+'/mtcdata.txt', 'wt' ) f = open( folder+'/mtcdata.txt', 'wt' )
@ -179,8 +179,8 @@ def acf_getMTC( VIN, preferFile=False ):
zf=zip.open(i) zf=zip.open(i)
vin3list=zf.read() vin3list=zf.read()
zf.close() zf.close()
for l in vin3list.split('\n'): for l in vin3list.split(b'\n'):
if l.startswith(VIN3): if l.startswith(VIN3.encode('utf-8')):
vindata = l vindata = l
break break
if vindata!='': break if vindata!='': break
@ -191,6 +191,9 @@ def acf_getMTC( VIN, preferFile=False ):
break break
if vindata!='': break if vindata!='': break
if type(vindata) == bytes:
vindata = vindata.decode("utf-8")
if vindata=='' or vindir=='': if vindata=='' or vindir=='':
print("\n\nVIN has not found in databse\n\n") print("\n\nVIN has not found in databse\n\n")
exit() exit()