From 848b2ebe1ee161aaabf92787d2f6f03defe5e21a Mon Sep 17 00:00:00 2001 From: shrlnm Date: Wed, 24 Aug 2022 21:02:50 +0300 Subject: [PATCH] fix acf and ddt --- pyren3/mod_ddt_ecu.py | 12 +++++++----- pyren3/mod_mtc.py | 13 ++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) mode change 100755 => 100644 pyren3/mod_ddt_ecu.py mode change 100755 => 100644 pyren3/mod_mtc.py diff --git a/pyren3/mod_ddt_ecu.py b/pyren3/mod_ddt_ecu.py old mode 100755 new mode 100644 index 0090c18..80c5cbe --- a/pyren3/mod_ddt_ecu.py +++ b/pyren3/mod_ddt_ecu.py @@ -96,8 +96,6 @@ class DDTECU(): self.Multipoint = '1' def __del__(self): - #debug - #print 'DDTECU __del__' try: del(self.elm) del(self.cecu) @@ -116,6 +114,7 @@ class DDTECU(): del(self.rotaryResultsQueue) del(self.elmAccess) except: + print('Exception in DDTECU __del__') pass def initRotary(self): @@ -259,6 +258,9 @@ class DDTECU(): print("Getting ID from 22xx") self.clearELMcache () + rule = 'replace' + #rule = 'ignore' may be a bit better in some cases + #DiagVersion F1A0 IdRsp_F1A0 = self.elm.request( req = '22F1A0', positive = '62', cache = False ) 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 ) if len(IdRsp_F18A)>8 and 'NR' not in IdRsp_F18A: Supplier = trim(IdRsp_F18A[9:].replace(' ','')) - Supplier = bytes.fromhex(Supplier).decode('utf-8') + Supplier = bytes.fromhex(Supplier).decode('utf-8',rule) #Soft F194 IdRsp_F194 = self.elm.request( req = '22F194', positive = '62', cache = False ) if len(IdRsp_F194)>8 and 'NR' not in IdRsp_F194: Soft = trim(IdRsp_F194[9:].replace(' ','')) - Soft = bytes.fromhex(Soft).decode('utf-8') + Soft = bytes.fromhex(Soft).decode('utf-8',rule) #Version F195 IdRsp_F195 = self.elm.request( req = '22F195', positive = '62', cache = False ) if len(IdRsp_F195)>8 and 'NR' not in IdRsp_F195: 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 diff --git a/pyren3/mod_mtc.py b/pyren3/mod_mtc.py old mode 100755 new mode 100644 index 0bd9db8..0f19e7f --- a/pyren3/mod_mtc.py +++ b/pyren3/mod_mtc.py @@ -13,15 +13,15 @@ from mod_utils import Choice def acf_saveMTCtoFile( folder, vindata, mtcdata, refdata, platform ): f = open( folder+'/vindata.txt', 'wt' ) - f.write(vindata) + f.write(str(vindata)) f.close() f = open( folder+'/refdata.txt', 'wt' ) - f.write(refdata) + f.write(str(refdata)) f.close() f = open( folder+'/platform.txt', 'wt' ) - f.write(platform) + f.write(str(platform)) f.close() f = open( folder+'/mtcdata.txt', 'wt' ) @@ -179,8 +179,8 @@ def acf_getMTC( VIN, preferFile=False ): zf=zip.open(i) vin3list=zf.read() zf.close() - for l in vin3list.split('\n'): - if l.startswith(VIN3): + for l in vin3list.split(b'\n'): + if l.startswith(VIN3.encode('utf-8')): vindata = l break if vindata!='': break @@ -191,6 +191,9 @@ def acf_getMTC( VIN, preferFile=False ): break if vindata!='': break + if type(vindata) == bytes: + vindata = vindata.decode("utf-8") + if vindata=='' or vindir=='': print("\n\nVIN has not found in databse\n\n") exit()