From ad623e19ec682f5c0d34fc0cb4a10b0dc2ea71b9 Mon Sep 17 00:00:00 2001 From: Qi Liu Date: Thu, 29 Feb 2024 09:21:34 -0800 Subject: [PATCH] fix occasional LKAS error --- board/safety/safety_defaults.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/board/safety/safety_defaults.h b/board/safety/safety_defaults.h index 26b52dd52d..00f593a10f 100644 --- a/board/safety/safety_defaults.h +++ b/board/safety/safety_defaults.h @@ -238,6 +238,10 @@ int default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } if ((addr == 284) && (bus_num == 0)) { + // the following two conditions are to stop spoofing + // when comma stops sending LKAS or ACC commands for whatever reason + // 284 is sent by the vehicle, and 502/658 is sent by comma, + // and they are sent in the same frequency (50Hz) if (counter_502 > 0) { counter_284_502 += 1; if (counter_284_502 - counter_502 > 25) { @@ -249,7 +253,7 @@ int default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } if (counter_658 > 0) { - counter_284_658 += 2; + counter_284_658 += 1; if (counter_284_658 - counter_658 > 25){ is_op_active = false; steer_type = 3;