update can_unique.py for new can_logger.py format
# in the background files.
# Expects the CSV file to be in the format from can_logger.py
+# Bus,MessageID,Message,MessageLength
+# 0,0x292,0x040000001068,6
+
+# The old can_logger.py format is also supported:
# Bus,MessageID,Message
# 0,344,c000c00000000000
+
import binascii
import csv
import sys
@@ -46,7 +51,13 @@ class Info():
reader = csv.reader(input)
next(reader, None) # skip the CSV header
for row in reader:
- message_id = row[1]
+ if row[1].startswith('0x'):
+ message_id = row[1][2:] # remove leading '0x'
+ else:
+ message_id = hex(int(row[1]))[2:] # old message IDs are in decimal
+ if row[1].startswith('0x'):
+ data = row[2][2:] # remove leading '0x'
+ else:
data = row[2]
if message_id not in self.messages:
self.messages[message_id] = Message(message_id)
