Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cedricp/ddt4all
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricp committed Jan 8, 2018
2 parents 269cd31 + 6072e49 commit 37034f2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
10 changes: 8 additions & 2 deletions ddt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ def init(self):
supplier = ecu.supplier
diag = ecu.diagversion

if not [ecu.name, ecu.protocol, supplier, diag, soft, version, projname] in stored_ecus[grp]:
stored_ecus[grp].append([ecu.name, ecu.protocol, supplier, diag, soft, version, projname])
row = [ecu.name, ecu.protocol, supplier, diag, soft, version, projname]
found = False
for r in stored_ecus[grp]:
if (r[0], r[1]) == (row[0], row[1]):
found = True
break
if not found:
stored_ecus[grp].append(row)

keys = stored_ecus.keys()
keys.sort(cmp=locale.strcoll)
Expand Down
2 changes: 1 addition & 1 deletion ddtplugins
24 changes: 19 additions & 5 deletions ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,13 +1124,16 @@ def __init__(self, diagversion, supplier, soft, version, name, group, href, prot
def checkWith(self, diagversion, supplier, soft, version, addr):
if self.diagversion == "":
return
supplier_strip = self.supplier.strip()
soft_strip = self.soft.strip()
version_strip = self.version.strip()
if int("0x" + self.diagversion, 16) != int("0x" + diagversion, 16):
return False
if self.supplier.strip() != supplier.strip():
if supplier_strip != supplier.strip()[:len(supplier_strip)]:
return False
if self.soft.strip() != soft.strip():
if soft_strip != soft.strip()[:len(soft_strip)]:
return False
if self.version.strip() != version.strip():
if version_strip != version.strip()[:len(version_strip)]:
return False

self.addr = addr
Expand Down Expand Up @@ -1415,6 +1418,7 @@ def identify_old(self, addr, label):
self.check_ecu(can_response, label, addr, "CAN")

def identify_new(self, addr, label):
printable_chars = set(string.printable)
diagversion = ""
supplier = ""
soft_version = ''
Expand All @@ -1439,6 +1443,8 @@ def identify_new(self, addr, label):
can_response = "62 F1 A0 04"
elif addr == '01':
can_response = "62 F1 A0 04"
elif addr == '04':
can_response = "62 F1 A0 04"
else:
can_response = options.elm.request(req='22F1A0', positive='', cache=False)
if 'WRONG' in can_response:
Expand All @@ -1462,6 +1468,10 @@ def identify_new(self, addr, label):
can_response = "62 F1 8A 41 46 4B"
elif addr == '01':
can_response = "62 F1 8A 43 41 53"
elif addr == '04':
can_response = "62 F1 8A 56 69 73 74 65 6F 6E 5F 4E 61 6D 65 73 74 6F 76 6F 5F 30 39 36 20 20 20 20"\
"20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20"\
"20 20 20 20 20 20 20 20 20 20 20 20 20"
else:
can_response = options.elm.request(req='22F18A', positive='', cache=False)
if 'WRONG' in can_response:
Expand All @@ -1483,11 +1493,14 @@ def identify_new(self, addr, label):
can_response = "62 F1 94 31 30 30 30 30 30 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 FF FF FF FF FF FF"
elif addr == '01':
can_response = "62 F1 94 4E 33 32 52 41 46 30 30 30 31 31 00 00 00 00 00 00"
elif addr == '04':
can_response = "62 F1 94 56 30 36 30 32 F1 94 56 30 36"
else:
can_response = options.elm.request(req='22F194', positive='', cache=False)
if 'WRONG' in can_response:
return False
soft = can_response.replace(' ', '')[6:38].decode('hex')
soft= filter(lambda x: x in printable_chars, soft)

# Check soft version
if options.simulation_mode:
Expand All @@ -1504,18 +1517,19 @@ def identify_new(self, addr, label):
can_response = "62 F1 95 30 35 30 31 30 30 30 32 31 37 30 30 FF FF FF FF FF"
elif addr == '01':
can_response = "62 F1 95 46 30 37 2F 34 6F 00 00 00 03"
elif addr == '04':
can_response = "62 F1 95 56 30 36 30 32 F1 95 56 30 36"
else:
can_response = options.elm.request(req='22F195', positive='', cache=False)
if 'WRONG' in can_response:
return False

# Remove unwanted non-ascii FF from string
soft_version = can_response.replace(' ', '')[6:38].decode('hex')
printable_chars = set(string.printable)
soft_version = filter(lambda x: x in printable_chars, soft_version)
if diagversion == "":
return False

print diagversion, supplier, soft, soft_version
self.check_ecu2(diagversion, supplier, soft, soft_version, label, addr, "CAN")
# New method succeded, return the good news
return True
Expand Down
2 changes: 1 addition & 1 deletion parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def sendElm(self, command, auto=False):

if not options.promode:
# Allow read only modes
if command[0:2] not in options.safe_commands:
if command[0:2] in options.safe_commands:

elm_response = options.elm.request(command, cache=False)
txt = '<font color=blue>' + _('Sending ELM request :') + '</font>'
Expand Down

0 comments on commit 37034f2

Please sign in to comment.