Skip to content

Commit

Permalink
fix TODO addressing missing entries E7": u"SCRCM", "E8": u"SVS
Browse files Browse the repository at this point in the history
  • Loading branch information
Furtif committed Dec 15, 2024
1 parent a4fc44a commit 17c594f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
11 changes: 5 additions & 6 deletions ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
_ = options.translator('ddt4all')

addressing = {}
# //TODO addressing missing entries
addressing_entries = {"E7": u"SCRCM", "E8": u"SVS"}


# Returns signed value from 16 bits (2 bytes)
Expand Down Expand Up @@ -1011,7 +1009,8 @@ def connect_to_hardware(self, canline=0):
else:
short_addr = elm.get_can_addr(self.ecu_send_id)
if short_addr is None:
print(_("Cannot retrieve functionnal address of ECU") + " %s @ %s" % (self.ecuname, self.ecu_send_id))
print(
_("Cannot retrieve functionnal address of ECU") + " %s @ %s" % (self.ecuname, self.ecu_send_id))
return False
ecu_conf = {'idTx': self.ecu_send_id, 'idRx': self.ecu_recv_id, 'ecuname': str(ecuname)}

Expand Down Expand Up @@ -1183,8 +1182,8 @@ def __init__(self, forceXML=False):
self.numecu = 0
self.available_addr_kwp = []
self.available_addr_can = []
self.addr_group_mapping_long = addressing_entries
self.addr_group_mapping = addressing_entries
self.addr_group_mapping_long = {}
self.addr_group_mapping = {}

for k, v in addressing.items():
self.addr_group_mapping[k] = v[0]
Expand Down Expand Up @@ -1684,7 +1683,7 @@ def check_ecu2(self, diagversion, supplier, soft, version, label, addr, protocol
found_exact = True
href = target.href
line = "<font color='green'>" + _("Identified ECU") + " [%s]@%s : %s DIAGVERSION [%s]" \
"SUPPLIER [%s] SOFT [%s] VERSION [%s] {%i}</font>" \
"SUPPLIER [%s] SOFT [%s] VERSION [%s] {%i}</font>" \
% (ecu_type, target.addr, href, diagversion, supplier, soft, version, targetNum)

options.main_window.logview.append(line)
Expand Down
28 changes: 16 additions & 12 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@
import options

_ = options.translator('ddt4all')

# //TODO missing entries this need look side ecu addressing missing entries or ignore {}
dnat_entries = {"E7": "7E4", "E8": "644"}
snat_entries = {"E7": "7EC", "E8": "5C4"}

snat = snat_entries
snat = {}
snat_ext = {}
dnat = dnat_entries
dnat = {}
dnat_ext = {}

# Code snippet from https://github.com/rbei-etas/busmaster
Expand Down Expand Up @@ -201,13 +196,15 @@
#v2.1 ;ACH ; ATZ ; Z ; reset all
'''


def addr_exist(addr):
result = True
if addr not in dnat:
if addr not in dnat_ext:
result = False
return result


def get_can_addr(txa):
for d in dnat.keys():
if dnat[d].upper() == txa.upper():
Expand Down Expand Up @@ -572,7 +569,8 @@ def __init__(self, portName, rate, adapter_type="STD", maxspeed="No"):
if len(options.log) > 0:
self.lf = open("./logs/elm_" + options.log + ".txt", "at", encoding="utf-8")
self.vf = open("./logs/ecu_" + options.log + ".txt", "at", encoding="utf-8")
self.vf.write("Timestamp;ECU_CAN_Address_HEX;Raw_Command_HEX;Raw_Response_HEX_or_STR;Error_message_if_happens\n")
self.vf.write(
"Timestamp;ECU_CAN_Address_HEX;Raw_Command_HEX;Raw_Response_HEX_or_STR;Error_message_if_happens\n")

self.lastCMDtime = 0
self.ATCFC0 = options.opt_cfc0
Expand Down Expand Up @@ -725,9 +723,13 @@ def request(self, req, positive='', cache=True, serviceDelay="0"):
if self.vf != 0:
tmstr = datetime.now().strftime("%H:%M:%S.%f")[:-3]
if self.currentaddress in dnat_ext and len(self.currentaddress) == 8:
self.vf.write(tmstr + ";" + "0x" + dnat_ext[self.currentaddress] + ";" + "0x" + req + ";" + "0x" + rsp.rstrip().replace(" ", ",0x") + ";" + "\n")
self.vf.write(tmstr + ";" + "0x" + dnat_ext[
self.currentaddress] + ";" + "0x" + req + ";" + "0x" + rsp.rstrip().replace(" ",
",0x") + ";" + "\n")
elif self.currentaddress in dnat:
self.vf.write(tmstr + ";" + "0x" + dnat[self.currentaddress] + ";" + "0x" + req + ";" + "0x" + rsp.rstrip().replace(" ", ",0x") + ";" + "\n")
self.vf.write(tmstr + ";" + "0x" + dnat[
self.currentaddress] + ";" + "0x" + req + ";" + "0x" + rsp.rstrip().replace(" ",
",0x") + ";" + "\n")
else:
print(_("Unknown address: "), self.currentaddress, "0x" + req, "0x" + rsp)
self.vf.flush()
Expand Down Expand Up @@ -904,9 +906,11 @@ def send_can(self, command):
if self.vf != 0:
tmstr = datetime.now().strftime("%H:%M:%S.%f")[:-3]
if self.currentaddress in dnat_ext and len(self.currentaddress) == 8:
self.vf.write(tmstr + ";" + dnat_ext[self.currentaddress] + ";" + "0x" + command + ";" + result + ";" + errorstr + "\n")
self.vf.write(tmstr + ";" + dnat_ext[
self.currentaddress] + ";" + "0x" + command + ";" + result + ";" + errorstr + "\n")
elif self.currentaddress in dnat:
self.vf.write(tmstr + ";" + dnat[self.currentaddress] + ";" + "0x" + command + ";" + result + ";" + errorstr + "\n")
self.vf.write(tmstr + ";" + dnat[
self.currentaddress] + ";" + "0x" + command + ";" + result + ";" + errorstr + "\n")
self.vf.flush()

# populate L1 cache
Expand Down

0 comments on commit 17c594f

Please sign in to comment.