JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 412
  • Score
    100M100P100Q87779F

Package Exports

  • node-libgpiod

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-libgpiod) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-libgpiod

Native nodejs bindings for libgpiod

npm

[[TOC]]

Requirements

  • libgpiod (and devel headers)
  • nodejs (and devel headers)
  • linux (tested on fedora 33 running on raspberry pi model 3 B+)
  • c/c++ development tools

Compiling

Just add it as a regular nodejs dependency:

npm i node-libgpiod

node-gyp will do the rest for you

Status

We already are able to read and write pins!

Here goes the sample blink led hello-world.js:

const { version, Chip, Line } = require("node-libgpiod");

const chip = new Chip(0);
const line = new Line(chip, 17); // led on GPIO17
let count = 10;

console.log(version());
line.requestOutputMode();

const interval = setInterval(() => {
  line.setValue(count-- % 2);
  if(!count) {
    clearInterval(interval);
    line.release();
  }
}, 1000);

See our testcases for more information

known issues

  • gpio character device needs special udev rules in order to belong to a special group so non-root users could access it freely
  • libgpiod must be installed in the system correctly with development headers otherwise npm install will fail.

Roadmap

  • basic read/write
  • basic instant read/write
  • Chip/Line abstractions
  • GPIO monitoring callbacks
  • Bulk read/write

All features present on libgpiod eventually will be added to node bindings.