I was really looking for an example using gpiod_ctxless_event_monitor(). I want keep using the what is in gpiod.h
so far I have
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//Callback function
int myEvent(int x, unsigned int c, const struct timespec * v, void * b)
{
printf(“hello/r/n”);
}
// in my main function
gpiod_ctxless_event_handle_cb p = &myEvent; //setup callback
const char* pBank = “gpiochip0”; //name of gpiochip
const char* c = “gpio-event”; // name of consumer
int in_line = 5; // offset for gpio
printf(“%d\r\n”, rc);
/////////////////////////////////////////////////////////
rc always gives me a -1. Which means I’m doing something wrong to set this up
I got the gpiod_ctxless_event_monitor to work, but it is a blocking function and the articles you refenced elude to polling the input and not a true event trigger. Can we conclude Linux does not have a way to jump to a callback when an input changes state with out constantly polling for the input? a non-blocking type event trigger? Only way I can think to do this is a separate thread, but for a real time event this is not great. any other ideas on how to get a real time event trigger. I’m trying to read a flow sensor, that gives me pulses based on flow rate.
I think thread with for(;;){gpiod_line_event_wait(); …} is the right way to use GPIO interrupts. From this thread you may call some simple callbacks or use pthread_cond_signal() to unlock other waiting threads