AP_Scripting: Add filtering of incoming CAN frames #25703
Merged
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.
Add filters to the CAN buffer; mask is bitwise ANDed with the frame ID and compared to value. If not match, frame is not put to the receiving buffer
-- By default, no filters are added, and all frames are buffered, writing is not affected by filters
-- Maximum number of filters is 8 per buffer.
-- You can open as many buffers per driver as you want (every get_device() call creates a new buffer)
Usage : - driver:add_filter(mask, value) add a generic filted
- driver:add_DroneCAN_filter(message ID) to add filter for a DroneCan message.
Peter Hall rewrote my original version to a fully configurable, multi-buffer filter, so it is basically his code...
Use cases:
On a shared bus non-handled frames can be filtered out, making processing relevant frames easier and requiring less buffer and slower script update.
Can add script driver for composite DroneCAN devices with custom or experimental messages without the need for processing the frames that a non-script driver already handles. (Processing a single 1Hz custom message from a GPS/MAG device with maximum buffer size requires 5ms update time without filtering. A slower update or smaller buffer causes drop of messages)