linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libgpiod] gpiod_line_get_value_bulk may be broken?
@ 2023-07-27 15:14 andy pugh
  2023-07-27 20:53 ` Kent Gibson
  0 siblings, 1 reply; 25+ messages in thread
From: andy pugh @ 2023-07-27 15:14 UTC (permalink / raw)
  To: linux-gpio

I am using v1.2 on a Raspberry Pi under Buster (as that is the
installed version)

However, the code appears to be the same in v1.6.

As far as I can see gpiod_line_get_value_bulk() always fails if the
bulk contains more than one line. The problem(I think)  is that
gpiod_line_same_chip() always returns -EINVAL

Test code output:

Chips line 0 0x3f1280 gpiochip0
Chips line 1 0x3f2af0 gpiochip0
Chips line 2 0x3f4350 gpiochip0

ie, all the same chip _name_ but the result of gpiod_line_get_chip (if
displayed as a pointer with %p) differs.

Test code

````
#include <gpiod.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <string.h>

int main(int argc, char **argv)
{
  struct gpiod_chip *chip;
  struct gpiod_line *line0, *line1, *line2;
  struct gpiod_line_bulk bulk;
  int retval;
  int val[4] = {0};

  // Open GPIO chip
  chip = gpiod_chip_open_by_name("gpiochip0");

  // Open GPIO lines
  line0 = gpiod_line_find("GPIO17");
  line1 = gpiod_line_find("GPIO18");
  line2 = gpiod_line_find("GPIO19");

  gpiod_line_request_input(line0, "test");
  gpiod_line_request_input(line1, "test");
  gpiod_line_request_input(line2, "test");

  gpiod_line_bulk_init(&bulk);
  gpiod_line_bulk_add(&bulk, line0);
  gpiod_line_bulk_add(&bulk, line1);
  gpiod_line_bulk_add(&bulk, line2);

  // Compare the return value of gpiod_line_get_chip() for each line
  printf("Chips line 0 %p %s\n", gpiod_line_get_chip(line0),
gpiod_chip_name(gpiod_line_get_chip(line0)));
  printf("Chips line 1 %p %s\n", gpiod_line_get_chip(line1),
gpiod_chip_name(gpiod_line_get_chip(line1)));
  printf("Chips line 2 %p %s\n", gpiod_line_get_chip(line2),
gpiod_chip_name(gpiod_line_get_chip(line2)));

  // try to read the IO lines
  retval = gpiod_line_get_value_bulk(&bulk, val);
  assert (retval == 0);

  // Release lines and chip
  gpiod_line_release_bulk(&bulk);
  gpiod_chip_close(chip);
  return 0;
}
````

--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2023-08-15 18:04 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-27 15:14 [libgpiod] gpiod_line_get_value_bulk may be broken? andy pugh
2023-07-27 20:53 ` Kent Gibson
2023-07-27 21:17   ` andy pugh
2023-07-27 21:55     ` Kent Gibson
2023-07-27 22:10       ` andy pugh
2023-07-27 22:36         ` Kent Gibson
2023-07-28  0:39       ` andy pugh
2023-07-28  1:07         ` andy pugh
2023-07-28  5:57         ` Kent Gibson
2023-07-28 19:01           ` andy pugh
2023-07-29  2:03             ` Kent Gibson
2023-08-05 22:55               ` andy pugh
2023-08-06  1:02                 ` Kent Gibson
2023-08-06  9:13                   ` andy pugh
2023-08-06  9:29                     ` Kent Gibson
2023-08-10  0:17                       ` andy pugh
2023-08-10  0:46                         ` Kent Gibson
2023-08-10 22:07                           ` andy pugh
2023-08-11  0:59                             ` Kent Gibson
2023-08-11  1:26                               ` andy pugh
2023-08-11  1:36                                 ` Kent Gibson
2023-08-14 22:25                                   ` How to use gpiod_line_set_flags andy pugh
2023-08-15  0:49                                     ` Kent Gibson
2023-08-15 18:03                                       ` andy pugh
2023-08-11 12:19               ` [libgpiod] gpiod_line_get_value_bulk may be broken? Bartosz Golaszewski

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).