Using Seed studio CAN shield to read and convert CAN data to dec value.
Example of expected result:
Full CAN message is 70 3B F1 FF 00 00 00 00 , using little endian first 4 bytes gives: FFF13B70 , which should be equal to converted dec value of -0.967824 (using factor of 0.000001).
Here is code to extract the text value I am using.
CAN.readMsgBuf(&len, buf);
unsigned char len = 0;
unsigned char buf[8];
{
String reg0 = String (buf[0], HEX);
String reg1 = String (buf[1], HEX);
String reg2 = String (buf[2], HEX);
String reg3 = String (buf[3], HEX);
Serial.print(reg3);
Serial.print("\t");
Serial.print(reg2);
Serial.print("\t");
Serial.print(reg1);
Serial.print("\t");
Serial.print(reg0);
Serial.print("\t");
String regsumm = (reg3 + reg2 + reg1 + reg0);
Serial.println(regsumm);
}
As result I got only text string which couldn't be converted into dec. Any other ways how do it?