Thanks Pylon, I will try this out right now ![]()
EDIT:
I tried but guess I don't understand the syntax of this.
Here is my Code (from MCU_CAN.h library)
void loop()
{
if(!digitalRead(CAN0_INT)) // If CAN0_INT pin is low, read receive buffer
{
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((rxId & 0x40000000) == 0x40000000){ // Determine if message is a remote request frame.
sprintf(msgString, " REMOTE REQUEST FRAME");
Serial.print(msgString);
} else {
for(byte i = 0; i<len; i++){
sprintf(msgString, " 0x%.2X", rxBuf[i]);
Serial.print(msgString);
}
}
Serial.println();
}
}
Although "msgString" is declared as a char array of length 128 the example does not use any index to write to it. That's alone something I don't understand ![]()
Basically, if I understand this of your post
Or extract the subvalue of variable "value" at startbit 12, length 8 bit:
Code: [Select]
uint32_t detail = (value >> 12) & 0xFF;
I don't see any need for arrays or the like, the processor is able to handle the bit values.
I would be happy. Could you just throw it in my code, I will try to understand from there!