Skip to content
Snippets Groups Projects
  • Kent Gibson's avatar
    8ffb6489
    tools: line name focussed rework · 8ffb6489
    Kent Gibson authored
    
    Rework the tool suite to support identifying lines by name and to
    support operating on the GPIO lines available to the user at once, rather
    than on one particular GPIO chip.
    
    All tools, other than gpiodetect, now provide the name to (chip,offset)
    mapping that was previously only performed by gpiofind. As names are not
    guaranteed to be unique, a --strict option is provided for all tools to
    either abort the operation or report all lines with the matching name, as
    appropriate.
    By default the tools operate on the first line found with a matching name.
    
    Selection of line by (chip,offset) is still supported with a --chip
    option, though it restricts the scope of the operation to an individual
    chip.  When the --chip option is specified, the lines are assumed to be
    identified by offset where they parse as an integer, else by name.
    To cater for the unusual case where a line name parses as an integer,
    but is different from the offset, the --by-name option forces the lines
    to be identified by name.
    
    The updated tools are intentionally NOT backwardly compatible with the
    previous tools. Using old command lines with the updated tools will
    almost certainly fail, though migrating old command lines is generally as
    simple as adding a '-c' before the chip.
    
    In addition the individual tools are modified as follows:
    
    gpiodetect:
    
    Add the option to select individual chips.
    
    gpioinfo:
    
    Change the focus from chips to lines, so the scope can be
    an individual line, a subset of lines, all lines on a particular chip,
    or all the lines available to the user.  For line scope a single line
    summary is output for each line.  For chip scope the existing format
    displaying a summary of the chip and each of its lines is retained.
    
    Line attributes are consolidated into a list format, and are extended
    to cover all attributes supported by uAPI v2.
    
    gpioget:
    
    The default output format is becomes line=value, as per the
    input for gpioset, and the value is reported as active or inactive,
    rather than 0 or 1.
    The previous format is available using the --numeric option.
    
    Add an optional hold period between requesting a line and reading the
    value to allow the line to settle once the requested configuration has
    been applied (e.g. bias).
    
    gpiomon:
    
    Consolidate the edge options into a single option.
    
    Add a debounce period option.
    
    Add options to report event times as UTC or localtime.
    
    Add format specifiers for GPIO chip path, line name, stringified event
    type, and event time as a datetime.
    
    Rearrange default output format to place fields with more predicable
    widths to the left, and to separate major field groups with tabs.
    Lines are identified consistent with the command line.
    
    gpioset:
    
    Add a hold period option that specifies the minimum period the line
    value must be held for.  This applies to all set options.
    
    Support line values specified as active/inactive, on/off and
    true/false, as well as 1/0.
    
    Add a toggle option that specifies a time sequence over which the
    requested lines should be toggled.  If the sequence is 0 terminated then
    gpioset exits when the sequence completes, else it repeats the sequence.
    This allows for anything from simple blinkers to bit bashing from the
    command line. e.g. gpioset -t 500ms LED=on
    
    Add an interactive option to provide a shell-like interface to allow
    manual or scripted manipulation of requested lines.  A basic command set
    allows lines to be get, set, or toggled, and to insert sleeps between
    operations.
    
    Remove the --mode, --sec, and --usec options.
    The combination of hold period and interactive mode provide functionality
    equivalent to the old --mode options.  By default gpioset now holds the
    line indefinitely, rather than exiting immediately.  The old exit
    behaviour can be emulated with a "-t 0" option.
    
    Signed-off-by: default avatarKent Gibson <warthog618@gmail.com>
    [Bartosz: coding style tweaks, dropped stray newlines and spaces]
    Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
    8ffb6489
    History
    tools: line name focussed rework
    Kent Gibson authored
    
    Rework the tool suite to support identifying lines by name and to
    support operating on the GPIO lines available to the user at once, rather
    than on one particular GPIO chip.
    
    All tools, other than gpiodetect, now provide the name to (chip,offset)
    mapping that was previously only performed by gpiofind. As names are not
    guaranteed to be unique, a --strict option is provided for all tools to
    either abort the operation or report all lines with the matching name, as
    appropriate.
    By default the tools operate on the first line found with a matching name.
    
    Selection of line by (chip,offset) is still supported with a --chip
    option, though it restricts the scope of the operation to an individual
    chip.  When the --chip option is specified, the lines are assumed to be
    identified by offset where they parse as an integer, else by name.
    To cater for the unusual case where a line name parses as an integer,
    but is different from the offset, the --by-name option forces the lines
    to be identified by name.
    
    The updated tools are intentionally NOT backwardly compatible with the
    previous tools. Using old command lines with the updated tools will
    almost certainly fail, though migrating old command lines is generally as
    simple as adding a '-c' before the chip.
    
    In addition the individual tools are modified as follows:
    
    gpiodetect:
    
    Add the option to select individual chips.
    
    gpioinfo:
    
    Change the focus from chips to lines, so the scope can be
    an individual line, a subset of lines, all lines on a particular chip,
    or all the lines available to the user.  For line scope a single line
    summary is output for each line.  For chip scope the existing format
    displaying a summary of the chip and each of its lines is retained.
    
    Line attributes are consolidated into a list format, and are extended
    to cover all attributes supported by uAPI v2.
    
    gpioget:
    
    The default output format is becomes line=value, as per the
    input for gpioset, and the value is reported as active or inactive,
    rather than 0 or 1.
    The previous format is available using the --numeric option.
    
    Add an optional hold period between requesting a line and reading the
    value to allow the line to settle once the requested configuration has
    been applied (e.g. bias).
    
    gpiomon:
    
    Consolidate the edge options into a single option.
    
    Add a debounce period option.
    
    Add options to report event times as UTC or localtime.
    
    Add format specifiers for GPIO chip path, line name, stringified event
    type, and event time as a datetime.
    
    Rearrange default output format to place fields with more predicable
    widths to the left, and to separate major field groups with tabs.
    Lines are identified consistent with the command line.
    
    gpioset:
    
    Add a hold period option that specifies the minimum period the line
    value must be held for.  This applies to all set options.
    
    Support line values specified as active/inactive, on/off and
    true/false, as well as 1/0.
    
    Add a toggle option that specifies a time sequence over which the
    requested lines should be toggled.  If the sequence is 0 terminated then
    gpioset exits when the sequence completes, else it repeats the sequence.
    This allows for anything from simple blinkers to bit bashing from the
    command line. e.g. gpioset -t 500ms LED=on
    
    Add an interactive option to provide a shell-like interface to allow
    manual or scripted manipulation of requested lines.  A basic command set
    allows lines to be get, set, or toggled, and to insert sleeps between
    operations.
    
    Remove the --mode, --sec, and --usec options.
    The combination of hold period and interactive mode provide functionality
    equivalent to the old --mode options.  By default gpioset now holds the
    line indefinitely, rather than exiting immediately.  The old exit
    behaviour can be emulated with a "-t 0" option.
    
    Signed-off-by: default avatarKent Gibson <warthog618@gmail.com>
    [Bartosz: coding style tweaks, dropped stray newlines and spaces]
    Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
