I have been looking through the forum and have not be able to find anyone with my issue. I am filtering CAN id' s and only need to look at 2 and got that working. I am trying to now make conditional statements from data bytes in the can ID. the rxBuf [3] is from ID 0x18FF81 and the rxBuf[7] is from ID 0x18FF62 but the send data will change if either rxBuf3 and 7 are true
void loop()
{
{
CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s)
if((rxId & 0x80000000) == 0x80000000 ) // Determine if ID is standard (11 bits) or extended (29 bits)
sprintf(msgString, "Extended ID: 0x%.8lX DLC: %1d Data:", (rxId & 0x1FFFFFFF), len);
else
sprintf(msgString, "Standard ID: 0x%.3lX DLC: %1d Data:", rxId, len);
Serial.print(msgString);
if(( rxBuf[3] == 0xC1) && (A == !prevA))
{
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, TC100);
A = true;
}
if( (rxBuf[3] == 0xC0) )
{
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, HOGoff);
A = false;
}
Serial.print("A");
Serial.print(A);
if((rxBuf[7] == 01) && (A == true) ) {
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, TC100);
}
if(rxBuf[7] == 02 && (A == true) ) {
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, TC75);
}
if(rxBuf[7] == 03 && (A == true) ) {
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, TC50);
}
if((rxBuf[7] == 04) && (A == true)) {
byte sndStat = CAN0.sendMsgBuf(0x1CFF0105, 1, 8, TC20);
}
delay(20); // send data
Serial.println();
}
}