All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: joussemetmathis@gmail.com
Cc: linux-gpio@vger.kernel.org
Subject: Re: Help regarding IO configuration of multiple lines
Date: Sat, 7 Mar 2026 10:13:44 +0800	[thread overview]
Message-ID: <20260307021344.GA14011@rigel> (raw)
In-Reply-To: <cf52e066ba190f52bbfbfcfdcbdf7addc8998616.camel@gmail.com>

On Fri, Mar 06, 2026 at 12:09:50PM +0100, joussemetmathis@gmail.com wrote:
> Hello,
> 
> I am trying to learn how to use libgpiod on a Pi 5. I created for that
> goal a simple circuit with a push button and 2 LEDs, one of which turns
> on on a button press.
> Since I want to keep my program as modular as possible, I created a
> pinconfig function that configures the pins according to the parameters
> passed in main.
> However, when trying to pass an enum array of gpiod_line_direction to
> the function, the code no longer works and the LEDs no longer turn on.
> I suspect it is due to the way the array is handled, but since this use
> case isn't shown in the examples and that online ressources seems to
> only talk about v1 of gpiod, I'm a bit stuck.
> Could someone help me? You'll find my code attached in a zip in this
> email.
> 

Yeah, the example code doesn't provide a good example of requesting
lines with different settings.
The closest is get_multiple_line_values.c.  Though that applies settings for
each line individually when it could just use a single
gpiod_line_config_add_line_settings() call, as all the lines have the
same settings.  Not sure why.  ¯\_(ツ)_/¯

The relevant section of your code, which seems to follow that example, is:

	gpiod_line_settings_set_direction(line_settings, *direction);
    // ...
	for (int i = 0; i < line_nbr; i++) {
		gpiod_line_config_add_line_settings(line_config, &pin_list[i], 1, line_settings);	
	}


That applies the first entry in your direction array as the direction for all
lines. Definitely not what you want.

See if this works for you:

	for (int i = 0; i < line_nbr; i++) {
	    gpiod_line_settings_set_direction(line_settings, direction[i]);
		gpiod_line_config_add_line_settings(line_config, &pin_list[i], 1, line_settings);	
	}

That applies the direction for each line individually, with other line
settings being the same.

Cheers,
Kent.

  reply	other threads:[~2026-03-07  2:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 11:09 Help regarding IO configuration of multiple lines joussemetmathis
2026-03-07  2:13 ` Kent Gibson [this message]
2026-03-31 13:23   ` Mathis Joussemet
2026-03-31 14:33     ` Kent Gibson

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=20260307021344.GA14011@rigel \
    --to=warthog618@gmail.com \
    --cc=joussemetmathis@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.