linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "brgl@bgdev.pl" <brgl@bgdev.pl>
Cc: "bartosz.golaszewski@linaro.org" <bartosz.golaszewski@linaro.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH libgpiod v5 4/4] dbus: add the D-Bus daemon, command-line client and tests
Date: Mon, 28 Oct 2024 13:07:21 +0000	[thread overview]
Message-ID: <93c9d617df7cc3f6814a56d07d90aa3f98e352f6.camel@siemens.com> (raw)
In-Reply-To: <20240812-dbus-v5-4-ead288509217@linaro.org>

Hi Bartosz!

On Mon, 2024-08-12 at 10:22 +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add the D-Bus API definition and its implementation in the form of a GPIO
> manager daemon and a companion command-line client as well as some
> additional configuration and data files (systemd service, example udev
> configuration, etc.) and test suites.
> 
> Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

[]

> diff --git a/dbus/client/wait.c b/dbus/client/wait.c
> new file mode 100644
> index 0000000..d65c4e7
> --- /dev/null
> +++ b/dbus/client/wait.c
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +// SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> +
> +#include <stdlib.h>
> +
> +#include "common.h"
> +
> +typedef struct {
> +	gboolean name_done;
> +	gboolean chip_done;
> +	const gchar *label;
> +} WaitData;
> +
> +static void obj_match_label(GpiodbusObject *chip_obj, WaitData *data)
> +{
> +	GpiodbusChip *chip = gpiodbus_object_peek_chip(chip_obj);
> +
> +	if (g_strcmp0(gpiodbus_chip_get_label(chip), data->label) == 0)
> +		data->chip_done = TRUE;
> +}
> +
> +static void check_label(gpointer elem, gpointer user_data)
> +{
> +	WaitData *data = user_data;
> +	GpiodbusObject *obj = elem;
> +
> +	obj_match_label(obj, data);
> +}
> +
> +static void on_object_added(GDBusObjectManager *manager G_GNUC_UNUSED,
> +			    GpiodbusObject *obj, gpointer user_data)
> +{
> +	WaitData *data = user_data;
> +
> +	obj_match_label(GPIODBUS_OBJECT(obj), data);
> +}
> +
> +static void wait_for_chip(WaitData *data)
> +{
> +	g_autoptr(GDBusObjectManager) manager = NULL;
> +	g_autolist(GpiodbusObject) objs = NULL;
> +
> +	manager = get_object_manager_client("/io/gpiod1/chips");
> +
> +	g_signal_connect(manager, "object-added",
> +			 G_CALLBACK(on_object_added), data);
> +
> +	objs = g_dbus_object_manager_get_objects(manager);
> +	g_list_foreach(objs, check_label, data);

Strange, I'd expect from this code to detect pre-existing chips immediately,
but this is not what I observe in practice:

$ gpiocli info --chip=gpiochip0 | head -n 1
gpiochip0 - 24 lines:
$ gpiocli wait --chip=gpiochip0 --timeout=1
gpiocli wait: wait timed out!

(without timeout it would wait endlessly)

This is not expected, right, otherwise it would be counter-intuitive and racy?

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

  reply	other threads:[~2024-10-28 13:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12  8:22 [PATCH libgpiod v5 0/4] dbus: add GLib-based D-Bus daemon and command-line client Bartosz Golaszewski
2024-08-12  8:22 ` [PATCH libgpiod v5 1/4] tests: split out reusable test code into a local static library Bartosz Golaszewski
2024-08-12  8:22 ` [PATCH libgpiod v5 2/4] tests: split out the common test code for bash scripts Bartosz Golaszewski
2024-08-12  8:22 ` [PATCH libgpiod v5 3/4] bindings: add GLib bindings Bartosz Golaszewski
2024-08-12  8:22 ` [PATCH libgpiod v5 4/4] dbus: add the D-Bus daemon, command-line client and tests Bartosz Golaszewski
2024-10-28 13:07   ` Sverdlin, Alexander [this message]
2024-10-28 19:13     ` Bartosz Golaszewski
2024-10-28 19:35       ` Sverdlin, Alexander
2024-10-28 19:44         ` Bartosz Golaszewski
2024-10-28 19:52           ` Sverdlin, Alexander
2024-08-12 13:19 ` [PATCH libgpiod v5 0/4] dbus: add GLib-based D-Bus daemon and command-line client Andy Shevchenko
2024-08-13  8:49 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93c9d617df7cc3f6814a56d07d90aa3f98e352f6.camel@siemens.com \
    --to=alexander.sverdlin@siemens.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).