@@ -105,7 +105,8 @@ const CanMsg SUBARU_GEN2_TX_MSGS[] = {
105
105
};
106
106
107
107
const CanMsg SUBARU_LKAS_ANGLE_TX_MSGS [] = {
108
- SUBARU_COMMON_TX_MSGS (SUBARU_MAIN_BUS , MSG_SUBARU_ES_LKAS_ANGLE )
108
+ SUBARU_COMMON_TX_MSGS (SUBARU_ALT_BUS , MSG_SUBARU_ES_LKAS_ANGLE )
109
+ SUBARU_COMMON_TX_MSGS (SUBARU_ALT_BUS , MSG_SUBARU_ES_LKAS )
109
110
};
110
111
111
112
const CanMsg SUBARU_GEN2_LONG_TX_MSGS [] = {
@@ -152,7 +153,7 @@ static uint32_t subaru_compute_checksum(const CANPacket_t *to_push) {
152
153
153
154
static void subaru_rx_hook (const CANPacket_t * to_push ) {
154
155
const int bus = GET_BUS (to_push );
155
- const int alt_main_bus = subaru_gen2 ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS ;
156
+ const int alt_main_bus = ( subaru_gen2 || subaru_lkas_angle ) ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS ;
156
157
const int stock_lkas_msg = subaru_lkas_angle ? MSG_SUBARU_ES_LKAS_ANGLE : MSG_SUBARU_ES_LKAS ;
157
158
158
159
int addr = GET_ADDR (to_push );
@@ -169,15 +170,18 @@ static void subaru_rx_hook(const CANPacket_t *to_push) {
169
170
}
170
171
171
172
// enter controls on rising edge of ACC, exit controls on ACC off
172
- if ((addr == MSG_SUBARU_CruiseControl ) && (bus == alt_main_bus )) {
173
- bool cruise_engaged = GET_BIT (to_push , 41U );
174
- pcm_cruise_check (cruise_engaged );
175
-
176
- }
177
- else if (subaru_lkas_angle && (addr == MSG_SUBARU_ES_DashStatus ) && (bus == SUBARU_CAM_BUS )) {
173
+ if (subaru_lkas_angle ) {
178
174
// LKAS Angle cars use different message
179
- bool cruise_engaged = GET_BIT (to_push , 36U );
180
- pcm_cruise_check (cruise_engaged );
175
+ if ((addr == MSG_SUBARU_ES_DashStatus ) && (bus == SUBARU_CAM_BUS )) {
176
+ bool cruise_engaged = GET_BIT (to_push , 36U );
177
+ pcm_cruise_check (cruise_engaged );
178
+ }
179
+ } else {
180
+ if ((addr == MSG_SUBARU_CruiseControl ) && (bus == alt_main_bus )) {
181
+ bool cruise_engaged = GET_BIT (to_push , 41U );
182
+ pcm_cruise_check (cruise_engaged );
183
+
184
+ }
181
185
}
182
186
183
187
// update vehicle moving with any non-zero wheel speed
@@ -310,7 +314,7 @@ static safety_config subaru_init(uint16_t param) {
310
314
311
315
safety_config ret ;
312
316
if (subaru_lkas_angle ) {
313
- ret = BUILD_SAFETY_CFG (subaru_rx_checks , SUBARU_LKAS_ANGLE_TX_MSGS );
317
+ ret = BUILD_SAFETY_CFG (subaru_gen2_rx_checks , SUBARU_LKAS_ANGLE_TX_MSGS );
314
318
}
315
319
else if (subaru_gen2 ) {
316
320
ret = subaru_longitudinal ? BUILD_SAFETY_CFG (subaru_gen2_rx_checks , SUBARU_GEN2_LONG_TX_MSGS ) : \
0 commit comments