Find dataId that is defined in the module file

When one or more undefined dataids in the snapshot response, try to find next dataId that is defined in the module file. When mnemonic request uses 21 service, do not use get_SnapShotMnemonic function. Disable perfomance mode, it needs to be integrated with the send_can_cfc method.
This commit is contained in:
Marianpol 2021-05-13 23:13:52 +02:00
parent 548e1b9795
commit 838520e001
5 changed files with 29 additions and 12 deletions

View File

@ -152,8 +152,7 @@ class ECU:
self.elm.start_session( self.ecudata['startDiagReq'] )
if mod_globals.os == 'android' or mod_globals.opt_csv:
if self.ecudata['pin'].lower()=='can' and self.DataIds:
mod_globals.opt_perform = True
if self.ecudata['pin'].lower()=='can' and self.DataIds and mod_globals.opt_perform:
self.elm.checkModulePerformaceLevel(self.DataIds)
print "Done"

View File

@ -64,7 +64,7 @@ def get_mnemonic( m, se, elm, raw = False ):
def get_SnapShotMnemonic(m, se, elm, dataids):
snapshotService = ""
byteLength = 3
byteLength = 3 #number of chars in one byte string (two chars with one whitespace)
dataIdByteLength = 2
for sid in se:
@ -81,24 +81,35 @@ def get_SnapShotMnemonic(m, se, elm, dataids):
numberOfIdentifiers = int("0x" + resp[7*byteLength:8*byteLength-1],16)
resp = resp[8*byteLength:]
didDict = {}
didDict = {} #dataIds with their corresponding data
numberOfPossibleDataId = 0 #number of unknown dataIds
posInResp = 0
dataIdLength = dataIdByteLength * byteLength
for x in range(numberOfIdentifiers):
for idNum in range(numberOfIdentifiers):
#break if unknown dataids number plus current number dataid number is larger than overall number of dataids in the response
if (idNum + numberOfPossibleDataId > numberOfIdentifiers):
break
dataId = resp[posInResp:posInResp + dataIdLength].replace(" ", "")
posInResp += dataIdLength
if dataId not in dataids.keys():
if dataId not in dataids.keys(): #unknown dataId in the snapShot response
bytePos = 1
restOfResp = resp[posInResp:]
while True:
while True: #try to find a next dataId that is defined in the module file
posInRestResp = bytePos*byteLength
#using '2' as possible start of dataId is not the best approach, to fix in the future
if len(restOfResp) > posInRestResp + dataIdLength and restOfResp[posInRestResp] == '2':
numberOfPossibleDataId = numberOfPossibleDataId + 1
possibleDataId = restOfResp[posInRestResp:posInRestResp + dataIdLength].replace(" ", "")
if possibleDataId in dataids.keys():
posInResp += posInRestResp
break
else:
bytePos += 1
else:
bytePos += 1
continue
@ -108,8 +119,8 @@ def get_SnapShotMnemonic(m, se, elm, dataids):
posInResp += didDataLength*byteLength
didDict[dataId] = didData
startByte = ""
startBit = ""
startByte = "1"
startBit = "0"
dataId = ""
for did in dataids.keys():
for mn in dataids[did].mnemolocations.keys():

View File

@ -15,7 +15,7 @@ def get_parameter( pr, mn, se, elm, calc, dataids = {} ):
for m in sorted(pr.mnemolist, key=len, reverse=True):
if dataids:
if dataids and mn[m].request.startswith("22"):
val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
else:
val = get_mnemonic( mn[m], se, elm )

View File

@ -11,7 +11,7 @@ def get_state( st, mn, se, elm, calc, dataids = {} ):
comp = st.computation
comp = comp.replace("&","&")
for m in sorted(st.mnemolist, key=len, reverse=True):
if dataids:
if dataids and mn[m].request.startswith("22"):
hex_val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
else:
hex_val = get_mnemonic( mn[m], se, elm )

View File

@ -196,6 +196,12 @@ def optParser():
default=False,
action="store_true")
parser.add_argument("--perform",
help="use UDS performance mode, not fully developed yet",
dest="perform",
default=False,
action="store_true")
options = parser.parse_args()
if not options.port and mod_globals.os != 'android':
@ -231,6 +237,7 @@ def optParser():
mod_globals.opt_exp = options.exp
mod_globals.opt_dump = options.dump
mod_globals.opt_can2 = options.can2
mod_globals.opt_perform = options.perform
mod_globals.opt_sd = options.sd
if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10':
mod_globals.opt_dev = False