Reed Solomon Error Detection and Correction Library
Reed Solomon ECC is written in C++ and it is delivered as a DLL that can be linked with almost any application. Bindings for all languages are provided as needed.
RS library exports only 4 functions:
- Initialize(int,int) - initialize RS library with specifiying the total packet length and ecc length
- Encode(unsigned char*,int) - encode array of unsigned chars by specifying its length
- Decode(unsigned char*,int) - decode array of unsigned chars by specifying its length
- Uninitialize() - free up library resources
In addition, the library is available as template library (special order) - source code provided.
RS library is very simple to use as shown in the example below:
#include "stdafx.h"
#include "..\RSLib\RSLib.h"
int _tmain(int argc, _TCHAR* argv[])
{
// Initialize
/*
rs(4,2) - packet is 4 bytes, where 2 bytes data and 2 bytes ecc
*/
if(Initialize(4, 2))
printf("Initialize success\n");
else printf("Initialize failure\n");
for(int k=0; k<4; ++k)
{
for(int i=0; i<256; ++i)
{
for(int j=0; j<256; ++j)
{
// Create message packet
unsigned char MsgPacket[] = {i,j,0,0};
// Encode message packet
if(!Encode(MsgPacket))
{
printf("Encode failure!\n");
break;
}
// make a copy of good packet
unsigned char MsgPacket2[] = { MsgPacket[0],MsgPacket[1],MsgPacket[2],MsgPacket[3]};
// add some corruption
MsgPacket[k] = i;
// Decode message packet
if(!Decode(MsgPacket))
{
printf("Decode failure!\n");
break;
}
// compare if fixing was successfull
if((MsgPacket[0] != MsgPacket2[0]) ||
(MsgPacket[1] != MsgPacket2[1]) ||
(MsgPacket[2] != MsgPacket2[2]) ||
(MsgPacket[3] != MsgPacket2[3]))
{
printf("Comparison failure!\n");
break;
}
}
}
}
Uninitialize();
return 0;
}