Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Serial Data Transfer Library Finished!

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    13

    Serial Data Transfer Library Finished!

    As part of one of my personal projects, I decided to write a library to transfer UART serial data in a fast and reliable manner.

    This library (SerialTransfer.h):
    • is non blocking
    • uses packet delimiters
    • uses consistent overhead byte stuffing
    • uses cyclic redundancy checksums
    • allows the use of dynamically sized packets (packets can have payload lengths anywhere from 1 to 255 bytes)


    It can be found in the Arduino Library Manager (see attached screenshot) or at https://github.com/PowerBroker2/SerialTransfer

    Here is an example set of Arduino sketches:

    TX Arduino:
    Code:
    #include "SerialTransfer.h"
    
    SerialTransfer myTransfer;
    
    void setup()
    {
      Serial.begin(115200);
      Serial1.begin(115200);
      myTransfer.begin(Serial1);
    }
    
    void loop()
    {
      myTransfer.txBuff[0] = 'h';
      myTransfer.txBuff[1] = 'i';
      myTransfer.txBuff[2] = '\n';
      
      myTransfer.sendData(3);
      delay(100);
    }
    RX Arduino:
    Code:
    #include "SerialTransfer.h"
    
    SerialTransfer myTransfer;
    
    void setup()
    {
      Serial.begin(115200);
      Serial1.begin(115200);
      myTransfer.begin(Serial1);
    }
    
    void loop()
    {
      int8_t result = myTransfer.available();
      if(result == NEW_DATA)
      {
        Serial.println("New Data");
        for(byte i = 0; i < 3; i++)
          Serial.write(myTransfer.rxBuff[i]);
        Serial.println();
      }
      else if((result != NO_DATA) && (result != CONTINUE))
      {
        Serial.print("ERROR: ");
        Serial.println(result);
      }
    }
    Click image for larger version. 

Name:	screenshot.PNG 
Views:	10 
Size:	411.0 KB 
ID:	17775

  2. #2
    Junior Member
    Join Date
    May 2018
    Posts
    3
    It looks like the library uses simple checksum instead of CRC?

  3. #3
    Senior Member
    Join Date
    Jan 2014
    Posts
    148
    Quote Originally Posted by MechWrench View Post
    It looks like the library uses simple checksum instead of CRC?
    Yep, looks like a simple checksum - no CCITT polynomial to be found. And it seems to be segmenting data inefficiently.

    Checksums are ok, but less reliable than CRC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •