Skip to content

Does not work with libgpiod3 #3

@makermelissa

Description

@makermelissa

Libgpiod3 is part of Trixie and the module will not run. When running make, I get:

gcc -c -O3 -o libgpiod_pulsein.o libgpiod_pulsein.c -I. -lgpiod -pthread -Wall
In file included from libgpiod_pulsein.c:23:
libgpiod_pulsein.h:10:36: warning: ‘struct gpiod_line’ declared inside parameter list will not be visible outside of this definition or declaration
   10 | float calculate_us_per_tick(struct gpiod_line *line);
      |                                    ^~~~~~~~~~
libgpiod_pulsein.h:11:26: warning: ‘struct gpiod_line’ declared inside parameter list will not be visible outside of this definition or declaration
   11 | void pulse_output(struct gpiod_line *line, bool idle_state, int trigger_len_us);
      |                          ^~~~~~~~~~
libgpiod_pulsein.c: In function ‘main’:
libgpiod_pulsein.c:191:10: error: implicit declaration of function ‘gpiod_chip_open_by_name’; did you mean ‘gpiod_chip_info_get_name’? [-Wimplicit-function-declaration]
  191 |   chip = gpiod_chip_open_by_name(device);
      |          ^~~~~~~~~~~~~~~~~~~~~~~
      |          gpiod_chip_info_get_name
libgpiod_pulsein.c:191:8: error: assignment to ‘struct gpiod_chip *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  191 |   chip = gpiod_chip_open_by_name(device);
      |        ^
libgpiod_pulsein.c:196:10: error: implicit declaration of function ‘gpiod_chip_get_line’; did you mean ‘gpiod_chip_get_info’? [-Wimplicit-function-declaration]
  196 |   line = gpiod_chip_get_line(chip, offset);
      |          ^~~~~~~~~~~~~~~~~~~
      |          gpiod_chip_get_info
libgpiod_pulsein.c:196:8: error: assignment to ‘struct gpiod_line *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  196 |   line = gpiod_chip_get_line(chip, offset);
      |        ^
libgpiod_pulsein.c:221:41: error: passing argument 1 of ‘calculate_us_per_tick’ from incompatible pointer type [-Wincompatible-pointer-types]
  221 |     us_per_tick = calculate_us_per_tick(line);
      |                                         ^~~~
      |                                         |
      |                                         struct gpiod_line *
libgpiod_pulsein.h:10:48: note: expected ‘struct gpiod_line *’ but argument is of type ‘struct gpiod_line *’
   10 | float calculate_us_per_tick(struct gpiod_line *line);
      |                             ~~~~~~~~~~~~~~~~~~~^~~~
libgpiod_pulsein.c:239:7: error: implicit declaration of function ‘gpiod_line_request_input’; did you mean ‘gpiod_line_request_get_fd’? [-Wimplicit-function-declaration]
  239 |   if (gpiod_line_request_input(line, consumername) != 0) {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
      |       gpiod_line_request_get_fd
libgpiod_pulsein.c:245:18: error: passing argument 1 of ‘pulse_output’ from incompatible pointer type [-Wincompatible-pointer-types]
  245 |     pulse_output(line, idle_state, trigger_len_us);
      |                  ^~~~
      |                  |
      |                  struct gpiod_line *
libgpiod_pulsein.h:11:38: note: expected ‘struct gpiod_line *’ but argument is of type ‘struct gpiod_line *’
   11 | void pulse_output(struct gpiod_line *line, bool idle_state, int trigger_len_us);
      |                   ~~~~~~~~~~~~~~~~~~~^~~~
libgpiod_pulsein.c:317:26: error: passing argument 1 of ‘pulse_output’ from incompatible pointer type [-Wincompatible-pointer-types]
  317 |             pulse_output(line, idle_state, trigger_len);
      |                          ^~~~
      |                          |
      |                          struct gpiod_line *
libgpiod_pulsein.h:11:38: note: expected ‘struct gpiod_line *’ but argument is of type ‘struct gpiod_line *’
   11 | void pulse_output(struct gpiod_line *line, bool idle_state, int trigger_len_us);
      |                   ~~~~~~~~~~~~~~~~~~~^~~~
libgpiod_pulsein.c: At top level:
libgpiod_pulsein.c:398:6: error: conflicting types for ‘pulse_output’; have ‘void(struct gpiod_line *, _Bool,  int)’
  398 | void pulse_output(struct gpiod_line *line, bool idle_state,
      |      ^~~~~~~~~~~~
libgpiod_pulsein.h:11:6: note: previous declaration of ‘pulse_output’ with type ‘void(struct gpiod_line *, _Bool,  int)’
   11 | void pulse_output(struct gpiod_line *line, bool idle_state, int trigger_len_us);
      |      ^~~~~~~~~~~~
libgpiod_pulsein.c: In function ‘pulse_output’:
libgpiod_pulsein.c:401:3: error: implicit declaration of function ‘gpiod_line_release’; did you mean ‘gpiod_line_request_release’? [-Wimplicit-function-declaration]
  401 |   gpiod_line_release(line);
      |   ^~~~~~~~~~~~~~~~~~
      |   gpiod_line_request_release
libgpiod_pulsein.c:403:7: error: implicit declaration of function ‘gpiod_line_request_output’; did you mean ‘gpiod_line_request_get_fd’? [-Wimplicit-function-declaration]
  403 |   if (gpiod_line_request_output(line, consumername, idle_state) != 0) {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |       gpiod_line_request_get_fd
libgpiod_pulsein.c:408:7: error: implicit declaration of function ‘gpiod_line_set_value’; did you mean ‘gpiod_line_request_set_value’? [-Wimplicit-function-declaration]
  408 |   if (gpiod_line_set_value(line, !idle_state) != 0) {
      |       ^~~~~~~~~~~~~~~~~~~~
      |       gpiod_line_request_set_value
libgpiod_pulsein.c: At top level:
libgpiod_pulsein.c:431:7: error: conflicting types for ‘calculate_us_per_tick’; have ‘float(struct gpiod_line *)’
  431 | float calculate_us_per_tick(struct gpiod_line *line) {
      |       ^~~~~~~~~~~~~~~~~~~~~
libgpiod_pulsein.h:10:7: note: previous declaration of ‘calculate_us_per_tick’ with type ‘float(struct gpiod_line *)’
   10 | float calculate_us_per_tick(struct gpiod_line *line);
      |       ^~~~~~~~~~~~~~~~~~~~~
libgpiod_pulsein.c: In function ‘calculate_us_per_tick’:
libgpiod_pulsein.c:448:15: error: implicit declaration of function ‘gpiod_line_get_value’; did you mean ‘gpiod_line_request_get_value’? [-Wimplicit-function-declaration]
  448 |     int ret = gpiod_line_get_value(line);
      |               ^~~~~~~~~~~~~~~~~~~~
      |               gpiod_line_request_get_value
make: *** [Makefile:7: libgpiod_pulsein.o] Error 1

It looks like function names such as gpiod_chip_open_by_name are now gpiod_chip_info_get_name.

Since libgpiod2 is only available on recent versions of linux, there another branch should be created for the older code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions