mirror of https://github.com/commaai/panda.git
Adding a .csv CAN logger example
Logs on all 3 CAN busses to output.csv
This commit is contained in:
parent
849f68879d
commit
ad21cd719e
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import binascii
|
||||
import csv
|
||||
from panda import Panda
|
||||
|
||||
def can_logger():
|
||||
|
||||
try:
|
||||
p = Panda()
|
||||
|
||||
outputfile = open('output.csv', 'wb')
|
||||
csvwriter = csv.writer(outputfile)
|
||||
#Write Header
|
||||
csvwriter.writerow(['Bus', 'MessageID', 'Message'])
|
||||
print("Writing csv file. Press Ctrl-C to exit...")
|
||||
|
||||
while True:
|
||||
can_recv = p.can_recv()
|
||||
for address, _, dat, src in can_recv:
|
||||
csvwriter.writerow([str(src), str(address), binascii.hexlify(dat)])
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Exiting...")
|
||||
outputfile.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
can_logger()
|
Loading…
Reference in New Issue