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:
parent
548e1b9795
commit
838520e001
@ -152,8 +152,7 @@ class ECU:
|
|||||||
self.elm.start_session( self.ecudata['startDiagReq'] )
|
self.elm.start_session( self.ecudata['startDiagReq'] )
|
||||||
|
|
||||||
if mod_globals.os == 'android' or mod_globals.opt_csv:
|
if mod_globals.os == 'android' or mod_globals.opt_csv:
|
||||||
if self.ecudata['pin'].lower()=='can' and self.DataIds:
|
if self.ecudata['pin'].lower()=='can' and self.DataIds and mod_globals.opt_perform:
|
||||||
mod_globals.opt_perform = True
|
|
||||||
self.elm.checkModulePerformaceLevel(self.DataIds)
|
self.elm.checkModulePerformaceLevel(self.DataIds)
|
||||||
|
|
||||||
print "Done"
|
print "Done"
|
||||||
|
@ -64,7 +64,7 @@ def get_mnemonic( m, se, elm, raw = False ):
|
|||||||
|
|
||||||
def get_SnapShotMnemonic(m, se, elm, dataids):
|
def get_SnapShotMnemonic(m, se, elm, dataids):
|
||||||
snapshotService = ""
|
snapshotService = ""
|
||||||
byteLength = 3
|
byteLength = 3 #number of chars in one byte string (two chars with one whitespace)
|
||||||
dataIdByteLength = 2
|
dataIdByteLength = 2
|
||||||
|
|
||||||
for sid in se:
|
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)
|
numberOfIdentifiers = int("0x" + resp[7*byteLength:8*byteLength-1],16)
|
||||||
resp = resp[8*byteLength:]
|
resp = resp[8*byteLength:]
|
||||||
|
|
||||||
didDict = {}
|
didDict = {} #dataIds with their corresponding data
|
||||||
|
numberOfPossibleDataId = 0 #number of unknown dataIds
|
||||||
posInResp = 0
|
posInResp = 0
|
||||||
dataIdLength = dataIdByteLength * byteLength
|
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(" ", "")
|
dataId = resp[posInResp:posInResp + dataIdLength].replace(" ", "")
|
||||||
posInResp += dataIdLength
|
posInResp += dataIdLength
|
||||||
if dataId not in dataids.keys():
|
|
||||||
|
if dataId not in dataids.keys(): #unknown dataId in the snapShot response
|
||||||
bytePos = 1
|
bytePos = 1
|
||||||
restOfResp = resp[posInResp:]
|
restOfResp = resp[posInResp:]
|
||||||
|
|
||||||
while True:
|
while True: #try to find a next dataId that is defined in the module file
|
||||||
posInRestResp = bytePos*byteLength
|
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':
|
if len(restOfResp) > posInRestResp + dataIdLength and restOfResp[posInRestResp] == '2':
|
||||||
|
numberOfPossibleDataId = numberOfPossibleDataId + 1
|
||||||
possibleDataId = restOfResp[posInRestResp:posInRestResp + dataIdLength].replace(" ", "")
|
possibleDataId = restOfResp[posInRestResp:posInRestResp + dataIdLength].replace(" ", "")
|
||||||
if possibleDataId in dataids.keys():
|
if possibleDataId in dataids.keys():
|
||||||
posInResp += posInRestResp
|
posInResp += posInRestResp
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
bytePos += 1
|
||||||
else:
|
else:
|
||||||
bytePos += 1
|
bytePos += 1
|
||||||
continue
|
continue
|
||||||
@ -108,8 +119,8 @@ def get_SnapShotMnemonic(m, se, elm, dataids):
|
|||||||
posInResp += didDataLength*byteLength
|
posInResp += didDataLength*byteLength
|
||||||
didDict[dataId] = didData
|
didDict[dataId] = didData
|
||||||
|
|
||||||
startByte = ""
|
startByte = "1"
|
||||||
startBit = ""
|
startBit = "0"
|
||||||
dataId = ""
|
dataId = ""
|
||||||
for did in dataids.keys():
|
for did in dataids.keys():
|
||||||
for mn in dataids[did].mnemolocations.keys():
|
for mn in dataids[did].mnemolocations.keys():
|
||||||
|
@ -15,7 +15,7 @@ def get_parameter( pr, mn, se, elm, calc, dataids = {} ):
|
|||||||
|
|
||||||
for m in sorted(pr.mnemolist, key=len, reverse=True):
|
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 )
|
val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
|
||||||
else:
|
else:
|
||||||
val = get_mnemonic( mn[m], se, elm )
|
val = get_mnemonic( mn[m], se, elm )
|
||||||
|
@ -11,7 +11,7 @@ def get_state( st, mn, se, elm, calc, dataids = {} ):
|
|||||||
comp = st.computation
|
comp = st.computation
|
||||||
comp = comp.replace("&","&")
|
comp = comp.replace("&","&")
|
||||||
for m in sorted(st.mnemolist, key=len, reverse=True):
|
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 )
|
hex_val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
|
||||||
else:
|
else:
|
||||||
hex_val = get_mnemonic( mn[m], se, elm )
|
hex_val = get_mnemonic( mn[m], se, elm )
|
||||||
|
@ -196,6 +196,12 @@ def optParser():
|
|||||||
default=False,
|
default=False,
|
||||||
action="store_true")
|
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()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if not options.port and mod_globals.os != 'android':
|
if not options.port and mod_globals.os != 'android':
|
||||||
@ -231,6 +237,7 @@ def optParser():
|
|||||||
mod_globals.opt_exp = options.exp
|
mod_globals.opt_exp = options.exp
|
||||||
mod_globals.opt_dump = options.dump
|
mod_globals.opt_dump = options.dump
|
||||||
mod_globals.opt_can2 = options.can2
|
mod_globals.opt_can2 = options.can2
|
||||||
|
mod_globals.opt_perform = options.perform
|
||||||
mod_globals.opt_sd = options.sd
|
mod_globals.opt_sd = options.sd
|
||||||
if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10':
|
if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10':
|
||||||
mod_globals.opt_dev = False
|
mod_globals.opt_dev = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user