Can-Bus Shield Unable to receive Extended ID

When I output a message with the extended ID the reciever just gets 11 bits, not the full 29.

The receive module has no way of specifying a way to receive extend fields.

[code]#include “mcp_can.h”
#include <SPI.h>
INT32U ID=0x700;
void setup()
{
Serial.begin(115200);
if(CAN.begin(CAN_50KBPS) ==CAN_OK) Serial.print(“can init ok!!\r\n”);
else Serial.print(“Can init fail!!\r\n”);
}

unsigned char stmp[8] = {
0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
ID++;
CAN.sendMsgBuf(ID, 1, 8, stmp);
delay(20);

}[/code]

The receive code:

[code]#include “mcp_can.h”
#include <SPI.h>
//#include <stdio.h>
#define INT8U unsigned char

boolean firstTime=false;
INT8U Flag_Recv = 0;
INT8U len = 0;
INT32U ID=0;
INT32U IDC=0;
INT8U buf[8];
char str[20];
void setup()
{
Serial.begin(115200);

Serial.println("Can RX module ");
CAN.begin(CAN_50KBPS);
attachInterrupt(0, MCP2515_ISR, FALLING); // digital pin 2

}

void MCP2515_ISR()
{
Flag_Recv = 1;
}

void loop()
{
if(Flag_Recv)
{

Flag_Recv = 0;
CAN.readMsgBuf(&len, buf);

IDC=CAN.getCanId();
Serial.print(" ID : ");
Serial.println(IDC,HEX);

if (!firstTime){
  ID=IDC+1; // this is to set comparator value
  firstTime=true;
} 
else {
  // we have a value to compare
  if (ID!=IDC){
    Serial.print("### IDC  = ");
    Serial.print(IDC,HEX);
    Serial.print(" ID  = ");
    Serial.println(ID,HEX);
    firstTime=false;
  } 
  else {
    ID++;
  }
}

}
}
[/code]

When initializing , the filters and mask was default standard frame. So, you can add code follows, it works fine.

#include "mcp_can.h"
#include <SPI.h>
//#include <stdio.h>
#define INT8U unsigned char
 
boolean firstTime=false;
INT8U Flag_Recv = 0;
INT8U len = 0;
INT32U ID=0;
INT32U IDC=0;
INT8U buf[8];
char str[20];
void setup()
{
  Serial.begin(115200);
 
  Serial.println("Can RX module ");
  CAN.begin(CAN_50KBPS);
  CAN.init_Mask(0,1, 0);            /* init Masks                   */
  CAN.init_Filt(0, 1, 0);               /* init filters                    */
  attachInterrupt(0, MCP2515_ISR, FALLING); // digital pin 2
 
}
 
void MCP2515_ISR()
{
  Flag_Recv = 1;
}
 
void loop()
{
  if(Flag_Recv)
  {
 
    Flag_Recv = 0;
    CAN.readMsgBuf(&len, buf);
 
    IDC=CAN.getCanId();
    Serial.print(" ID : ");
    Serial.println(IDC,HEX);
 
    if (!firstTime){
      ID=IDC+1; // this is to set comparator value
      firstTime=true;
    } 
    else {
      // we have a value to compare
      if (ID!=IDC){
        Serial.print("### IDC  = ");
        Serial.print(IDC,HEX);
        Serial.print(" ID  = ");
        Serial.println(ID,HEX);
        firstTime=false;
      } 
      else {
        ID++;
      }
    }
 
 
  }
}

I can receive normal messages with the filter init code inserted.
When I set the extended bit in the send code, I get nothing.

  CAN.sendMsgBuf(ID, 1, 8, stmp);