Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Safe wrapper around Rust FFI bindings for libgpiod
libgpiod
is a C library that provides an easy to use abstraction over the Linux GPIO
character driver. This crate builds on top of libgpiod-sys
and exports a safe
interface to the C library.
Build requirements
By default, libgpiod-sys
builds against the libgpiod version identified via
pkg-config
. See the README.md
of libgpiod-sys
for options to override
that.
Currently at least libgpiod 2.0 is required with the default feature set.
Features
The Rust bindings will usually be built against whatever libgpiod version a system provides. Hence, only the functionality of the oldest supported libgpiod C library will be exposed by default.
Setting flags allows to increase the base version and export features of newer versions:
v2_1
: Minimum version of2.1.x
vnext
: The upcoming, still unreleased version of the C lib
Examples
Get GPIO chip information:
let chip = open?;
let info = chip.info?;
println!;
Print GPIO line name:
let chip = open?;
let info = chip.line_info?;
let name = info.name.unwrap_or;
println!;
Toggle GPIO line output value:
let mut settings = new?;
settings
.set_direction?
.set_output_value?;
let mut line_cfg = new?;
line_cfg.add_line_settings?;
let mut req_cfg = new?;
req_cfg.set_consumer?;
let chip = open?;
/* Request with value 1 */
let mut req = chip.request_lines?;
/* Toggle to value 0 */
req.set_value?;
Read GPIO line event:
let mut lsettings = new?;
lsettings
.set_direction?
.set_edge_detection?;
let mut line_cfg = new?;
line_cfg.add_line_settings?;
let mut req_cfg = new?;
req_cfg.set_consumer?;
let chip = open?;
let req = chip.request_lines?;
let mut buffer = new?;
loop
License
This project is licensed under either of
- Apache License, Version 2.0
- BSD-3-Clause License