Read Snapshot prototype
This commit is contained in:
parent
4382d41159
commit
ea1b6afb2c
@ -431,7 +431,10 @@ class ECU:
|
|||||||
if dr.type=='State':
|
if dr.type=='State':
|
||||||
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
if dr.type=='Parameter':
|
if dr.type=='Parameter':
|
||||||
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
if self.DataIds and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].datarefs:
|
||||||
|
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
|
||||||
|
else:
|
||||||
|
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
if dr.type=='Identification':
|
if dr.type=='Identification':
|
||||||
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
if dr.type=='Command':
|
if dr.type=='Command':
|
||||||
@ -748,7 +751,7 @@ class ECU:
|
|||||||
|
|
||||||
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
|
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
|
||||||
|
|
||||||
tmp_dtrf = self.Defaults[dtchex[:4]].datarefs + self.ext_de
|
tmp_dtrf = self.Defaults[dtchex[:4]].datarefs + self.Defaults[dtchex[:4]].ssdatarefs + self.ext_de
|
||||||
|
|
||||||
#self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
|
#self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
|
||||||
self.show_datarefs(tmp_dtrf, path)
|
self.show_datarefs(tmp_dtrf, path)
|
||||||
|
@ -350,6 +350,7 @@ class ecu_default:
|
|||||||
label = ""
|
label = ""
|
||||||
status = 0
|
status = 0
|
||||||
datarefs = []
|
datarefs = []
|
||||||
|
ssdatarefs = []
|
||||||
helps = []
|
helps = []
|
||||||
caracter = {}
|
caracter = {}
|
||||||
interpInfoPeri = ""
|
interpInfoPeri = ""
|
||||||
@ -384,6 +385,7 @@ class ecu_default:
|
|||||||
for dr in DataRef:
|
for dr in DataRef:
|
||||||
dataref = ecu_screen_dataref( dr )
|
dataref = ecu_screen_dataref( dr )
|
||||||
self.datarefs.append( dataref )
|
self.datarefs.append( dataref )
|
||||||
|
self.ssdatarefs = []
|
||||||
MemorisedInfo = df.getElementsByTagName("MemorisedInfo")
|
MemorisedInfo = df.getElementsByTagName("MemorisedInfo")
|
||||||
if MemorisedInfo:
|
if MemorisedInfo:
|
||||||
for mi in MemorisedInfo:
|
for mi in MemorisedInfo:
|
||||||
@ -391,7 +393,7 @@ class ecu_default:
|
|||||||
if DataRef:
|
if DataRef:
|
||||||
for dr in DataRef:
|
for dr in DataRef:
|
||||||
dataref = ecu_screen_dataref( dr )
|
dataref = ecu_screen_dataref( dr )
|
||||||
self.datarefs.append( dataref )
|
self.ssdatarefs.append( dataref )
|
||||||
|
|
||||||
self.helps = []
|
self.helps = []
|
||||||
Helps = df.getElementsByTagName("Helps")
|
Helps = df.getElementsByTagName("Helps")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from mod_ecu_service import *
|
from mod_ecu_service import *
|
||||||
|
from mod_globals import curPosInSnapshotResp
|
||||||
|
|
||||||
from mod_utils import Choice
|
from mod_utils import Choice
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
@ -93,6 +94,74 @@ def get_mnemonic( m, se, elm, raw = 0 ):
|
|||||||
|
|
||||||
return hexval
|
return hexval
|
||||||
|
|
||||||
|
def get_SnapShotMnemonic(m, se, elm, dataids):
|
||||||
|
snapshotService = ""
|
||||||
|
for sid in se:
|
||||||
|
if len(se[sid].params) > 1:
|
||||||
|
if se[sid].params[1]['type'] == 'Snapshot':
|
||||||
|
snapshotService = se[sid]
|
||||||
|
|
||||||
|
resp = executeService( snapshotService, elm, [], "", True )
|
||||||
|
resp = resp.strip().replace(' ','')
|
||||||
|
if not all(c in string.hexdigits for c in resp): resp = ''
|
||||||
|
resp = ' '.join(a+b for a,b in zip(resp[::2], resp[1::2]))
|
||||||
|
resp = resp[8*3:]
|
||||||
|
|
||||||
|
if mod_globals.curPosInSnapshotResp >= len(resp):
|
||||||
|
mod_globals.curPosInSnapshotResp = 0
|
||||||
|
|
||||||
|
dataId = resp[mod_globals.curPosInSnapshotResp:mod_globals.curPosInSnapshotResp + 2*3].replace(" ", "")
|
||||||
|
|
||||||
|
didDataLength = int(dataids[dataId].dataBitLength)/8
|
||||||
|
didData = resp[mod_globals.curPosInSnapshotResp + 2*3: mod_globals.curPosInSnapshotResp + 2*3 + didDataLength*3]
|
||||||
|
mod_globals.curPosInSnapshotResp += 2*3 + didDataLength * 3
|
||||||
|
|
||||||
|
startByte = ""
|
||||||
|
startBit = ""
|
||||||
|
|
||||||
|
for mn in dataids[dataId].mnemolocations.keys():
|
||||||
|
if mn == m.name:
|
||||||
|
startByte = dataids[dataId].mnemolocations[m.name].startByte
|
||||||
|
startBit = dataids[dataId].mnemolocations[m.name].startBit
|
||||||
|
|
||||||
|
#prepare local variables
|
||||||
|
sb = int(startByte) - 1
|
||||||
|
bits = int(m.bitsLength)
|
||||||
|
sbit = int(startBit)
|
||||||
|
bytes = (bits+sbit-1)/8+1
|
||||||
|
rshift = ((bytes+1)*8 - (bits+sbit))%8
|
||||||
|
|
||||||
|
#check length of responce
|
||||||
|
if (sb*3+bytes*3-1)>(len(didData)):
|
||||||
|
return '00'
|
||||||
|
|
||||||
|
#extract hex
|
||||||
|
hexval = didData[sb*3:(sb+bytes)*3-1]
|
||||||
|
hexval = hexval.replace(" ","")
|
||||||
|
|
||||||
|
#shift and mask
|
||||||
|
val = (int(hexval,16)>>rshift)&(2**bits-1)
|
||||||
|
|
||||||
|
#format result
|
||||||
|
hexval = hex(val)[2:]
|
||||||
|
#remove 'L'
|
||||||
|
if hexval[-1:].upper()=='L':
|
||||||
|
hexval = hexval[:-1]
|
||||||
|
#add left zero if need
|
||||||
|
if len(hexval)%2:
|
||||||
|
hexval = '0'+hexval
|
||||||
|
|
||||||
|
#revert byte order if little endian
|
||||||
|
if m.littleEndian == '1':
|
||||||
|
a = hexval
|
||||||
|
b = ''
|
||||||
|
if not len(a) % 2:
|
||||||
|
for i in range(0,len(a),2):
|
||||||
|
b = a[i:i+2]+b
|
||||||
|
hexval = b
|
||||||
|
|
||||||
|
return hexval
|
||||||
|
|
||||||
class ecu_mnemonic:
|
class ecu_mnemonic:
|
||||||
|
|
||||||
name = ""
|
name = ""
|
||||||
|
@ -7,7 +7,7 @@ from xml.dom.minidom import parseString
|
|||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
import mod_globals
|
import mod_globals
|
||||||
|
|
||||||
def get_parameter( pr, mn, se, elm, calc ):
|
def get_parameter( pr, mn, se, elm, calc, dataids = {} ):
|
||||||
|
|
||||||
comp = pr.computation
|
comp = pr.computation
|
||||||
comp = comp.replace("&","&")
|
comp = comp.replace("&","&")
|
||||||
@ -15,7 +15,10 @@ def get_parameter( pr, mn, se, elm, calc ):
|
|||||||
|
|
||||||
for m in sorted(pr.mnemolist, key=len, reverse=True):
|
for m in sorted(pr.mnemolist, key=len, reverse=True):
|
||||||
|
|
||||||
val = get_mnemonic( mn[m], se, elm )
|
if dataids:
|
||||||
|
val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
|
||||||
|
else:
|
||||||
|
val = get_mnemonic( mn[m], se, elm )
|
||||||
if mn[m].type=="SNUM8" and int(val,16)>0x7f:
|
if mn[m].type=="SNUM8" and int(val,16)>0x7f:
|
||||||
val = str(int(val,16)-0x100)
|
val = str(int(val,16)-0x100)
|
||||||
elif mn[m].type=="SNUM16" and int(val,16)>0x7fff:
|
elif mn[m].type=="SNUM16" and int(val,16)>0x7fff:
|
||||||
|
@ -40,6 +40,7 @@ state_scan = False
|
|||||||
currentDDTscreen = None
|
currentDDTscreen = None
|
||||||
|
|
||||||
ext_cur_DTC = "000000"
|
ext_cur_DTC = "000000"
|
||||||
|
curPosInSnapshotResp = 0
|
||||||
|
|
||||||
none_val = "None"
|
none_val = "None"
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import string
|
|||||||
import mod_globals
|
import mod_globals
|
||||||
import mod_utils
|
import mod_utils
|
||||||
import mod_ecu
|
import mod_ecu
|
||||||
|
import mod_db_manager
|
||||||
from mod_utils import clearScreen
|
from mod_utils import clearScreen
|
||||||
from mod_utils import pyren_encode
|
from mod_utils import pyren_encode
|
||||||
from mod_utils import KBHit
|
from mod_utils import KBHit
|
||||||
@ -37,7 +38,7 @@ def run( elm, ecu, command, data ):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
DOMTree = xml.dom.minidom.parse(data)
|
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
|
||||||
ScmRoom = DOMTree.documentElement
|
ScmRoom = DOMTree.documentElement
|
||||||
|
|
||||||
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
|
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
|
||||||
@ -88,6 +89,7 @@ def run( elm, ecu, command, data ):
|
|||||||
|
|
||||||
paramsToSend = mnemo1Data + resetBytes + mnemo2Data
|
paramsToSend = mnemo1Data + resetBytes + mnemo2Data
|
||||||
|
|
||||||
|
print mod_ecu_mnemonic.get_mnemonicDTC(ecu.Mnemonics["_CSF_UPSTREAM_TEMPERATURE"], "62 24 42 0F 44 00 00")
|
||||||
print title
|
print title
|
||||||
print '*'*80
|
print '*'*80
|
||||||
print messageInfo
|
print messageInfo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user