|  |  | @ -22,6 +22,8 @@ def send_thread(s, flock): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     for i in [0, 1, 2, 3, 0xFFFF]: |  |  |  |     for i in [0, 1, 2, 3, 0xFFFF]: | 
			
		
	
		
		
			
				
					
					|  |  |  |       s.can_clear(i) |  |  |  |       s.can_clear(i) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       s.set_can_speed_kbps(i, 500) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       s.set_can_data_speed_kbps(i, 500) | 
			
		
	
		
		
			
				
					
					|  |  |  |     s.set_ignition(False) |  |  |  |     s.set_ignition(False) | 
			
		
	
		
		
			
				
					
					|  |  |  |     time.sleep(5) |  |  |  |     time.sleep(5) | 
			
		
	
		
		
			
				
					
					|  |  |  |     s.set_ignition(True) |  |  |  |     s.set_ignition(True) | 
			
		
	
	
		
		
			
				
					|  |  | @ -64,6 +66,11 @@ def connect(): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       for s in p.list(): |  |  |  |       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=(p(s), flashing_lock)) | 
			
		
	
		
		
			
				
					
					|  |  |  |           serials[s].start() |  |  |  |           serials[s].start() | 
			
		
	
	
		
		
			
				
					|  |  | @ -71,9 +78,10 @@ def connect(): | 
			
		
	
		
		
			
				
					
					|  |  |  |     # try to join all send threads |  |  |  |     # try to join all send threads | 
			
		
	
		
		
			
				
					
					|  |  |  |     cur_serials = serials.copy() |  |  |  |     cur_serials = serials.copy() | 
			
		
	
		
		
			
				
					
					|  |  |  |     for s, t in cur_serials.items(): |  |  |  |     for s, t in cur_serials.items(): | 
			
		
	
		
		
			
				
					
					|  |  |  |       t.join(0.01) |  |  |  |       if t is  not None: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       if not t.is_alive(): |  |  |  |         t.join(0.01) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         del serials[s] |  |  |  |         if not t.is_alive(): | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           del serials[s] | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     time.sleep(1) |  |  |  |     time.sleep(1) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |