/**
* @brief Wait for events on a single GPIO line.
+ * @param consumer Name of the consumer.
* @param device Name, path or number of the gpiochip.
* @param offset GPIO line offset on the chip.
* @param active_low The active state of this line - true if low.
* @return 0 no errors were encountered, -1 if an error occured.
*
*/
-int gpiod_simple_event_loop(const char *device, unsigned int offset,
- bool active_low, struct timespec *timeout,
- gpiod_event_cb callback, void *cbdata) GPIOD_API;
+int gpiod_simple_event_loop(const char *consumer, const char *device,
+ unsigned int offset, bool active_low,
+ struct timespec *timeout, gpiod_event_cb callback,
+ void *cbdata) GPIOD_API;
/**
* @}
static const char dev_dir[] = "/dev/";
static const char cdev_prefix[] = "gpiochip";
-static const char libgpiod_consumer[] = "libgpiod";
/*
* The longest error message in glibc is about 50 characters long so 64 should
return 0;
}
-int gpiod_simple_event_loop(const char *device, unsigned int offset,
- bool active_low, struct timespec *timeout,
- gpiod_event_cb callback, void *cbdata)
+int gpiod_simple_event_loop(const char *consumer, const char *device,
+ unsigned int offset, bool active_low,
+ struct timespec *timeout, gpiod_event_cb callback,
+ void *cbdata)
{
struct gpiod_line_event event;
struct gpiod_chip *chip;
return -1;
}
- status = gpiod_line_event_request_all(line,
- libgpiod_consumer, active_low);
+ status = gpiod_line_event_request_all(line, consumer, active_low);
if (status < 0) {
gpiod_chip_close(chip);
return -1;
signal(SIGINT, sighandler);
signal(SIGTERM, sighandler);
- status = gpiod_simple_event_loop(device, offset, active_low,
+ status = gpiod_simple_event_loop("gpiomon", device, offset, active_low,
&timeout, event_callback, NULL);
if (status < 0)
die_perror("error waiting for events");