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

service-gpio

v1.0.4

Published

Generic Linux GPIO plug-in for express-modular-server

Downloads

8

Readme

Generic Linux GPIO plug-in for express-modular-server

This is a plug-in for express-modular-server. It provides a service for controlling GPIOs through the Linux sysfs interface.

If a string option is presented upon initialization, it is the base endpoint to serve GPIO control from. If this option is not present, a base endpoint of /gpio/ is used.

Install

npm install service-gpio

The device you are running on must have kernel support for the sysfs GPIO interface including actual GPIOs which can be controlled. This code has been tested on a Technologic Systems TS-7680.

Usage

The following example loads the gpio module with the default endpoint:

var server = require("express-modular-server")({
     http:true
   })
    // other API calls here
    .API("gpio")
    .start()

In this example, an endpoint of /io/ is used to control GPIOs:

var server = require("express-modular-server")({
     http:true
   })
    // other API calls here
    .API("gpio","/io/")
    .start()

To get the current state of one GPIO, issue an HTTP GET request to the server with the GPIO number at the end of the URL. Multiple GPIOs can be returned in a single call by separating GPIO numbers with a comma.

The GET request will return a JSON string encoding an array where each element corresponds to the value of the GPIO in the corresponding element of the request. Possible values returns for a GPIO are:

  • "INPUT_HIGH" (is an input currently reading high)
  • "INPUT_LOW" (is an input currently reading low)
  • "HIGH" (is currently driving high as a
  • "LOW" (is currently driving low as an output)

Example 1 (get the state of GPIO 5 which happens to be driven high):

wget http://192.168.1.100/gpio/5
=>
[ "HIGH" ]

Example 2 (get the state of GPIOs 5,6, and 23, which happen to be an input reading low, and input reading high, and driven low, respectively):

wget http://192.168.1.100/gpio/5,6,23
=>
[ "INPUT_LOW", "INPUT_HIGH", "LOW" ]

To set the state of a GPIO, issue an HTTP request to the server with the GPIO number, a slash, and the state to set at the end of the URL. Possible states are "INPUT" to set the GPIO as an input, "HIGH" to set it as an output driving a high state, and "LOW" to set it as an output driving a low state. Multiple GPIOs can be set to the same value in a single call by separating GPIO numbers with a comma. The server will return a JSON string encoding an array of status strings for each GPIO, which is either "OK" on success or "ERROR" on failure.

Example 1 (set GPIO 6 to drive a low output):

wget http://192.168.1.100/gpio/6/LOW
=>
[ "OK" ]

Example 2 (set the state of GPIOs 1 and 5 to INPUTs):

wget http://192.168.1.100/gpio/1,2/INPUT
=>
[ "OK", "OK" ]

To Do

Allow multiple values to be specified for multiple GPIOs.

Copyright

Written by Michael Schmidt.

License

GPL 3.0