Hello,
I am working with the following code below.
#include <SPI.h> //SPI is used to talk to the CAN Controller
#include <mcp_can.h>
MCP_CAN CAN(9); //set SPI Chip Select to pin 9
void setup()
{
Serial.begin(115200); //to communicate with Serial monitor
//tries to initialize, if failed --> it will loop here for ever
START_INIT:
if (CAN_OK == CAN.begin(CAN_500KBPS)) //setting CAN baud rate to 500Kbps
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
//loading the data bytes of the message. Up to 8 bytes
unsigned char stmp[8] = {0xC0, 0x29, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00};
//{192 mph, 10542 RPM, check ON, oil ON, 5 unused}
void loop()
{
//CAN.sendMsgBuf(msg ID, extended?, #of data bytes, data array);
CAN.sendMsgBuf(0xF1, 0, 8, stmp);
delay(3000);
}
For helping my own understanding, I want to see the output of CAN.sendMsgBuf in the serial monitor. I've tried doing so with Serial.print(CAN.sendMsgBuf(0xF1, 0, 8, stmp)), but it results with a single number and that is not what I expect it to be. Is this what it is supposed to be or is there a different way to see the correct output?