Git Product home page Git Product logo

arduino-fec's Introduction

Arduino-FEC

Forward Error Correction library with Reed-Solomon
Based on mersinvald's code:
https://github.com/mersinvald/Reed-Solomon

Install

Donwload, and import into Arduino IDE

Exmaple

#include <RS-FEC.h>

char message[] = "Some very important message";
const int msglen = 60;  const uint8_t ECC_LENGTH = 10;  //Max message lenght, and "guardian bytes", Max corrected bytes ECC_LENGTH/2
char message_frame[msglen]; // The message size would be different, so need a container
char repaired[msglen];    char encoded[msglen + ECC_LENGTH];

RS::ReedSolomon<msglen, ECC_LENGTH> rs;


void setup() {
  Serial.begin(115200);      while (!Serial);             // initialize serial
 
  memset(message_frame, 0, sizeof(message_frame));        // Clear the array
  for(uint i = 0; i <= msglen; i++) {    message_frame[i] = message[i];     } // Fill with the message
 
  rs.Encode(message_frame, encoded); 
 
  Serial.print("Original: "); Serial.println(message_frame);
  Serial.print("Encoded:  ");        for(uint i = 0; i < sizeof(encoded); i++) {    Serial.print(encoded[i]);    }    Serial.println("");
  for(uint i = 20; i < 25; i++) {        encoded[i] = '-';    } //Let's steal some byte from 20 to 25.
  Serial.print("Corrupted: ");      for(uint i = 0; i < sizeof(encoded); i++) {     Serial.print(encoded[i]);    }    Serial.println("");
  rs.Decode(encoded, repaired);
  String result;    memcmp(message_frame, repaired, msglen) == 0 ? result="SUCCESS" : result="FAILURE"; //Compare the arrays
  Serial.print("Result: ");   Serial.println(result);
  Serial.print("Repaired: "); Serial.println(repaired);
    
}

void loop() { }

The Output:

Original: Some very important message
Encoded:  Some very important message?�Êü?
Corrupted: Some very important -----ge?�Êü?
Result: SUCCESS
Repaired: Some very important message

arduino-fec's People

Contributors

simonyipeter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.