Re: [libgpiod] gpiod_line_get_value_bulk may be broken?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 27 Jul 2023 at 22:55, Kent Gibson <warthog618@xxxxxxxxx> wrote:

> > I did try that way first, but it didn't seem to be working for me.
> > I am currently upgrading the system to Bookworm (gpiod v1.6) to try again.
> >
>
> If you can repeat it, and ideally provide a failing test case, then we can
> take a look at it.

Now using gpiod v1.6 in Bookworm. gpiod_line_request_bulk() does not
seem to set the consumer.
Also, with the suggested use of bulk requests I still get an error
return from gpiod_line_get_value_bulk and an errno (22) that suggests
that it is line_bulk_same_chip() which has caused the problem.

test output:

line0 (null) line1 (null) line2 (null)
Error = Invalid argument (22)
a.out: test.c:47: main: Assertion `retval == 0' failed.
Aborted


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_bulk_init(&bulk);
  gpiod_line_bulk_add(&bulk, line0);
  gpiod_line_bulk_add(&bulk, line1);
  gpiod_line_bulk_add(&bulk, line2);
  gpiod_line_request_bulk_input(&bulk, "test");

  printf("line0 %s line1 %s line2 %s\n", gpiod_line_consumer(line0),
                gpiod_line_consumer(line1), gpiod_line_consumer(line2));

 retval = gpiod_line_get_value_bulk(&bulk, val);
 printf("Error = %s (%i)\n", strerror(errno), errno);
 assert (retval == 0);
 usleep(1000000);

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

````

If Instead I use

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

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

then the result is

line0 test line1 test line2 test

Which I think is why I was using separate requests. Initially I
thought that this might be the problem, as the
gpiod_line_get_value_bulk
function checks both all-the-same-chip and that all lines are requested the same


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




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux