libgpiod icon indicating copy to clipboard operation
libgpiod copied to clipboard

Feature Request: Ability to retrieve line by name via libgpiodbus

Open OllieGitHub opened this issue 1 month ago • 5 comments

While implementing the ability for a user-space application to configure GPIO pins via the libgpiodbus library I found myself having to copy/utilize a lot of helper functions from the client code in order to be able to retrieve a line via name

"get_line_obj_by_name" is the entry point I used to retrieve a "GpiodbusLine *line" object. This requires copying/implementing many other helper functions (get_chip_objs, get_line_obj_by_name_for_chip, get_object_manager_client)

It would be nice if there was a "gpiodbus_get_line_obj_by_name" API that would abstract all of this

OllieGitHub avatar Nov 21 '25 13:11 OllieGitHub

libgpiodbus is entirely dynamically generated by gdbus-codegen. I suggest you create a library of such helpers and we can discuss making it part of libgpiod as a separate entity linking against libgpiodbus.

brgl avatar Nov 21 '25 14:11 brgl

Would my utils.c library (https://github.com/Maru006/contrib/blob/master/dht11/utils.c) help you somehow?

It abstracts requesting a line as output or as an input.

Maru006 avatar Nov 22 '25 16:11 Maru006

@Maru006 Thanks for providing your repo as an example on how to request a line via API provided by libgpiod.

@brgl Most, if not all, of the helper functions that I have utilized are directly from https://github.com/brgl/libgpiod/blob/master/dbus/client/common.c It feels a bit counterproductive to implement yet another library that provides the same functionality

OllieGitHub avatar Nov 23 '25 11:11 OllieGitHub

I think I'm in a similar situation. Since gpiochip names are dynamic in newer kernels, everyone needs to use the --by-name option provided by the command line tools. However, it would be nice if there were a gpiod_request_line_by_name() in the library. Unless I'm missing something, and there is a way to do this.

I'm in the process of extracting the line resolver code from tools-common.c now.

davenmccalla-diagraph avatar Nov 23 '25 15:11 davenmccalla-diagraph

@brgl Most, if not all, of the helper functions that I have utilized are directly from https://github.com/brgl/libgpiod/blob/master/dbus/client/common.c It feels a bit counterproductive to implement yet another library that provides the same functionality

Fait enough but I personally will most likely not have the time nor motivation to do it. The project is open-source though, so if you find the time to create a separate library of helpers, let's call it libgpiocli or something, create a set of common helpers with a nice API and make gpiocli use it instead of keeping that code in common.c, then I'm more than willing to make it part of libgpiod! Just please use a common prefix for public symbols and follow the coding convention established for the rest of the project.

brgl avatar Nov 24 '25 09:11 brgl