Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

C implementation of Reed-Solomon error-correction codes. For detection syndrome decoding is used. Works in GF(256).

Notifications You must be signed in to change notification settings

Warchant/reed-solomon_syndrome_gf256

Repository files navigation

Description

C implementation of Reed-Solomon error-correction codes. For detection syndrome decoding is used. Works in GF(256).

  • highly portable, includes only stdio.h and stdlib.h
  • header-only
  • syndrome decoding
  • implemented for t=1 and t=2 (can locate and correct 1 or 2 errors), probably I'll implement for more
  • tested on Ubuntu and Arduino Nano (for Arduino, change contents of fatal and vector_print methods from util.h, because it has no printf and exit methods)

How to use

To build and run tests:

mkdir build
cd build
cmake ..
make
ctest

How to use:

#include "rs.h"

int main(){
    // sender side
    uint8_t* msg = (uint8_t*)"hello world";
    uint8_t    t = 2; // we want to fix 2 mistakes at max
    uint32_t len = 0; // new length of codeword will be 2*t + len(msg)
    uint8_t *codeword = encode_message(msg, strlength(msg), t, &len); // yes, I know about strlen. for this I need to include one more header, but I don't want
    
    // send codeword through noisy channel

    // receiver side
    uint8_t out_len = 0; // length of decoded message
    uint8_t *corrected_msg = decode_message(codeword, len, t, &out_len);
    printf("%s\n", corrected_msg); // "hello world"

    return 0;
}

About

C implementation of Reed-Solomon error-correction codes. For detection syndrome decoding is used. Works in GF(256).

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published