Been a while since my previous post on reading spidev. The main gist there was that I was looking for a reliable way to capture any changes to the digital inputs. My "solution" there was to do a simple polling on groups of modbus coils, exposed via the modbus TCP server, see modbridge. I am happy to say this sort of already works for me ...
What I noticed while working on the modbridge was that when I did not constrain the polling speed, CPU load for the polling program got quite high, as well as for the modbus TCP server that needed to keep up with all this polling. Although the current setup would probably work OK, I figured that using the sysfs interfacing would probably have a better performance as this should in principle allow me to deal with events directly provided from the kernel level.
I earlier did install the unipi neuron images with the sysfs drivers and I could indeed see any input changes reflected in the sysfs files. I then looked into how I could capture changes as events using golang's fsnotify (a golang wrapper around inotify). Apparently fsnotify (/inotify) is not really used for sysfs files, so I was instead looking at epoll, but seemed to capture too much changes (probably for every spi-level update).
Before digging deeper into epoll, my main question is what do you recommend as the best way of capturing changes as events from the sysfs interface? Is there some sort of (C)-API to directly capture these -- either via some library you provide or directly via standard linux syscalls (epoll)? I do not have any experience with linux syscalls atm, so I'd rather check what is the "preferred" way of dealing with this.