Comments (2)
Set both masks to 0x7FF and all the filters to 0x20A (522 in hex). That should guarantee only 522 is the only ID received.
num is the filter (0 to 5) or mask (0 to 1) to set.
ext tells the library if we are using extended (1) or standard (0) IDs.
ulData is the number to set.
from arduino_can_bus_mcp2515.
Thank you. It is working this way but there are some problems with error checking and filtering messages after reset.
I use CAN.checkError() before every reading so that I know if there are some lost frames. The result after an error is permanently CAN_CTRLERROR (5) because datasheet says, eflg has to be reset manually. Maybe it will be a good idea to implement this in library (something like reset_error(void)).
The other problem: My Shield is using in industrial application and I do not have influence if other nodes are sending and with which frequency. So when there is a node sending messages (with IDs which should be blocked) when MCP is initializing, filtering does not work because I only can call init_Mask and init_Filt after CAN.begin is called. Maybe it is better if there is a possibility to set filters and masks before CAN.begin.
Example: A node is sending on ID 5 very, very fast all time.
When starting sketch I call CAN.begin and init_Mask and init_Filt to receive ID 522 only.
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
CAN.init_Mask(0, 0, 0x3FF);
CAN.init_Mask(1, 0, 0x3FF);
CAN.init_Filt(0, 0, 0x20A);
CAN.init_Filt(1, 0, 0x20A);
CAN.init_Filt(2, 0, 0x20A);
CAN.init_Filt(3, 0, 0x20A);
CAN.init_Filt(4, 0, 0x20A);
CAN.init_Filt(5, 0, 0x20A);
delay(100);
Serial.println("masks and filters set!");
}
The result: No message is filtered. All messages from all IDs arrive the buffer.
If there is no other Node sending data when resetting MCP, the filtering is working find and only ID 522 comes into buffer.
from arduino_can_bus_mcp2515.
Related Issues (20)
- Error Sending Messages... HOT 4
- MCP_CAN on ESP8266 NodeMCU - SPI not correct? HOT 2
- ext not initialized in sendMsgBuf HOT 1
- Second Mask and Filters Not Working HOT 2
- Speed selection is incorrect. HOT 1
- Extended ID issue
- can this library be used with stm32f103c8t6?
- Required to Reinit Driver Consistently
- Is This Possible to send String data ?
- RobotDyn Shield HOT 4
- SdFat + MCP_CAN_lib
- RTR code HOT 1
- mcp_can.h no such file or directory error
- spelling error in repo name HOT 1
- Identifying Car Data MCP2515
- error compiling for ESP32 dev module HOT 2
- sharing the Arduino_CAN_BUS_MCP2515
- Drive(control) Motor With MCP2515
- Probably invalid transmission check?
- Install does not work in Windows 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino_can_bus_mcp2515.