Giter Club home page Giter Club logo

lio's Introduction

LIO - Simplified GPIO handling in C++

The purpose of this library is to simplify/unifiy GPIO pin handling in C++. Use this library to handle I/O pins unified, regardless from HW and OS. Hence you can implement platform and hw independent business logic.

Implementation

Linux (any linux based OS, i.e.: Raspbian for Raspbery PIs)

  • GPIOLib
  • Sysfs (legacy) Both of the implementation can be used from user space (user shoud be in gpio group). They are located under ./linux directory. If you need performance critical IO driving, you should consider to write a driver for your applcation and use new GPIOlib features. Kernel also provide various of functionalities (including debouncing) so it worths a try. This library and the implemetation of IO driving in linux tries to make easier taking the first step and simplify GPIO handling from user space.

Example

Example was tested on Raspiabian 10 (buster). HW was a Raspberry Pi 4. The example SW generate 4s wavelength square wave on pin 20 and 16, and creates async linstener on pin 26 and 19. Output waveform image 20, 26 pins are driven by sysfs, 16, 19 pins are driven buy gpiolib implementation. image

If you pull up input pins to 3.3V or pull down to GND, std output should show that the event occurred. Sysfs implementation are attached to a SW implemented debouncer.

ESP32-FreeRTOS

In progress

Compilation

Project uses CMake. To compile download and install CMake from https://cmake.org/download/. To create build files enter LIO and configure the project:

cmake ./CMakeLists.txt -Bbuild
cd build
cmake --build . -j

Compiler should support at least cpp14.

From release-2.0.3 you can generate the project with cake 3.13. It means you are able to use the officially shipped cmake package on raspian.

Tests

Unit tests are witten with the help of gtest/gmock framework. You can enable them to set BUILD_TESTS cmake veriable.

Release notes

v2.0 are not backwards compatible to v1.0. Sorry about that.

License

This project is licensed under the Appache 2.0 License - see the [LICENSE]

lio's People

Contributors

perimeno avatar

Stargazers

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

Watchers

 avatar  avatar

lio's Issues

adding Documentation

I am interested in using the library but could not find much documentation. The example is not very helpful either if you don't even know how the library works.
It would be nice to have some more examples (that also have descriptions) and to have an API documentation (maybe generated by doxygen or some similar software).
These should also be linked in the readme so that new developers can get started without many problems.

Missing library symbols

I built the lib on Raspian - hand installed includes and libs in /usr/local

My attempts to compile example.cpp report missing symbols when linked with either/or/both LIOlib & LIOLinuxlib

i.e.
g++ -L/usr/local/lib -lLIOLinuxlib -lLIOlib example.o
-o example
/usr/bin/ld: example.o: in function main': example.cpp:(.text+0x3e0): undefined reference to LIO::DebouncedInput::DebouncedInput(LIO::InputPin&, LIO::BasicTimer&, std::chrono::duration<long long, std::ratio<1ll, 1000ll> >)'
/usr/bin/ld: example.cpp:(.text+0x404): undefined reference to LIO::DebouncedInput::setOnCallback(std::function<void ()>)' /usr/bin/ld: example.cpp:(.text+0x434): undefined reference to LIO::DebouncedInput::setOffCallback(std::function<void ()>)'
/usr/bin/ld: example.cpp:(.text+0x470): undefined reference to LIO::InputPin::SetEventCallback(std::function<void (bool)>)' /usr/bin/ld: example.cpp:(.text+0x690): undefined reference to LIO::DebouncedInput::~DebouncedInput()'
/usr/bin/ld: example.cpp:(.text+0x73c): undefined reference to LIO::DebouncedInput::~DebouncedInput()' /usr/bin/ld: example.o: in function void __gnu_cxx::new_allocatorLIO::OutputSysfs::construct<LIO::OutputSysfs, int>(LIO::OutputSysfs*, int&&)':
example.cpp:(.text.ZN9__gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPT_DpOT0[ZN9__gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPT_DpOT0]+0x48): undefined reference to LIO::OutputSysfs::OutputSysfs(unsigned int)' /usr/bin/ld: example.o: in function void __gnu_cxx::new_allocatorLIO::InputSysfs::construct<LIO::InputSysfs, int>(LIO::InputSysfs*, int&&)':
example.cpp:(.text.ZN9__gnu_cxx13new_allocatorIN3LIO10InputSysfsEE9constructIS2_JiEEEvPT_DpOT0[ZN9__gnu_cxx13new_allocatorIN3LIO10InputSysfsEE9constructIS2_JiEEEvPT_DpOT0]+0x48): undefined reference to LIO::InputSysfs::InputSysfs(unsigned int)' /usr/bin/ld: example.o: in function void __gnu_cxx::new_allocatorLIO::OutputGpioLib::construct<LIO::OutputGpioLib, char const (&) [10], int>(LIO::OutputGpioLib*, char const (&) [10], int&&)':
example.cpp:(.text.ZN9__gnu_cxx13new_allocatorIN3LIO13OutputGpioLibEE9constructIS2_JRA10_KciEEEvPT_DpOT0[ZN9__gnu_cxx13new_allocatorIN3LIO13OutputGpioLibEE9constructIS2_JRA10_KciEEEvPT_DpOT0]+0x5c): undefined reference to LIO::OutputGpioLib::OutputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in function void __gnu_cxx::new_allocatorLIO::InputGpioLib::construct<LIO::InputGpioLib, char const (&) [10], int>(LIO::InputGpioLib*, char const (&) [10], int&&)':
example.cpp:(.text.ZN9__gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPT_DpOT0[ZN9__gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPT_DpOT0]+0x5c): undefined reference to LIO::InputGpioLib::InputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in function void __gnu_cxx::new_allocatorLIO::SoftTimer::constructLIO::SoftTimer(LIO::SoftTimer*)':
example.cpp:(.text.ZN9__gnu_cxx13new_allocatorIN3LIO9SoftTimerEE9constructIS2_JEEEvPT_DpOT0[ZN9__gnu_cxx13new_allocatorIN3LIO9SoftTimerEE9constructIS2_JEEEvPT_DpOT0]+0x2c): undefined reference to `LIO::SoftTimer::SoftTimer()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:35: example] Error 1

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.