I've got this Arduino-checksum function I'd like to use in C# to check the validity of the data I received:
char
s in Arduino are 1 byte long, int
s take two bytes, the corresponding data-type in C# is short
char Send::calcChecksum(const char* const packet, const int packetLength) {
int i = 0;
char checksum = 0;
while(i < packetLength) {
checksum ^= packet[i++];
}
return checksum;
}
How would I write this function in C# ? I'm especially confused what the ^=
operator does.