I'm trying to add CAN transmission to MySensors.
This is my fork: https://github.com/AdamSlowik/MySensors/tree/feature/can
This is how I connected my CAN modules to arduino (except pin INT of CAN module is connected to pin 2 of arduino):
My CAN module is popular one (mpc2515 with tja1050)
My fork contains following examples:
-CANSwitch (simpler version of BinarySwitchSleepSensor)
Heavy lifting (MCP2515 driver stuff) is done by https://github.com/coryjfowler/MCP_CAN_lib
After uploading mentioned sketches to arduinos, sensor sends frame. I belive this is request for new node ID (it's 7 bytes long).
Gateway recives this frame (data is same as in sensor side). After that strange things happens. Gateway ends up in some endless loop calling 'transportDataAvailable'. This might be normal but 'IF' statement 'if(!hwDigitalRead(CAN0_INT))' is always true. Because this statement is true program reads data from CAN. Since 'IF' statement (in my opinion) is false positiv, data from CAN are garbage (0xFFFFFFFF).
Two easiest explenation for me are:
a) Gateway uses pin 2 and this interfere with communication code
b) Used CAN library is somehow incompatible with MySensors
I belive wiring issue is not the case. All things are soldered in universal board and tested with examples provided by CAN library.
Can someone look at My code especialy at how I use pin 2?
Perhaps someone have CAN modules to reproduce My issue?