Skip to content

lrc

lrc(data): number

Defined in: checksum/lrc.ts:14

Computes the longitudinal redundancy check (two’s-complement negated sum) of data, as used by Modbus ASCII and Intel HEX.

The sum of data and its LRC is always 0 mod 256, which is the usual way a receiver verifies the check byte: sum every byte including the LRC itself and confirm the low 8 bits are zero.

Complexity: O(n) in the byte length of data.

Uint8Array

The bytes to check.

number

An unsigned 8-bit check byte.