Skip to content

Super simple, lightweight implementation of the byte stuffing aspect of PPP (point-to-point protocol) for use in embedded projects, in particular for communicating with a PC host over a USB-Serial adapter, or in other cases where IDLE line detection is impossible or impractical.

Notifications You must be signed in to change notification settings

Ocanath/byte-stuffing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embedded Byte Stuffing Library

Introduction

This library contains C .h and .c files for byte stuffing. The library implements the following protocols:

Usage

Option 1: Direct Integration

Copy the headers into your project directly and add to your build environment.

Option 2: Git Submodule

Add this library as a submodule and link to the headers.

Option 3: CMake with FetchContent (Recommended)

Add this to your CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(
    byte_stuffing
    GIT_REPOSITORY https://github.com/Ocanath/byte-stuffing.git
    GIT_TAG        master  # or specific commit/tag
)

FetchContent_MakeAvailable(byte_stuffing)

# Link the libraries to your target
target_link_libraries(your_target_name PRIVATE cobs PPP)

Manual Build

To build the libraries manually:

mkdir build && cd build
cmake ..
cmake --build .

This will generate:

  • libcobs.a - COBS (Consistent Overhead Byte Stuffing) library
  • libPPP.a - PPP/HDLC (High-Level Data Link Control) library

C++ Integration

Both libraries are C++ compatible. Include the headers in your C++ code:

#include "cobs.h"    // COBS functionality
#include "PPP.h"     // PPP/HDLC functionality

Unit Tests

C Tests

To run the C unit tests, install ceedling and simply run: ceedling test:all

Python Tests

A Python implementation of COBS is available in cobs.py. To run the Python tests:

pip install pytest
pytest Python\test_cobs.py -v

About

Super simple, lightweight implementation of the byte stuffing aspect of PPP (point-to-point protocol) for use in embedded projects, in particular for communicating with a PC host over a USB-Serial adapter, or in other cases where IDLE line detection is impossible or impractical.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published