Coder Social home page Coder Social logo

krkind / circularbuffer Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 0.0 19 KB

This repository contains a circular buffer or a ring buffer implementation in C code suitable for embedded systems.

License: MIT License

Python 9.44% C 53.80% C++ 30.99% Shell 5.77%
circular-buffer circularbuffer ring-buffer ringbuffer c

circularbuffer's Introduction

Circular Buffer

This repository contains a circular buffer or a ring buffer implementation in C code suitable for embedded systems. The implementation using a single empty cell to detect the buffer "full" case; for supporting a single producer thread and single consumer thread without OS lock primitive. For use of efficient algorithms the maximum number of elements in the circular buffer must be a power of 2. The code follows the Google C++ Style Guide with one exception that instead of 2 spaces it use 4 spaces.

Unittest

The added unittest uses the googletest framework and the SCons build system.

Follow the steps below for building the unittest

  1. Install the scons, if you run on an Ubuntu machine:

    sudo apt install scons

  2. Go to https://github.com/google/googletest and clone the git repo besides the circularbuffer repo.

  3. Create a directory called build_gtest beside the circularbuffer and googletest repos.

  4. Now you shall have the following directory structure:

  <your path>
      | build_gtest
      | circularbuffer
      | googletest
  1. Change directory to the new directory build_gtest.

  2. Build the google test framework:

    <your path>/build_gtest$ cmake ../googletest/

    <your path>/build_gtest$ make

  3. Change directory to <your path>/circularbuffer.

  4. Build, run and clean the units test with the scons command:

    <your path>/circularbuffer$ scons test

    <your path>/circularbuffer$ scons test -c

  5. Optional build, run and clean the units test with the commands:

    <your path>/circularbuffer$ scons

    <your path>/circularbuffer$ ./build/circularbuffer-gtest

    <your path>/circularbuffer$ scons -c

Follow the steps below for generate code coverage report

  1. Install the lcov, if you run on an Ubuntu machine:

    sudo apt install lcov

  2. Generate report:

    <your path>/circularbuffer$ ./gen_test_report.sh

  3. Html output result is found here

    <your path>/circularbuffer/build/out$

  4. Delete report:

    <your path>/circularbuffer$ ./gen_test_report.sh -c

circularbuffer's People

Contributors

krkind avatar

Stargazers

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

Watchers

 avatar

circularbuffer's Issues

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.