gpio-utils 0.1.1

Command-line utilities for interacting with GPIOs under Linux This wraps the `sysfs_gpio` crate in a form usable by both Rust applications or any other applications.
Documentation

Linux GPIO Utils

Build Status Version License

GPIO Utils provides convenient access to GPIOs on a Linux system. The library builds on top of the sysfs interface to GPIOs exposed by the kernel and provides essential functionality required for most embedded systems.

Install

To install the latest released version of gpio utils, ensure that you have installed Rust and then run:

cargo install gpio-utils

Features

  • Infrastructure for providing names for the GPIOs in one's system providing names that map to individual pins. These names (in addition to GPIO numbers) may be used with other commands.
  • Ability to export/unexport GPIOs and expose symlinks using the GPIO "friendly" names simpler.
  • Ability to set input/output state on each pin
  • Ability to get/set gpio values by pin number or name (including temporary export if necessary)
  • Ability to block awaiting pin state change (with timeout)

System Integration

GPIO Utils provides two main pieces that one may integrate into their final system:

  1. The gpio command. This provides the core functionality for GPIO Utils and is useful in its own right.
  2. The gpio init script/systemd service. This can be integrated into a target system and will ensure that configured GPIOs get exported on system startup (The GPIO command searches for /etc/gpio.toml and /etc/gpio.d/*.toml configs)

The GPIO Utils library is built on top of the Rust sysfs-gpio library which may be used independent of this project.

GPIO Configuration File

GPIO Utils uses the TOML. There is some flexibility in the configuration, but the following examples shows the basics of how you can configure your GPIOs.

#
# Example GPIO configuration (e.g. /etc/gpio.toml)
#
# The main configuration consists of zero or more pins, each of which may have
# the following keys:
#
# - `num`: Required.  The GPIO number.
# - `names`: Required.  One or more names for the GPIO
# - `direction`: Default: `"in"`.  Must be either "in" or "out"
# - `active_low`: Default: `false`.  If set to true, the polarity of the pin will
#    be reversed.
# - `export`: Default: `true`.  If true, this GPIO will be automatically
#    exported when `gpio export-all` is run (e.g. by an init script).
#

[[pins]]
num = 73                 # required
names = ["reset_button"] # required (may have multiple)
direction = "in"         # default: in
active_low = false       # default: false (really means invert logic)
export = true            # default: true

[[pins]]
num = 37
names = ["status_led", "A27", "green_led"]
direction = "out"

# ...

Implementation Notes

Unlike several other existing solutions to this problem, this project is implemented in Rust (a modern systems programming language operating at the same level as C but with a type system providing greater productivity and reliability) and seeks to operate with a minimum of overhead.

Contributing

Contributions are very welcome. See CONTRIBUTING.md for additional information on how to report bugs, submit changes, test changes, get support, etc.

License

Copyright (c) 2016, The gpio-utils Authors.

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
http://www.apache.org/license/LICENSE-2.0> or the MIT license
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
option.  This file may not be copied, modified, or distributed
except according to those terms.