Is it possible to set the JAVA NIO WatchService on files in the /sys/class/gpio/gpioX
device tree to supervise changes there ?
It would be nice idea to detect changes on the GPIO files (i.e. the GPIO -inputs) directly from within Java, but I fear that is not supported.
A confirmation that it's not supported (and perhaps why) would be sufficient.
The linux implementation of the Java 7 NIO FileWatcher uses inotify. Inotify is a linux kernel subsystem to notice filesystem changes. It has restrictions and doesn't work on /proc, /sys and network shares. Please read inotify limitations on wiki :
Inotify does report some but not all events in sysfs and procfs.
Notification via inotify requires the kernel to be aware of all relevant filesystem events, which is not always possible for networked filesystems such as NFS where changes made by one client are not immediately broadcast to other clients.
and a bit more:
inotify missing events
Java WatchService doesn't work on some folders
Java WatchService not generating events while watching mapped drives
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With