rendash testing
This commit is contained in:
parent
b11919ea86
commit
6296ecf1f6
@ -82,6 +82,7 @@ class ECU:
|
|||||||
self.elm = 0
|
self.elm = 0
|
||||||
self.ecudata = cecu
|
self.ecudata = cecu
|
||||||
|
|
||||||
|
|
||||||
self.getDTCmnemo = ""
|
self.getDTCmnemo = ""
|
||||||
self.resetDTCcommand = ""
|
self.resetDTCcommand = ""
|
||||||
self.screens = []
|
self.screens = []
|
||||||
@ -133,12 +134,7 @@ class ECU:
|
|||||||
di_class = ecu_dataids( self.DataIds, ddoc, opt_file.dict, tran )
|
di_class = ecu_dataids( self.DataIds, ddoc, opt_file.dict, tran )
|
||||||
|
|
||||||
def initELM(self, elm):
|
def initELM(self, elm):
|
||||||
|
|
||||||
print("Loading PLY ")
|
|
||||||
self.calc = Calc()
|
|
||||||
|
|
||||||
print("Init ELM")
|
print("Init ELM")
|
||||||
|
|
||||||
self.elm = elm
|
self.elm = elm
|
||||||
|
|
||||||
if self.ecudata['pin'].lower()=='can':
|
if self.ecudata['pin'].lower()=='can':
|
||||||
|
@ -10,7 +10,6 @@ import os
|
|||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
"""
|
"""
|
||||||
Base class for a lexer/parser that has the rules defined as methods
|
Base class for a lexer/parser that has the rules defined as methods
|
||||||
|
@ -4,14 +4,22 @@ from mod_elm import ELM
|
|||||||
from mod_scan_ecus import ScanEcus
|
from mod_scan_ecus import ScanEcus
|
||||||
from mod_optfile import optfile
|
from mod_optfile import optfile
|
||||||
from mod_ecu import ECU
|
from mod_ecu import ECU
|
||||||
|
from mod_ply import Calc
|
||||||
from mod_ecu_state import get_state
|
from mod_ecu_state import get_state
|
||||||
|
from mod_ecu_parameter import get_parameter
|
||||||
|
|
||||||
from pickle import dump, load
|
from pickle import dump, load
|
||||||
|
from time import sleep
|
||||||
|
from mod_utils import clearScreen
|
||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import mod_globals
|
REQUIRED_ECU_STATES = {
|
||||||
mod_globals.opt_demo = True
|
"UCH_J84_SE_0450_4C_A": ["E031", "E032", "E029", "E030", "E027", "E074", "E075", "E078", "E122", "E073", "E100", "E072"],
|
||||||
|
"INJ_S30001_A754_00_A": ["E092", "E093", "P004", "P006", "P007", "P051"],
|
||||||
|
"UPC_X 84 C_0600_00_A": ["E001", "E004", "E005", "E006"],
|
||||||
|
"FRE_FPA_FF_0300_08_A": ["E002"]
|
||||||
|
}
|
||||||
|
|
||||||
class RenDash:
|
class RenDash:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
@ -40,28 +48,44 @@ class RenDash:
|
|||||||
self.ecus.append(ECU(ecu, self.lang.dict))
|
self.ecus.append(ECU(ecu, self.lang.dict))
|
||||||
dump(self.ecus, open("frozen_ecus.p", "wb+"))
|
dump(self.ecus, open("frozen_ecus.p", "wb+"))
|
||||||
|
|
||||||
|
for ecu in self.ecus:
|
||||||
|
setattr(ecu, "calc", Calc())
|
||||||
|
|
||||||
def get_ecu_names(self):
|
def get_ecu_names(self):
|
||||||
return [ecu.ecudata["doc"] for ecu in self.ecus]
|
return [ecu.ecudata["doc"] for ecu in self.ecus]
|
||||||
|
|
||||||
def get_ecu_by_doc(self, doc):
|
def get_ecu_by_doc(self, doc):
|
||||||
for ecu in self.ecus:
|
for ecu in self.ecus:
|
||||||
if ecu.ecudata["doc"] == doc:
|
if ecu.ecudata["doc"] == doc:
|
||||||
|
if self.current_ecu is not ecu:
|
||||||
|
ecu.initELM(self.elm)
|
||||||
|
self.current_ecu = ecu
|
||||||
return ecu
|
return ecu
|
||||||
|
|
||||||
def get_ecu_states(self, doc):
|
def get_ecu_states(self, doc):
|
||||||
ecu = self.get_ecu_by_doc(doc)
|
ecu = self.get_ecu_by_doc(doc)
|
||||||
return ecu.States
|
return ecu.Parameters
|
||||||
|
|
||||||
def get_ecu_state(self, doc, state):
|
def get_ecu_state(self, doc, state):
|
||||||
ecu = self.get_ecu_by_doc(doc)
|
ecu = self.get_ecu_by_doc(doc)
|
||||||
if self.current_ecu is not ecu:
|
|
||||||
ecu.initELM(self.elm)
|
|
||||||
self.current_ecu = ecu
|
|
||||||
datastr, help, csvd = get_state(ecu.States[state], ecu.Mnemonics, ecu.Services, self.elm, ecu.calc)
|
datastr, help, csvd = get_state(ecu.States[state], ecu.Mnemonics, ecu.Services, self.elm, ecu.calc)
|
||||||
return datastr
|
return datastr
|
||||||
|
|
||||||
|
def get_ecu_param(self, doc, param):
|
||||||
|
ecu = self.get_ecu_by_doc(doc)
|
||||||
|
datastr, help, csvd = get_parameter(ecu.Parameters[param], ecu.Mnemonics, ecu.Services, self.elm, ecu.calc)
|
||||||
|
return datastr
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
rd = RenDash("/dev/tty0")
|
rd = RenDash("/dev/tty0")
|
||||||
print(rd.get_ecu_names())
|
|
||||||
while True:
|
while True:
|
||||||
print(rd.get_ecu_state("UCH_J84_SE_0450_4C_A", "E031"))
|
clearScreen()
|
||||||
|
for ecu_doc, values in REQUIRED_ECU_STATES.items():
|
||||||
|
for val in values:
|
||||||
|
if val.startswith("E"):
|
||||||
|
print(rd.get_ecu_state(ecu_doc, val))
|
||||||
|
elif val.startswith("P"):
|
||||||
|
print(rd.get_ecu_param(ecu_doc, val))
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user