Re: [libgpiod][PATCH 0/8] replace tool examples with use case examples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 23, 2023 at 6:39 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
>
> This series is the continuation of providing a set of use case based examples
> for libgpiod. The focus of this series is replacement of the examples
> replicating the the tools with examples that minimally cover the use case that
> each tool addresses.
>
> The mapping from tool to use case is:
>   gpiodetect  ->  get_chip_info
>   gpiofind    ->  find_line_by_name
>   gpioget     ->  get_multiple_line_values
>   gpioinfo    ->  get_line_info
>   gpiomon     ->  watch_multiple_line_values
>   gpionotify  ->  watch_line_info
>   gpioset     ->  toggle_multiple_line_values
>
> Also added a watch_line_rising example to demonstrate getting events from only
> one edge rather than both, so another gpiomon sub-case.
>
> The rust bindings had a couple of additional examples, gpio_events and
> gpio_threaded_info_events.
>
> gpio_threaded_info_events is an example of using one thread to generate info
> change events that are observed by another thread.  This is borrowed from test
> cases and has no other practical application, but the reconfiguring component
> inspired the reconfigure_input_to_output example.  That provides an example of
> reconfiguring a requested line, and is provided for all languages, not just
> rust.
>
> gpio_events is an example of how borrowed buffered events must be cloned before
> the event buffer can be reused.  This was simplified and renamed
> buffered_event_lifetimes.  As I write this I realise it may also be applicable
> to other languages - as an example of using gpiod_edge_event_copy().
> Maybe provide those in v2, or a subsequent series?
>
> The series is split into 8 parts.  For each language there is a patch that
> provides some consistency cleanups to make the existing examples more consistent
> with each other, with the examples in other languages, and with the examples to
> follow. There are also a few minor bug fixes that didn't seem sufficiently
> serious to warrant a separate patch.
>
> The second patch for each language replaces the old tool examples with the new
> use case based examples.
>
> Cheers,
> Kent.
>
> Kent Gibson (8):
>   core: examples: consistency cleanups
>   core: examples: add more use case examples
>   bindings: cxx: examples: consistency cleanup
>   bindings: cxx: examples: replace tools examples with use case examples
>   bindings: python: examples: consistency cleanup
>   bindings: python: examples: replace tools examples with use case
>     examples
>   bindings: rust: examples: consistency cleanup
>   bindings: rust: examples: replace tools examples with use case
>     examples
>
>  bindings/cxx/examples/.gitignore              |  16 +-
>  bindings/cxx/examples/Makefile.am             |  42 ++---
>  .../cxx/examples/async_watch_line_value.cpp   |   8 +-
>  bindings/cxx/examples/find_line_by_name.cpp   |  42 +++++
>  bindings/cxx/examples/get_chip_info.cpp       |  27 ++++
>  bindings/cxx/examples/get_line_info.cpp       |  39 +++++
>  bindings/cxx/examples/get_line_value.cpp      |  28 ++--
>  .../cxx/examples/get_multiple_line_values.cpp |  40 +++++
>  bindings/cxx/examples/gpiodetectcxx.cpp       |  30 ----
>  bindings/cxx/examples/gpiofindcxx.cpp         |  32 ----
>  bindings/cxx/examples/gpiogetcxx.cpp          |  40 -----
>  bindings/cxx/examples/gpioinfocxx.cpp         |  61 -------
>  bindings/cxx/examples/gpiomoncxx.cpp          |  65 --------
>  bindings/cxx/examples/gpionotifycxx.cpp       |  55 -------
>  bindings/cxx/examples/gpiosetcxx.cpp          |  53 ------
>  .../examples/reconfigure_input_to_output.cpp  |  56 +++++++
>  bindings/cxx/examples/toggle_line_value.cpp   |  16 +-
>  .../examples/toggle_multiple_line_values.cpp  |  63 ++++++++
>  bindings/cxx/examples/watch_line_info.cpp     |  49 ++++++
>  bindings/cxx/examples/watch_line_rising.cpp   |  64 ++++++++
>  bindings/cxx/examples/watch_line_value.cpp    |  12 +-
>  .../examples/watch_multiple_line_values.cpp   |  60 +++++++
>  bindings/python/examples/Makefile.am          |  18 ++-
>  .../python/examples/async_watch_line_value.py |  15 +-
>  bindings/python/examples/find_line_by_name.py |  37 +++++
>  bindings/python/examples/get_chip_info.py     |  20 +++
>  bindings/python/examples/get_line_info.py     |  29 ++++
>  bindings/python/examples/get_line_value.py    |  13 +-
>  .../examples/get_multiple_line_values.py      |  29 ++++
>  bindings/python/examples/gpiodetect.py        |  15 --
>  bindings/python/examples/gpiofind.py          |  20 ---
>  bindings/python/examples/gpioget.py           |  29 ----
>  bindings/python/examples/gpioinfo.py          |  28 ----
>  bindings/python/examples/gpiomon.py           |  26 ---
>  bindings/python/examples/gpionotify.py        |  21 ---
>  bindings/python/examples/gpioset.py           |  36 -----
>  bindings/python/examples/helpers.py           |  15 --
>  .../examples/reconfigure_input_to_output.py   |  39 +++++
>  bindings/python/examples/toggle_line_value.py |  34 ++--
>  .../examples/toggle_multiple_line_values.py   |  47 ++++++
>  bindings/python/examples/watch_line_info.py   |  23 +++
>  bindings/python/examples/watch_line_rising.py |  31 ++++
>  bindings/python/examples/watch_line_value.py  |  19 ++-
>  .../examples/watch_multiple_line_values.py    |  43 +++++
>  bindings/rust/libgpiod/examples/Makefile.am   |  21 +--
>  .../examples/buffered_event_lifetimes.rs      |  58 +++++++
>  .../libgpiod/examples/find_line_by_name.rs    |  29 ++++
>  .../rust/libgpiod/examples/get_chip_info.rs   |  22 +++
>  .../rust/libgpiod/examples/get_line_info.rs   |  37 +++++
>  .../rust/libgpiod/examples/get_line_value.rs  |   4 +-
>  .../examples/get_multiple_line_values.rs      |  29 ++++
>  .../rust/libgpiod/examples/gpio_events.rs     |  88 ----------
>  .../examples/gpio_threaded_info_events.rs     | 132 ---------------
>  bindings/rust/libgpiod/examples/gpiodetect.rs |  30 ----
>  bindings/rust/libgpiod/examples/gpiofind.rs   |  36 -----
>  bindings/rust/libgpiod/examples/gpioget.rs    |  45 ------
>  bindings/rust/libgpiod/examples/gpioinfo.rs   |  97 -----------
>  bindings/rust/libgpiod/examples/gpiomon.rs    |  74 ---------
>  bindings/rust/libgpiod/examples/gpionotify.rs |  53 ------
>  bindings/rust/libgpiod/examples/gpioset.rs    |  63 --------
>  bindings/rust/libgpiod/examples/gpiowatch.rs  |  53 ------
>  .../examples/reconfigure_input_to_output.rs   |  42 +++++
>  .../libgpiod/examples/toggle_line_value.rs    |  17 +-
>  .../examples/toggle_multiple_line_values.rs   |  55 +++++++
>  .../rust/libgpiod/examples/watch_line_info.rs |  32 ++++
>  .../libgpiod/examples/watch_line_rising.rs    |  44 +++++
>  .../libgpiod/examples/watch_line_value.rs     |  10 +-
>  .../examples/watch_multiple_line_values.rs    |  46 ++++++
>  examples/.gitignore                           |   9 ++
>  examples/Makefile.am                          |  35 +++-
>  examples/async_watch_line_value.c             |   6 +-
>  examples/find_line_by_name.c                  | 111 +++++++++++++
>  examples/get_chip_info.c                      |  40 +++++
>  examples/get_line_info.c                      |  56 +++++++
>  examples/get_line_value.c                     |  11 +-
>  examples/get_multiple_line_values.c           | 119 ++++++++++++++
>  examples/reconfigure_input_to_output.c        | 152 ++++++++++++++++++
>  examples/toggle_line_value.c                  |  17 +-
>  examples/toggle_multiple_line_values.c        | 136 ++++++++++++++++
>  examples/watch_line_info.c                    |  72 +++++++++
>  examples/watch_line_rising.c                  | 129 +++++++++++++++
>  examples/watch_line_value.c                   |   6 +-
>  examples/watch_multiple_line_values.c         | 140 ++++++++++++++++
>  83 files changed, 2289 insertions(+), 1352 deletions(-)
>  create mode 100644 bindings/cxx/examples/find_line_by_name.cpp
>  create mode 100644 bindings/cxx/examples/get_chip_info.cpp
>  create mode 100644 bindings/cxx/examples/get_line_info.cpp
>  create mode 100644 bindings/cxx/examples/get_multiple_line_values.cpp
>  delete mode 100644 bindings/cxx/examples/gpiodetectcxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpiofindcxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpiogetcxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpioinfocxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpiomoncxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpionotifycxx.cpp
>  delete mode 100644 bindings/cxx/examples/gpiosetcxx.cpp
>  create mode 100644 bindings/cxx/examples/reconfigure_input_to_output.cpp
>  create mode 100644 bindings/cxx/examples/toggle_multiple_line_values.cpp
>  create mode 100644 bindings/cxx/examples/watch_line_info.cpp
>  create mode 100644 bindings/cxx/examples/watch_line_rising.cpp
>  create mode 100644 bindings/cxx/examples/watch_multiple_line_values.cpp
>  create mode 100755 bindings/python/examples/find_line_by_name.py
>  create mode 100755 bindings/python/examples/get_chip_info.py
>  create mode 100755 bindings/python/examples/get_line_info.py
>  create mode 100755 bindings/python/examples/get_multiple_line_values.py
>  delete mode 100755 bindings/python/examples/gpiodetect.py
>  delete mode 100755 bindings/python/examples/gpiofind.py
>  delete mode 100755 bindings/python/examples/gpioget.py
>  delete mode 100755 bindings/python/examples/gpioinfo.py
>  delete mode 100755 bindings/python/examples/gpiomon.py
>  delete mode 100755 bindings/python/examples/gpionotify.py
>  delete mode 100755 bindings/python/examples/gpioset.py
>  delete mode 100644 bindings/python/examples/helpers.py
>  create mode 100755 bindings/python/examples/reconfigure_input_to_output.py
>  create mode 100755 bindings/python/examples/toggle_multiple_line_values.py
>  create mode 100755 bindings/python/examples/watch_line_info.py
>  create mode 100755 bindings/python/examples/watch_line_rising.py
>  create mode 100755 bindings/python/examples/watch_multiple_line_values.py
>  create mode 100644 bindings/rust/libgpiod/examples/buffered_event_lifetimes.rs
>  create mode 100644 bindings/rust/libgpiod/examples/find_line_by_name.rs
>  create mode 100644 bindings/rust/libgpiod/examples/get_chip_info.rs
>  create mode 100644 bindings/rust/libgpiod/examples/get_line_info.rs
>  create mode 100644 bindings/rust/libgpiod/examples/get_multiple_line_values.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpio_events.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpio_threaded_info_events.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpiodetect.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpiofind.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpioget.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpioinfo.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpiomon.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpionotify.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpioset.rs
>  delete mode 100644 bindings/rust/libgpiod/examples/gpiowatch.rs
>  create mode 100644 bindings/rust/libgpiod/examples/reconfigure_input_to_output.rs
>  create mode 100644 bindings/rust/libgpiod/examples/toggle_multiple_line_values.rs
>  create mode 100644 bindings/rust/libgpiod/examples/watch_line_info.rs
>  create mode 100644 bindings/rust/libgpiod/examples/watch_line_rising.rs
>  create mode 100644 bindings/rust/libgpiod/examples/watch_multiple_line_values.rs
>  create mode 100644 examples/find_line_by_name.c
>  create mode 100644 examples/get_chip_info.c
>  create mode 100644 examples/get_line_info.c
>  create mode 100644 examples/get_multiple_line_values.c
>  create mode 100644 examples/reconfigure_input_to_output.c
>  create mode 100644 examples/toggle_multiple_line_values.c
>  create mode 100644 examples/watch_line_info.c
>  create mode 100644 examples/watch_line_rising.c
>  create mode 100644 examples/watch_multiple_line_values.c
>
> --
> 2.41.0
>

Thanks! I applied patches 1-5 and 7-8. I had some comments on patch 6,
you don't have to resend the others.

Bart




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux