| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <errno.h> |
| 7 |
#include <gpiod.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <string.h> |
| 11 |
|
| 12 |
int main(void) |
| 13 |
{ |
| 14 |
|
| 15 |
static const char *const chip_path = "/dev/gpiochip0"; |
| 16 |
|
| 17 |
struct gpiod_chip_info *info; |
| 18 |
struct gpiod_chip *chip; |
| 19 |
|
| 20 |
chip = gpiod_chip_open(chip_path); |
| 21 |
if (!chip) { |
| 22 |
fprintf(stderr, "failed to open chip: %s\n", strerror(errno)); |
| 23 |
return EXIT_FAILURE; |
| 24 |
} |
| 25 |
|
| 26 |
info = gpiod_chip_get_info(chip); |
| 27 |
if (!info) { |
| 28 |
fprintf(stderr, "failed to read info: %s\n", strerror(errno)); |
| 29 |
return EXIT_FAILURE; |
| 30 |
} |
| 31 |
|
| 32 |
printf("%s [%s] (%zu lines)\n", gpiod_chip_info_get_name(info), |
| 33 |
gpiod_chip_info_get_label(info), |
| 34 |
gpiod_chip_info_get_num_lines(info)); |
| 35 |
|
| 36 |
gpiod_chip_info_free(info); |
| 37 |
gpiod_chip_close(chip); |
| 38 |
|
| 39 |
return EXIT_SUCCESS; |
| 40 |
} |