GPIO control libraries for C++, Python3, Node.js, Node-red

Post Reply
User avatar
tony.hong
Posts: 136
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 32 times
Been thanked: 40 times
Contact:

GPIO control libraries for C++, Python3, Node.js, Node-red

Post by tony.hong »

GPIO control libraries for C++, Python3, Node.js, Node-red

The goals
  • Allows users to write code in a language they are familiar with
  • Allows users to easily change another language. APIs are very similar. So they can easily change it.
  • Allows users to control GPIO using diagrams. It supports Node-red.
  • Supports C++, Python3, Node.js, Rust, Go, Node-red, Arduino, Scratch, Etc.
  • Supports All Odroid boards.
  • Supports happy coding for a lot of users, for a lot of IoT projects. LoLIoT =>LOT
There are no libraries above v1.0.0. Until v1.0.0, API may not be backward compatible even if the MAJOR version does not change.

C++, Python3, Node.js for Odroid-N2 support Digital I/O, Analog I, Uart, I2c, Spi.
Node-red for Odroid-N2 supports Digital I/O, Analog I.

Try it out and comment on any issue(bug, enhancement, question, etc).

Note that these libraries only use physical pin numbers.

See the installation guide below.

utility: https://github.com/loliot/lot
Odroid-N2(C++): https://github.com/loliot/lot-odroid-n2
Python3: https://github.com/loliot/python3-lot
Node.js: https://github.com/loliot/node-lot-gpio
Node-red: https://github.com/loliot/node-red-contrib-lot

Docs

You can create C ++ Docs using Doxygen.

Python3 Docs is very comfortable.

Code: Select all

>>> import lot
>>> help(lot)
>>> help(lot.Gpio)
>>> help(lot.Spi)
>>> help(lot.I2c)
>>> help(lot.Uart)
>>> help(lot.Gpio.toggle)
...
Blink Example

Ref: 'lot' spelling is L, O, T.

C++

Code: Select all

#include <lot/lot.h>
#include <lot/Gpio.h>

int main( void )
{
    lot::init_time();
    lot::Gpio led( 13 );
    led.mode( lot::DOUT );

    while( 1 )
    {
        led.toggle();
        lot::delay_ms( 200 );
    }
}
Python3

Code: Select all

import lot

lot.init_time()
led = lot.Gpio(13)
led.mode(lot.DOUT)

while True:
    led.toggle()
    lot.delay_ms(200)

Node.js

Code: Select all

const lot = require("lot-gpio");

const led = new lot.Gpio(13);
led.mode(lot.DOUT);

setInterval(() => {
    led.toggle();
}, 200);
Node-red
.
node-red-lot-blink.gif
node-red-lot-blink.gif (65.41 KiB) Viewed 7353 times
These users thanked the author tony.hong for the post (total 5):
mad_ady (Tue Jan 28, 2020 2:58 pm) • joerg (Tue Jan 28, 2020 3:35 pm) • mctom (Fri Nov 26, 2021 6:44 am) • istanbulls (Tue Nov 30, 2021 1:18 am) • m_ueberall (Thu Feb 03, 2022 6:12 am)

User avatar
mad_ady
Posts: 10817
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4 (HC1, HC2), C1+, C2, C4 (HC4), N1, N2, H2, Go, Go Advance, M1
Location: Bucharest, Romania
Has thanked: 647 times
Been thanked: 951 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by mad_ady »

Quite a big project you have here :)

User avatar
joerg
Posts: 1645
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 134 times
Been thanked: 288 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by joerg »

Very impressive!

User avatar
tony.hong
Posts: 136
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 32 times
Been thanked: 40 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by tony.hong »

I will be the god of GPIO 8-) :lol:

mandooawr
Posts: 60
Joined: Tue Dec 08, 2020 5:29 pm
languages_spoken: english
ODROIDs: N2+
Has thanked: 0
Been thanked: 0
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by mandooawr »

지금은 사용이 안되나요?

habakuk
Posts: 14
Joined: Wed Feb 10, 2021 5:05 pm
languages_spoken: english
ODROIDs: C2 on Ubuntu 18.04
Has thanked: 1 time
Been thanked: 0
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by habakuk »

hello!

I am looking forward to install your nodes but unfortunately I cannot:

i am running Odroid C2, Ubuntu 18.04 on 5.13.14 node-red 2.1.3:
==================================================================

Code: Select all

2021-11-11T13:10:26.056Z Installieren : node-red-contrib-lot 0.3.0

