XOR checksum
in
Programming Questions
•
2 years ago
I am programming an application to communicate with a LED indicator board. A typical request looks like this:
- <ID01><L1><PA><FE><MA><WC><FE>Probe3E<E>
I found an allegedly working example coded in Delphi and tried to adopt it to Processing, but this doesn't seem to result in a correct checksum:
- String myCommand = "<ID01><L1><PA><FE><MA><WC><FE>Probe"; // result should be: 3E
byte res = 0;
for(int i=0; i<myCommand.length(); i++){
res ^= byte(myCommand.charAt(i));
}
String checksum = hex(res);
1