Hi,
Doing something with MCP2515/TJA 1050. Trying to receive CAN data from a BMS unit through constantly transmitted CAN messages, using Cory Fowlers Library. There are two CAN IDs transmitting at the same interval 8ms. One is required by the system (Id: 0x3B) hence can't disable or manipulate and the other is a custom message (Id:0X11A) generated to obtain usable data. The arduino is only showing the earlier and not 0x11A which is expected.
Wondering if setting up Masks and Filters could help, if so how?
Thanks
Vivek
// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13
#include <SPI.h>
#include "mcp_can.h"
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
//const int SPI_CS_PIN = 10;
//MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
MCP_CAN CAN1(10);
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN1.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println(" Init CAN BUS Shield again");
delay(100);
}
Serial.println("CAN BUS Shield init ok!");
CAN1.setMode(MCP_LISTENONLY);
}
void loop()
{
long unsigned int rxId;
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN1.checkReceive()) // check if data coming
{
CAN1.readMsgBuf(&rxId, &len, buf); // read data, len: data length, buf: data buf
Serial.println("-----------------------------");
Serial.print("Get data from ID: 0x");
Serial.println(rxId, HEX);
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf[i], HEX);
Serial.print("\t");
}
Serial.println();
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
Output generated
Get data from ID: 0xBB
0 0 0 60 A0
-----------------------------
Get data from ID: 0x3B
0 0 0 60 A0
-----------------------------
Get data from ID: 0x3B
0 0 0 60 A0
-----------------------------
Get data from ID: 0x3B
0 0 0 60 A0