Thread (19 messages) 19 messages, 3 authors, 2021-08-13

Re: [libgpiod v2.0][PATCH] core: extend config objects

From: Kent Gibson <warthog618@gmail.com>
Date: 2021-08-08 23:10:20

On Sun, Aug 08, 2021 at 09:11:14PM +0200, Bartosz Golaszewski wrote:
On Sat, Aug 7, 2021 at 10:48 AM Kent Gibson [off-list ref] wrote:
quoted
On Fri, Aug 06, 2021 at 03:28:10PM +0200, Bartosz Golaszewski wrote:
quoted
Kent suggested that we may want to add getters for the config objects in
his reviews under the C++ patches. Indeed when working on Python bindings
I noticed it would be useful for implementing __str__ and __repr__
callbacks. In C++ too we could use them for overloading stream operators.

This extends the config objects with getters. They are straightforward for
the request config but for the line config, they allow to only read
per-offset values that would be used if the object was used in a request
at this moment. We also add getters for the output values: both taking
the line offset as argument as well as ones that take the index and allow
to iterate over all configured output values.

The sanitization of input for the getters has subsequently been changed
so that we never return invalid values. The input values are verified
immediately and if an invalid value is passed, it's silently replaced
by the default value for given setting.

This patch also adds the reset function for the line config object - it
can be used to reset all stored configuration if - for example - the
config has become too complex.

As this patch will be squashed into the big v2 patch anyway, I allowed
myself to include some additional changes: some variable renames and
other minor tweaks.

Signed-off-by: Bartosz Golaszewski <redacted>
A few minor nit-picks in the gpiod.h documentation below...

Cheers,
Kent.
Thanks,

With that fixed, do you think it's good to be applied?
Sure.

I was also wondering if anything could be done to simplify the
structures in line-config.c, but that isn't specific to this patch.
Not having access to the offsets, or even num_lines, and doing the
allocation up-front makes it rather painful.  Especially if the most
common case is only one or two lines.
But, as long as you are happy with the external API, that is just
implementation detail that can be optimised later.

Cheers,
Kent.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help