I was instructed to develop some meager instructions for developing a control byte from a sequence of bytes between the cash register and the scale, and then implement it in C.
Instructions from the manual (to get a checksum):
ID XOR B1 XOR B2 XOR B3 XOR B4 XOR B5
Other similar protocols mention that this may be the XORingmost significant bit in each byte - (I don’t know how to do this or even if necessary)
Fortunately, I have a scale and a computer to check exactly what is sent, ID = asciiand I am B1 to B5the weight, in this example, when the weight on the scale shows 00748; The sequence returned in ascii isi00748, then the checksum is sent:45 decimal.
Some code I tried below unfortunately returns 82 in decimal format.
char out = 0;
char in[6] = "i00748";
int i;
for(i=0; i<6; i++)
out = out ^ in[i];
printf("%d",out);
Any help was appreciated.
source
share