I'm having trouble setting message ID for outgoing CAN messages using the Arduino_PortentaMachineControl.h library.
My output seems to have the correct message body, but, I'm having trouble getting the correct message ID. I'm sending to 2FF when I'm trying to send to 18EF8AFF.
Also, if anyone knows the syntax to send in CAN extended format, that would be of help too.
Is there a resource showing more in depth information on how to use this library? I'm not seeing all the information I need in the library guide.
#include <Arduino_PortentaMachineControl.h>
void setup(){
Serial.begin(9600); //Start serial communication
while (!Serial) { //Wait for serial port to connect. Program waits for serial monitor to open before proceeding.
}
if (!MachineControl_CANComm.begin(CanBitRate::BR_250k)) {
Serial.println("Bitrate Set Failed");
while(1);
}
else{
Serial.println("Bitrate Set");
}
}
int MessageID = 0x18EF8AFF;
unsigned char payload[] = {0xFD,0xFF,0xFF,0xBF,0xFF,0xFF,0xFF,0xFF};
int payload_size = 8;
void loop(){
CanMsg msg(MessageID, 8, payload);
int const rc = MachineControl_CANComm.write(msg);
if (rc <= 0) {
Serial.println("Failure");
Serial.print(msg);
while(1);
}
else{
Serial.println("Success");
Serial.println(msg);
while(1);
}
}