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

Thread: Serial Data Transfer Library Finished!

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

    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:	18 
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
    149
    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.

  4. #4
    Junior Member
    Join Date
    Feb 2018
    Posts
    16
    Quote Originally Posted by BJB View Post
    it seems to be segmenting data inefficiently.
    I'm not sure what you're getting at - what do you mean?

  5. #5
    Junior Member
    Join Date
    Feb 2018
    Posts
    16
    Also, I updated the library a ton since originally posting this. One of the big updates is that I replaced the checksum portion with CRC-8 (polynomial 0x9B with a lookup table)

  6. #6
    Junior Member
    Join Date
    Feb 2018
    Posts
    16
    Recently finished writing the pip-installable Python package pySerialTransfer that is compatible with SerialTransfer.h. Now you can easily, quickly, and reliably communicate with Arduinos via Python!

Posting Permissions

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