1

I want to receive an extended CAN-Message. I send a extended CAN-Message, but nothing happens. Maybe somebody have an idea what the problem is..

It works with a standard CAN-Message.

Thanks in advance.

// demo: CAN-BUS Shield, send data
// loovee@seeed.cc

#include <mcp_can.h>
#include <SPI.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 = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

void setup()
{
    Serial.begin(115200);

    while (CAN_OK != CAN.begin(CAN_250KBPS))              // init can bus : baudrate = 250k
    {

        CAN.init_Mask(0,1,0);
        CAN.init_Filt(0,1,0);

        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 len = 0;
unsigned char buf[30];

void loop()
{    
    CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
    unsigned long canId = CAN.getCanId();
    Serial.println("-----------------------------");
    Serial.print("Get Data from ID: 0x");
    Serial.println(canId, HEX);
    Serial.println("Data content:");
    for(int i = 0; i<len; i++) // print the data
    {
        Serial.print(buf[i]);
        Serial.print("\t");
    }
    Serial.println("-----------------------------");
}
  • What happens if you remove the filter and the mask? – oh.dae.su Jan 8 at 12:17
  • It change nothing. – user52806 Jan 8 at 12:19
  • Maybe this discussion can help you: github.com/Seeed-Studio/CAN_BUS_Shield/issues/39 – oh.dae.su Jan 8 at 12:28
  • Unfortunately, I found this discussion, but nothing changed. – user52806 Jan 8 at 12:32
  • How do you send the message? With the same Can-shield on a different Arduino? If yes, can you post code of the sender? I assume you don't have any other device to verify, if the extended frame is actually sent to the bus? – oh.dae.su Jan 8 at 12:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.