I'm writing a little lib (wrapper) in NodeJS using basic
NodeJS spawns a new process and pipes the command
Now, I'd like a way to constantly monitor the input from a specific pin, such that (say) when I push a button (or when a digital peripheral - sensor) outputs a new/changed value (0/1) I can capture that data.
I think I can write an EventListener that would interface with a shell (or a running CLI program) and listen for those values, however, I can't seem to find a way to constantly monitor a given "OUT" pin by using any of the
gpioctl
commands for the RP. Something like this:
JavaScript:
...
module.exports.toggle_led = function (pin_number, callback) {
let err = new Error();
if (typeof (pin_number) != "number") {
err.name = errlist.ERR818.name;
err.message = errlist.ERR818.message;
callback(err, feedback);
}
else {
shell_cmd(`gpioctl -t ${pin_number}`, `utf8`, (error, stdout, stderr) => {
if (error != null) {
err.name = error.code;
err.message = error.signal;
callback(err, feedback);
}
});
}
}
NodeJS spawns a new process and pipes the command
gpioctl -<flag> -<pin_num>
to the OS. This works O.K. for setting pins/toggling pins.Now, I'd like a way to constantly monitor the input from a specific pin, such that (say) when I push a button (or when a digital peripheral - sensor) outputs a new/changed value (0/1) I can capture that data.
I think I can write an EventListener that would interface with a shell (or a running CLI program) and listen for those values, however, I can't seem to find a way to constantly monitor a given "OUT" pin by using any of the
gpio
commands.
Last edited: