I don't understand why it gives such an error in the code.
#include <SPI.h>
#include <mcp_can.h>
#define SPI_CS_PIN 9
#define LED 8
MCP_CAN CAN0(SPI_CS_PIN);
void setup()
{
Serial.begin(9600);
pinMode(LED,OUTPUT);
while (CAN_OK == CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ)) //can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield Baslatmasi Basarili!");
}
Serial.println("CAN BUS Shield Baslatma Hatasi");
Serial.println("CAN BUS Shield Tekrar Baslatiliyor…");
delay(100);
}
void loop()
{
unsigned char len = 0;
unsigned char buf[8]={0,0,0,0,0,0,0,0};
if(CAN_MSGAVAIL == CAN0.checkReceive())
{
CAN0.readMsgBuf(&len, buf);
unsigned long canId = CAN0.getCanId();
Serial.println("—————————–");
Serial.print("Verici ID: 0x");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++)
{
Serial.print(buf[i]);
Serial.print("\t");
digitalWrite(LED, buf[0]);
delay(100);
}
Serial.println();
}
}
error messages
/tmp/332594481/sketch_may13a/sketch_may13a.ino: In function 'void loop()':
/tmp/332594481/sketch_may13a/sketch_may13a.ino:26:30: error: no matching function for call to 'MCP_CAN::readMsgBuf(char*, unsigned char [8])'
CAN0.readMsgBuf(&len, buf);
^
In file included from /tmp/332594481/sketch_may13a/sketch_may13a.ino:2:0:
/home/builder/opt/libraries/latest/mcp_can_1_5_0/mcp_can.h:119:11: note: candidate: byte MCP_CAN::readMsgBuf(long unsigned int*, byte*, byte*, byte*)
INT8U readMsgBuf(INT32U *id, INT8U *ext, INT8U *len, INT8U *buf); // Read message from receive buffer
^~~~~~~~~~
/home/builder/opt/libraries/latest/mcp_can_1_5_0/mcp_can.h:119:11: note: candidate expects 4 arguments, 2 provided
/home/builder/opt/libraries/latest/mcp_can_1_5_0/mcp_can.h:120:11: note: candidate: byte MCP_CAN::readMsgBuf(long unsigned int*, byte*, byte*)
INT8U readMsgBuf(INT32U *id, INT8U *len, INT8U *buf); // Read message from receive buffer
^~~~~~~~~~
/home/builder/opt/libraries/latest/mcp_can_1_5_0/mcp_can.h:120:11: note: candidate expects 3 arguments, 2 provided
/tmp/332594481/sketch_may13a/sketch_may13a.ino:27:32: error: 'class MCP_CAN' has no member named 'getCanId'; did you mean 'getGPI'?
unsigned long canId = CAN0.getCanId();
^~~~~~~~
getGPI
Error during build: exit status 1