Subaru: fixed bug and added safety tests
parent
176f1325ba
commit
e437b9b4b1
|
@ -44,7 +44,7 @@ static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
|||
|
||||
// steer cmd checks
|
||||
if (addr == 0x122) {
|
||||
int desired_torque = ((to_send->RDLR >> 16) && 0x1FFF);
|
||||
int desired_torque = ((to_send->RDLR >> 16) & 0x1FFF);
|
||||
int violation = 0;
|
||||
uint32_t ts = TIM2->CNT;
|
||||
desired_torque = to_signed(desired_torque, 13);
|
||||
|
|
|
@ -30,25 +30,20 @@ typedef struct
|
|||
uint32_t CNT;
|
||||
} TIM_TypeDef;
|
||||
|
||||
void set_controls_allowed(int c);
|
||||
int get_controls_allowed(void);
|
||||
void set_timer(int t);
|
||||
void reset_angle_control(void);
|
||||
|
||||
void init_tests_toyota(void);
|
||||
void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void toyota_init(int16_t param);
|
||||
void set_controls_allowed(int c);
|
||||
void reset_angle_control(void);
|
||||
int get_controls_allowed(void);
|
||||
void init_tests_toyota(void);
|
||||
void set_timer(int t);
|
||||
void set_toyota_torque_meas(int min, int max);
|
||||
void set_cadillac_torque_driver(int min, int max);
|
||||
void set_gm_torque_driver(int min, int max);
|
||||
void set_hyundai_torque_driver(int min, int max);
|
||||
void set_chrysler_torque_meas(int min, int max);
|
||||
void set_toyota_rt_torque_last(int t);
|
||||
void set_toyota_desired_torque_last(int t);
|
||||
int get_toyota_torque_meas_min(void);
|
||||
int get_toyota_torque_meas_max(void);
|
||||
int get_chrysler_torque_meas_min(void);
|
||||
int get_chrysler_torque_meas_max(void);
|
||||
void set_toyota_torque_meas(int min, int max);
|
||||
void set_toyota_desired_torque_last(int t);
|
||||
void set_toyota_rt_torque_last(int t);
|
||||
|
||||
void init_tests_honda(void);
|
||||
int get_ego_speed(void);
|
||||
|
@ -66,6 +61,7 @@ void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
|||
int cadillac_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void set_cadillac_desired_torque_last(int t);
|
||||
void set_cadillac_rt_torque_last(int t);
|
||||
void set_cadillac_torque_driver(int min, int max);
|
||||
|
||||
void init_tests_gm(void);
|
||||
void gm_init(int16_t param);
|
||||
|
@ -73,6 +69,7 @@ void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
|||
int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void set_gm_desired_torque_last(int t);
|
||||
void set_gm_rt_torque_last(int t);
|
||||
void set_gm_torque_driver(int min, int max);
|
||||
|
||||
void init_tests_hyundai(void);
|
||||
void nooutput_init(int16_t param);
|
||||
|
@ -80,6 +77,7 @@ void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
|||
int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void set_hyundai_desired_torque_last(int t);
|
||||
void set_hyundai_rt_torque_last(int t);
|
||||
void set_hyundai_torque_driver(int min, int max);
|
||||
|
||||
void toyota_ipas_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
int toyota_ipas_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
|
@ -89,6 +87,16 @@ void chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
|||
int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void set_chrysler_desired_torque_last(int t);
|
||||
void set_chrysler_rt_torque_last(int t);
|
||||
int get_chrysler_torque_meas_min(void);
|
||||
int get_chrysler_torque_meas_max(void);
|
||||
void set_chrysler_torque_meas(int min, int max);
|
||||
|
||||
void init_tests_subaru(void);
|
||||
void subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
void set_subaru_desired_torque_last(int t);
|
||||
void set_subaru_rt_torque_last(int t);
|
||||
void set_subaru_torque_driver(int min, int max);
|
||||
|
||||
|
||||
""")
|
||||
|
|
|
@ -26,7 +26,8 @@ struct sample_t toyota_torque_meas;
|
|||
struct sample_t cadillac_torque_driver;
|
||||
struct sample_t gm_torque_driver;
|
||||
struct sample_t hyundai_torque_driver;
|
||||
struct sample_t chrysler_torque_driver;
|
||||
struct sample_t chrysler_torque_meas;
|
||||
struct sample_t subaru_torque_driver;
|
||||
|
||||
TIM_TypeDef timer;
|
||||
TIM_TypeDef *TIM2 = &timer;
|
||||
|
@ -87,6 +88,11 @@ void set_chrysler_torque_meas(int min, int max){
|
|||
chrysler_torque_meas.max = max;
|
||||
}
|
||||
|
||||
void set_subaru_torque_driver(int min, int max){
|
||||
subaru_torque_driver.min = min;
|
||||
subaru_torque_driver.max = max;
|
||||
}
|
||||
|
||||
int get_chrysler_torque_meas_min(void){
|
||||
return chrysler_torque_meas.min;
|
||||
}
|
||||
|
@ -123,6 +129,10 @@ void set_chrysler_rt_torque_last(int t){
|
|||
chrysler_rt_torque_last = t;
|
||||
}
|
||||
|
||||
void set_subaru_rt_torque_last(int t){
|
||||
subaru_rt_torque_last = t;
|
||||
}
|
||||
|
||||
void set_toyota_desired_torque_last(int t){
|
||||
toyota_desired_torque_last = t;
|
||||
}
|
||||
|
@ -143,6 +153,10 @@ void set_chrysler_desired_torque_last(int t){
|
|||
chrysler_desired_torque_last = t;
|
||||
}
|
||||
|
||||
void set_subaru_desired_torque_last(int t){
|
||||
subaru_desired_torque_last = t;
|
||||
}
|
||||
|
||||
int get_ego_speed(void){
|
||||
return ego_speed;
|
||||
}
|
||||
|
@ -200,14 +214,23 @@ void init_tests_hyundai(void){
|
|||
}
|
||||
|
||||
void init_tests_chrysler(void){
|
||||
chrysler_torque_driver.min = 0;
|
||||
chrysler_torque_driver.max = 0;
|
||||
chrysler_torque_meas.min = 0;
|
||||
chrysler_torque_meas.max = 0;
|
||||
chrysler_desired_torque_last = 0;
|
||||
chrysler_rt_torque_last = 0;
|
||||
chrysler_ts_last = 0;
|
||||
set_timer(0);
|
||||
}
|
||||
|
||||
void init_tests_subaru(void){
|
||||
subaru_torque_driver.min = 0;
|
||||
subaru_torque_driver.max = 0;
|
||||
subaru_desired_torque_last = 0;
|
||||
subaru_rt_torque_last = 0;
|
||||
subaru_ts_last = 0;
|
||||
set_timer(0);
|
||||
}
|
||||
|
||||
void init_tests_honda(void){
|
||||
ego_speed = 0;
|
||||
gas_interceptor_detected = 0;
|
||||
|
|
Loading…
Reference in New Issue