Smart Tools
Blog博客
Theme
Search
start generating
A Brief Overview of LRC

Longitudinal Redundancy Check (LRC) is a commonly used form of error checking in communications, also known as LRC checking or longitudinal checking. It is an error detection method that generates check bits from specific bit strings on a longitudinal channel.In matrix formats (such as magnetic tape), LRC is often used in conjunction with VRC to generate a parity bit for each character. In the industrial sector, the Modbus protocol’s ASCII mode employs this algorithm.

The specific algorithm is as follows:

1. Pair the data to be checked (2n characters) and calculate the sum of their hexadecimal values.

2. Take the modulo of the sum with 256

3. Subtract the resulting modulo value from 256 to obtain the checksum (alternatively, invert the modulo value bitwise and add 1)

For example, with the hexadecimal data: 01 A0 7C FF 02

(Hexadecimal calculation) Sum: 01 + A0 + 7C + FF + 02 = 21E Modulo: 21E % 100 = 1E Calculation: 100 - 1E = E2

(Decimal calculation) Sum: 01 + 160 + 124 + 255 + 02 = 542 Modulo: 542 % 256 = 30 Calculation: 256 - 30 = 226

Recommended Tools
Home Search Favorites Language