-
Notifications
You must be signed in to change notification settings - Fork 0
state rejection reasons #351
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
Open
chpy04
wants to merge
6
commits into
develop
Choose a base branch
from
#330-state-transition-rejection-reasons
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a4c7710
state rejection reasons
chpy04 8fa5828
bit shift in enum values
chpy04 ae68bef
add to 1
chpy04 60413b5
right size for state
chpy04 b0ba15f
another size issue
chpy04 ff12e35
check both conditions before short circuit
chpy04 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -44,9 +44,9 @@ static bool enter_drive_enabled = false; | |
| static void send_nero_msg(dti_t *mc) | ||
| { | ||
| bitstream_t nero_msg; | ||
| uint8_t bitstream_data[6]; | ||
| uint8_t bitstream_data[7]; | ||
| bitstream_init(&nero_msg, bitstream_data, | ||
| 6); // Create 5-byte bitstream | ||
| 7); // Create 5-byte bitstream | ||
|
|
||
| bitstream_add(&nero_msg, get_nero_state().home_mode, 4); | ||
| bitstream_add(&nero_msg, get_nero_state().nero_index, 4); | ||
|
|
@@ -56,6 +56,7 @@ static void send_nero_msg(dti_t *mc) | |
| bitstream_add(&nero_msg, cerberus_state.functional != F_REVERSE, 1); | ||
| bitstream_add(&nero_msg, get_regen_limit(), 10); | ||
| bitstream_add(&nero_msg, get_launch_control(), 1); | ||
| bitstream_add(&nero_msg, cerberus_state.transition_error, 8); | ||
|
|
||
| can_msg_t msg = { .id = 0x501, .len = sizeof(bitstream_data) }; | ||
|
|
||
|
|
@@ -119,6 +120,7 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, | |
| case F_REVERSE: | ||
| #ifdef DISABLE_REVERSE | ||
| printf("Reverse is disabled."); | ||
| cerberus_state.transition_error = (1 << REVERSE_DISABLED); | ||
|
Contributor
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. with the above comment, then just OR |
||
| return 4; | ||
| #endif | ||
| osTimerStart(reverse_sound_timer, pdMS_TO_TICKS(500)); | ||
|
|
@@ -132,10 +134,18 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, | |
| (!brake_state || | ||
| cerberus_state.functional == | ||
| FAULTED)) { // only enforce brake / fault if tsms is actually on | ||
| if (!brake_state) { | ||
| cerberus_state.transition_error |= ENTER_DRIVE_BREAKS_NOT_ENGAGED; | ||
| } | ||
| if (cerberus_state.functional == FAULTED) { | ||
| cerberus_state.transition_error |= DRIVE_FROM_FAULT; | ||
| } | ||
| return 3; | ||
| } | ||
| printf("Ignoring tsms\n\n"); | ||
| #else | ||
| cerberus_state.transition_error |= (cerberus_state.functional == FAULTED ? DRIVE_FROM_FAULT : 0); | ||
| cerberus_state.transition_error |= (!enter_drive_enabled ? ENTER_DRIVE_DISABLED : 0); | ||
| if (cerberus_state.functional == FAULTED) { | ||
| printf("Cannot drive from a fault!\n"); | ||
| return 3; | ||
|
|
@@ -148,6 +158,12 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, | |
|
|
||
| /* Only turn on motor if brakes engaged and tsms is on */ | ||
| if (!brake_state || !get_tsms()) { | ||
| if (!brake_state) { | ||
| cerberus_state.transition_error |= ENTER_DRIVE_BREAKS_NOT_ENGAGED; | ||
| } | ||
| if (!get_tsms()) { | ||
| cerberus_state.transition_error |= ENTER_DRIVE_TSMS_OFF; | ||
| } | ||
| return 3; | ||
| } | ||
| #endif | ||
|
|
@@ -196,6 +212,12 @@ static int transition_nero_state(nero_state_t new_state, pdu_t *pdu, dti_t *mc, | |
| if (new_state.nero_index == GAMES) { | ||
| #ifndef TSMS_OVERRIDE | ||
| if (get_tsms() || dti_get_mph(mc) >= 1) { | ||
| if (get_tsms()) { | ||
| cerberus_state.transition_error |= ENTER_GAMES_TSMS_ON; | ||
| } | ||
| if (dti_get_mph(mc) >= 1) { | ||
| cerberus_state.transition_error |= ENTER_GAMES_WHILE_MOVING; | ||
| } | ||
| return 1; | ||
| } | ||
| #endif | ||
|
|
@@ -319,6 +341,7 @@ void rising_ts_cb(void *args) | |
| void vStateMachineDirector(void *pv_params) | ||
| { | ||
| cerberus_state.functional = READY; | ||
| cerberus_state.transition_error = START_TRANSITION_OK; | ||
| cerberus_state.nero.nero_index = 0; | ||
| cerberus_state.nero.home_mode = true; | ||
|
|
||
|
|
||
Submodule Embedded-Base
updated
10 files
Oops, something went wrong.
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.
just so you dont have to it bitshift these in the code later you coulddo it like this:
Then you can just OR them together with no bit shift