tools: new tool - gpioctl
Get series with b4
b4 am [email protected] change-id 20251001-gpioctl-336556e702fdVersions newest first
- v2 Latest4 patches 1 replyIn review
- v1 RFC3 patches 7 repliesSuperseded
Changes in v2 from the cover letter · 41 lines
- Make the server startup more robust: use lockfiles to rule out races between multiple processes starting a server on the same socket
- Add a "startup" pipe allowing the server to communicate errors to
client before the server is fully set up and the connection
established
- Don't let slow clients block the server: drop a client that doesn't
read data sent to it fast enough and make client sockets non-blocking
- Make the default output of gpioctl monitor (without the --format option) match that of gpiomon
- Set output values together with settings in build_line_config()
instead of having these ops split into two far from one another
- Fix an unnecessary double fetch of the request list from monitor_resolve()
- Prefer "positive" tests first
- Map reconfigured values to lines by name on the daemon side and ensure the ordering libgpiod requires for a correct reconfigure
- Update loop variables inside the for () statement
- Unify the range of supported event format specifiers across gpiomon
and gpioctl
- Reword the docs to make it clear that the daemon stays alive as long
as there are any active GPIO requests or client connections
- Make examples in docs better match the actual behavior of gpioctl
(they were mostly written earlier with the behavior changed since)
- Use a single counter variable in validate_request_opts()
- Don't let the server die on SIGPIPE
- Don't dispatch pending epoll events to receivers removed while
processing the same batch
- Abstract socket names are not owned by anyone so make sure to verify credentials and only talk to servers and clients of the same user
- Fix regressions introduced by moving event formatting code to tools-common
- Only sent as many bytes as are needed per message type, not a fixed, almost 4k byte message even for small amounts of data like edge events
- Fix several memory leaks
- fix parsing of the -F command-line option in gpioctl monitor
- Use the right die() variants in the server-only code
- Don't look up the user name just to print it in a log message as a call to getpwuid() may block on a NSS request for no reason or drop a valid client with no passwd entry
- Add error checking when redirecting FDs when daemonizing the server
- Reset optind consistently in sub-command parsers
- Reject empty offsets in gpioctl set
- Add meson tests for new headers and functions used in gpioctl
- Fix parsing of line=value pairs for corner-cases, allow '=' in line
names in shunit2 helper
- Reject too many lines given by name
- Refactor the code handling the printing of line events: use less positional arguments in favor of structs and unduplicate parts of the logic
- Rework the gpioctl-test-helper program, add more functionalities
- Many other small tweaks and fixes...
- Link to v1: https://patch.msgid.link/[email protected]
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | tools: factor out line value parsing into tools-commontools/ tools/ tools/ | +103 | 0 replies | |
| 2/4 | tools: factor out line event formatting into tools-commontools/ tools/ tools/ | +166 | 0 replies | |
| 3/4 | tests: bash: allow '=' in line names in shunit2 helpertests/ | +1 | 0 replies | |
| 4/4 | tools: implement gpioctlTODO docs/ docs/ +9 more | +6395 | 0 replies |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Linus Walleij |
|---|---|
| Series | A-b |
| 1/4 | |
| 2/4 | |
| 3/4 | |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH libgpiod v2 0/4] tools: new tool - gpioctl
Provide gpioctl, a new command-line tool for persistent GPIO line control. Unlike gpioget and gpioset which release lines on exit, gpioctl holds requested lines in a background daemon so their state survives across multiple client invocations.
Before adding the new program: move some code we'll reuse out of gpioset and gpiomon and into tools-common.
This is a v2 of the RFC I sent before. It's been quite heavily reworked, the details are in the changelog below.
---
Changes in v2:
- Make the server startup more robust: use lockfiles to rule out races between multiple processes starting a server on the same socket
- Add a "startup" pipe allowing the server to communicate errors to
client before the server is fully set up and the connection
established
- Don't let slow clients block the server: drop a client that doesn't
read data sent to it fast enough and make client sockets non-blocking
- Make the default output of gpioctl monitor (without the --format option) match that of gpiomon
- Set output values together with settings in build_line_config()
instead of having these ops split into two far from one another
- Fix an unnecessary double fetch of the request list from monitor_resolve()
- Prefer "positive" tests first
- Map reconfigured values to lines by name on the daemon side and ensure the ordering libgpiod requires for a correct reconfigure
- Update loop variables inside the for () statement
- Unify the range of supported event format specifiers across gpiomon
and gpioctl
- Reword the docs to make it clear that the daemon stays alive as long
as there are any active GPIO requests or client connections
- Make examples in docs better match the actual behavior of gpioctl
(they were mostly written earlier with the behavior changed since)
- Use a single counter variable in validate_request_opts()
- Don't let the server die on SIGPIPE
- Don't dispatch pending epoll events to receivers removed while
processing the same batch
- Abstract socket names are not owned by anyone so make sure to verify credentials and only talk to servers and clients of the same user
- Fix regressions introduced by moving event formatting code to tools-common
- Only sent as many bytes as are needed per message type, not a fixed, almost 4k byte message even for small amounts of data like edge events
- Fix several memory leaks
- fix parsing of the -F command-line option in gpioctl monitor
- Use the right die() variants in the server-only code
- Don't look up the user name just to print it in a log message as a call to getpwuid() may block on a NSS request for no reason or drop a valid client with no passwd entry
- Add error checking when redirecting FDs when daemonizing the server
- Reset optind consistently in sub-command parsers
- Reject empty offsets in gpioctl set
- Add meson tests for new headers and functions used in gpioctl
- Fix parsing of line=value pairs for corner-cases, allow '=' in line
names in shunit2 helper
- Reject too many lines given by name
- Refactor the code handling the printing of line events: use less positional arguments in favor of structs and unduplicate parts of the logic
- Rework the gpioctl-test-helper program, add more functionalities
- Many other small tweaks and fixes...
- Link to v1: https://patch.msgid.link/[email protected]
---
Bartosz Golaszewski (4):
tools: factor out line value parsing into tools-common
tools: factor out line event formatting into tools-common
tests: bash: allow '=' in line names in shunit2 helper
tools: implement gpioctl
TODO | 14 - docs/.gitignore | 2 + docs/conf.py | 8 + docs/gpio_tools.rst | 11 +- docs/gpioctl_top.rst | 209 ++ man/meson.build | 39 + meson.build | 7 + tests/scripts/gpiod-bash-test-helper.inc | 2 +- tools/gpio-tools-test.bash | 2394 ++++++++++++++++++++ tools/gpioctl-test-helper.c | 196 ++ tools/gpioctl.c | 3509 ++++++++++++++++++++++++++++++ tools/gpiomon.c | 128 +- tools/gpioset.c | 89 - tools/meson.build | 21 +- tools/tools-common.c | 242 ++- tools/tools-common.h | 25 + 16 files changed, 6665 insertions(+), 231 deletions(-)
---
base-commit: 114d75e95c92fe5aa5721a0c6da2c56f2414ebb4
change-id: 20251001-gpioctl-336556e702fd
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>