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

Only run tx hooks on msgs in safety_config.tx_msgs. #1851

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ccdunder
Copy link

@ccdunder ccdunder commented Feb 26, 2025

#1838

Dependencies: #1867

TODO:

  • write a test for this
  • file an issue to track backfilling the missing hyundai_canfd test

@github-actions github-actions bot added the car safety vehicle-specific safety code label Feb 26, 2025
@ccdunder ccdunder force-pushed the issue1838 branch 2 times, most recently from 3fba360 to 447a45f Compare February 26, 2025 06:27
@sshane
Copy link
Contributor

sshane commented Feb 27, 2025

safety tests are failing

@sshane
Copy link
Contributor

sshane commented Feb 27, 2025

Are our tests wrong?

@ccdunder
Copy link
Author

tests are complaining about coverage for lines that no longer get hit.

also i got stuck in a bad state last night that was only recoverable by clearing scons cache. ugh

@ccdunder
Copy link
Author

ccdunder commented Feb 27, 2025

@sshane nooutput tx hook will never get exercised after this change. i'm going to exclude the line from coverage and misra and document it (though technically the misra checker didn't catch it anyway). if that's not acceptable for misra, let me know if there's an approach you'd generally take for this kind of thing. (i could always concoct a "test" to exercise that line but that seems convoluted.)

also, just to check, does tx hook should be filtered by address mean ignore length? (my guess is no but figured i'd ask in case you see this before the final code review)

@ccdunder

This comment was marked as outdated.

@ccdunder
Copy link
Author

ccdunder commented Feb 27, 2025

Just want to call out that it's certainly possible that some car models rely on the existing bad behavior. What's your rollout policy for potentially breaking changes?

  1. are harness failures acceptable in master? (anticipating they get reported before release)
  2. do you have a way to run this over all recent car segments to check for a regression?
  3. otherwise, it could be done as a dark launch. my hunch is this is overkill, but really can't say without knowing your policy.

@ccdunder
Copy link
Author

ccdunder commented Feb 27, 2025

also this seems like something that should really have a test but there doesn't seem to be a simple way to do right now with adding new test infra. i'm assuming (& hoping) you want that in the same PR, but just calling out that it will make it larger.

Just to be clear, I believe making it larger is the right thing to do based on my principles as follow. Please let me know if you require something different:

i'm not backfilling existing missing tests (in hyundai_canfd) (since they're already missing so this strictly improves the codebase regardless). i am adding a test for the behavior this modifies (since not doing so strictly worsens the codebase by making bugs like this possible).

@ccdunder
Copy link
Author

ccdunder commented Feb 27, 2025

TIL the coverage report uses a different tool (lcov) than the coverage test (gcov). gcov doesn't support exclusion markers easily. gcovr does. will send a separate PR to add support for exclusion from gcov.

@ccdunder
Copy link
Author

safety tests pass with #1867. will figure out some decent way of testing this behavior next

@@ -198,9 +198,12 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) {
violation |= longitudinal_accel_checks(desired_accel_val, HYUNDAI_LONG_LIMITS);
} else {
// only used to cancel on here
// GCOV_EXCL_START
// TODO: Cover this with tests.
Copy link
Contributor

@sshane sshane Feb 27, 2025

Choose a reason for hiding this comment

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

Are you sure our test isn't accidentally sending this on the wrong bus? We should definitely hit this

Comment on lines +83 to +84
int raw_accel = ((GET_BYTE(to_send, 2) << 3) | (GET_BYTE(to_send, 3) >> 5)) - 1024U;
if (longitudinal_accel_checks(raw_accel, RIVIAN_LONG_LIMITS)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this because 0x160 is now blocked since it's not in the tx messages?

Copy link
Author

Choose a reason for hiding this comment

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

correct. the case where addr == 0x160 && !rivian_longitudinal becomes unreachable with this change.

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