Giter Site home page Giter Site 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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

arduino-fec's Issues

Missing license information

The original code (from mersinvald) contains a LICENSE file and author references in header files. I think this distribution should contain at least the original LICENSE file (a MIT license) or its content should be included in a comment block in the header file.

FEC over bytes?

Hi!
i'd like to apply FEC over 3 bytes per message, but i cant seem to get it working. How would i implement this?
(i want to send 24 1's or 0's)

with regards,
Daniël

Appreciation letter to code author

The code usage was successful on ESP8266 core platform too, as message originator and sender.
Problems took place on receiption side, relaized on ESP32, but not due to introduced library itself.
Most convenient and short interpretation of receiption job for me was the following code for message sending via UART:
for(uint i = 0; i < sizeof(encoded); i++) { mySerial.print(encoded[i]); } mySerial.print('\n');
and beneath for the receiption:
if (Serial1.available()) encoded = Serial1.readStringUntil('\n');
Byte by byte reading on receiption side was not successful and data integrity has been suffered with unknown reason. In meantime the "readStringUntil" function performed well enough.
Having sent for example, 10 byte (5 as original message content and 5 additional, which generates the encoder library) and termination EOL, I got 12 bytes on the rest. One byte is the NULL, which has every string by definition. On receiving side we are not able to use the string as decoding function argument, due to variable type itself and two additional bytes presence: NULL and EOL.
Neither of Ardunio or C++ string to char array function were able to convert the string to char array.

1. Arduino: myString.toCharArray(buf, len)
2. C++: sprintf(rawleft, "%.9s", encodedleft.c_str());
3. C++: strncpy(rawleft, encodedleft.c_str(), 9);

Even encoded bytes were not possiple to copy and transfer to somewhere by computer's clipboard from serial monitor terminal. An simple task, namely, the string to char convertation became as a BIG trouble.
The solution found accidentally, upon some days long hardwork.
if (Serial1.available()) encodedleft = Serial1.readStringUntil('\n'); for (uint i = 0; i < 10; i++) { rawleft[i] = encodedleft[i]; }
The "rawleft" has been declared globally, as char array and the "encodedleft"-as a string variable accordingly. It is was an eyeopening subject for me that the string can be accessed char by char, by index. So, this method has solved the task, having copied the string to char array, bypassed last two bytes transfer to char array.
Thanks to author for good job.
A question however I have to bring up. What is the optimal relation between original message lenght and additional bytes lenght?

CubeCell Architecture

library Arduino-FEC-master claims to run on (esp32) architecture(s) and may be incompatible with your current board which runs on (CubeCell) architecture(s).

Point out limit in AVR

It seems that there is a limit of 128 bytes in message + redundancy when using this library on AVR (in my case, LoRa32u4). It would be nice to point out in documentation that library does work on AVR with limitations.

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.