Moving my original post and progress to the correct category...
I'm using node-red-node-pi-gpio as a starting place but I've had to make a lot of modifications for a number of reasons:
-
The sysfs method of interfacing with GPIO has long since been deprecated in the kernel (circa 4.8) and is not available on Fedora. Therefore I'm porting things to use the libgpiod library.
-
Due to #1, I'm going to call the binaries directly (gpioget, gpioset, gpiomon) so all the python stuff is gone. One nice thing about the python library is it mapped the IO pin number to the correct GPIO BCM. libgpiod doesn't do this so I must map things myself.
The nice thing about this overall approach is that it can be easily ported to any GPIO device supported by libgpiod.
I've created the following logic to call gpiomon with the correct BCM number but it's not working. I am not a javascript programmer by any means so a lot of this is guessing and googling.
var pin2bcm = {
"3":"2", "5":"3", "7":"4", "8":"14", "10":"15", "11":"17", "12":"18", "13":"27", "15":"22",
"16":"23", "18":"24", "19":"10", "21":"9", "22":"25", "23":"11", "24":"8", "26":"7",
"29":"5", "31":"6", "32":"12", "33":"13", "35":"19", "36":"16", "37":"26", "38":"20", "40":"21"
}
Which now that I look at the github version has since been added with the exact same name. Funny.
I've got the inputs mostly working because gpiomon doesn't exit so the functionality is similar to the rpi-gpio, however, function GPIOOutNode(n)
also wants a process that doesn't exit, but gpioget
returns the state and exits.
This of course triggers node.on("close"...
and the status goes to not-running
.
Before I roto-rooter the logic, can someone point me to a best practice for how to handle this situation?
Basically, as long as it exits 0
then the command was successful.
Thanks,
Richard