Temperature data part of the message is ten times to enlarge the decimal values, in a converted to hexadecimal send,
Such as: the current temperature 30, address + command code + 485 + [data] + check=00 01 00 01 [c] 2 01 xx xx,
Excuse me, what is the easy way to hexadecimal Numbers into decimal, 10 x magnification and then converted to hexadecimal?
CodePudding user response:
Strtolitoa
CodePudding user response:
unsigned char data [2];
Short int temperature;
Short int temperature10;
Temperature=30;
Temperature10=10 * temperature;
Data [0]=(unsigned char) (temperature10/256);
Data [1]=(unsigned char) (temperature10%256);