Giter Club home page Giter Club logo

raspberry-gpio-daemon's Introduction

raspberry-gpio-daemon

About

This is a simple daemon that facilitates access to the Raspberry Pi (RPi) GPIO ports from processes that are not running as root. This daemon, running as root, waits for connections on a Unix domain socket and implements a very simple command/response protocol to permit input and output from the GPIO ports. A typical application would be for a Web CGI script that needs access to the GPIO interface, since it's strongly advised not to run a web server as root.

Python requirements

Commands

General

  • All commands are initiated by the client program and are terminated by a newline character.
  • port is the pin number on the RPi connector, not the Broadcom channel number.
  • One response is generated per command, also terminated by a newline character.
  • Commands are case-independent.
  • Lines beginning with # are treated as comments

Command syntax

SETUP port OUT [LOW|HIGH]

Sets port as output. Optional parameter LOW or HIGH specifies the initial state of the port. Responds with 'ok' or an error message.

SETUP port IN [PULLUP|PULLDOWN]

Sets port as input. Optional parameter PULLUP or PULLDOWN specifies whether a pull up or pull down resistor is configured on the port; the default is no pull up or pull down. Responds with 'ok' or an error message.

OUTPUT port LOW|HIGH

Sets the state of the specified output port, and responds with 'ok' or an error message.

INPUT port

Reads the specified input port, and responds with its state: 'true' or 'false' or an error message.

Examples

SETUP 16 IN PULLUP
OUTPUT 11 HIGH
INPUT 16

Installation

  • Copy gpiod.py to a suitable location, such as /usr/local/sbin
  • copy gpiod (the init script) to /etc/init.d
  • Ensure that the modules listed above under Python Requirements have been installed
  • Start the daemon and test with gpiotest.py
  • If you want to initialize the interface when the daemon starts, create a script with gpiod commands at /etc/gpiod.cfg

Future work

Some ideas for enhancements include:

  • More comprehensive support of the GPIO port capabilities, such as event detection (although this may also imply changes to the socket protocol).
  • Better initialization using a pidfile
  • Ability to specify a duration for timed output pulses

Change Log

0.1.0

  • Initial version

raspberry-gpio-daemon's People

Contributors

jimfenton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.