From 0e229c0b6d29c5059edd65aa9c687def6731fbd3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Apr 2024 10:27:10 -0500 Subject: [PATCH] wip --- clearpilot_notes.txt | 14 +++++++++++++- panda/board/safety/safety_hyundai.h | 16 ++++++++-------- selfdrive/car/hyundai/carcontroller.py | 4 +++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/clearpilot_notes.txt b/clearpilot_notes.txt index 655645d..14f591e 100644 --- a/clearpilot_notes.txt +++ b/clearpilot_notes.txt @@ -1,3 +1,15 @@ example of using stdin and stdout as a message buffer: -selfdrive/manager/build.py \ No newline at end of file +selfdrive/manager/build.py + +pandacan: pandacan is a user space library for talking to your car over USB or Wi-Fi from Python. It allows full read/write access to all the CAN and LIN buses. “pip install pandacan” + +SocketCAN: SocketCAN is the Linux standard for CAN interfaces. The included driver allows panda to work with all SocketCAN tools, including can-utils and Wireshark. + +SunnyPilot lfa btn: +class HyundaiFlagsSP(IntFlag): + SP_ENHANCED_SCC = 1 + SP_CAN_LFA_BTN = 2 + SP_NAV_MSG = 4 +LFA_Pressed + 188,47: self.lkas_enabled = cp.vl["BCM_PO_11"]["LFA_Pressed"] \ No newline at end of file diff --git a/panda/board/safety/safety_hyundai.h b/panda/board/safety/safety_hyundai.h index 49565b9..1fccf13 100644 --- a/panda/board/safety/safety_hyundai.h +++ b/panda/board/safety/safety_hyundai.h @@ -283,16 +283,16 @@ static bool hyundai_tx_hook(const CANPacket_t *to_send) { if ((addr == 0x4F1) && !hyundai_longitudinal) { int button = GET_BYTE(to_send, 0) & 0x7U; - // bool allowed_resume = (button == 1) && controls_allowed; - // bool allowed_cancel = (button == 4) && cruise_engaged_prev; - // if (!(allowed_resume || allowed_cancel)) { - // tx = false; - // } - - // CLEARPILOT - Allow buttons 1 (accel), 2 (decel), 4 (pause/resume) - if (!(button == 1 || button == 2 || button == 3)) { + bool allowed_resume = (button == 1) && controls_allowed; + bool allowed_cancel = (button == 4) && cruise_engaged_prev; + if (!(allowed_resume || allowed_cancel)) { tx = false; } + + // CLEARPILOT - Allow buttons 1 (accel), 2 (decel), 4 (pause/resume) + // if (!(button == 1 || button == 2 || button == 3)) { + // tx = false; + // } } return tx; diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index a61da9f..12d736e 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -121,7 +121,9 @@ class CarController(CarControllerBase): # LFA and HDA icons if self.frame % 5 == 0 and (not hda2 or hda2_long): - can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled, CC.latActive)) + # CLEARPILOT TEST self.CS.lkas_enabled + # can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled, CC.latActive)) + can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CS.lkas_enabled, CS.lkas_enabled)) # blinkers if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS: