Counter2 pointer missing fix
This commit is contained in:
parent
24904752ab
commit
d2ec17c3cf
@ -18,6 +18,7 @@ import time
|
|||||||
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 pyren_encode
|
from mod_utils import pyren_encode
|
||||||
from mod_utils import clearScreen
|
from mod_utils import clearScreen
|
||||||
from mod_utils import hex_VIN_plus_CRC
|
from mod_utils import hex_VIN_plus_CRC
|
||||||
@ -59,7 +60,7 @@ def run( elm, ecu, command, data ):
|
|||||||
#
|
#
|
||||||
# Data file parsing
|
# Data file parsing
|
||||||
#
|
#
|
||||||
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")
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
'''
|
||||||
|
Scenarium usage example
|
||||||
|
|
||||||
|
Name of this script should be exactly the same as in scenaruim URL but with '.py' extension
|
||||||
|
|
||||||
|
URL - scm:scen_ecri_calinj1#scen_ecri_calinj1_xxxxx.xml
|
||||||
|
|
||||||
|
'run' procedure will be executed by pyren script
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -9,108 +19,125 @@ import mod_globals
|
|||||||
import mod_utils
|
import mod_utils
|
||||||
import mod_ecu
|
import mod_ecu
|
||||||
import mod_db_manager
|
import mod_db_manager
|
||||||
from mod_utils import clearScreen
|
|
||||||
from mod_utils import pyren_encode
|
|
||||||
from mod_utils import KBHit
|
|
||||||
import mod_ecu_mnemonic
|
import mod_ecu_mnemonic
|
||||||
|
from mod_utils import pyren_encode
|
||||||
|
from mod_utils import clearScreen
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
def run( elm, ecu, command, data ):
|
def run( elm, ecu, command, data ):
|
||||||
|
'''
|
||||||
clearScreen()
|
MAIN function of scenarium
|
||||||
header = '['+command.codeMR+'] '+command.label
|
|
||||||
|
|
||||||
ScmSet = {}
|
Parameters:
|
||||||
ScmParam = {}
|
elm - refernce to adapter class
|
||||||
|
ecu - reference to ecu class
|
||||||
def get_message( msg ):
|
command - refernce to the command this scenarium belongs to
|
||||||
if msg in ScmParam.keys():
|
data - name of xml file with parameters from scenarium URL
|
||||||
value = ScmParam[msg]
|
'''
|
||||||
else:
|
|
||||||
value = msg
|
|
||||||
if value.isdigit() and value in mod_globals.language_dict.keys():
|
|
||||||
value = pyren_encode( mod_globals.language_dict[value] )
|
|
||||||
return value
|
|
||||||
|
|
||||||
def get_message_by_id( id ):
|
|
||||||
if id.isdigit() and id in mod_globals.language_dict.keys():
|
|
||||||
value = pyren_encode( mod_globals.language_dict[id] )
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
|
|
||||||
ScmRoom = DOMTree.documentElement
|
|
||||||
|
|
||||||
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
|
clearScreen()
|
||||||
|
header = '['+command.codeMR+'] '+command.label
|
||||||
for Param in ScmParams:
|
|
||||||
name = pyren_encode( Param.getAttribute("name") )
|
|
||||||
value = pyren_encode( Param.getAttribute("value") )
|
|
||||||
|
|
||||||
ScmParam[name] = value
|
|
||||||
|
|
||||||
ScmSets = ScmRoom.getElementsByTagName("ScmSet")
|
ScmSet = {}
|
||||||
|
ScmParam = {}
|
||||||
|
|
||||||
|
def get_message( msg, encode = 1 ):
|
||||||
|
if msg in ScmParam.keys():
|
||||||
|
value = ScmParam[msg]
|
||||||
|
else:
|
||||||
|
value = msg
|
||||||
|
if value.isdigit() and value in mod_globals.language_dict.keys():
|
||||||
|
if encode:
|
||||||
|
value = pyren_encode(mod_globals.language_dict[value])
|
||||||
|
else:
|
||||||
|
value = mod_globals.language_dict[value]
|
||||||
|
return value
|
||||||
|
|
||||||
|
def get_message_by_id( id, encode = 1 ):
|
||||||
|
if id.isdigit() and id in mod_globals.language_dict.keys():
|
||||||
|
if encode:
|
||||||
|
value = pyren_encode(mod_globals.language_dict[id])
|
||||||
|
else:
|
||||||
|
value = mod_globals.language_dict[id]
|
||||||
|
return value
|
||||||
|
|
||||||
|
#
|
||||||
|
# Data file parsing
|
||||||
|
#
|
||||||
|
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data))
|
||||||
|
ScmRoom = DOMTree.documentElement
|
||||||
|
|
||||||
|
ScmParams = ScmRoom.getElementsByTagName("ScmParam")
|
||||||
|
|
||||||
for Set in ScmSets:
|
for Param in ScmParams:
|
||||||
setname = pyren_encode(Set.getAttribute("name"))
|
name = pyren_encode( Param.getAttribute("name") )
|
||||||
ScmParams = Set.getElementsByTagName("ScmParam")
|
value = pyren_encode( Param.getAttribute("value") )
|
||||||
|
|
||||||
for Param in ScmParams:
|
ScmParam[name] = value
|
||||||
name = pyren_encode( Param.getAttribute("name") )
|
|
||||||
value = pyren_encode( Param.getAttribute("value") )
|
|
||||||
|
|
||||||
ScmSet[setname]= value
|
|
||||||
ScmParam[name] = value
|
|
||||||
|
|
||||||
kb = KBHit()
|
ScmSets = ScmRoom.getElementsByTagName("ScmSet")
|
||||||
|
|
||||||
|
for Set in ScmSets:
|
||||||
|
if len(Set.attributes) != 1:
|
||||||
|
setname = pyren_encode(mod_globals.language_dict[Set.getAttribute("name")])
|
||||||
|
ScmParams = Set.getElementsByTagName("ScmParam")
|
||||||
|
|
||||||
|
for Param in ScmParams:
|
||||||
|
name = pyren_encode( Param.getAttribute("name") )
|
||||||
|
value = pyren_encode( Param.getAttribute("value") )
|
||||||
|
|
||||||
|
ScmSet[setname]= value
|
||||||
|
ScmParam[name] = value
|
||||||
|
|
||||||
|
confirm = get_message_by_id('19800')
|
||||||
|
title = get_message('Title')
|
||||||
|
messageInfo = get_message('Message1')
|
||||||
|
succesMessage = get_message('CommandFinished')
|
||||||
|
failMessage = get_message('CommandImpossible')
|
||||||
|
|
||||||
confirm = get_message_by_id('19800')
|
mnemonics = ecu.get_ref_id(ScmParam['default']).mnemolist
|
||||||
title = get_message("Title")
|
|
||||||
messageInfo = get_message("Message1")
|
|
||||||
succesMessage = get_message("CommandFinished")
|
|
||||||
failMessage = get_message("CommandImpossible")
|
|
||||||
|
|
||||||
mnemonics = ecu.get_ref_id(ScmParam["default"]).mnemolist
|
if mnemonics[0][-2:] > mnemonics[1][-2:]:
|
||||||
|
mnemo1 = mnemonics[1]
|
||||||
|
mnemo2 = mnemonics[0]
|
||||||
|
else:
|
||||||
|
mnemo1 = mnemonics[0]
|
||||||
|
mnemo2 = mnemonics[1]
|
||||||
|
|
||||||
|
byteFrom = int(mnemo1[-2:])
|
||||||
|
byteTo = int(re.findall('\d+',mnemo2)[1])
|
||||||
|
byteCount = byteTo - byteFrom - 1
|
||||||
|
resetBytes = byteCount * '00'
|
||||||
|
|
||||||
if mnemonics[0][-2:] > mnemonics[1][-2:]:
|
mnemo1Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo1], ecu.Services, elm, 1)
|
||||||
mnemo1 = mnemonics[1]
|
mnemo2Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo2], ecu.Services, elm, 1)
|
||||||
mnemo2 = mnemonics[0]
|
|
||||||
else:
|
|
||||||
mnemo1 = mnemonics[0]
|
|
||||||
mnemo2 = mnemonics[1]
|
|
||||||
|
|
||||||
byteFrom = int(mnemo1[-2:])
|
|
||||||
byteTo = int(re.findall("\d+", mnemo2)[1])
|
|
||||||
byteCount = byteTo - byteFrom - 1
|
|
||||||
resetBytes = byteCount * "00"
|
|
||||||
|
|
||||||
mnemo1Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo1], ecu.Services, elm, 1)
|
paramsToSend = mnemo1Data + resetBytes + mnemo2Data
|
||||||
mnemo2Data = mod_ecu_mnemonic.get_mnemonic(ecu.Mnemonics[mnemo2], ecu.Services, elm, 1)
|
|
||||||
|
|
||||||
paramsToSend = mnemo1Data + resetBytes + mnemo2Data
|
clearScreen()
|
||||||
|
|
||||||
print title
|
|
||||||
print '*'*80
|
|
||||||
print messageInfo
|
|
||||||
print '*'*80
|
|
||||||
print
|
|
||||||
ch = raw_input(confirm + ' <YES/NO>: ')
|
|
||||||
while (ch.upper()!='YES') and (ch.upper()!='NO'):
|
|
||||||
ch = raw_input(confirm + ' <YES/NO>: ')
|
|
||||||
if ch.upper()!='YES':
|
|
||||||
return
|
|
||||||
|
|
||||||
clearScreen()
|
|
||||||
|
|
||||||
print
|
print title
|
||||||
response = ecu.run_cmd(ScmParam['Cmde1'], paramsToSend)
|
print '*'*80
|
||||||
print
|
print messageInfo
|
||||||
|
print '*'*80
|
||||||
|
print
|
||||||
|
ch = raw_input(confirm + ' <YES/NO>: ')
|
||||||
|
while (ch.upper()!='YES') and (ch.upper()!='NO'):
|
||||||
|
ch = raw_input(confirm + ' <YES/NO>: ')
|
||||||
|
if ch.upper()!='YES':
|
||||||
|
return
|
||||||
|
|
||||||
if "NR" in response:
|
clearScreen()
|
||||||
print failMessage
|
|
||||||
else:
|
print
|
||||||
print succesMessage
|
response = ecu.run_cmd(ScmParam['Cmde1'], paramsToSend)
|
||||||
|
print
|
||||||
print
|
|
||||||
ch = raw_input('Press ENTER to exit')
|
if 'NR' in response:
|
||||||
return
|
print failMessage
|
||||||
|
else:
|
||||||
|
print succesMessage
|
||||||
|
|
||||||
|
print
|
||||||
|
ch = raw_input("Press ENTER to exit")
|
||||||
|
return
|
@ -18,6 +18,7 @@ import time
|
|||||||
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 pyren_encode
|
from mod_utils import pyren_encode
|
||||||
from mod_utils import clearScreen
|
from mod_utils import clearScreen
|
||||||
from mod_utils import KBHit
|
from mod_utils import KBHit
|
||||||
@ -65,7 +66,7 @@ def run( elm, ecu, command, data ):
|
|||||||
# Data file parsing
|
# Data file parsing
|
||||||
#
|
#
|
||||||
|
|
||||||
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")
|
||||||
|
@ -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
|
||||||
@ -36,7 +37,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")
|
||||||
|
@ -18,6 +18,7 @@ import time
|
|||||||
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 pyren_encode
|
from mod_utils import pyren_encode
|
||||||
from mod_utils import clearScreen
|
from mod_utils import clearScreen
|
||||||
from mod_utils import KBHit
|
from mod_utils import KBHit
|
||||||
@ -67,7 +68,7 @@ def run( elm, ecu, command, data ):
|
|||||||
#
|
#
|
||||||
# Data file parsing
|
# Data file parsing
|
||||||
#
|
#
|
||||||
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
|
||||||
|
|
||||||
# read parameters
|
# read parameters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user