io.gpiod1.Chip

Description

Represents a single GPIO chip in the system.

Properties

io.gpiod1.Chip:Name

Name readable s

Name of the chip as represented in the kernel.

io.gpiod1.Chip:Label

Label readable s

Label of the chip as represented in the kernel.

io.gpiod1.Chip:NumLines

NumLines readable u

Number of GPIO lines exposed by this chip.

io.gpiod1.Chip:Path

Path readable ay

Filesystem path used to open this chip.

Methods

io.gpiod1.Chip.RequestLines

RequestLines (
  IN line_config (a(aua{sv})ai),
  IN request_config a{sv},
  OUT request_path o
)

Requests a set of lines and makes it possible for the users of this API to manipulate them depending on the line configuration.

Line configuration is a tuple of two arrays. The first one contains mappings of arrays of line offsets to sets of line settings. The second contains the list of default output values which are only used in output mode.

Available line config options:

  • “direction”: String representing the line direction. Accepts the following values: “input”, “output”.

  • “edge”: String representing the edge detection setting. Accepts the following values: “falling”, “rising”, “both”.

  • “active-low”: Boolean representing the active-low setting.

  • “drive”: String representing the drive settings. Accepts the following values: “push-pull”, “open-drain”, “open-source”.

  • “bias”: String representing the internal bias settings. Accepts the following values: “disabled”, “pull-up”, “pull-down”, “as-is”.

  • “debounce-period”: Debounce period in microseconds, represented as a signed 64-bit integer.

  • “event-clock”: String representing the clock used to timestamp edge events. Accepts the following values: “monotonic”, “realtime”, “hte”.

Output values are applied to the lines in the order they appear in the settings mappings.

Example variant that allows requesting lines at offsets 1, 5, and 11 in output, push-pull, and active-low modes, and specifies the output values as active (as visualized with g_variant_print()):

// Line config tuple
(
  // Array of line settings mappings
  [
    // Single mapping tuple
    (
      // Offsets to map
      [1, 5, 11],
      // Line settings dict
      {
        'direction': <'output'>,
        'drive': <'push-pull'>,
        'active-low': <true>
      }
    )
  ],
  // Output values
  [1, 1, 1]
)

Request configuration is a hashmap mapping names of the available config options to their values wrapped in a variant.

Available request config options:

  • “consumer”: Consumer name as a string.

  • “event-buffer-size”: Requested size of the in-kernel edge event buffer, as an unsigned 32-bit integer.

The object path to the new request is returned on success. The user should wait for it to appear before trying to use the requested lines in any way.

line_config

Line configuration. See below for details.

request_config

Request configuration. See below for details.

request_path

Object path pointing to the newly added request.