Reference

rsff-f9(3)

The 3-byte error-correcting encoder and decoder based on the Reed-Soloman (255, 249) code over the Galois Field (256).

delim $$

NAME

rs255_249_encode, rs255_249_decode, rsencode, rsdecode - The 3-byte error-correcting encoder and decoder based on the Reed-Soloman (255, 249) code over the Galois Field (256).

SYNOPSIS

#include <gf256.h>
#include <rsff-f9.h>

cc ... -lecc

void rs255_249_encode (data, parity) const GF256 *data; GF256 *parity;

status = rs255_249_decode (received) int status; GF256 *received;

int rs255_249_number_of_errors (status) int status;

rsencode (data, code) unsigned char data[249], code[255];

rsdecode (msg, result, num_errs) unsigned char msg[255], result[249]; int *num_errs;

DESCRIPTION

This manual page documents the GNU ecc library - the 3-byte error-correcting encoder and decoder based on the Reed-Solomon (255, 249) code over Galois Field GF($2 sup 8$).

data points to an array of 249 unsigned char, and parity points to an array of 6 unsigned char. received points to an array of 255 unsigned char. See below on the relationship between received and data/parity. The possible values for status is the set of symbolic constants defined below.

The generating polynomial for the Reed-Solomon (255, 249) used in this library is

g ( x ) = ( x - 2 ) cdot ( x - 2 sup 2 ) cdot ( x - 2 sup 3 ) cdot ... cdot ( x - 2 sup 6 )

For each block of 249 bytes passed in as data, rs255_249_encode() computes the values of the 6 bytes in parity such that the polynomial defined as

c ( x ) = c sub 254 cdot x sup 254 + c sub 253 cdot x sup 253 + ... + c sub 2 cdot x sup 2 + c sub 1 cdot x + c sub 0

where

c sub 254 ... c sub 6 == data[248] ... data[0]
c sub 5 ... c sub 0 == parity[5] ... parity[0]

is a multiple of the generating polynomial $g ( x )$.

The bytes pointed to by data and parity may be transmitted in any manner. At the receiver, received is constructed as follows

received[0] ... received[248] = d[0] ... d[248]
received[249] ... received[254] = p[0] ... p[5]

where d and p are the received versions of data and parity respectively.

If 3 or less errors had occurred, rs255_249_decode() will correct all the errors, and upon return from this function, the first 249 bytes of received may be safely assumed to be those of data. Some or all of the errors may occurred in parity, ie the bytes from r[249] to r[254]. These errors are never corrected.

If status is RS255_249_E4, some irrecoverable error has occurred. This usually means that there are 4 or more errors in the block of 255 bytes.

The simplest application is to check status. If it is RS255_249_E4, arrange for the retransmission of the entire block. Otherwise, ignore the last 6 bytes of received and return the first 249 bytes as data in that block.

For applications that wish to be verbose whenever 1 to 3 errors had occurred, the returned value is RS255_249_E$x$_C $y$, where $1 <= x <= 3$ and $0 <= y <= x$. x is the number of errors and y is the number of these errors occurring in the data portion. The function rs255_249_number_of_errors() returns the value of $x$ when it is passed the returned value of rs255_249_decode().

rsencode() and rsdecode() are older versions of rs255_249_encode() and rs255_249_decode() respectively. Upon return from rsencode(), the value of code is

code[0] ... code[5] = parity[5] ... parity[0]
code[6] ... code[254] = data[248] ... data[0]

code is transmitted, and in the absence of error,

msg[0] ... msg[254] = code[254] ... code[0]

Whenever the value of *num_errs is not equal to 4, result can be safely be assumed to be that of data.

WARNING

The 2 functions rsencode()and rsdecode() are included in the library for backward-compatibility to earlier versions of this library. They may be removed in future releases.

SEE ALSO

gf256(3)