npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wiringpi-sx

v0.0.1

Published

wiringpi for Node.js on Raspberry Pi

Downloads

3

Readme

wiringpi-sx

Install

npm install wiringpi-sx

Usage

Javascript

var wpi = require('wiring-pi');

Typescript

use * as wpi from 'wiringpi-sx';

Documentation

See the DOCUMENTATION.md file to find some more detailed documentation, but hold in mind, that only basics are implemented at the moment.

See the index.d.ts file to see in detail which functions and constants are implemented at the moment.

Overview

This package implements the binding to the native wiringPi library for Node.js on Raspberry Pi.

This project is a further development of the existing packages wiringpi-node and wiringpi. In contrast to these projects, this package is using the Node.js N-API interface to integrate the native wiringPi library into the Node.js virtual machine.

The N-API interface is independent from the underlying JavaScript runtime (ex V8) and is maintained as part of Node.js itself. This API will be Application Binary Interface (ABI) stable across versions of Node.js. It is intended to insulate Addons from changes in the underlying JavaScript engine and allow modules compiled for one version to run on later versions of Node.js without recompilation.

At the moment only basic functions are implemented:

  • Digital pin mode
  • Digital pin read and write operation
  • SPI interface
  • UART interface

The usage of macros is avoided to allow simple straightforward analysis of code. Also the failure handling is improved by:

  • the usage of exceptions.
  • the usage of file names and line numbers in error messages.
  • checking all native return values consequently.

Also some files of the orignal wiringPi library are modified in order to:

  • allow acces to error messages from the linux system (strerror())
  • avoiding an exit call in case of an error, which would lead to a break down of the Node.js process. Instead an error break down, an javascript error is thrown which could be catched and handled inside javascript / typescript.

The type definitions inside the file [index.d.ts][index.d.ts] allow the usage of Typescript as programming language.

Building the project

In case of install fails or change of code you can rebuild this project.

Building the native wiringPi library

Make sure that all C++ building tools are available (apt install build-essential).

  1. Change to the cloned project (git clone ...) or the installed package under the subdirectory path node_modules.
  2. Change to subdirectory wiringPi/wiringPi with cd wiringPi/wiringPi
  3. Clean the project with make clean
  4. Rebuild the project with make static

As result the binary library file libwiringPi.a is available in the subdirectory wiringPi/wiringPi. This file is statically included into the binary Node.js module file wiring_pi_sx.node in the subdirectory build/Release.

For further information see http://wiringpi.com/download-and-install. Hold in mind that the wiringPi source files differ from the original wiringPi sources!

Building the binary Node.js module file

The source files are located in the subdirctory src. For building the npm package module node-gyp is needed. Normally it is installed globally with the command sudo npm install -g node-gyp before building C++ Add-Ons.

The following commands can be used to build the native Node.js module file:

  • node-gyp configure
    Create the needed files, using the definitions in the file binding.gyp.
  • node-gyp rebuild
    Use this command when the native wiringPi library file wiringPi/wiringPi/libwiringPi.a has changed.
  • node-gyp build
    Use this command when source code in subdirctory src was changed.

For further information see https://nodejs.org/api/addons.html#addons_building.