Podría tratarse también de un
check de paridad como explican aquí:
https://en.wikipedia.org/wiki/Longit...dundancy_check
Ten en cuenta que parece que al ser dos bytes de paridad deberías trabajar con WORDs y si el último byte del mensaje queda sin su par para generar un word habrá que resolverlo agregándole otro (por delante o por detrás) con valor 0.
Código:
Pseudocodigo byte
Set LRC = 0
For each byte b in the buffer
do
Set LRC = (LRC + b) AND 0xFF
end do
Set LRC = (((LRC XOR 0xFF) + 1) AND 0xFF)
Pseudocodigo word
Set LRC = 0
For each word b in the buffer
do
Set LRC = (LRC + b) AND 0xFFFF
end do
Set LRC = (((LRC XOR 0xFFFF) + 1) AND 0xFFFF)