Crate gpiod_core

Source
Expand description

§libgpiod in Rust

github crate docs MIT CI

Rust crate for interfacing with Linux GPIO character devices.

It provides an interface to the Linux GPIO using the chardev module. This interface involves calling ioctl funcions which are unsafe and require some unintuitive variable mapping. The functionality provided here is highly inspired by libgpiod.

Since all functionality is dependent on Linux function calls, this crate only compiles for Linux systems.

§ABI compatibility

Both ABI v1 (linux >= 4.0) and v2 (linux >= v5.10) supported but edge detection implemented for v2 only. Deprecated sysfs-based API (linux < 4.0) currently is not supported at all.

§Crates

  • gpiod-core - core abstractions and low level interface (not for end users)
  • gpiod - sync interface which supports synchronous operation only
  • tokio-gpiod - async interface for tokio fans
  • async-gpiod - async interface to use with non-tokio async runtimes

Structs§

ChipInfo
GPIO chip interface info
Error
The error type for I/O operations of the Read, Write, Seek, and associated traits.
Event
Signal edge detection event
Input
Input direction
Internal
Wrapper to hide internals
LineInfo
The information of a specific GPIO line
LineMap
Line offset to bit offset mapping
Masked
Line values with mask
Options
GPIO line values request options
Output
Output direction
Path
A slice of a path (akin to str).
PathBuf
An owned, mutable path (akin to String).
Time
A Duration type to represent a span of time, typically used for system timeouts.
ValuesInfo
GPIO lines values interface info

Enums§

Active
Active state condition of a line
Bias
Input bias of a GPIO line
Direction
Direction of a GPIO line
Drive
Output drive mode of a GPIO line
Edge
Signal edge or level transition of a GPIO line
EdgeDetect
Edge detection setting for GPIO line

Constants§

MAX_BITS
Maximum number of bits which can be get or set per time
MAX_VALUES
Maximum number of values which can be get or set per time

Traits§

AsDevicePath
Device path trait
AsValues
Something that can be used to get GPIO line values
AsValuesMut
Something that can be used to get and set GPIO line values
DirectionType
Direction trait

Functions§

check_len
check_len_str
check_size
invalid_data
invalid_input
is_set
major
This definition from libc
minor
This definition from libc
safe_get_str
safe_set_str
set_nonblock
Set non-block flag to fd
time_from_nanos

Type Aliases§

BitId
Bit offset
Bits
Value bits and mask
LineId
Line offset
RawEvent
Raw event ro read from fd
Result
A specialized Result type for I/O operations.
Values
Default values representation