Calculate block check character (BCC) for serial communication

I communicate with the device through the serial interface of the SerialPort.NET class and based on the requirements for the specifications of third-party devices, I need to calculate the "block control character". The only information I'm talking about is that it is an exceptional OR (XOR) operation and must be performed on all characters.

So, if I have the line "Bob, 001", how would I calculate BCC?

+4
source share
1 answer

This is most likely a character based XOR. You will need to get samples from them to check, but most checksums usually end with 0.

So, for the XOR checksum, you will have the package:

Bob,001X 

where X is the checksum, and when you XOR all these characters together, you will most likely get 0.

So, to handle X, you just XOR all the characters in "Bob, 001". This is due to the fact that N xor N is always 0, for any N.

Now it may happen that X will have two hexadecimal characters if you are allowed to have only alphanumeric characters. To do this, you need either data samples (so that we can fix it) or the correct specification (which the device manufacturer must provide).

What actual device do you mean? This may be information on the Internet that shows how to do this.

Based on the update:

This is a PMS Amadeus Hospitality device. Not all of them say that this should be done for all characters. excluding STX and ETX.

You will need to get some sample data for confirmation, but most likely this will lead to data flow:

  Running Data ChkSum ====== ======= STX 02 B 42 42 o 6f 2d b 62 4f , 2c 63 0 30 53 0 30 63 1 31 52 4 52 00 ETX 03 

The position of the checksum may vary, and indeed its calculation may vary, although this is much less likely. I do not think that much more can be done without sample data or additional information from the supplier. A quick search on the Internet did not find technical details.

+3
source

All Articles