2022-07-05 15:40:57 -07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
|
2022-07-28 21:29:23 -07:00
|
|
|
chrysler_to_ram = {
|
|
|
|
"_stellantis_common_ram_dt_generated.dbc": {
|
|
|
|
258: 35,
|
2022-07-28 21:51:34 -07:00
|
|
|
264: 37,
|
|
|
|
280: 181,
|
2022-07-28 21:29:23 -07:00
|
|
|
284: 121,
|
|
|
|
320: 131,
|
|
|
|
344: 139,
|
2022-08-04 22:45:55 -07:00
|
|
|
368: 147,
|
2022-07-28 21:29:23 -07:00
|
|
|
464: 464,
|
|
|
|
500: 153,
|
|
|
|
501: 232,
|
|
|
|
544: 49,
|
|
|
|
571: 177,
|
|
|
|
559: 157,
|
|
|
|
678: 250,
|
|
|
|
720: 720,
|
|
|
|
792: 792,
|
|
|
|
820: 657,
|
|
|
|
},
|
|
|
|
"_stellantis_common_ram_hd_generated.dbc": {
|
|
|
|
571: 570,
|
|
|
|
678: 629,
|
|
|
|
},
|
2022-07-05 15:40:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
src = '_stellantis_common.dbc'
|
|
|
|
chrysler_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
2022-07-28 21:29:23 -07:00
|
|
|
for out, addr_lookup in chrysler_to_ram.items():
|
|
|
|
with open(os.path.join(chrysler_path, src)) as in_f, open(os.path.join(chrysler_path, out), 'w') as out_f:
|
|
|
|
out_f.write(f'CM_ "Generated from {src}"\n\n')
|
2022-07-05 15:40:57 -07:00
|
|
|
|
2022-07-28 21:29:23 -07:00
|
|
|
wrote_addrs = set()
|
|
|
|
for line in in_f.readlines():
|
2022-08-04 22:51:44 -07:00
|
|
|
if line.startswith(('BO_', 'VAL_')):
|
2022-07-28 21:29:23 -07:00
|
|
|
sl = line.split(' ')
|
|
|
|
addr = int(sl[1])
|
|
|
|
wrote_addrs.add(addr)
|
2022-07-05 15:40:57 -07:00
|
|
|
|
2022-07-28 21:29:23 -07:00
|
|
|
sl[1] = str(addr_lookup.get(addr, addr))
|
|
|
|
line = ' '.join(sl)
|
|
|
|
out_f.write(line)
|
2022-07-05 15:40:57 -07:00
|
|
|
|
2022-07-28 21:29:23 -07:00
|
|
|
missing_addrs = set(addr_lookup.keys()) - wrote_addrs
|
|
|
|
assert len(missing_addrs) == 0, f"Missing addrs from {src}: {missing_addrs}"
|