* [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx
@ 2023-06-12 14:56 Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 1/2] bindings: cxx: provide request_builder::set_output_values() Bartosz Golaszewski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2023-06-12 14:56 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
Cc: linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent,
This is an alternative approach to the problem you raised with your gpioset
patches. It adds a new helper method that allows to set all output values at
request-time using the line_config's set_output_values() method.
Please take a look and let me know what you think.
Bart
Bartosz Golaszewski (2):
bindings: cxx: provide request_builder::set_output_values()
bindings: cxx: examples: fix potential glitch in gpiosetcxx
bindings/cxx/examples/gpiosetcxx.cpp | 3 +--
bindings/cxx/gpiodcxx/request-builder.hpp | 8 ++++++++
bindings/cxx/request-builder.cpp | 8 ++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [libgpiod][PATCH 1/2] bindings: cxx: provide request_builder::set_output_values()
2023-06-12 14:56 [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx Bartosz Golaszewski
@ 2023-06-12 14:56 ` Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 2/2] bindings: cxx: examples: fix potential glitch in gpiosetcxx Bartosz Golaszewski
2023-06-12 15:06 ` [libgpiod][PATCH 0/2] bindings: cxx: " Kent Gibson
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2023-06-12 14:56 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
Cc: linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Implement a new method in the request_builder class that allows to set
output values at request-time by calling the set_output_values() method
of the internal line_config object.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/cxx/gpiodcxx/request-builder.hpp | 8 ++++++++
bindings/cxx/request-builder.cpp | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/bindings/cxx/gpiodcxx/request-builder.hpp b/bindings/cxx/gpiodcxx/request-builder.hpp
index 3216216..90cc8f0 100644
--- a/bindings/cxx/gpiodcxx/request-builder.hpp
+++ b/bindings/cxx/gpiodcxx/request-builder.hpp
@@ -114,6 +114,14 @@ public:
*/
request_builder& add_line_settings(const line::offsets& offsets, const line_settings& settings);
+ /**
+ * @brief Set output values for a number of lines in the line config
+ * stored by this object.
+ * @param values Buffer containing the output values.
+ * @return Reference to self.
+ */
+ request_builder& set_output_values(const line::values& values);
+
/**
* @brief Make the line request.
* @return New line_request object.
diff --git a/bindings/cxx/request-builder.cpp b/bindings/cxx/request-builder.cpp
index 6a1a487..d11e47b 100644
--- a/bindings/cxx/request-builder.cpp
+++ b/bindings/cxx/request-builder.cpp
@@ -106,6 +106,14 @@ request_builder::add_line_settings(const line::offsets& offsets, const line_sett
return *this;
}
+GPIOD_CXX_API request_builder&
+request_builder::set_output_values(const line::values& values)
+{
+ this->_m_priv->line_cfg.set_output_values(values);
+
+ return *this;
+}
+
GPIOD_CXX_API line_request request_builder::do_request()
{
line_request_ptr request(::gpiod_chip_request_lines(
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [libgpiod][PATCH 2/2] bindings: cxx: examples: fix potential glitch in gpiosetcxx
2023-06-12 14:56 [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 1/2] bindings: cxx: provide request_builder::set_output_values() Bartosz Golaszewski
@ 2023-06-12 14:56 ` Bartosz Golaszewski
2023-06-12 15:06 ` [libgpiod][PATCH 0/2] bindings: cxx: " Kent Gibson
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2023-06-12 14:56 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
Cc: linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpiosetcxx requests lines without setting their output value, and so
sets them all inactive, and subsequently sets them to their requested
value. This can result in glitches on lines which were active and
are set active.
As this is example code, it is also important to demonstrate that the
output value can be set by the request itself.
Request the lines with the correct output values set in the request
itself.
Suggested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/cxx/examples/gpiosetcxx.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/bindings/cxx/examples/gpiosetcxx.cpp b/bindings/cxx/examples/gpiosetcxx.cpp
index dde5379..f46cb85 100644
--- a/bindings/cxx/examples/gpiosetcxx.cpp
+++ b/bindings/cxx/examples/gpiosetcxx.cpp
@@ -44,10 +44,9 @@ int main(int argc, char **argv)
::gpiod::line_settings()
.set_direction(::gpiod::line::direction::OUTPUT)
)
+ .set_output_values(values)
.do_request();
- request.set_values(values);
-
::std::cin.get();
return EXIT_SUCCESS;
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx
2023-06-12 14:56 [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 1/2] bindings: cxx: provide request_builder::set_output_values() Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 2/2] bindings: cxx: examples: fix potential glitch in gpiosetcxx Bartosz Golaszewski
@ 2023-06-12 15:06 ` Kent Gibson
2 siblings, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2023-06-12 15:06 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Andy Shevchenko, Viresh Kumar, linux-gpio,
Bartosz Golaszewski
On Mon, Jun 12, 2023 at 04:56:51PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Kent,
>
> This is an alternative approach to the problem you raised with your gpioset
> patches. It adds a new helper method that allows to set all output values at
> request-time using the line_config's set_output_values() method.
>
> Please take a look and let me know what you think.
>
That works for me - it is waaaay less painful than the per-line approach.
Reviewed-by: Kent Gibson <warthog618@gmail.com>
for the series.
Though come to think of it, it could use tests as well.
But you can always add some subsequently.
Btw, this is also an example of the outcome I expected to see from
expanding the examples - identify common pain points and extend the API
to address them.
Cheers,
Kent.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-12 15:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 14:56 [libgpiod][PATCH 0/2] bindings: cxx: fix potential glitch in gpiosetcxx Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 1/2] bindings: cxx: provide request_builder::set_output_values() Bartosz Golaszewski
2023-06-12 14:56 ` [libgpiod][PATCH 2/2] bindings: cxx: examples: fix potential glitch in gpiosetcxx Bartosz Golaszewski
2023-06-12 15:06 ` [libgpiod][PATCH 0/2] bindings: cxx: " Kent Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).