Skip to content

Commit

Permalink
Can now load json file containing cct data decoded from IDS xml files…
Browse files Browse the repository at this point in the history
… (which are encrypted, don't ask me about it)
  • Loading branch information
consp committed Jul 31, 2020
1 parent 293ba31 commit 00cec31
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/statics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

class JumpTables(object):
BVNI = [ # correct as from 5U5T
"SYNC",
Expand Down Expand Up @@ -3813,7 +3815,7 @@ def item(self):

def decode(self, value, other=None, other2=None):
try:
s = "[ %3d ] %s:%s" % (self.index, self.name, (40 - len(self.name)) * " ")
s = "[ %3d ] %s:%s" % (self.index, self.name, (48 - len(self.name)) * " ")
v = value[self.byte]
d = (v >> self.bit) & ((2**self.size) - 1)
if other is None:
Expand All @@ -3830,18 +3832,18 @@ def decode(self, value, other=None, other2=None):
v3 = other2[self.byte]
d3 = (v3 >> self.bit) & ((2**self.size) - 1)
if self.type == CCTypes.ENUM:
s = s + "%-32s [%02X] - [%02X] %32s - %-32s [%02X]" % (self.itemlist[d], d, d2, self.itemlist[d2] if d != d2 else "--", self.itemlist[d3] if d != d3 else "--", d3)
s = s + "%-56s [%02X] - [%02X] %56s - %-56s [%02X]" % (self.itemlist[d], d, d2, self.itemlist[d2] if d != d2 else "--", self.itemlist[d3] if d != d3 else "--", d3)
elif self.type == CCTypes.VALUE:
s = s + " %02X - %02X - %02X" % (d, d2, d3)
s = s + " %02X - %02X - %02X" % (d, d2, d3)
elif self.type == CCTypes.FLAG:
s = s + "%02X %s" % (d, "True" if d else "False")
else:
s = s + "???"
else:
if self.type == CCTypes.ENUM:
s = s + "%-32s [%02X] - [%02X] %32s" % (self.itemlist[d], d, d2, self.itemlist[d2] if d != d2 else "--")
s = s + "%-56s [%02X] - [%02X] %56s" % (self.itemlist[d], d, d2, self.itemlist[d2] if d != d2 else "--")
elif self.type == CCTypes.VALUE:
s = s + " %02X - %02X" % (d, d2)
s = s + " %02X - %02X" % (d, d2)
elif self.type == CCTypes.FLAG:
s = s + "%02X %s" % (d, "True" if d else "False")
else:
Expand All @@ -3854,7 +3856,31 @@ def decode(self, value, other=None, other2=None):


class CentralConfiguration:
FIESTA = [
FIESTA = None

def __init__(self, fiesta=None):
if fiesta is not None:
self.FIESTA = []
with open(fiesta, "r") as f:
jsondata = f.read()
for key, item in json.loads(jsondata).items():
print(item)
t = CCTypes.ENUM
o = []
if len(item['options']) > 0:
for option in item['options']:
o.append([option['value'], option['name']])
else:
t = CCTypes.VALUE

o.sort(key=lambda i: i[0])
self.FIESTA.append(CCItem(item['name'].replace("PARAM_EUCD_CCF_", ""), item['start'], item['stop'], 0, 8, items=o, type=t))
self.FIESTA.sort(key=lambda i: i.index)
else:
self.FIESTA = self.OLD


OLD = [
CCItem("Checksum", 0, 1, 0, 8, items=[], type=CCTypes.VALUE),
CCItem("Vehicle Type", 1, 2, 0, 8, items=[
[0x17, "Ford Fiesta"],
Expand Down

0 comments on commit 00cec31

Please sign in to comment.