|  |  | @ -2,6 +2,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | import argparse |  |  |  | import argparse | 
			
		
	
		
		
			
				
					
					|  |  |  | import os |  |  |  | import os | 
			
		
	
		
		
			
				
					
					|  |  |  | import time |  |  |  | import time | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import usb1 | 
			
		
	
		
		
			
				
					
					|  |  |  | import threading |  |  |  | import threading | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | os.environ['FILEREADER_CACHE'] = '1' |  |  |  | os.environ['FILEREADER_CACHE'] = '1' | 
			
		
	
	
		
		
			
				
					|  |  | @ -42,7 +43,11 @@ def send_thread(s, flock): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     snd = CAN_MSGS[idx] |  |  |  |     snd = CAN_MSGS[idx] | 
			
		
	
		
		
			
				
					
					|  |  |  |     snd = list(filter(lambda x: x[-1] <= 2, snd)) |  |  |  |     snd = list(filter(lambda x: x[-1] <= 2, snd)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     try: | 
			
		
	
		
		
			
				
					
					|  |  |  |       s.can_send_many(snd) |  |  |  |       s.can_send_many(snd) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     except usb1.USBErrorTimeout: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       # timeout is fine, just means the CAN TX buffer is full | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       pass | 
			
		
	
		
		
			
				
					
					|  |  |  |     idx = (idx + 1) % len(CAN_MSGS) |  |  |  |     idx = (idx + 1) % len(CAN_MSGS) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # Drain panda message buffer |  |  |  |     # Drain panda message buffer | 
			
		
	
	
		
		
			
				
					|  |  | @ -57,19 +62,10 @@ def connect(): | 
			
		
	
		
		
			
				
					
					|  |  |  |   flashing_lock = threading.Lock() |  |  |  |   flashing_lock = threading.Lock() | 
			
		
	
		
		
			
				
					
					|  |  |  |   while True: |  |  |  |   while True: | 
			
		
	
		
		
			
				
					
					|  |  |  |     # look for new devices |  |  |  |     # look for new devices | 
			
		
	
		
		
			
				
					
					|  |  |  |     for p in [Panda, PandaJungle]: |  |  |  |     for s in PandaJungle.list(): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       if p is None: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         continue |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       for s in p.list(): |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       if s not in serials: |  |  |  |       if s not in serials: | 
			
		
	
		
		
			
				
					
					|  |  |  |           with p(s) as pp: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             if pp.get_type() == Panda.HW_TYPE_TRES: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |               serials[s] = None |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |               continue |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         print("starting send thread for", s) |  |  |  |         print("starting send thread for", s) | 
			
		
	
		
		
			
				
					
					|  |  |  |           serials[s] = threading.Thread(target=send_thread, args=(p(s), flashing_lock)) |  |  |  |         serials[s] = threading.Thread(target=send_thread, args=(PandaJungle(s), flashing_lock)) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         serials[s].start() |  |  |  |         serials[s].start() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # try to join all send threads |  |  |  |     # try to join all send threads | 
			
		
	
	
		
		
			
				
					|  |  | @ -94,7 +90,7 @@ if __name__ == "__main__": | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   print("Loading log...") |  |  |  |   print("Loading log...") | 
			
		
	
		
		
			
				
					
					|  |  |  |   if args.route_or_segment_name is None: |  |  |  |   if args.route_or_segment_name is None: | 
			
		
	
		
		
			
				
					
					|  |  |  |     args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/10:16" |  |  |  |     args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/1:3" | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   sr = LogReader(args.route_or_segment_name) |  |  |  |   sr = LogReader(args.route_or_segment_name) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |