Hey guys,
I recently purchased the CAN-BUS shield v1.2 from seeeduino and mounted it on top of my Arduino Uno. The code runs fine but whenever I read the ID that was sent "CAN.sendMsgBuf(0x190,0,0, 3, Readtag);" I receive 90, totally ignoring the first number, as if the limit is 255 or 0xFF. Anyone has gone through anything similar?
Thanks in advance!
#include <mcp_can.h>
#include <SPI.h>
MCP_CAN CAN(9);
unsigned char Length = 8;
unsigned char ID;
unsigned char buffer;
unsigned char Storage[8]; // Stored values are in Hex format
unsigned char Readtag[3] = {0xE4, 0x00, 0x00};
int i = 0;
void setup()
{
Serial.begin(57600); //Set Baudrate for Arduino-Computer interface
Stage:
if(CAN_OK == CAN.begin(CAN_100KBPS)) // init can bus : baudrate = 100k
{
Serial.println("CAN BUS Shield initialisation successful!");
}
else
{
Serial.println("CAN BUS Shield initalisation failed!");
Serial.println("Initalising CAN BUS Shield again");
delay(100);
goto Stage;
}
}
void loop()
{
delay(5000); //time to allow myself to open serial monitor
CAN.sendMsgBuf(0x190,0,0, 3, Readtag);
CAN.readMsgBuf(&Length, Storage);
// if(CAN_MSGAVAIL == CAN.checkReceive())
ID = CAN.getCanId();
Serial.println(ID);
for (i=0; i<8; i++){
Serial.println(Storage[i], HEX);
}
delay (5000);
}