GPIO line request

class gpiod.LineRequest(req: gpiod._ext.Request)

Stores the context of a set of requested GPIO lines.

Synchronization: objects of this class require external synchronization. Protect calls with a lock when sharing an instance across threads.

Note: LineRequest objects can only be instantiated by a Chip parent. LineRequest.__init__() is not part of stable API.

property chip_name: str

Name of the chip this request was made on.

property fd: int

File descriptor associated with this request.

fileno() int

Return the underlying file descriptor.

get_value(line: int | str) Value

Get a single GPIO line value.

Args:
line:

Offset or name of the line to get value for.

Returns:

Logical value of the line.

get_values(lines: Iterable[int | str] | None = None) list[Value]

Get values of a set of GPIO lines.

Args:
lines:

List of names or offsets of GPIO lines to get values for. Can be None in which case all requested lines will be read.

Returns:

List of logical line values.

property lines: list[int | str]

List of requested lines. Lines requested by name are listed as such.

property num_lines: int

Number of requested lines.

property offsets: list[int]

List of requested offsets. Lines requested by name are mapped to their offsets.

read_edge_events(max_events: int | None = None) list[EdgeEvent]

Read a number of edge events from a line request.

Args:
max_events:

Maximum number of events to read.

Returns:

List of read EdgeEvent objects.

reconfigure_lines(config: dict[Iterable[int | str] | int | str, LineSettings | None]) None

Reconfigure requested lines.

Args:
config

Dictionary mapping offsets or names (or tuples thereof) to LineSettings. If no entry exists, or a None is passed as the settings, then the configuration for that line is not changed. Any settings for non-requested lines are ignored.

release() None

Release this request and free all associated resources. The object must not be used after a call to this method.

set_value(line: int | str, value: Value) None

Set the value of a single GPIO line.

Args:
line:

Offset or name of the line to set.

value:

New value.

set_values(values: dict[int | str, Value]) None

Set the values of a subset of GPIO lines.

Args:
values:

Dictionary mapping line offsets or names to desired values.

wait_edge_events(timeout: timedelta | float | None = None) bool

Wait for edge events on any of the requested lines.

Args:
timeout:

Wait time limit expressed as either a datetime.timedelta object or the number of seconds stored in a float. If set to 0, the method returns immediately, if set to None it blocks indefinitely.

Returns:

True if events are ready to be read. False on timeout.