|  |  | @ -1,25 +1,23 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #!/usr/bin/env python3 |  |  |  | #!/usr/bin/env python3 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import argparse | 
			
		
	
		
		
			
				
					
					|  |  |  | import binascii |  |  |  | import binascii | 
			
		
	
		
		
			
				
					
					|  |  |  | import os |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import sys |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from collections import defaultdict |  |  |  | from collections import defaultdict | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cereal.messaging as messaging |  |  |  | import cereal.messaging as messaging | 
			
		
	
		
		
			
				
					
					|  |  |  | from common.realtime import sec_since_boot |  |  |  | from common.realtime import sec_since_boot | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): |  |  |  | def can_printer(bus, max_msg, addr): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   logcan = messaging.sub_sock('can', addr=addr) |  |  |  |   logcan = messaging.sub_sock('can', addr=addr) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   start = sec_since_boot() |  |  |  |   start = sec_since_boot() | 
			
		
	
		
		
			
				
					
					|  |  |  |   lp = sec_since_boot() |  |  |  |   lp = sec_since_boot() | 
			
		
	
		
		
			
				
					
					|  |  |  |   msgs = defaultdict(list) |  |  |  |   msgs = defaultdict(list) | 
			
		
	
		
		
			
				
					
					|  |  |  |   canbus = int(os.getenv("CAN", bus)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   while 1: |  |  |  |   while 1: | 
			
		
	
		
		
			
				
					
					|  |  |  |     can_recv = messaging.drain_sock(logcan, wait_for_one=True) |  |  |  |     can_recv = messaging.drain_sock(logcan, wait_for_one=True) | 
			
		
	
		
		
			
				
					
					|  |  |  |     for x in can_recv: |  |  |  |     for x in can_recv: | 
			
		
	
		
		
			
				
					
					|  |  |  |       for y in x.can: |  |  |  |       for y in x.can: | 
			
		
	
		
		
			
				
					
					|  |  |  |         if y.src == canbus: |  |  |  |         if y.src == bus: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |           msgs[y.address].append(y.dat) |  |  |  |           msgs[y.address].append(y.dat) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if sec_since_boot() - lp > 0.1: |  |  |  |     if sec_since_boot() - lp > 0.1: | 
			
		
	
	
		
		
			
				
					|  |  | @ -32,11 +30,12 @@ def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): | 
			
		
	
		
		
			
				
					
					|  |  |  |       lp = sec_since_boot() |  |  |  |       lp = sec_since_boot() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | if __name__ == "__main__": |  |  |  | if __name__ == "__main__": | 
			
		
	
		
		
			
				
					
					|  |  |  |   if len(sys.argv) > 3: |  |  |  |   parser = argparse.ArgumentParser(description="PlotJuggler plugin for reading openpilot logs", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     can_printer(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3]) |  |  |  |                                    formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   elif len(sys.argv) > 2: |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     can_printer(int(sys.argv[1]), int(sys.argv[2])) |  |  |  |   parser.add_argument("--bus", help="CAN bus to print out", default=0) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   elif len(sys.argv) > 1: |  |  |  |   parser.add_argument("--max_msg", help="max addr ") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     can_printer(int(sys.argv[1])) |  |  |  |   parser.add_argument("--addr", default="127.0.0.1") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   else: |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     can_printer() |  |  |  |   args = parser.parse_args() | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   can_printer(args.bus, args.max_msg, args.addr) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |