Read Snapshot prototype
This commit is contained in:
parent
4382d41159
commit
ea1b6afb2c
@ -431,7 +431,10 @@ class ECU:
|
||||
if dr.type=='State':
|
||||
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||
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':
|
||||
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||
if dr.type=='Command':
|
||||
@ -748,7 +751,7 @@ class ECU:
|
||||
|
||||
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(tmp_dtrf, path)
|
||||
|
@ -350,6 +350,7 @@ class ecu_default:
|
||||
label = ""
|
||||
status = 0
|
||||
datarefs = []
|
||||
ssdatarefs = []
|
||||
helps = []
|
||||
caracter = {}
|
||||
interpInfoPeri = ""
|
||||
@ -384,6 +385,7 @@ class ecu_default:
|
||||
for dr in DataRef:
|
||||
dataref = ecu_screen_dataref( dr )
|
||||
self.datarefs.append( dataref )
|
||||
self.ssdatarefs = []
|
||||
MemorisedInfo = df.getElementsByTagName("MemorisedInfo")
|
||||
if MemorisedInfo:
|
||||
for mi in MemorisedInfo:
|
||||
@ -391,7 +393,7 @@ class ecu_default:
|
||||
if DataRef:
|
||||
for dr in DataRef:
|
||||
dataref = ecu_screen_dataref( dr )
|
||||
self.datarefs.append( dataref )
|
||||
self.ssdatarefs.append( dataref )
|
||||
|
||||
self.helps = []
|
||||
Helps = df.getElementsByTagName("Helps")
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from mod_ecu_service import *
|
||||
from mod_globals import curPosInSnapshotResp
|
||||
|
||||
from mod_utils import Choice
|
||||
from xml.dom.minidom import parse
|
||||
@ -93,6 +94,74 @@ def get_mnemonic( m, se, elm, raw = 0 ):
|
||||
|
||||
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:
|
||||
|
||||
name = ""
|
||||
|
@ -7,7 +7,7 @@ from xml.dom.minidom import parseString
|
||||
import xml.dom.minidom
|
||||
import mod_globals
|
||||
|
||||
def get_parameter( pr, mn, se, elm, calc ):
|
||||
def get_parameter( pr, mn, se, elm, calc, dataids = {} ):
|
||||
|
||||
comp = pr.computation
|
||||
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):
|
||||
|
||||
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:
|
||||
val = str(int(val,16)-0x100)
|
||||
elif mn[m].type=="SNUM16" and int(val,16)>0x7fff:
|
||||
|
@ -40,6 +40,7 @@ state_scan = False
|
||||
currentDDTscreen = None
|
||||
|
||||
ext_cur_DTC = "000000"
|
||||
curPosInSnapshotResp = 0
|
||||
|
||||
none_val = "None"
|
||||
|
||||
|
@ -8,6 +8,7 @@ import string
|
||||
import mod_globals
|
||||
import mod_utils
|
||||
import mod_ecu
|
||||
import mod_db_manager
|
||||
from mod_utils import clearScreen
|
||||
from mod_utils import pyren_encode
|
||||
from mod_utils import KBHit
|
||||
@ -37,7 +38,7 @@ def run( elm, ecu, command, data ):
|
||||
return value
|
||||
|
||||
|
||||
DOMTree = xml.dom.minidom.parse(data)
|
||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
|
||||
ScmRoom = DOMTree.documentElement
|
||||
|
||||
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
|
||||
@ -88,6 +89,7 @@ def run( elm, ecu, command, data ):
|
||||
|
||||
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 '*'*80
|
||||
print messageInfo
|
||||
|
Loading…
x
Reference in New Issue
Block a user