wip
This commit is contained in:
@@ -21,18 +21,21 @@ const SteeringLimits HYUNDAI_CANFD_STEERING_LIMITS = {
|
||||
const CanMsg HYUNDAI_CANFD_HDA2_TX_MSGS[] = {
|
||||
{0x50, 0, 16}, // LKAS
|
||||
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
||||
{426, 1, 16}, // CRUISE_BUTTONS_ALT
|
||||
{0x2A4, 0, 24}, // CAM_0x2A4
|
||||
};
|
||||
|
||||
const CanMsg HYUNDAI_CANFD_HDA2_ALT_STEERING_TX_MSGS[] = {
|
||||
{0x110, 0, 32}, // LKAS_ALT
|
||||
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
||||
{426, 1, 16}, // CRUISE_BUTTONS_ALT
|
||||
{0x362, 0, 32}, // CAM_0x362
|
||||
};
|
||||
|
||||
const CanMsg HYUNDAI_CANFD_HDA2_LONG_TX_MSGS[] = {
|
||||
{0x50, 0, 16}, // LKAS
|
||||
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
||||
{426, 1, 16}, // CRUISE_BUTTONS_ALT
|
||||
{0x2A4, 0, 24}, // CAM_0x2A4
|
||||
{0x51, 0, 32}, // ADRV_0x51
|
||||
{0x730, 1, 8}, // tester present for ADAS ECU disable
|
||||
@@ -70,6 +73,9 @@ const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = {
|
||||
#define HYUNDAI_CANFD_ALT_BUTTONS_ADDR_CHECK(pt_bus) \
|
||||
{.msg = {{0x1aa, (pt_bus), 16, .check_checksum = false, .max_counter = 0xffU, .frequency = 50U}, { 0 }, { 0 }}}, \
|
||||
|
||||
#define HYUNDAI_CANFD_ALT_BUTTONS_ADDR_CHECK(pt_bus) \
|
||||
{.msg = {{0x1aa, (pt_bus), 16, .check_checksum = false, .max_counter = 0xffU, .frequency = 50U}, { 0 }, { 0 }}}, \
|
||||
|
||||
// SCC_CONTROL (from ADAS unit or camera)
|
||||
#define HYUNDAI_CANFD_SCC_ADDR_CHECK(scc_bus) \
|
||||
{.msg = {{0x1a0, (scc_bus), 32, .check_checksum = true, .max_counter = 0xffU, .frequency = 50U}, { 0 }, { 0 }}}, \
|
||||
@@ -159,6 +165,74 @@ static void hyundai_canfd_rx_hook(const CANPacket_t *to_push) {
|
||||
const int pt_bus = hyundai_canfd_hda2 ? 1 : 0;
|
||||
const int scc_bus = hyundai_camera_scc ? 2 : pt_bus;
|
||||
|
||||
// Todo: test:
|
||||
// BO_ 1345 CGW1: 8 BCM
|
||||
// SG_ C_SunRoofOpenState : 57|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,DATC,IBOX,DATC,IBOX
|
||||
// BO_ 68 DATC11: 8 DATC
|
||||
// SG_ CR_Datc_OutTempC : 24|8@1+ (0.5,-41.0) [-41.0|86.5] "deg" CLU,FPCM
|
||||
// SG_ CR_Datc_OutTempF : 32|8@1+ (1.0,-42.0) [-42.0|213.0] "deg" CLU
|
||||
// SG_ CF_Datc_IncarTemp : 40|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" BCM,CLU
|
||||
// BO_ 64 DATC14: 8 DATC
|
||||
// SG_ CF_Datc_AqsLevelOut : 0|4@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ CF_Datc_DiagMode : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ CR_Datc_SelfDiagCode : 8|8@1+ (1.0,-1.0) [0.0|254.0] "" CLU
|
||||
// SG_ DATC_SyncDisp : 16|4@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ DATC_OffDisp : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ DATC_SmartVentDisp : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ DATC_SmartVentOnOffStatus : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ DATC_AutoDefogSysOff_Disp : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// SG_ DATC_ADSDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU
|
||||
// VAL_ 1144 DRIVE_MODE2 3 "Set Sport" 1 "Set Normal" 2 "Set Eco";
|
||||
// BO_ 1151 HVAC_TOUCH_BUTTONS: 8 XXX
|
||||
// SG_ AUTO_BUTTON : 8|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ SYNC_BUTTON : 12|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ FR_DEFROST_BUTTON : 20|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ RR_DEFROST_BUTTON : 22|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ FAN_SPEED_UP_BUTTON : 24|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ FAN_SPEED_DOWN_BUTTON : 26|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ AIR_DIRECTION_BUTTON : 28|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ AC_BUTTON : 40|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ DRIVER_ONLY_BUTTON : 44|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ RECIRC_BUTTON : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
// SG_ HEAT_BUTTON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
// BO_ 304 GEAR_SHIFTER: 16 XXX
|
||||
// SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX
|
||||
// SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX
|
||||
// SG_ PARK_BUTTON : 32|2@1+ (1,0) [0|3] "" XXX
|
||||
// SG_ GEAR : 64|3@1+ (1,0) [0|7] "" XXX
|
||||
// SG_ KNOB_POSITION : 40|3@1+ (1,0) [0|3] "" XXX
|
||||
// BO_ 1322 CLU15: 8 CLU
|
||||
// SG_ CF_Clu_VehicleSpeed : 0|8@1+ (1.0,0.0) [0.0|255.0] "" BCM
|
||||
// SG_ CF_Clu_Gear : 9|4@1+ (1,0) [0|15] "" BCM
|
||||
// SG_ CF_Clu_HudInfoSet : 13|7@1+ (1.0,0.0) [0.0|127.0] "" HUD
|
||||
// SG_ CF_Clu_HudFontColorSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_HudBrightUpSW : 22|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_HudBrightDnSW : 24|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_HudHeightUpSW : 26|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_HudHeightDnSW : 28|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_HudSet : 30|1@1+ (1.0,0.0) [0.0|1.0] "" HUD
|
||||
// SG_ CF_Clu_HudFontSizeSet : 31|2@1+ (1.0,0.0) [0.0|3.0] "" HUD
|
||||
// SG_ CF_Clu_LanguageInfo : 33|5@1+ (1.0,0.0) [0.0|31.0] "" BCM,PGS
|
||||
// SG_ CF_Clu_ClusterSound : 38|1@1- (1.0,0.0) [0.0|0.0] "" BCM,CGW,FATC
|
||||
// SG_ CF_Clu_VehicleSpeed2 : 48|8@1+ (1,0) [0|255] "" XXX
|
||||
// BO_ 1292 CLU13: 8 CLU
|
||||
// SG_ CF_Clu_LowfuelWarn : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,FPCM,IBOX
|
||||
// SG_ CF_Clu_RefDetMod : 2|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX
|
||||
// SG_ CF_Clu_AvgFCU : 3|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX
|
||||
// SG_ CF_Clu_AvsmCur : 5|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,SCC
|
||||
// SG_ CF_Clu_AvgFCI : 6|10@1+ (0.1,0.0) [0.0|102.2] "" IBOX
|
||||
// SG_ CF_Clu_DrivingModeSwi : 16|2@1+ (1.0,0.0) [0.0|3.0] "" DATC,ECS,EMS,ESC,IAP,MDPS,TCU
|
||||
// SG_ CF_Clu_FuelDispLvl : 18|5@1+ (1.0,0.0) [0.0|31.0] "" CGW,IBOX
|
||||
// SG_ CF_Clu_FlexSteerSW : 23|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS
|
||||
// SG_ CF_Clu_DTE : 24|10@1+ (1.0,0.0) [0.0|1023.0] "" DATC
|
||||
// SG_ CF_Clu_TripUnit : 34|2@1+ (1.0,0.0) [0.0|3.0] "" DATC
|
||||
// SG_ CF_Clu_SWL_Stat : 36|3@1+ (1.0,0.0) [0.0|7.0] "" ACU,EMS
|
||||
// SG_ CF_Clu_ActiveEcoSW : 39|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,EMS,TCU
|
||||
// SG_ CF_Clu_EcoDriveInf : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CUBIS,EMS,IAP,IBOX
|
||||
// SG_ CF_Clu_IsaMainSW : 43|1@1+ (1.0,0.0) [0.0|1.0] "" EMS
|
||||
// SG_ CF_Clu_LdwsLkasSW : 56|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS
|
||||
// SG_ CF_Clu_AltLStatus : 59|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,DATC,EMS
|
||||
// SG_ CF_Clu_AliveCnt2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,LDWS_LKAS
|
||||
if (bus == pt_bus) {
|
||||
// driver torque
|
||||
if (addr == 0xea) {
|
||||
@@ -168,6 +242,7 @@ static void hyundai_canfd_rx_hook(const CANPacket_t *to_push) {
|
||||
}
|
||||
|
||||
// cruise buttons
|
||||
// todo: allow paddle shifter presses through
|
||||
const int button_addr = hyundai_canfd_alt_buttons ? 0x1aa : 0x1cf;
|
||||
if (addr == button_addr) {
|
||||
bool main_button = false;
|
||||
@@ -243,16 +318,83 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) {
|
||||
}
|
||||
|
||||
// cruise buttons check
|
||||
if (addr == 0x1cf) {
|
||||
int button = GET_BYTE(to_send, 2) & 0x7U;
|
||||
bool is_cancel = (button == HYUNDAI_BTN_CANCEL);
|
||||
bool is_resume = (button == HYUNDAI_BTN_RESUME);
|
||||
/*
|
||||
BO_ 463 CRUISE_BUTTONS: 8 XXX
|
||||
SG_ _CHECKSUM : 0|8@1+ (1,0) [0|65535] "" XXX
|
||||
SG_ LKAS_BTN : 23|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_1 : 29|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ ADAPTIVE_CRUISE_MAIN_BTN : 19|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ NORMAL_CRUISE_MAIN_BTN : 21|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 12|4@1+ (1,0) [0|255] "" XXX
|
||||
SG_ CRUISE_BUTTONS : 16|3@1+ (1,0) [0|3] "" XXX
|
||||
*/
|
||||
|
||||
bool allowed = (is_cancel && cruise_engaged_prev) || (is_resume && controls_allowed);
|
||||
if (!allowed) {
|
||||
tx = false;
|
||||
}
|
||||
}
|
||||
// Pass all desired buttons for now
|
||||
// if (addr == 0x1cf) {
|
||||
// int button = GET_BYTE(to_send, 2) & 0x7U;
|
||||
// bool is_cancel = (button == HYUNDAI_BTN_CANCEL);
|
||||
// bool is_resume = (button == HYUNDAI_BTN_RESUME);
|
||||
// bool is_set = (button == HYUNDAI_BTN_SET);
|
||||
|
||||
// bool allowed =
|
||||
// (is_cancel && cruise_engaged_prev) ||
|
||||
// (is_resume && controls_allowed);
|
||||
// (is_set && controls_allowed)
|
||||
// ;
|
||||
|
||||
// if (!allowed) {
|
||||
// tx = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// 'alt' buttons check
|
||||
/*
|
||||
|
||||
BO_ 426 CRUISE_BUTTONS_ALT: 16 XXX
|
||||
SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX
|
||||
SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ NEW_SIGNAL_1 : 24|4@1+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_ME_1 : 28|2@1+ (1,0) [0|3] "" XXX
|
||||
SG_ DISTANCE_UNIT : 30|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ NEW_SIGNAL_2 : 31|3@1+ (1,0) [0|7] "" XXX
|
||||
SG_ ADAPTIVE_CRUISE_MAIN_BTN : 34|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ NEW_SIGNAL_3 : 35|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ LFA_BTN : 39|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ CRUISE_BUTTONS : 36|3@1+ (1,0) [0|4] "" XXX
|
||||
SG_ NEW_SIGNAL_4 : 40|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ NORMAL_CRUISE_MAIN_BTN : 41|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ NEW_SIGNAL_5 : 42|2@1+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_2 : 44|3@1+ (1,0) [0|7] "" XXX
|
||||
SG_ NEW_SIGNAL_6 : 47|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ BYTE6 : 48|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE7 : 56|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE8 : 64|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE9 : 72|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE10 : 80|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE11 : 88|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE12 : 96|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE13 : 104|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE14 : 112|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ BYTE15 : 120|8@1+ (1,0) [0|255] "" XXX
|
||||
*/
|
||||
|
||||
// HVAC
|
||||
/*
|
||||
BO_ 1151 HVAC_TOUCH_BUTTONS: 8 XXX
|
||||
SG_ AUTO_BUTTON : 8|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SYNC_BUTTON : 12|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ FR_DEFROST_BUTTON : 20|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ RR_DEFROST_BUTTON : 22|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ FAN_SPEED_UP_BUTTON : 24|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ FAN_SPEED_DOWN_BUTTON : 26|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ AIR_DIRECTION_BUTTON : 28|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ AC_BUTTON : 40|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DRIVER_ONLY_BUTTON : 44|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ RECIRC_BUTTON : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ HEAT_BUTTON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
*/
|
||||
|
||||
// UDS: only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address
|
||||
if ((addr == 0x730) && hyundai_canfd_hda2) {
|
||||
|
||||
Reference in New Issue
Block a user