| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -53,16 +53,12 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if ((to_push->RIR>>21) == 0x1D2) { | 
					 | 
					 | 
					 | 
					  if ((to_push->RIR>>21) == 0x1D2) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // 5th bit is CRUISE_ACTIVE
 | 
					 | 
					 | 
					 | 
					    // 5th bit is CRUISE_ACTIVE
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int cruise_engaged = to_push->RDLR & 0x20; | 
					 | 
					 | 
					 | 
					    int cruise_engaged = to_push->RDLR & 0x20; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // 4th bit is GAS_RELEASED
 | 
					 | 
					 | 
					 | 
					    if (!cruise_engaged) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int gas = !(to_push->RDLR & 0x10); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!cruise_engaged || | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        (gas && !toyota_gas_prev && !gas_interceptor_detected && long_controls_allowed)) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      controls_allowed = 0; | 
					 | 
					 | 
					 | 
					      controls_allowed = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } else if (cruise_engaged && !toyota_cruise_engaged_last) { | 
					 | 
					 | 
					 | 
					    } else if (cruise_engaged && !toyota_cruise_engaged_last) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      controls_allowed = 1; | 
					 | 
					 | 
					 | 
					      controls_allowed = 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    toyota_cruise_engaged_last = cruise_engaged; | 
					 | 
					 | 
					 | 
					    toyota_cruise_engaged_last = cruise_engaged; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    toyota_gas_prev = gas; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // exit controls on rising edge of gas press if interceptor (0x201)
 | 
					 | 
					 | 
					 | 
					  // exit controls on rising edge of gas press if interceptor (0x201)
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -77,6 +73,15 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    gas_interceptor_prev = gas_interceptor; | 
					 | 
					 | 
					 | 
					    gas_interceptor_prev = gas_interceptor; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  // exit controls on rising edge of gas press
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  if ((to_push->RIR>>21) == 0x2C1) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    int gas = (to_push->RDHR >> 16) & 0xFF; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if ((gas > 0) && (toyota_gas_prev == 0) && !gas_interceptor_detected && long_controls_allowed) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      controls_allowed = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    toyota_gas_prev = gas; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  int bus = (to_push->RDTR >> 4) & 0xF; | 
					 | 
					 | 
					 | 
					  int bus = (to_push->RDTR >> 4) & 0xF; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // msgs are only on bus 2 if panda is connected to frc
 | 
					 | 
					 | 
					 | 
					  // msgs are only on bus 2 if panda is connected to frc
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if (bus == 2) { | 
					 | 
					 | 
					 | 
					  if (bus == 2) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |