I am trying to write some code to communicate with an old device over serial that uses the Siemens 3964r protocol. This includes a checksum, or more accurately a BCC (block check character) at the end of the transmission. A single char after the ETX. The docs define the BCC as this:
With the 3964R transfer protocol, data security is enhanced by sending an additional block check character (BCC = Block Check Character). The block check character is the even longitudinal parity (EXOR logic operation of all data bytes) of a sent or received block. Its calculation begins with the first byte of user data (first byte of the frame) after the connection establishment, and ends after the DLE ETX character at connection termination.
Here is some sample data in hex. 53 54 41 54 55 53 10 03 07
07 is the BCC in this one.
4d 45 41 53 4d 50 54 45 53 54 41 4e 41 50 52 47 30 30 30 55 78 30 31 31 2e 30 30 5a 30 31 31 31 30 10 03 61
61 is the BCC in this one.
I know in general how to do XOR operations, but I haven't been able to figure out any combination of things that gives me a proper BCC. I think I am interpreting the definition wrong.
My preferred language for this is javascript as it's for a node.js electron app. I can read the buffer and get the hex values. And I can construct propoer messages back. But it won't work correctly until I can include a proper BCC. So just looking for someone smarter than me that knows exactly how to produce a valid BCC.
thanks!