-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix for #3863: STM Check can sync error #4329
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
Conversation
I would implement the timeout handling in both while loops, i.e. also after line 200. |
@ohagendorf I have added that for safety check, but the HW synchronization occurs only when going from init_mode to normal_mode. That's why I had put the timeout only on the 2nd while loop. |
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.
I found some code style inconsistencies, it would be nice if you could fix those please.
targets/TARGET_STM/can_api.c
Outdated
can_frequency(obj, 100000); | ||
if (can_frequency(obj, 100000) != 1) { | ||
error("Can frequency could not be set\n"); | ||
}; |
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.
;
is redundant
targets/TARGET_STM/can_api.c
Outdated
while ((can->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) { | ||
if((HAL_GetTick() - tickstart ) > 2) |
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.
Whitespace missing between if
and (
, also there's a redundant whitespace after tickstart
.
targets/TARGET_STM/can_api.c
Outdated
while ((can->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) { | ||
if((HAL_GetTick() - tickstart ) > 2) | ||
{ |
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.
Opening bracket should be on the same line with if
targets/TARGET_STM/can_api.c
Outdated
/* Get tick */ | ||
tickstart = HAL_GetTick(); | ||
while ((can->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) { | ||
if((HAL_GetTick() - tickstart ) > 2) |
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.
Same issues as above.
targets/TARGET_STM/can_api.c
Outdated
break; | ||
} | ||
} | ||
if (status ==0) { |
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.
One space is missing.
targets/TARGET_STM/can_api.c
Outdated
} | ||
} | ||
if (status ==0) { | ||
error("can ESR 0x%04x.%04x + timeout status %d", (can->ESR&0XFFFF0000)>>16, (can->ESR&0XFFFF), status); |
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.
Would add spaces around &
and >>
, also use lowercase 0x
prefix instead of 0X
.
targets/TARGET_STM/can_api.c
Outdated
} else { | ||
return 0; | ||
status=0; |
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.
Missing spaces.
Very good! There's still a redundant space on those lines: |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@adustm This needs a conflict resolved. |
@sg- Rebase done. Thanks |
Hello, Is it ok now ? |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Seems this is reliant on #4165 which had an API change and was thus targeted for 5.5.0 |
Description
Can init function needs 11 bits at the same level to synchronize to the CAN bus.
In some cases this cannot occur (refer to #3863 where the object is initialized at a lower frequency than the bus and the bus is very busy). We thus need a timeout mechanism to exit the init function.
in TARGET_STM/can_api.c:
Status
READY
Migrations
NO
Steps to test or reproduce
refer to #3863 : need a 1st device that overloads the CAN bus with a high frequency. Then try to initialize the 2nd device with a low frequency (or the default one at 100kHz).
The CAN object of the 2nd device will not output of the init function because the HW synchronization cannot occur
With this PR, you will be notified that the initialization could not occur.
cc @bperry730 @ohagendorf