2021-11-11T13:10:28.132Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-lot@0.3.0
2021-11-11T13:10:37.724Z [err] npm
2021-11-11T13:10:37.725Z [err]  WARN deprecated har-validator@5.1.5: this library is no longer supported
2021-11-11T13:10:38.005Z [err] npm
2021-11-11T13:10:38.005Z [err]  WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
2021-11-11T13:10:38.364Z [err] npm
2021-11-11T13:10:38.365Z [err]  WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
2021-11-11T13:10:42.599Z [err] npm
2021-11-11T13:10:42.600Z [err]  ERR! code 1
2021-11-11T13:10:42.600Z [err] npm ERR! path /home/odroid/.node-red/node_modules/lot-gpio
2021-11-11T13:10:42.616Z [err] npm
2021-11-11T13:10:42.617Z [err]  ERR! command failed
2021-11-11T13:10:42.617Z [err] npm
2021-11-11T13:10:42.618Z [err]  ERR! command sh -c node-gyp rebuild
2021-11-11T13:10:42.618Z [err] npm ERR! make: Entering directory '/home/odroid/.node-red/node_modules/lot-gpio/build'
2021-11-11T13:10:42.619Z [err] npm ERR!   CC(target) Release/obj.target/nothing/node_modules/node-addon-api/src/nothing.o
2021-11-11T13:10:42.619Z [err] npm ERR!   AR(target) Release/obj.target/node_modules/node-addon-api/src/nothing.a
2021-11-11T13:10:42.619Z [err] npm
2021-11-11T13:10:42.620Z [err]  ERR!   COPY Release/nothing.a
2021-11-11T13:10:42.620Z [err] npm ERR!   CXX(target) Release/obj.target/lot/c_src/lot.o
2021-11-11T13:10:42.620Z [err] npm ERR! lot.target.mk:119: recipe for target 'Release/obj.target/lot/c_src/lot.o' failed
2021-11-11T13:10:42.620Z [err] npm ERR!
2021-11-11T13:10:42.620Z [err]  make: Leaving directory '/home/odroid/.node-red/node_modules/lot-gpio/build'
2021-11-11T13:10:42.620Z [err] npm ERR!
2021-11-11T13:10:42.621Z [err]  gyp info it worked if it ends with ok
2021-11-11T13:10:42.621Z [err] npm ERR! gyp info using node-gyp@5.0.7
2021-11-11T13:10:42.621Z [err] npm ERR! gyp info using node@12.11.1 | linux | arm64
2021-11-11T13:10:42.621Z [err] npm ERR! gyp info find Python using Python version 2.7.17 found at "/usr/bin/python"
2021-11-11T13:10:42.622Z [err] npm ERR! gyp info spawn /usr/bin/python
2021-11-11T13:10:42.622Z [err] npm ERR! gyp info spawn args [
2021-11-11T13:10:42.622Z [err] npm ERR! gyp info spawn args   '/home/odroid/.node-red/node_modules/node-gyp/gyp/gyp_main.py',
2021-11-11T13:10:42.622Z [err] npm
2021-11-11T13:10:42.623Z [err]  ERR! gyp info spawn args   'binding.gyp',
2021-11-11T13:10:42.623Z [err] npm 
2021-11-11T13:10:42.623Z [err] ERR! gyp info spawn args   '-f',
2021-11-11T13:10:42.623Z [err] npm 
2021-11-11T13:10:42.623Z [err] ERR! gyp info spawn args   'make',
2021-11-11T13:10:42.623Z [err] npm
2021-11-11T13:10:42.624Z [err]  ERR! gyp info spawn args   '-I',
2021-11-11T13:10:42.624Z [err] npm
2021-11-11T13:10:42.624Z [err]  ERR! gyp info spawn args   '/home/odroid/.node-red/node_modules/lot-gpio/build/config.gypi',
2021-11-11T13:10:42.624Z [err] npm
2021-11-11T13:10:42.624Z [err]  ERR! gyp info spawn args   '-I',
2021-11-11T13:10:42.624Z [err] npm ERR!
2021-11-11T13:10:42.625Z [err]  gyp info spawn args   '/home/odroid/.node-red/node_modules/node-gyp/addon.gypi',
2021-11-11T13:10:42.625Z [err] npm 
2021-11-11T13:10:42.625Z [err] ERR! gyp info spawn args   '-I',
2021-11-11T13:10:42.625Z [err] npm 
2021-11-11T13:10:42.625Z [err] ERR! gyp info spawn args   '/home/odroid/.cache/node-gyp/12.11.1/include/node/common.gypi',
2021-11-11T13:10:42.625Z [err] npm
2021-11-11T13:10:42.625Z [err]  ERR! gyp info spawn args   '-Dlibrary=shared_library',
2021-11-11T13:10:42.626Z [err] npm ERR! gyp info spawn args   '-Dvisibility=default',
2021-11-11T13:10:42.626Z [err] npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/odroid/.cache/node-gyp/12.11.1',
2021-11-11T13:10:42.626Z [err] npm
2021-11-11T13:10:42.626Z [err]  ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/odroid/.node-red/node_modules/node-gyp',
2021-11-11T13:10:42.627Z [err] npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/odroid/.cache/node-gyp/12.11.1/<(target_arch)/node.lib',
2021-11-11T13:10:42.627Z [err] npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/odroid/.node-red/node_modules/lot-gpio',
2021-11-11T13:10:42.627Z [err] npm
2021-11-11T13:10:42.627Z [err]  ERR! gyp info spawn args   '-Dnode_engine=v8',
2021-11-11T13:10:42.627Z [err] npm
2021-11-11T13:10:42.628Z [err]  ERR! gyp info spawn args   '--depth=.',
2021-11-11T13:10:42.628Z [err] npm ERR! gyp info spawn args   '--no-parallel',
2021-11-11T13:10:42.628Z [err] npm ERR! gyp info spawn args   '--generator-output',
2021-11-11T13:10:42.628Z [err] npm
2021-11-11T13:10:42.629Z [err]  ERR! gyp info spawn args   'build',
2021-11-11T13:10:42.629Z [err] npm ERR! gyp info spawn args   '-Goutput_dir=.'
2021-11-11T13:10:42.629Z [err] npm
2021-11-11T13:10:42.629Z [err]  ERR! gyp info spawn args ]
2021-11-11T13:10:42.629Z [err] npm 
2021-11-11T13:10:42.629Z [err] ERR! gyp info spawn make
2021-11-11T13:10:42.629Z [err] npm 
2021-11-11T13:10:42.630Z [err] ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
2021-11-11T13:10:42.630Z [err] npm
2021-11-11T13:10:42.630Z [err]  ERR! In file included from ../c_src/lot.cpp:28:0:
2021-11-11T13:10:42.630Z [err] npm
2021-11-11T13:10:42.630Z [err]  ERR! ../c_src/GpioWrapper.h:28:10: fatal error: lot/Gpio.h: No such file or directory
2021-11-11T13:10:42.630Z [err] npm 
2021-11-11T13:10:42.631Z [err] ERR!  #include <lot/Gpio.h>
2021-11-11T13:10:42.631Z [err] npm
2021-11-11T13:10:42.631Z [err]  ERR!           ^~~~~~~~~~~~
2021-11-11T13:10:42.631Z [err] npm
2021-11-11T13:10:42.631Z [err]  ERR! compilation terminated.
2021-11-11T13:10:42.631Z [err] npm
2021-11-11T13:10:42.632Z [err]  ERR! make: *** [Release/obj.target/lot/c_src/lot.o] Error 1
2021-11-11T13:10:42.632Z [err] npm
2021-11-11T13:10:42.632Z [err]  ERR! gyp ERR! build error 
2021-11-11T13:10:42.632Z [err] npm
2021-11-11T13:10:42.632Z [err]  ERR! gyp ERR! stack Error: `make` failed with exit code: 2
2021-11-11T13:10:42.632Z [err] npm
2021-11-11T13:10:42.633Z [err]  ERR! gyp ERR! stack     at ChildProcess.onExit (/home/odroid/.node-red/node_modules/node-gyp/lib/build.js:194:23)
2021-11-11T13:10:42.633Z [err] npm 
2021-11-11T13:10:42.633Z [err] ERR! gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
2021-11-11T13:10:42.633Z [err] npm 
2021-11-11T13:10:42.633Z [err] ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
2021-11-11T13:10:42.633Z [err] npm 
2021-11-11T13:10:42.634Z [err] ERR! gyp ERR! System Linux 5.14.16-arm64
2021-11-11T13:10:42.634Z [err] npm ERR!
2021-11-11T13:10:42.634Z [err]  gyp ERR! command "/home/odroid/.nvm/versions/node/v12.11.1/bin/node" "/home/odroid/.node-red/node_modules/.bin/node-gyp" "rebuild"
2021-11-11T13:10:42.634Z [err] npm 
2021-11-11T13:10:42.634Z [err] ERR! gyp ERR! cwd /home/odroid/.node-red/node_modules/lot-gpio
2021-11-11T13:10:42.634Z [err] npm ERR!
2021-11-11T13:10:42.635Z [err]  gyp ERR! node -v v12.11.1
2021-11-11T13:10:42.635Z [err] npm ERR!
2021-11-11T13:10:42.635Z [err]  gyp ERR! node-gyp -v v5.0.7
2021-11-11T13:10:42.635Z [err] npm ERR!
2021-11-11T13:10:42.635Z [err]  gyp ERR! not ok
2021-11-11T13:10:42.673Z [err] 
2021-11-11T13:10:42.673Z [err] npm ERR! A complete log of this run can be found in:
2021-11-11T13:10:42.674Z [err] npm ERR!     /home/odroid/.npm/_logs/2021-11-11T13_10_42_643Z-debug.log
2021-11-11T13:10:42.708Z rc=1

do you have any ideas?

User avatar
mctom
Posts: 1946
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1
Location: Gdansk, Poland
Has thanked: 223 times
Been thanked: 273 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by mctom »

Thanks a dozen for your C++ library, that surely helped me develop N2(+) support for my board. Kudos!
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

MrMark
Posts: 2
Joined: Mon Jan 24, 2022 10:22 pm
languages_spoken: english
ODROIDs: N2/N2+
Has thanked: 0
Been thanked: 0
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Post by MrMark »

Is this still active?
would love to get node-red to work with the GPIO pins on the Odroid N2+, but so far no luck at all...
Running Odroid N2+ with armbian buster, also tried focal & bullseye, will try mate later this week...

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 5 guests