Changed logic to ignore all unwanted can frames#69
Merged
tridge merged 1 commit intodronecan:masterfrom Jul 12, 2025
Merged
Conversation
4379e8f to
81c212f
Compare
tridge
requested changes
Jul 11, 2025
81c212f to
588e4fd
Compare
Member
|
@berman00 I've force-pushed the change to do it the more efficient way |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, libcanard only calls the should_accept function on the first frame of a multiframe transfer. This means that the following frames will cause a CANARD_ERROR_RX_MISSED_START. I would be better if it returned a CANARD_ERROR_RX_NOT_WANTED instead, which is a better description of the problem.
The reason I came across this was that I connected a microcontroller with libcanard to a Flight controller running Ardupilot. I don't care about the ardupilot messages, so my should_accept function ignores them. However, I do care about possible errors on the CAN bus to monitor the health of the system, so I keep track of CANARD_ERROR_RX_MISSED_START as well as other CAN bus related errors. The way it is currently implemented, it is impossible to distinguish between a missed started because of an unwanted multiframe message or a missed start caused by an actual problem with the system. With this change all unwanted frames are ignored.
Here is the output of the serial monitor that I was using to debug.
Before the change:
I was logging all received messages through libcanard, as well as CANARD_ERROR_RX_NOT_WANTED and CANARD_ERROR_RX_MISSED_START. The microcontroller is connected to an ardupilot flight controller that is sendig a bunch of ardupilot messages, which I don't care about. As you can see, both errors are present.
After the change
Now only the CANARD_ERROR_RX_NOT_WANTED is the only error present, which in my application I can safely ignore.