Quote Originally Posted by papriko View Post
S_M_A
No this is not a school assignment and yes I was wrong it's 18 not 14

krmed
I know what XOR is , I need it to work with Hex !
Acutally you are not correct here - the checksum is not 18 as you say - it should be B3 as mentioned in my earlier post.

The data you show is quoted, so I'm assuming you are wanting to send a string of characters (i.e. "16 00 49 ab 47") to your device, but you need the checksum. This being the case, you need to get your string into variables so you can use the xor on the. You might want to have something like
Code:
unsigned char first = 0;
unsigned char second = 0;
unsigned char third = 0;
unsigned char fourth = 0;
unsigned char fifth = 0;
unsigned char checksum = 0;
Now you need to convert your string to put the values in the variable - perhaps sscanf can be your friend.

Now you can calculate your checksum:
Code:
checksum = first ^ second ^ third ^ fourth ^ fifth;
Hex is simply a way to display the data - it's still binary data just as shown before.

Hope that helps.