I'm having problem fixing the endianness of the value that I got.
What I'm thinking is separate a
crc_data = 0A95
value_1 = 0x95
value_2 = 0x0A
You could cast to a
char*. You would do it like this:
crc_data = 0x0A95 const unsigned char *k = (const unsigned char*) &crc_data; value_1 = k; value_2 = k;
The char pointer just lets you treat the data as though it was a string of bytes. You can then read them with the
Another way is to use math to get the upper and lower parts. The bitshift operator
<< will shitf your data down 8 bits. It's the same as dividing by 256.
crc_data = 0x0A95; value_1 = crc_data & 0xFF; value_2 = (crc_data << 8) & 0xFF;
Another option is to use a union. Basically there are a lot of ways to do this.