I have merge the send and receive check files. I am sending a extended ID CAN message without any problems. When I try to receive an extended ID it seems to ignore the message? Any help would be great, here is the code:
#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
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_500KBPS)) // 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!");
}
unsigned char stmp[8] = {0x03,0x22,0x70,0x00,0x00,0x00,0x00,0x00};
void loop()
{
// send data: id = 0x00000000, extended ID, standard frame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0x18DA60F1, 1, 8, stmp);
delay(100); // send data per 100ms
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
Serial.print("ID:");
Serial.print(CAN.getCanId(),HEX);
Serial.print("\, ");
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf[i],HEX);
Serial.print("\, ");
}
Serial.println();
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/