Using incrontab to read GPIO's in pure bash - Raspberry Pi Forums
i tried following:
in rc.local, have: in: incrontab -l when wave hand in front of motion detector, nothing happens. supposed create file in directory /var/alarm/ containing date & time of when last change of gpio pin happened. (ill change wget command fetch cgi script on main "large" server then)
however, when "cat /sys/class/gpio/gpio24/value" "1" when theres no motion, , "0" when theres motion.
, when "cat /sys/class/gpio/gpio25/value", "1" when cover on motion detector closed, , "0" when cover open.
im doing wrong? file "value" in folder "/sys/class/gpio/gpio24/" (and gpio25) is changed why aren't incrontab executing command told execute?
verified command "date > /var/alarm/motion" work.
in rc.local, have:
code: select all
echo 24 > /sys/class/gpio/export echo 25 > /sys/class/gpio/export echo in > /sys/class/gpio/gpio24/direction echo in > /sys/class/gpio/gpio25/direction
code: select all
/sys/class/gpio/gpio24/value in_modify date > /var/alarm/motion /sys/class/gpio/gpio25/value in_modify date > /var/alarm/tamper
however, when "cat /sys/class/gpio/gpio24/value" "1" when theres no motion, , "0" when theres motion.
, when "cat /sys/class/gpio/gpio25/value", "1" when cover on motion detector closed, , "0" when cover open.
im doing wrong? file "value" in folder "/sys/class/gpio/gpio24/" (and gpio25) is changed why aren't incrontab executing command told execute?
verified command "date > /var/alarm/motion" work.
inotify works because, when changing file on behalf of 1 process, kernel remembers process registered interest in file, , informs of change.
gpio value psuedo-files not changed kernel, report current state of hardware, kernel not automatically know when have changed. cannot continuously check gpio state, because kind of inefficient mechanism inotify intended avoid.
on pi, hardware can configured interrupt kernel when gpio changes state ("echo rising >/sys/class/gpio/gpio24/edge"). might think allow inotify work on value file, not implemented way. instead, interrupt causes urgent/exceptional condition on gpio value file, , condition must checked or waited using poll() or select() system calls, not using inotify.
not aware of method of using poll() or select() @ shell level. however, of usual gpio libraries in c , python support waiting , reacting level change interrupts.
gpio value psuedo-files not changed kernel, report current state of hardware, kernel not automatically know when have changed. cannot continuously check gpio state, because kind of inefficient mechanism inotify intended avoid.
on pi, hardware can configured interrupt kernel when gpio changes state ("echo rising >/sys/class/gpio/gpio24/edge"). might think allow inotify work on value file, not implemented way. instead, interrupt causes urgent/exceptional condition on gpio value file, , condition must checked or waited using poll() or select() system calls, not using inotify.
not aware of method of using poll() or select() @ shell level. however, of usual gpio libraries in c , python support waiting , reacting level change interrupts.
raspberrypi
Comments
Post a Comment