I am working on a project with CAN shield + MEGA2560.
Angle information from an encoder is received and decoded as required. The following code snippet does this :
if ((rxId & 0x1FFFFFFF) == 0x18FF0108) { // Determine if message is a required one...
for (byte i = 0; i < len; i++) {
sprintf(msgString, " 0x%.2X", rxBuf[i]);
Serial.print(msgString);
}
float angleVal = (rxBuf[4] << 8) | rxBuf[3]; // Process the data for angle information.
Serial.print("Angle in Deg.: ");
if (angleVal > 2047) {
((angleVal - 4095) * 180 / 2048);
} else {
angleVal * 180 / 2048;
}
Serial.println( angleVal);
}
Now I want to test above for various angles and right now do not have the hardware . So I have to inject CAN data into the above code and see how it handles different values and there are other functions ( not shown here for keeping the post small ) . The sample CAN data will be like this : 7B 66 7E 99 7D E6 00 00
In other words I need to load msgString variable with the above Hex data .
Thanks for any tips on this .