NIO watchservice for UNIX sys / classes / gpio files

Is it possible to install JAVA NIO WatchService on files in the device tree /sys/class/gpio/gpioX to control the changes there?

It would be nice to detect changes in GPIO files (i.e. GPIO inputs) directly from Java, but I'm afraid this is not supported.

Confirmation that it is not supported (and possibly why) will be sufficient.

+6
source share
1 answer

The linux implementation of Java 7 NIO FileWatcher uses inotify. Inotify is the Linux kernel subsystem to notice file system changes. It has limitations and does not work on / proc, / sys and network resources. Please read the prohibit wiki usage :

Inotify reports some, but not all, events in sysfs and procfs.

Notification via inotify requires the kernel to be aware of all relevant file system events, which is not always possible for network file systems such as NFS, where changes made by one client are not immediately transferred to other clients.

and a little more:

initialize missing events
Java WatchService does not work in some folders
Java WatchService does not generate events when viewing mapped drives

+4
source

Source: https://habr.com/ru/post/987043/


All Articles