I am using the coryjfowler library for MCP2515 with an Arduino Nano Every and I am continually getting error 6 when attempting to transmit data with sendMsgBuf(). I am trying to use the gear indicator at the links below:
https://www.powertraincontrolsolutions.com/aftermarket/displays/sku/GDR5005
https://pcswebsite.s3.amazonaws.com/resources/PCS%20J1939%20Messages%20v2_1.pdf
Any help is greatly appreciated. My current code is shown below. I am trying to the J1939 protocol, but I have also tried to use the GMLAN protocol at the link below:
https://pcswebsite.s3.amazonaws.com/resources/PCS%20Proprietary%20CAN%20Messages%20v1_1.pdf
#include <Arduino.h>
#include <mcp_can.h>
#include <SPI.h>
MCP_CAN sendCAN(10); // Set CS to pin 10
void setup() {
// put your setup code here, to run once:
pinMode(readCAN_INT, INPUT);
Serial.begin(115200);
// Initialize MCP2515 running at 8MHz with a baudrate of 250kb/s and the masks and filters disabled.
if (sendCAN.begin(MCP_ANY, CAN_250KBPS, MCP_8MHZ) == CAN_OK)
Serial.println("MCP2515 Initialized Successfully on Pin 10!");
else
Serial.println("Error Initializing MCP2515...on Pin 10");
sendCAN.setMode(MCP_NORMAL); // Change to normal mode to allow messages to be transmitted
}
byte dataToScreen[8] = { 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void loop() {
// put your main code here, to run repeatedly:
sendCAN();
}
void sendCAN(){
byte sndStat = sendCAN.sendMsgBuf(0x18F00504, 1,8, dataToScreen);
if(sndStat == CAN_OK){
Serial.println(dataToScreen[0]);
Serial.println("Message Sent Successfully!");
} else {
Serial.println("Error Sending Message...");
Serial.println(sndStat);
}
delay(100); // send data per 100ms
}
