Closed Shubhranshu153 closed 10 months ago
I recommend using character device GPIOs instead, as sysfs GPIOs have been deprecated for some time now. Character device GPIOs also have a richer event API with timestamping.
Regarding the minor point, the polling object returned by select.poll()
expects milliseconds for timeout: https://docs.python.org/3/library/select.html#select.poll.poll .
Regarding your major point, the kernel always sets both POLLPRI
and POLLERR
when polling sysfs (kernfs) files: https://elixir.bootlin.com/linux/v6.5.5/source/fs/kernfs/file.c#L883
As for inotify, in the man page you listed -- "Furthermore, various pseudo-filesystems such as /proc, /sys, and /dev/pts are not monitorable with inotify."
minor -> the timeout should be divided by 1000 not multiplied to convert sec to millisec as select.poll.poll is expecting in second
major: the events are returned as a bitmap that needs to be deciphered probably in a if else kind of state (as we are having or on 2 events). if an error occurs we should return false.
Not sure about this: but i think this part of the code should use https://man7.org/linux/man-pages/man7/inotify.7.html. to detect changes to the files and based on the edge set, it should return true or false. if we can discuss this and come to a solution, will like to code contribute this part.