Git Product home page Git Product logo

gpiod's Introduction

LINUX GPIO DAEMON (GPIOD)

Daemon to monitor gpio via sysfs or uapi interface and send them over network or execute user defined hooks with desired arguments.

Build Status

Requirements

Explanatory note

Concept

gpiod supports both uapi and sysfs interface and currently (although this is not recommended) it can be used both at the same time. Triggers can be set to rising edge, falling edge, both or be polled via configured interval.

On being triggered an event is dispatched to all connected clients.

gpiod fully acts as a daemon, through it needs privileges to be launched as gpio's are not considered user-space.

Installation

Compiling

For version that supports both sysfs and uapi simply invoke:

$ make

For sysfs only version provide flag:

$ make WITHOUT_GPIOD_UAPI=1

Cross-Compiling

$ make CROSS_COMPILE=${TARGET_CROSS}-
# for example:
$ make CROSS_COMPILE=arm-none-linux-gnueabi-

Installing

$ make DESTDIR= prefix= install

Both DESTDIR and prefix should be used when installing to an extern rootfs.

By default /etc/gpio.d and /etc/gpiod.conf are not created - you can find different examples in etc directory of repository.

Tests

Some sanity tests are provided in tests. bats (https://github.com/sstephenson/bats) is additionally required to perform tests.

Running

Following options can be passed:

-v, --version              prints version and exits
-V, --verbose              be more verbose
-l, --log-level            set log level[default=LOG_INFO]
-n                         don't fork off as daemon
-k, --kill                 kill old daemon instance in case if present
-H, --hup                  send daemon signal to reload configuration
-p, --pid                  path to pid file[default=/var/run/gpiod.pid]
-c, --config=FILE          configuration file[default=/etc/gpiod/gpiod.conf]
-d, --tabdir=DIR           tabs location directory[default=/etc/gpiod.d/]
-h, --help                 prints this message

Configuration file

# (optional) listen on specific address, can be overriden by cmd args [default=127.0.0.1]
listen = 127.0.0.1
# (optional) listen on port, can be overriden by cmd args [default=1500]
port = 1500
# (optional) poll interval in msec, can be overriden by cmd args [default = 50]
poll = 50

gpio {
  # facility to use for this gpio sysfs or uapi [default = uapi]
  facility = uapi

  # (optional) calculated system gpio offset [nodefault]
  system = 256

  # (optional) gpiochip name [nodefault]
  gpiochip = gpiochip0

  # (optional) local offset in gpiochip, can be negative [nodefault]
  offset = 0

  # (optional) local mapping [default=system]
  local = 0

  # label for passing via libpack i.e. WD0, WD1, ..., WDN
  label = WD0

  # rising, falling, both, polled [default=both]
  edge = both
}

Hook tabs

gpiod supports launching user defined executables based on configured trigger files placed under /etc/gpio.d or specified by --tabdir,-d argument.

Tab files should be in form of :

[LABEL] [MODIFIERS]         [PATH]       [ARGS]
WD0     EDGE_RISING         /tmp/test.sh -n --version -v 23 -s test $@ $% $&

Where LABEL is pin label defined in config file i.e. label =, MODIFIERS one of EDGE_RISING, EDGE_FALLING, EDGE_BOTH and (optional) NO_LOOP, ONESHOT flags.

NO_LOOP prevents launching before previous launch has finished and ONESHOT to launch hook only once per daemon lifetime.

see etc/gpio.d/testtab example.

Copyright

© 2019 Nikita Shubin

gpiod's People

Contributors

maquefel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

gpiod's Issues

Improve README to conform current status

Currently sysfs and uapi are configurated a bit differently, i.e. some option have no effect in depence of chosen facility.

Also add global option descriptions and their effect.

respect gpio labels for sysfs

When gpio-line-names is set in device tree or via gpio-mockup gpio_mockup_named_lines parameter sysfs created gpio's will no longer have gpioN value, but instead the one provided by label:

	dev = device_create_with_groups(&gpio_class, &gdev->dev,
					MKDEV(0, 0), data, gpio_groups,
					ioname ? ioname : "gpio%u",
					desc_to_gpio(desc));

Please document how to use this daemon

I tried to understand how to use your gpiod. I read the tests and the config file. I could not find any documentation. I do not understand the bats files, sorry.
I can see it's listening to a port, but I don't know what message to send into that port.
Is there a standard message format?
Is there a way to control output pins, or is it input only?
Thanks!

Create json api for gpiod

Create json api capable of :

  • Queering information about chips and pins
  • Receive events about gpio inputs
  • Manipulate gpio outputs

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.