TODO 2.09 KiB
# SPDX-License-Identifier: CC-BY-SA-4.0
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>

TODO list for libgpiod

==========

This document contains the list of things I'd like to have in libgpiod before
declaring it "mostly feature-complete". If anyone wants to help, this can
serve as the starting point.

==========

* implement dbus API for controlling GPIOs

A common complaint from users about gpioset is that the state of a line is not
retained once the program exits. While this is precisely the way linux
character devices work, it's understandable that most users will want some
centralized way of controlling GPIOs - similar to how sysfs worked.

One of the possible solutions is a DBus API. We need a daemon exposing chips
and lines as dbus objects and allowing to control and inspect lines using
dbus methods and monitor them using signals.

As of writing of this document some of the work has already been done and the
skeleton of the dbus daemon written in C using GLib has already been developed
and is partially functional.

----------

* implement a simple daemon for controlling GPIOs in C together with a client
  program

This is by far the lowest priority task. Similarly as with the dbus daemon:
the goal is to provide a centralized agent controlling GPIOs with a simple
interface consisting of a command line client communicating with the server
over unix sockets.

In this case however the goal is to have as few dependencies as possible. This
is because for some small systems dbus is overkill. Since we won't be using any
standardized protocol, it will take much more effort to implement it correctly.

----------

* improve gpioset --interactive tab completion

The existing tab completion uses libedit's readline emulation layer which
has a few limitations, including not being able to correctly handle quoted
line names and being disabled when stdin/stdout are not a tty (which makes
testing with gpio-tools-test.bats using coproc problematic).

One approach that could address both these problems is to bypass the readline
emulation and use the libedit API (histedit.h) directly.