I have a function in C that receives two bytes one with the highest significant value (msb) and one with a smaller value (lsb) and then converts them to decimal.
int get_pea(char *buffer)
{
char lsb[8], msb[8], pea[16];
unsigned int i;
convertDecimalBinary((int) buffer[0], lsb, 8);
convertDecimalBinary((int) buffer[1], msb, 8);
for (i=0; i<8; i++) {
pea[i] = msb[i];
}
for (i=0; i<8; i++) {
pea[i+8] = lsb[i];
}
return convertBinaryDecimal(pea, 16);
}
This function is pretty stupid with so many type conversions, I know that in C there is no need to do so much, but I did not see another way to:
buffer[0] = 0x84;
buffer[1] = 0x03;
Having these two bytes as I convert to decimal 0x03 0x84?