rendash testing

This commit is contained in:
marios8543 2024-05-01 20:57:44 +03:00
parent b11919ea86
commit 6296ecf1f6
3 changed files with 35 additions and 16 deletions

View File

@ -76,11 +76,12 @@ class ECU:
ecudata = {}
minimumrefreshrate = 0.100
def __init__(self, cecu, tran ):
self.elm = 0
self.ecudata = cecu
self.getDTCmnemo = ""
self.resetDTCcommand = ""
@ -133,12 +134,7 @@ class ECU:
di_class = ecu_dataids( self.DataIds, ddoc, opt_file.dict, tran )
def initELM(self, elm):
print("Loading PLY ")
self.calc = Calc()
print("Init ELM")
self.elm = elm
if self.ecudata['pin'].lower()=='can':

View File

@ -10,7 +10,6 @@ import os
import time
import re
class Parser:
"""
Base class for a lexer/parser that has the rules defined as methods

View File

@ -4,14 +4,22 @@ from mod_elm import ELM
from mod_scan_ecus import ScanEcus
from mod_optfile import optfile
from mod_ecu import ECU
from mod_ply import Calc
from mod_ecu_state import get_state
from mod_ecu_parameter import get_parameter
from pickle import dump, load
from time import sleep
from mod_utils import clearScreen
from typing import List
import mod_globals
mod_globals.opt_demo = True
REQUIRED_ECU_STATES = {
"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:
def __init__(self,
@ -40,28 +48,44 @@ class RenDash:
self.ecus.append(ECU(ecu, self.lang.dict))
dump(self.ecus, open("frozen_ecus.p", "wb+"))
for ecu in self.ecus:
setattr(ecu, "calc", Calc())
def get_ecu_names(self):
return [ecu.ecudata["doc"] for ecu in self.ecus]
def get_ecu_by_doc(self, doc):
for ecu in self.ecus:
if ecu.ecudata["doc"] == doc:
if self.current_ecu is not ecu:
ecu.initELM(self.elm)
self.current_ecu = ecu
return ecu
def get_ecu_states(self, doc):
ecu = self.get_ecu_by_doc(doc)
return ecu.States
return ecu.Parameters
def get_ecu_state(self, doc, state):
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
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__":
rd = RenDash("/dev/tty0")
print(rd.get_ecu_names())
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)