mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-23 23:12:04 +08:00
make fingerprint script nice
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from tools.lib.route import Route
|
||||
from tools.lib.logreader import MultiLogIterator
|
||||
|
||||
|
||||
def get_fingerprint(lr):
|
||||
# TODO: make this a nice tool for car ports. should also work with qlogs for FW
|
||||
|
||||
fw = None
|
||||
msgs = {}
|
||||
for msg in lr:
|
||||
if msg.which() == 'carParams':
|
||||
fw = msg.carParams.carFw
|
||||
elif msg.which() == 'can':
|
||||
for c in msg.can:
|
||||
# read also msgs sent by EON on CAN bus 0x80 and filter out the
|
||||
# addr with more than 11 bits
|
||||
if c.src % 0x80 == 0 and c.address < 0x800:
|
||||
msgs[c.address] = len(c.dat)
|
||||
|
||||
# show CAN fingerprint
|
||||
fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items()))
|
||||
print(f"\nfound {len(msgs)} messages. CAN fingerprint:\n")
|
||||
print(fingerprint)
|
||||
|
||||
# TODO: also print the fw fingerprint merged with the existing ones
|
||||
# show FW fingerprint
|
||||
print("\nFW fingerprint:\n")
|
||||
for f in fw:
|
||||
print(f" (Ecu.{f.ecu}, {hex(f.address)}, {None if f.subAddress == 0 else f.subAddress}): [")
|
||||
print(f" {f.fwVersion},")
|
||||
print(" ],")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: ./get_fingerprint_internal.py <route>")
|
||||
sys.exit(1)
|
||||
|
||||
route = Route(sys.argv[1])
|
||||
lr = MultiLogIterator(route.log_paths()[:5], wraparound=False)
|
||||
get_fingerprint(lr)
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from tools.lib.route import Route
|
||||
from tools.lib.logreader import MultiLogIterator
|
||||
|
||||
|
||||
def get_fingerprint(lr):
|
||||
can_msgs = [m for m in lr if m.which() == 'can']
|
||||
|
||||
msgs = {}
|
||||
|
||||
for msg in can_msgs:
|
||||
for c in msg.can:
|
||||
# read also msgs sent by EON on CAN bus 0x80 and filter out the
|
||||
# addr with more than 11 bits
|
||||
if c.src % 0x80 == 0 and c.address < 0x800:
|
||||
msgs[c.address] = len(c.dat)
|
||||
|
||||
fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items()))
|
||||
print("number of messages {0}:".format(len(msgs)))
|
||||
print("fingerprint {0}".format(fingerprint))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: ./get_fingerprint_internal.py <route>")
|
||||
sys.exit(1)
|
||||
|
||||
route = Route(sys.argv[1])
|
||||
lr = MultiLogIterator(route.log_paths()[:5], wraparound=False)
|
||||
get_fingerprint(lr)
|
||||
Reference in New Issue
Block a user