-
-
Notifications
You must be signed in to change notification settings - Fork 87
CAN Filter and Mask #170
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
Merged
Merged
CAN Filter and Mask #170
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ec36500
CAN Filter and Mask
Woodwarth 378a3ce
Update CANReadFilter.ino
Woodwarth c345c88
Update libraries/Arduino_CAN/src/R7FA4M1_CAN.cpp
Woodwarth e3303ff
Update libraries/Arduino_CAN/src/R7FA4M1_CAN.cpp
Woodwarth c3cd8ec
Update libraries/Arduino_CAN/src/R7FA4M1_CAN.h
Woodwarth 649a07c
Update libraries/Arduino_CAN/src/R7FA4M1_CAN.h
Woodwarth a565370
Instead of relying on the user knowing internals of the CAN library -…
aentinger 1808bfa
Replace #define with a constant, use speaking names.
aentinger 432cb04
Rewrite filter id to be more convenient and failsafe.
aentinger 5ed7c63
Add missing NO = Number Of to constant name.
aentinger 8249937
Add newly added methods and constants to keywords.txt for syntax high…
aentinger 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
69 changes: 69 additions & 0 deletions
69
libraries/Arduino_CAN/examples/CANReadFilter/CANReadFilter.ino
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
CANRead | ||
|
||
Receive and read CAN Bus messages | ||
Read ID 0x100 EXTENDED and ID 0x10 STANDARD | ||
|
||
|
||
Mailbox Groups 0-3 (Mailbox 0-15) -> TRANSMIT | ||
Mailbox Groups 4-5 (Mailbox 16-23) -> RECEIVE EXTENDED | ||
Mailbox Groups 6-7 (Mailbox 24-31) -> RECEIVE STANDARD | ||
|
||
Mailbox Mask 5,7 are preset with 0x1FFFFFFF | ||
Mailbox Mask 4,6 are preset with 0x00 | ||
|
||
|
||
See the full documentation here: | ||
https://docs.arduino.cc/tutorials/uno-r4-wifi/can | ||
*/ | ||
|
||
/************************************************************************************** | ||
* INCLUDE | ||
**************************************************************************************/ | ||
|
||
#include <Arduino_CAN.h> | ||
|
||
/************************************************************************************** | ||
* CONST | ||
**************************************************************************************/ | ||
|
||
static uint32_t const CAN_FILTER_MASK_STANDARD = 0x1FFC0000; | ||
static uint32_t const CAN_FILTER_MASK_EXTENDED = 0x1FFFFFFF; | ||
|
||
/************************************************************************************** | ||
* SETUP/LOOP | ||
**************************************************************************************/ | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial) { } | ||
|
||
CAN.setFilterMask_Extended(CAN_FILTER_MASK_EXTENDED); | ||
CAN.setFilterMask_Standard(CAN_FILTER_MASK_STANDARD); | ||
|
||
for (int mailbox = 0; mailbox < R7FA4M1_CAN::CAN_MAX_NO_EXTENDED_MAILBOXES; mailbox++) | ||
{ | ||
CAN.setFilterId_Extended(mailbox, 0x0100); | ||
} | ||
|
||
for (int mailbox = 0; mailbox < R7FA4M1_CAN::CAN_MAX_NO_STANDARD_MAILBOXES; mailbox++) | ||
{ | ||
CAN.setFilterId_Standard(mailbox, 0x10); | ||
} | ||
|
||
if (!CAN.begin(CanBitRate::BR_250k)) | ||
{ | ||
Serial.println("CAN.begin(...) failed."); | ||
for (;;) {} | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
if (CAN.available()) | ||
{ | ||
CanMsg const msg = CAN.read(); | ||
Serial.println(msg); | ||
} | ||
} |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.