[libgpiod] gpiod_line_get_value_bulk may be broken?

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

 



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




[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