Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

sunnyhaibin
Copy link
Contributor

@sunnyhaibin sunnyhaibin commented Mar 9, 2025

  • Split from Hyundai Safety: Safety flags in one place #1964
  • Moves all Hyundai safety flags to safety_hyundai_flags.h:
    • Common flags
    • CAN-specific flags
    • CAN FD-specific flags
  • Creates three dedicated flag initialization functions:
    • hyundai_common_flags
    • hyundai_flags
    • hyundai_canfd_flags
  • Changes static variables to extern declarations
  • Removes:
    • Redundant initializations
    • Unused hyundai_legacy variable
    • Scattered flag handling code
  • Part of Clean up Hyundai safety and car interface #1942

@github-actions github-actions bot added the car safety vehicle-specific safety code label Mar 9, 2025
@sunnyhaibin sunnyhaibin force-pushed the hyundai-safety-flags branch from d0d8f83 to e6d18b1 Compare March 9, 2025 15:23
sunnyhaibin added a commit to sunnypilot/opendbc that referenced this pull request Mar 10, 2025
sunnyhaibin added a commit to sunnypilot/opendbc that referenced this pull request Mar 10, 2025
This reverts commit c325de2.
Comment on lines 37 to 41
const int HYUNDAI_PARAM_EV_GAS = 1;
const int HYUNDAI_PARAM_HYBRID_GAS = 2;
const int HYUNDAI_PARAM_CAMERA_SCC = 8;
const int HYUNDAI_PARAM_CANFD_LKA_STEERING = 16; // TODO: rename for support with CAN/CAN FD Blended platforms
const int HYUNDAI_PARAM_FCEV_GAS = 256;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't feel any cleaner and still has the same issue of out of order flags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try using anonymous enum, similar to this:

enum {
HYUNDAI_BTN_NONE = 0,
HYUNDAI_BTN_RESUME = 1,
HYUNDAI_BTN_SET = 2,
HYUNDAI_BTN_CANCEL = 4,
};

@@ -318,16 +315,14 @@ static safety_config hyundai_init(uint16_t param) {
}

static safety_config hyundai_legacy_init(uint16_t param) {
hyundai_flags(param);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a much more ambiguous name than hyundai_common_init

@@ -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;
Copy link
Contributor

@sshane sshane Mar 12, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
car safety vehicle-specific safety code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants