From d76a0a6cdf92950aabdb5387c464059d767155cb Mon Sep 17 00:00:00 2001 From: shrlnm Date: Sun, 9 Apr 2023 21:00:34 +0300 Subject: [PATCH] fix some issues --- pyren3/acf.py | 15 ++++++++++++--- pyren3/mod_acf_proc.py | 19 +++++++++++-------- pyren3/mod_ddt_ecu.py | 8 ++++---- pyren3/mod_ddt_screen.py | 39 +++++++++++++++++++++++++++++++++++++-- pyren3/mod_elm.py | 3 ++- pyren3/mod_globals.py | 2 ++ pyren3/pyren3.py | 4 ++-- pyren3/soh.py | 38 +++++++++++++++++++------------------- 8 files changed, 89 insertions(+), 39 deletions(-) mode change 100755 => 100644 pyren3/mod_globals.py diff --git a/pyren3/acf.py b/pyren3/acf.py index 1093d7b..90309c5 100755 --- a/pyren3/acf.py +++ b/pyren3/acf.py @@ -105,6 +105,12 @@ def optParser(): default=False, action="store_true") + parser.add_argument("--exp", + help="Explore options", + dest="exp", + default=False, + action="store_true") + parser.add_argument("--vin", help="vin number", dest="vinnum", @@ -160,6 +166,7 @@ def optParser(): mod_globals.opt_verbose2 = options.verbose2 mod_globals.opt_ref = options.ref mod_globals.opt_mtc = options.mtc + mod_globals.opt_exp = options.exp if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10': mod_globals.opt_dev = False @@ -305,9 +312,11 @@ def main(): else: print("%2s : %s : " % (m['idf'],m['sref'])) - #for option in mtc: - # acf_MTC_optionsExplorer( de, option ) - + if mod_globals.opt_exp: + for option in sorted(mtc): + res = acf_MTC_optionsExplorer( module_list, option, mtc ) + for l in res: + print( l ) if __name__ == '__main__': main() diff --git a/pyren3/mod_acf_proc.py b/pyren3/mod_acf_proc.py index 6713688..ea78e1a 100644 --- a/pyren3/mod_acf_proc.py +++ b/pyren3/mod_acf_proc.py @@ -230,7 +230,7 @@ def acf_MTC_findDiff( m, mtc, elm ): #acf_form_commands( m, cu, op ) break -def acf_MTC_optinInfluence( m, option ): +def acf_MTC_optinInfluence( m, option, allmtc ): ''' m - module definition map ''' ''' option - option name from MTC list ''' ''' this function finds dependent parameters in one module''' @@ -260,7 +260,7 @@ def acf_MTC_optinInfluence( m, option ): #check every mtc for op in cu.opts: if option not in op.MTC: continue - res = acf_MTC_compare(op.MTC, option) + res = acf_MTC_compare(op.MTC, allmtc) if res: tmpMTC = op.MTC.split() if op.MTC.startswith('SAUF'): continue @@ -271,22 +271,25 @@ def acf_MTC_optinInfluence( m, option ): return out -def acf_MTC_optionsExplorer( de, option ): +def acf_MTC_optionsExplorer( de, option, allmtc ): ''' de - list of all ecus ''' ''' option - option name from MTC list ''' ''' this function finds dependent parameters in every module''' - print('################### ', '%-10s'%(option), ' #########################') + res = [] + + res.append(f'################### {option:10} #########################') for m in de: if 'sref' not in list(m.keys()) or m['sref']=='': continue if 'sref' in list(m.keys()): if 'mo' in list(m.keys()) and m['mo']!='': - out = acf_MTC_optinInfluence( m, option ) + out = acf_MTC_optinInfluence( m, option, allmtc ) if len(out)>0: - print('-'*30," Family : ",m['idf'], ' : ', m['fam_txt']) - print(out) - + res.append(f"--------------------- Family : {m['idf']} : {m['fam_txt']}") + res.append(out) + + return res diff --git a/pyren3/mod_ddt_ecu.py b/pyren3/mod_ddt_ecu.py index 4795913..241b744 100644 --- a/pyren3/mod_ddt_ecu.py +++ b/pyren3/mod_ddt_ecu.py @@ -1197,10 +1197,10 @@ def AutoIdents_distance( DiagVersion, Supplier, Soft, Version, ai ): #catch not hex supplier with len 6 pass - d = distance( DiagVersion, ai['DiagVersion']) * 0.25 - d = d + distance( Supplier, ai['Supplier']) * 0.25 - d = d + distance( Soft, ai['Soft']) * 0.25 - d = d + distance( Version, ai['Version']) * 0.25 + d = distance( DiagVersion, ai['DiagVersion']) * 0.35 + d = d + distance( Supplier, ai['Supplier']) * 0.35 + d = d + distance( Soft, ai['Soft']) * 0.15 + d = d + distance( Version, ai['Version']) * 0.15 return round( d, 4 ) diff --git a/pyren3/mod_ddt_screen.py b/pyren3/mod_ddt_screen.py index acd1a9b..da277ac 100644 --- a/pyren3/mod_ddt_screen.py +++ b/pyren3/mod_ddt_screen.py @@ -126,6 +126,7 @@ class FindDialog (tkinter.simpledialog.Dialog): def __init__(self, parent, ecu ): self.ecu = ecu + self.choise = '' self.top = tk.Toplevel (parent) self.top.title ('Find Dialog') @@ -1083,6 +1084,12 @@ class DDTScreen (tk.Frame): self.root.wait_window (dialog.top) def find(self): + + restart = False + if self.start: + self.startStop() + restart = True + scr_name = FindDialog(self.root, self.decu ).show() if '@' in scr_name: key = scr_name.split('@')[0] @@ -1090,6 +1097,10 @@ class DDTScreen (tk.Frame): #self.loadSyntheticScreen (self.Screens[key]) #else: self.loadScreen (self.Screens[key]) + + if restart: + self.startStop() + return def torqpids(self): @@ -1417,6 +1428,19 @@ class DDTScreen (tk.Frame): self.loadSyntheticScreen(scr) return + #debug + #deb_time1 = time.time() + #print( "#"*50 ) + + # stop ratary. Do not read ELM + restart = False + if self.start: + self.startStop() + restart = True + + #debug + #print( f"DEBUG POINT1: {time.time()-deb_time1}") + ns = {'ns0': 'http://www-diag.renault.com/2002/ECU', 'ns1': 'http://www-diag.renault.com/2002/screens'} @@ -1446,7 +1470,6 @@ class DDTScreen (tk.Frame): max_y = h # print xrLeft, xrTop, xrHeight, xrWidth - deb_time1 = time.time() # main frame re-create self.ddt.delete ('all') self.ddt.update_idletasks () @@ -1855,6 +1878,9 @@ class DDTScreen (tk.Frame): # clear elm cache self.decu.clearELMcache () + if restart: + self.startStop() + # request to update dInputs self.update_dInputs () @@ -1874,9 +1900,14 @@ class DDTScreen (tk.Frame): if len (self.sReq_lst): self.startScreen () - def loadSyntheticScreen(self, rq): + # stop ratary. Do not read ELM + restart = False + if self.start: + self.startStop() + restart = True + read_cmd = self.decu.requests[rq].SentBytes if read_cmd[:2]=='21': read_cmd = read_cmd[:4] @@ -2035,6 +2066,10 @@ class DDTScreen (tk.Frame): # clear elm cache self.decu.clearELMcache () + # restart if need + if restart: + self.startStop() + # request to update dInputs self.update_dInputs () diff --git a/pyren3/mod_elm.py b/pyren3/mod_elm.py index 7e26c63..fcc2865 100644 --- a/pyren3/mod_elm.py +++ b/pyren3/mod_elm.py @@ -330,7 +330,7 @@ class Port: print('*' * 40) print('* Connection to ELM was lost') mod_globals.opt_demo = True - + if type(byte) == str: byte = byte.encode() @@ -485,6 +485,7 @@ class Port: self.hdr.timeout = 1 self.hdr.baudrate = boudrate + time.sleep (0.1) self.write ("\r") # search > diff --git a/pyren3/mod_globals.py b/pyren3/mod_globals.py old mode 100755 new mode 100644 index 911f8f8..1ba5324 --- a/pyren3/mod_globals.py +++ b/pyren3/mod_globals.py @@ -36,6 +36,8 @@ opt_stn = False #STN(PIC24) ELM327 which has ability to automatically s opt_sd = False #separate doc files opt_performance = False opt_minordtc = False +opt_ref = "" #alternative ref set for acf +opt_mtc = "" #alternative mtc set for acf dumpName = "" state_scan = False diff --git a/pyren3/pyren3.py b/pyren3/pyren3.py index 9bf46e9..3777a6f 100755 --- a/pyren3/pyren3.py +++ b/pyren3/pyren3.py @@ -78,12 +78,12 @@ def optParser(): default="") parser.add_argument("-s", - help="com port speed configured on ELM {38400[default],57600,115200,230400,500000} DEPRECATED", + help="com port speed configured on ELM {38400[default],115200,230400,500000} DEPRECATED", dest="speed", default="38400") parser.add_argument("-r", - help="com port rate during diagnostic session {38400[default],57600,115200,230400,500000}", + help="com port rate during diagnostic session {38400[default],115200,230400,500000}", dest="rate", default="38400",) diff --git a/pyren3/soh.py b/pyren3/soh.py index 9bea417..6e1d615 100755 --- a/pyren3/soh.py +++ b/pyren3/soh.py @@ -477,8 +477,8 @@ class tl: y1 = float(line['volt'][i*2+1]) self.CV.create_line(tx + x0 * xm, ty + (ymax - y0) * ym, tx + x1 * xm, ty + (ymax - y1) * ym, width=1, fill=f ) - if hist: - return + #if hist: + # return self.findPoints( line ) @@ -498,6 +498,13 @@ class tl: except: Tc = int(line['temp']) + # average interval among points + interval = (line['volt'][-2] - line['volt'][0]) / len(line['volt']) * 2 + + #points in 50ms (take in to account only odds) + # 50ms radius of zone for local min/max + radius = int(.1 / interval ) * 2 + 1 + self.T0 = line['volt'][0] u = 2 mean = 0 @@ -509,29 +516,21 @@ class tl: self.V0 = mean // count # find first min - min = line['volt'][u-1] - while line['volt'][u+1]-min < 0.25 and umax: - max = line['volt'][u+1] + while line['volt'][u+1]min(list(line['volt'][u-1:u+radius:2])) and u