-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hyundai Safety: Safety flags in one place #1964
Closed
+87
−74
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1856374
no need for hyundai legacy var
sunnyhaibin e50b9f8
safety flags in its own
sunnyhaibin 41402a9
use safety flag in tests
sunnyhaibin 11f2498
actually in the same file now
sunnyhaibin e6d18b1
do we need this?
sunnyhaibin 2fb2120
move around and comment
sunnyhaibin bce915c
more
sunnyhaibin fc3b4f6
let's use anon enum
sunnyhaibin 8a814fd
Revert "use safety flag in tests"
sunnyhaibin 08341dc
do we need to be this explicit?
sunnyhaibin 194d066
Merge branch 'master' into hyundai-safety-flags
sunnyhaibin 11d8a76
Merge remote-tracking branch 'commaai/opendbc/master' into hyundai-sa…
sunnyhaibin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,6 @@ static const CanMsg HYUNDAI_TX_MSGS[] = { | |
HYUNDAI_COMMON_TX_MSGS(0) | ||
}; | ||
|
||
static bool hyundai_legacy = false; | ||
|
||
static uint8_t hyundai_get_counter(const CANPacket_t *to_push) { | ||
int addr = GET_ADDR(to_push); | ||
|
||
|
@@ -271,6 +269,8 @@ static bool hyundai_fwd_hook(int bus_num, int addr) { | |
} | ||
|
||
static safety_config hyundai_init(uint16_t param) { | ||
hyundai_flags(param); | ||
|
||
static const CanMsg HYUNDAI_LONG_TX_MSGS[] = { | ||
HYUNDAI_LONG_COMMON_TX_MSGS(0) | ||
{0x38D, 0, 8, false}, // FCA11 Bus 0 | ||
|
@@ -286,9 +286,6 @@ static safety_config hyundai_init(uint16_t param) { | |
HYUNDAI_LONG_COMMON_TX_MSGS(2) | ||
}; | ||
|
||
hyundai_common_init(param); | ||
hyundai_legacy = false; | ||
|
||
safety_config ret; | ||
if (hyundai_longitudinal) { | ||
static RxCheck hyundai_long_rx_checks[] = { | ||
|
@@ -318,16 +315,14 @@ static safety_config hyundai_init(uint16_t param) { | |
} | ||
|
||
static safety_config hyundai_legacy_init(uint16_t param) { | ||
hyundai_flags(param); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a much more ambiguous name than |
||
|
||
// older hyundai models have less checks due to missing counters and checksums | ||
static RxCheck hyundai_legacy_rx_checks[] = { | ||
HYUNDAI_COMMON_RX_CHECKS(true) | ||
HYUNDAI_SCC12_ADDR_CHECK(0) | ||
}; | ||
|
||
hyundai_common_init(param); | ||
hyundai_legacy = true; | ||
hyundai_longitudinal = false; | ||
hyundai_camera_scc = false; | ||
return BUILD_SAFETY_CFG(hyundai_legacy_rx_checks, HYUNDAI_TX_MSGS); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#pragma once | ||
|
||
enum { | ||
HYUNDAI_PARAM_EV_GAS = 1, | ||
HYUNDAI_PARAM_HYBRID_GAS = 2, | ||
#ifdef ALLOW_DEBUG | ||
HYUNDAI_PARAM_LONGITUDINAL = 4, | ||
#endif | ||
HYUNDAI_PARAM_CAMERA_SCC = 8, | ||
HYUNDAI_PARAM_CANFD_LKA_STEERING = 16, // TODO: rename for support with CAN/CAN FD Blended platforms | ||
HYUNDAI_PARAM_CANFD_ALT_BUTTONS = 32, | ||
HYUNDAI_PARAM_ALT_LIMITS = 64, | ||
HYUNDAI_PARAM_CANFD_LKA_STEERING_ALT = 128, | ||
// HYUNDAI_PARAM_FCEV_GAS = 256, | ||
HYUNDAI_PARAM_ALT_LIMITS_2 = 512, | ||
}; | ||
|
||
// common flags | ||
extern bool hyundai_ev_gas_signal; | ||
bool hyundai_ev_gas_signal = false; | ||
|
||
extern bool hyundai_hybrid_gas_signal; | ||
bool hyundai_hybrid_gas_signal = false; | ||
|
||
extern bool hyundai_longitudinal; | ||
bool hyundai_longitudinal = false; | ||
|
||
extern bool hyundai_camera_scc; | ||
bool hyundai_camera_scc = false; | ||
|
||
extern bool hyundai_canfd_lka_steering; | ||
bool hyundai_canfd_lka_steering = false; | ||
|
||
//extern bool hyundai_fcev_gas_signal; | ||
//bool hyundai_fcev_gas_signal = false; | ||
|
||
// shared flags for non CAN FD cars | ||
extern bool hyundai_alt_limits; | ||
bool hyundai_alt_limits = false; | ||
|
||
extern bool hyundai_alt_limits_2; | ||
bool hyundai_alt_limits_2 = false; | ||
|
||
// shared flags for CAN FD cars | ||
extern bool hyundai_canfd_alt_buttons; | ||
bool hyundai_canfd_alt_buttons = false; | ||
|
||
extern bool hyundai_canfd_lka_steering_alt; | ||
bool hyundai_canfd_lka_steering_alt = false; | ||
|
||
void hyundai_common_flags(uint16_t param) { | ||
hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); | ||
hyundai_hybrid_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS); | ||
hyundai_camera_scc = GET_FLAG(param, HYUNDAI_PARAM_CAMERA_SCC); | ||
hyundai_canfd_lka_steering = GET_FLAG(param, HYUNDAI_PARAM_CANFD_LKA_STEERING); | ||
// hyundai_fcev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_FCEV_GAS); | ||
|
||
#ifdef ALLOW_DEBUG | ||
hyundai_longitudinal = GET_FLAG(param, HYUNDAI_PARAM_LONGITUDINAL); | ||
#else | ||
hyundai_longitudinal = false; | ||
#endif | ||
} | ||
|
||
void hyundai_flags(uint16_t param) { | ||
hyundai_common_flags(param); | ||
|
||
hyundai_alt_limits = GET_FLAG(param, HYUNDAI_PARAM_ALT_LIMITS); | ||
hyundai_alt_limits_2 = GET_FLAG(param, HYUNDAI_PARAM_ALT_LIMITS_2); | ||
} | ||
|
||
void hyundai_canfd_flags(uint16_t param) { | ||
hyundai_common_flags(param); | ||
|
||
hyundai_canfd_lka_steering_alt = GET_FLAG(param, HYUNDAI_PARAM_CANFD_LKA_STEERING_ALT); | ||
hyundai_canfd_alt_buttons = GET_FLAG(param, HYUNDAI_PARAM_CANFD_ALT_BUTTONS); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep non-common bools where they are used