@@ -87,7 +87,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) {
8787
8888 // check ACC main state
8989 // 0x326 for all Bosch and some Nidec, 0x1A6 for some Nidec
90- if ((addr == 0x326 ) || (addr == 0x1A6 )) {
90+ if ((( addr == 0x326 ) && ( bus == pt_bus ) ) || (addr == 0x1A6 )) {
9191 acc_main_on = GET_BIT (to_push , ((addr == 0x326 ) ? 28U : 47U ));
9292 if (!acc_main_on ) {
9393 controls_allowed = false;
@@ -173,6 +173,11 @@ static void honda_rx_hook(const CANPacket_t *to_push) {
173173 int bus_rdr_car = (honda_hw == HONDA_BOSCH ) ? 0 : 2 ; // radar bus, car side
174174 bool stock_ecu_detected = false;
175175
176+ // // TODO: tick the body harness gatewayheartbeat. If we lose contact with the OP, should we go not controls_allowed???
177+ // if ((addr == 0x801) && (len == 8)) {
178+ //
179+ // }
180+
176181 // If steering controls messages are received on the destination bus, it's an indication
177182 // that the relay might be malfunctioning
178183 if ((addr == 0xE4 ) || (addr == 0x194 )) {
@@ -197,6 +202,7 @@ static bool honda_tx_hook(const CANPacket_t *to_send) {
197202 .min_accel = -350 ,
198203
199204 .max_gas = 2000 ,
205+ .min_gas = -40 ,
200206 .inactive_gas = -30000 ,
201207 };
202208
@@ -299,11 +305,29 @@ static bool honda_tx_hook(const CANPacket_t *to_send) {
299305 }
300306 }
301307
308+ // KWP over CAN. Allow only short turn signal request and cancel
309+ // TODO: move to gateway firmware
310+ if (addr == 0x16F118F0 ){
311+ bool signalCmd = ((GET_LEN (to_send ) == 8U ) && ((GET_BYTES (to_send , 0 , 4 ) == 0x000F0A30U ) || (GET_BYTES (to_send , 0 , 4 ) == 0x000F0B30U )) && (GET_BYTES (to_send , 4 , 4 ) == 0x0U ));
312+ bool cancelCmd = ((GET_LEN (to_send ) == 1U ) && (GET_BYTE (to_send , 0 ) == 0x20U ));
313+ // always allow cancel
314+ if (!cancelCmd ) {
315+ if (!controls_allowed ) {
316+ tx = false;
317+ }
318+ else {
319+ if (!signalCmd ) {
320+ tx = false;
321+ }
322+ }
323+ }
324+ }
325+
302326 return tx ;
303327}
304328
305329static safety_config honda_nidec_init (uint16_t param ) {
306- static CanMsg HONDA_N_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x194 , 0 , 4 }, {0x1FA , 0 , 8 }, {0x30C , 0 , 8 }, {0x33D , 0 , 5 }};
330+ static CanMsg HONDA_N_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x194 , 0 , 4 }, {0x1FA , 0 , 8 }, {0x30C , 0 , 8 }, {0x33D , 0 , 5 }, { 0x16F118F0 , 0 , 8 }, { 0x16F118F0 , 0 , 1 } };
307331
308332 const uint16_t HONDA_PARAM_NIDEC_ALT = 4 ;
309333
@@ -321,7 +345,7 @@ static safety_config honda_nidec_init(uint16_t param) {
321345
322346 if (enable_nidec_alt ) {
323347 // For Nidecs with main on signal on an alternate msg (missing 0x326)
324- static RxCheck honda_nidec_alt_rx_checks [] = {
348+ static RxCheck honda_nidec_alt_rx_checks [] = {
325349 HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS (0 )
326350 };
327351
@@ -336,10 +360,10 @@ static safety_config honda_nidec_init(uint16_t param) {
336360}
337361
338362static safety_config honda_bosch_init (uint16_t param ) {
339- static CanMsg HONDA_BOSCH_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0xE5 , 0 , 8 }, {0x296 , 1 , 4 }, {0x33D , 0 , 5 }, {0x33DA , 0 , 5 }, {0x33DB , 0 , 8 }} ; // Bosch
340- static CanMsg HONDA_BOSCH_LONG_TX_MSGS [] = {{0xE4 , 1 , 5 }, {0x1DF , 1 , 8 }, {0x1EF , 1 , 8 }, {0x1FA , 1 , 8 }, {0x30C , 1 , 8 }, {0x33D , 1 , 5 }, {0x33DA , 1 , 5 }, {0x33DB , 1 , 8 }, {0x39F , 1 , 8 }, {0x18DAB0F1 , 1 , 8 }}; // Bosch w/ gas and brakes
341- static CanMsg HONDA_RADARLESS_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x296 , 2 , 4 }, {0x33D , 0 , 8 }}; // Bosch radarless
342- static CanMsg HONDA_RADARLESS_LONG_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x33D , 0 , 8 }, {0x1C8 , 0 , 8 }, {0x30C , 0 , 8 }}; // Bosch radarless w/ gas and brakes
363+ static CanMsg HONDA_BOSCH_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0xE5 , 0 , 8 }, {0x296 , 1 , 4 }, {0x33D , 0 , 5 }, {0x33DA , 0 , 5 }, {0x33DB , 0 , 8 }, { 0x16F118F0 , 0 , 8 }, { 0x16F118F0 , 0 , 1 }} ; // Bosch w/ body
364+ static CanMsg HONDA_BOSCH_LONG_TX_MSGS [] = {{0xE4 , 1 , 5 }, {0x1DF , 1 , 8 }, {0x1EF , 1 , 8 }, {0x1FA , 1 , 8 }, {0x30C , 1 , 8 }, {0x33D , 1 , 5 }, {0x33DA , 1 , 5 }, {0x33DB , 1 , 8 }, {0x39F , 1 , 8 }, {0x16F118F0 , 0 , 8 }, { 0x16F118F0 , 0 , 1 }, { 0x18DAB0F1 , 1 , 8 }}; // Bosch w/ gas and brakes and body
365+ static CanMsg HONDA_RADARLESS_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x296 , 2 , 4 }, {0x33D , 0 , 8 }, { 0x16F118F0 , 0 , 8 }, { 0x16F118F0 , 0 , 1 } }; // Bosch radarless
366+ static CanMsg HONDA_RADARLESS_LONG_TX_MSGS [] = {{0xE4 , 0 , 5 }, {0x33D , 0 , 8 }, {0x1C8 , 0 , 8 }, {0x30C , 0 , 8 }, { 0x16F118F0 , 0 , 8 }, { 0x16F118F0 , 0 , 1 } }; // Bosch radarless w/ gas and brakes
343367
344368 const uint16_t HONDA_PARAM_ALT_BRAKE = 1 ;
345369 const uint16_t HONDA_PARAM_RADARLESS = 8 ;
0 commit comments