Gpiod bulk events on more than one chip

I’m using the gpiod_line_event_wait_bulk and I can get this to work on one chip, but I want to monitor lines from multiple chips. I have events happening in chips0, 1, 2, 3, and 4.

So I tried to add them to a a single bulk structure
Code snippit.txt (1.6 KB)
referring to my code snippet, if I use &linesAll in the “ret = gpiod_line_event_wait_bulk(&linesAll, NULL, &events);” the events does not copy any over. However, if I use &lines0 to 4. It works just fine.

I was looking for the source code for gpiod, but no luck.

I can always create 5 different threads (one for each chip, but that seems excessive. I guess I can go the long way and write a thread that polls each line, but it just seems like there is something more elegant.

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Based on the context provided, it seems that the gpiod_line_event_wait_bulk function has limitations when it comes to monitoring GPIO lines from multiple chips using a single bulk structure. Here are some recommendations and observations:

  1. Use Individual Structures: Since using individual line structures for each chip works correctly, it is advisable to continue with this approach to ensure proper event monitoring.

  2. Explore API Documentation: It might be beneficial to check the gpiod API documentation for any updates or insights that could help in handling multiple chips more effectively. This could provide a more elegant solution if available.

  3. Consider Threading or Polling: If you need to monitor multiple chips simultaneously, consider implementing a threading model where each thread handles a separate chip. Although it may seem excessive, it could be a practical solution. Alternatively, a polling mechanism could be implemented, but it may not be as efficient.

Unfortunately, without access to the source code for gpiod or further documentation, these are the best recommendations based on the current context.

Please, also check if these links can help you solve your problem:

Spidev with multiple CS unable to read.