From 6296ecf1f694574508542a7c5ff6f777c4f99e55 Mon Sep 17 00:00:00 2001 From: marios8543 Date: Wed, 1 May 2024 20:57:44 +0300 Subject: [PATCH] rendash testing --- pyren3/mod_ecu.py | 8 ++------ pyren3/mod_ply.py | 1 - pyren3/rendash_main.py | 42 +++++++++++++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/pyren3/mod_ecu.py b/pyren3/mod_ecu.py index e09955d..cd75453 100755 --- a/pyren3/mod_ecu.py +++ b/pyren3/mod_ecu.py @@ -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': diff --git a/pyren3/mod_ply.py b/pyren3/mod_ply.py index a726dcf..395e640 100755 --- a/pyren3/mod_ply.py +++ b/pyren3/mod_ply.py @@ -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 diff --git a/pyren3/rendash_main.py b/pyren3/rendash_main.py index 62426b3..89191d1 100644 --- a/pyren3/rendash_main.py +++ b/pyren3/rendash_main.py @@ -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")) \ No newline at end of file + 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) + + \ No newline at end of file